バージョン

CloneDiscarded イベント (ButtonTool)

ツールのクローンが破棄されるときに発生します。
シンタックス
'宣言
 
Public Event CloneDiscarded As EventHandler(Of ToolCloneDiscardedEventArgs)
public event EventHandler<ToolCloneDiscardedEventArgs> CloneDiscarded
イベント データ

イベント ハンドラが、このイベントに関連するデータを含む、ToolCloneDiscardedEventArgs 型の引数を受け取りました。次の ToolCloneDiscardedEventArgs プロパティには、このイベントの固有の情報が記載されます。

プロパティ解説
ClonedTool クローンされたツール インスタンスを返します(読み取り専用)
Handled System.Windows.RoutedEventArgsから継承されます。Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.
OriginalSource System.Windows.RoutedEventArgsから継承されます。Gets the original reporting source as determined by pure hit testing, before any possible System.Windows.RoutedEventArgs.Source adjustment by a parent class.
OriginalTool クローンされたツール インスタンスを返します(読み取り専用)
RoutedEvent System.Windows.RoutedEventArgsから継承されます。Gets or sets the System.Windows.RoutedEventArgs.RoutedEvent associated with this System.Windows.RoutedEventArgs instance.
Source System.Windows.RoutedEventArgsから継承されます。Gets or sets a reference to the object that raised the event.
使用例
Private xamRibbon As XamRibbon
Private Sub addButtonToolProperties()
'Code to Create XamRibbon object..
ListBox mListBox;

    If xamRibbon.Tabs.Count < 1 Then
        Return
    End If
    Dim igrTabItem As RibbonTabItem = xamRibbon.Tabs(0)
    'add RibbonGroup
    Dim buttonToolGroup As RibbonGroup = getRibbonGroup(igrTabItem, "ButtonToolProperties")
    'add ButtonTool
    Dim btnTool As ButtonTool = addButtonToolToRibbonGroup(buttonToolGroup, "buttonToolPtoperties", "btnToolProperties", "/images/icons/Ribbon/New_Large.png")
    Dim btnToolbuttonToolProperties As ButtonTool = addButtonToolToRibbonGroup(buttonToolGroup, "buttonToolProperties", "btnToolProperties", "/images/icons/Ribbon/EditCut.png")
   
    'ButtnTool Properties
    btnTool.Id = "btnToolProperties"
    btnTool.KeyTip = "PR1"
    btnTool.SmallImage = getImageSource("/images/icons/Ribbon/New_Large.png")
   
    'ButtonTool Events
    AddHandler btnTool.Click, AddressOf btnTool_Click
    AddHandler btnTool.Cloned, AddressOf btnTool_Cloned
    AddHandler btnTool.CloneDiscarded, AddressOf btnTool_CloneDiscarded
   
End Sub

'Event Handlers
Private Sub btnTool_CloneDiscarded(ByVal sender As Object, ByVal e As Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs)
    Me.mListBox.Items.Add("" & Chr(10) & "ButtonTool " + getSendername(sender) + " is cloned discarded!")
    mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1))
End Sub

Private Sub btnTool_Cloned(ByVal sender As Object, ByVal e As Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs)
    Me.mListBox.Items.Add("" & Chr(10) & "ButtonTool " + getSendername(sender) + " is cloned!")
    mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1))
End Sub

Private Sub btnTool_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Me.mListBox.Items.Add("" & Chr(10) & "ButtonTool " + getSendername(sender) + " is clicked!")
    mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1))
End Sub

Private Function addButtonToolToRibbonGroup(ByVal igRibbongroup As RibbonGroup, ByVal caption As String, ByVal tagString As String, ByVal imageUriString As String) As ButtonTool
    Dim btnTool As ButtonTool = getButtonTool(caption, tagString, imageUriString)
    igRibbongroup.Items.Add(btnTool)
    Return btnTool
End Function

'Get ButtonTool properties
Private Function getSendername(ByVal sender As Object) As String
    Dim result As String = "unknown"
   
    If TypeOf sender Is ButtonTool Then
        Dim btool As ButtonTool = TryCast(sender, ButtonTool)
        result = "ButtonTool" + ":" + btool.Caption + " location:" + btool.Location.ToString()
        result += "" & Chr(10) & "IsActine=" + btool.IsActive.ToString() + ",IsOnQat=" + btool.IsOnQat.ToString()
        result += "" & Chr(10) & "HaImage=" + btool.HasImage.ToString() + ",IsQatCommonTool=" + btool.IsQatCommonTool.ToString()
        result += "" & Chr(10) & "SizingMode=" + btool.SizingMode.ToString() + ",KeyTip=" + btool.KeyTip
        result += "" & Chr(10) & "HasCaption=" + btool.HasCaption.ToString() + ",Id=" + btool.Id
        result += "" & Chr(10) & "LargeImage=" + btool.LargeImage.ToString()
           
           
        result += "" & Chr(10) & "SmallImage=" + btool.SmallImage.ToString()
    End If
    Return result
End Function

'Get Image Source
Private Function getImageSource(ByVal uriString As String) As BitmapImage
    Dim bmpImage As New BitmapImage()
    bmpImage.BeginInit()
    bmpImage.UriSource = New Uri(uriString, UriKind.RelativeOrAbsolute)
    bmpImage.EndInit()
    Return bmpImage
End Function

'Add ButtonTool to RIbbonGroup
Private Function addButtonToolToRibbonGroup(ByVal igRibbongroup As RibbonGroup, ByVal caption As String, ByVal tagString As String, ByVal imageUriString As String) As ButtonTool
    Dim btnTool As ButtonTool = getButtonTool(caption, tagString, imageUriString)
    igRibbongroup.Items.Add(btnTool)
    Return btnTool
