当前位置: 首页>>代码示例>>C#>>正文


C# Controls.ContextMenuEventArgs类代码示例

本文整理汇总了C#中System.Windows.Controls.ContextMenuEventArgs的典型用法代码示例。如果您正苦于以下问题:C# ContextMenuEventArgs类的具体用法?C# ContextMenuEventArgs怎么用?C# ContextMenuEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ContextMenuEventArgs类属于System.Windows.Controls命名空间,在下文中一共展示了ContextMenuEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnContextMenuOpening

		protected override void OnContextMenuOpening(ContextMenuEventArgs e)
		{
			var treeNode = this.SelectedItem as ModelCollectionTreeNode;
			if (treeNode != null) {
				treeNode.ShowContextMenu();
			}
		}
开发者ID:RHE24,项目名称:SharpDevelop,代码行数:7,代码来源:ClassBrowserTreeView.cs

示例2: DataGridContextMenuOpening

        private void DataGridContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            var element = e.OriginalSource as FrameworkElement;
            var dg = (MultiSelector)sender;

            if (element != null && element.DataContext is ITrack)
            {
                var commandbar = new CommandBar();

                if (dg.SelectedItems.Count == 1)
                {
                    var track = (ITrack)dg.SelectedItems[0];
                    _eventAggregator.GetEvent<TrackCommandBarEvent>().Publish(new TrackCommandBarModel(track, commandbar));
                }
                else if (dg.SelectedItems.Count > 1)
                {
                    var tracks = dg.SelectedItems.Cast<ITrack>();
                    _eventAggregator.GetEvent<TracksCommandBarEvent>().Publish(new TracksCommandBarModel(tracks, commandbar));
                }

                dg.ContextMenu = new CommandBarContextMenu
                {
                    ItemsSource = commandbar.ChildMenuItems
                };
            }
        }
开发者ID:kms,项目名称:torshify-client,代码行数:26,代码来源:AlbumView.xaml.cs

示例3: RichTextBoxContextMenuClosing

 private void RichTextBoxContextMenuClosing(object sender, ContextMenuEventArgs e)
 {
     foreach (Control menuItem in dynamicContextMenuItems)
     {
         contextMenu.Items.Remove(menuItem);
     }
 }
开发者ID:hliang89,项目名称:WpfApplicationFramework,代码行数:7,代码来源:RichTextView.xaml.cs

示例4: listView2_ContextMenuOpening

        private void listView2_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            if (listView2.SelectedItems == null || listView2.SelectedItems.Count == 0)
            {
                e.Handled = true;
                return;
            }

            System.Windows.Controls.ListBox src = e.Source as System.Windows.Controls.ListBox;

            src.ContextMenu.Items.Clear();

            MenuItem m = new MenuItem();
            m.Foreground = Brushes.Black;
            m.Header = "Download selected items";
            m.Command = Model.Download;
            m.CommandParameter = listView2.SelectedItems;
            src.ContextMenu.Items.Add(m);

           /* m = new MenuItem();
            m.Foreground = Brushes.Black;
            m.Header = "View in share";
            m.Command = Model.ViewShare;
            m.CommandParameter = listView2.SelectedItems;
            src.ContextMenu.Items.Add(m);*/
        }
开发者ID:Kayomani,项目名称:FAP,代码行数:26,代码来源:SearchPanel.xaml.cs

示例5: treeView_ContextMenuOpening

		void treeView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
		{
			SharpTreeNode[] selectedNodes = treeView.GetTopLevelSelection().ToArray();
			if (selectedNodes.Length == 0)
				return;
			ContextMenu menu = new ContextMenu();
			foreach (var category in entries.OrderBy(c => c.Metadata.Order).GroupBy(c => c.Metadata.Category)) {
				if (menu.Items.Count > 0) {
					menu.Items.Add(new Separator());
				}
				foreach (var entryPair in category) {
					IContextMenuEntry entry = entryPair.Value;
					if (entry.IsVisible(selectedNodes)) {
						MenuItem menuItem = new MenuItem();
						menuItem.Header = entryPair.Metadata.Header;
						if (!string.IsNullOrEmpty(entryPair.Metadata.Icon)) {
							menuItem.Icon = new Image {
								Width = 16,
								Height = 16,
								Source = Images.LoadImage(entry, entryPair.Metadata.Icon)
							};
						}
						if (entryPair.Value.IsEnabled(selectedNodes)) {
							menuItem.Click += delegate {
								entry.Execute(selectedNodes);
							};
						}
						menu.Items.Add(menuItem);
					}
				}
			}
			if (menu.Items.Count > 0)
				treeView.ContextMenu = menu;
		}
