'宣言 Public Event Cloned As EventHandler(Of ToolClonedEventArgs)
public event EventHandler<ToolClonedEventArgs> Cloned
イベント ハンドラが、このイベントに関連するデータを含む、ToolClonedEventArgs 型の引数を受け取りました。次の ToolClonedEventArgs プロパティには、このイベントの固有の情報が記載されます。
プロパティ | 解説 |
---|---|
ClonedTool | クローンされたツール インスタンスを返します(読み取り専用) |
EventHandlersAttached | のイベントの送られたイベント ハンドラーが OriginalTool 用の同じイベントに関連付けられているかどうかを示すブール値を返します。 |
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. |
XamRibbon で追加位置に配置することを有効にするためにツールのクローンが作成される時に発生されます。たとえば、ツールが QuickAccessToolbar に追加されると、XamRibbon はリボン上に表示されるツールのインスタンスのクローンを作成して、QAT 上にクローンが作成されたインスタンスを配置します。このイベントは、クローン作成が行われた後で発生し、クローンが作成されたツールでイベントのためのイベント リスナーをフックする便利な点です。
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; }