End Function

'Create RibbonGroup
Private Function getRibbonGroup(ByVal igTabItem As RibbonTabItem, ByVal ribbonGroupCaption As String) As RibbonGroup
    Dim ribbonGroup As New RibbonGroup()
    ribbonGroup.Caption = ribbonGroupCaption
    Dim toolHorizontalWrapPanel As New ToolHorizontalWrapPanel()
    ribbonGroup.Items.Add(toolHorizontalWrapPanel)
    igTabItem.RibbonGroups.Add(ribbonGroup)
    Return ribbonGroup
End Function
XamRibbon xamRibbon;
//Code to Create XamRibbon object..
ListBox mListBox;

private void addButtonToolProperties()
{
	if (xamRibbon.Tabs.Count < 1) { return; }
	RibbonTabItem igrTabItem = xamRibbon.Tabs[0];
	//add RibbonGroup
	RibbonGroup buttonToolGroup = getRibbonGroup(igrTabItem, "ButtonToolProperties");
	//add ButtonTool
	ButtonTool btnTool = addButtonToolToRibbonGroup(buttonToolGroup, "buttonToolPtoperties", "btnToolProperties", "/images/icons/Ribbon/New_Large.png");
	ButtonTool btnToolbuttonToolProperties = addButtonToolToRibbonGroup(buttonToolGroup, "buttonToolProperties", "btnToolProperties", "/images/icons/Ribbon/EditCut.png");

	//ButtnTool Properties
	btnTool.Id = "btnToolProperties";
	btnTool.KeyTip = "PR1";
	btnTool.SmallImage = getImageSource("/images/icons/Ribbon/New_Large.png");

	//ButtonTool Events
	btnTool.Click += new RoutedEventHandler(btnTool_Click);
	btnTool.Cloned += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs>(btnTool_Cloned);
	btnTool.CloneDiscarded += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs>(btnTool_CloneDiscarded);

}

//Event Handlers
void btnTool_CloneDiscarded(object sender, Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs e)
{
	this.mListBox.Items.Add("\nButtonTool " + getSendername(sender) + " is cloned discarded!");
	mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]);
}

void btnTool_Cloned(object sender, Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs e)
{
	this.mListBox.Items.Add("\nButtonTool " + getSendername(sender) + " is cloned!");
	mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]);
}

void btnTool_Click(object sender, RoutedEventArgs e)
{
	this.mListBox.Items.Add("\nButtonTool " + getSendername(sender) + " is clicked!");
	mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]);
}

private ButtonTool addButtonToolToRibbonGroup(RibbonGroup igRibbongroup, string caption, string tagString, string imageUriString)
{
	ButtonTool btnTool = getButtonTool(caption, tagString, imageUriString);
	igRibbongroup.Items.Add(btnTool);
	return btnTool;
}

//Get ButtonTool properties
private string getSendername(object sender)
{
	string result = "unknown";

	if (sender is ButtonTool)
	{
		ButtonTool btool = sender as ButtonTool;
		result = "ButtonTool" + ":" + btool.Caption + " location:" + btool.Location.ToString();
		result += "\nIsActine=" + btool.IsActive.ToString() + ",IsOnQat=" + btool.IsOnQat.ToString();
		result += "\nHaImage=" + btool.HasImage.ToString() + ",IsQatCommonTool=" + btool.IsQatCommonTool.ToString();
		result += "\nSizingMode=" + btool.SizingMode.ToString() + ",KeyTip=" + btool.KeyTip;
		result += "\nHasCaption=" + btool.HasCaption.ToString() + ",Id=" + btool.Id;
		result += "\nLargeImage=" + btool.LargeImage.ToString();
		result += "\nSmallImage=" + btool.SmallImage.ToString();


	}
	return result;
}

//Get Image Source
private BitmapImage getImageSource(string uriString)
{
	BitmapImage bmpImage = new BitmapImage();
	bmpImage.BeginInit();
	bmpImage.UriSource = new Uri(uriString, UriKind.RelativeOrAbsolute);
	bmpImage.EndInit();
	return bmpImage;
}		

//Add ButtonTool to RIbbonGroup
private ButtonTool addButtonToolToRibbonGroup(RibbonGroup igRibbongroup, string caption, string tagString, string imageUriString)
{
	ButtonTool btnTool = getButtonTool(caption, tagString, imageUriString);
	igRibbongroup.Items.Add(btnTool);
	return btnTool;
}

//Create RibbonGroup
private RibbonGroup getRibbonGroup(RibbonTabItem igTabItem, string ribbonGroupCaption)
{
	RibbonGroup ribbonGroup = new RibbonGroup();
	ribbonGroup.Caption = ribbonGroupCaption;
	ToolHorizontalWrapPanel toolHorizontalWrapPanel = new ToolHorizontalWrapPanel();
	ribbonGroup.Items.Add(toolHorizontalWrapPanel);
	igTabItem.RibbonGroups.Add(ribbonGroup);
	return ribbonGroup;
}
<!--ButtonTool-->
<igRibbon:ButtonTool Caption="Paste" Id="Paste" KeyTip="BT1" 
   
igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge" 
   
SmallImage="Images\icons\Ribbon\Paste_16x16.png"
   
LargeImage="Images\icons\Ribbon\Paste_32x32.png" 
    
Click="ButtonTool_Click" KeyDown="ButtonTool_KeyDown" />
<!--ButtonTool-end-->
参照