开发者ID:tanujmathur,项目名称:ILSpy,代码行数:34,代码来源:ContextMenuEntry.cs

示例6: OnContextMenuOpening

        protected override void OnContextMenuOpening(ContextMenuEventArgs e)
        {
            this.SelectedLink = boxOutput.SelectedLink;
            if (!string.IsNullOrEmpty(this.SelectedLink))
            {
                if (Constants.UrlRegex.IsMatch(this.SelectedLink))
                {
                    boxOutput.ContextMenu = this.Resources["cmHyperlink"] as ContextMenu;
                }
                else
                {
                    if (this.Type == ChatPageType.DccChat)
                    {
                        return;
                    }
                    this.SelectedLink = this.GetNickWithoutLevel(this.SelectedLink);
                    boxOutput.ContextMenu = this.Resources["cmNickname"] as ContextMenu;
                }
                boxOutput.ContextMenu.IsOpen = true;
                e.Handled = true;
            }
            else
            {

                boxOutput.ContextMenu = this.GetDefaultContextMenu();
                if (this.IsServer && boxOutput.ContextMenu != null)
                {
                    boxOutput.ContextMenu.Items.Refresh();
                }
            }

            base.OnContextMenuOpening(e);
        }
开发者ID:tommyettinger,项目名称:Floe,代码行数:33,代码来源:ChatControl_Events.cs

示例7: listFilters_ContextMenuOpening

 private void listFilters_ContextMenuOpening(object sender, ContextMenuEventArgs e)
 {
     if (listFilters.SelectedIndex==-1)
     {
         e.Handled = true;
     }
 }
开发者ID:MIZiper,项目名称:MizTagger,代码行数:7,代码来源:SearchCondition.xaml.cs

示例8: ContextMenu_Showing

        private static void ContextMenu_Showing(SystemOptionsView systemOptionsView, object sender, ContextMenuEventArgs e)
        {
            if (e.ContextMenuGroupCollection.Any(c => c.Type == ContextMenuGroupType.Custom))
            {
                return;
            }

            var cmd = new Telerik.Windows.Documents.RichTextBoxCommands.InsertPictureCommand(systemOptionsView.HTMLRichTextBox);
            var insertImageMenuItem = new RadMenuItem
                                          {
                                              Header = "Insert Image...",
                                              Command = cmd,
                                              Icon = new Image()
                                                      {
                                                          Source = new BitmapImage(new Uri("/Cebos.Veyron.Common.SL;component/Assets/Icons/presentation.png", UriKind.Relative)),
                                                          //// This is valid too, if the image is within the same assembly
                                                          //Source = new BitmapImage(new Uri("Images/MenuIcons/Clear.png", UriKind.Relative)),              
                                                          Stretch = Stretch.Fill
                                                      }
                                          };
            var customContextMenuGroup = new ContextMenuGroup { insertImageMenuItem };
            e.ContextMenuGroupCollection.Add(customContextMenuGroup);

            var textFormatting = e.ContextMenuGroupCollection.FirstOrDefault(x => x.Type == ContextMenuGroupType.FloatingBlockCommands);
            if (textFormatting != null)
            {
                e.ContextMenuGroupCollection.Remove(textFormatting);
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:29,代码来源:SystemOptionsView.xaml.cs

示例9: MainWindowContextMenuOpening

        private void MainWindowContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            var fe = sender as FrameworkElement;
            var _scriptingUIHelper = CompositionManager.Get<IScriptingUIHelper>();
            var _scriptingConfiguration = CompositionManager.Get<IScriptingConfiguration>();

            if (fe == null)
                return;

            var newcontextualmenu = new ContextMenu();
            if (_scriptingUIHelper != null)
            {
                List<object> menu = _scriptingUIHelper.CreateContextMenusFromScripts(false,
                                                                                     _scriptingConfiguration.
                                                                                         MainWindowContextMenuEntryPoint,
                                                                                     MenuItemClick);

                if (menu != null)
                {
                    foreach (object i in menu)
                        newcontextualmenu.Items.Add(i);
                }
            }

            fe.ContextMenu = newcontextualmenu;
        }
开发者ID:nickhodge,项目名称:MahTweets.LawrenceHargrave,代码行数:26,代码来源:StreamsContainer.xaml.cs

示例10: OnContextMenuOpening

        protected override void OnContextMenuOpening(ContextMenuEventArgs e)
        {
            this.ContextMenu.ItemsSource = ContextMenuOptions;

            if (this.ContextMenu.Items.Count == 0)
                e.Handled = true;

            base.OnContextMenuOpening(e);
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:9,代码来源:DesignerCanvas.cs

示例11: _OnContextMenuOpening

 private void _OnContextMenuOpening(object sender, ContextMenuEventArgs e)
 {
     try
     {
       //  _UpdateContextMenuItemsStatus(sender as Button);
     }
     catch
     { }
 }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:9,代码来源:RecordListItem.xaml.cs

示例12: contextMenuSelectedTextOpening

        private void contextMenuSelectedTextOpening(object sender, ContextMenuEventArgs e)
        {
            var fe = sender as FrameworkElement;

            var newcontextualmenu = new ContextMenu();
            var _scriptingUIHelper = CompositionManager.Get<IScriptingUIHelper>();
            var _scriptingConfiguration = CompositionManager.Get<IScriptingConfiguration>();

            var ewf = Keyboard.FocusedElement as UIElement; // this retrieves the current textbox that has selection
            if (ewf is CompositionTextBox) // if it is a compositiontextbox
            {
                var tbwf = ewf as RichTextBox;
                var spellingSuggestions = tbwf.GetSpellingError(tbwf.CaretPosition);
                if (spellingSuggestions != null)
                {
                    if (spellingSuggestions.Suggestions.HasItems())
                    {
                        foreach (string str in spellingSuggestions.Suggestions)
                        {
                            var mi = new MenuItem
                                         {
                                             Header = str,
                                             FontWeight = FontWeights.Bold,
                                             Command = EditingCommands.CorrectSpellingError,
                                             CommandParameter = str,
                                             CommandTarget = tbwf
                                         };
                            newcontextualmenu.Items.Add(mi);
                        }
                    }
                    else
                    {
                        var mi = new MenuItem
                                     {Header = "No Suggestions", FontWeight = FontWeights.Bold, IsEnabled = false};
                        newcontextualmenu.Items.Add(mi);
                    }
                    newcontextualmenu.Items.Add(new Separator());
                }
            }
            if (_scriptingUIHelper != null)
            {
                _scriptingUIHelper.createCCPContextualMenus(newcontextualmenu, contextMenuItem_StandardCCP);

                var menu =
                    _scriptingUIHelper.CreateContextMenusFromScripts(true,
                                                                     _scriptingConfiguration.
                                                                         ComposeTextContextMenuEntryPoint,
                                                                     mi_TextSelect_Click);

                if (menu != null)
                {
                    foreach (object i in menu)
                        newcontextualmenu.Items.Add(i);
                }
            }
            if (fe != null) fe.ContextMenu = newcontextualmenu;
        }
开发者ID:nickhodge,项目名称:MahTweets.LawrenceHargrave,代码行数:57,代码来源:CompositionBox.xaml.cs

示例13: OnContextMenuOpening

 //Not Needed anymore since WindowChrome is Doing the Job now
 protected override void OnContextMenuOpening(ContextMenuEventArgs e)
 {
     //if (e.Handled)
     //    return;
     //var source = PresentationSource.FromVisual(this) as HwndSource;
     //if (source != null)
     //    ModernChromeWindow.ShowWindowMenu(source, this, Mouse.GetPosition(this), RenderSize);
     //e.Handled = true;
 }
开发者ID:vebin,项目名称:ModernApplicationFramework,代码行数:10,代码来源:MainWindowTitleBar.cs

示例14: OnContextMenuOpening

        private void OnContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            var commit = GetCurrentSelectedCommit();

            if (commit == null)
            {
                e.Handled = true;
                return;
            }
        }
开发者ID:jez9999,项目名称:Git-GUI,代码行数:10,代码来源:ChangesetHistoryContextMenu.xaml.cs

示例15: FrameworkElement_ContextMenuOpening

		void FrameworkElement_ContextMenuOpening(object sender, ContextMenuEventArgs e) {
			if (IsIgnored(sender, e))
				return;

			bool? b = menuService.ShowContextMenu(e, element, ctxMenuGuid, ctxMenuGuid, new GuidObject(guid, element), provider, initCtxMenu, e.CursorLeft == -1 && e.CursorTop == -1);
			if (b == null)
				return;
			if (!b.Value)
				e.Handled = true;
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:10,代码来源:ContextMenuProvider.cs


注:本文中的System.Windows.Controls.ContextMenuEventArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。