• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Controls.ContextMenuEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: OnDocumentViewerContextMenuOpening

 private static void OnDocumentViewerContextMenuOpening(object sender, ContextMenuEventArgs e)
 {
     if (e.CursorLeft == KeyboardInvokedSentinel)
     {
         DocumentViewer dv = sender as DocumentViewer;
         if (dv != null && dv.ScrollViewer != null)
         {
             OnContextMenuOpening(dv.ScrollViewer.Content, e);
         }
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:11,代码来源:DocumentGridContextMenu.cs


示例17: OnContextMenuOpening

        /// <summary>
        /// Opens the shell context menu instead of the normal context menu on right click.
        /// </summary>
        static void OnContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            Control control = sender as Control;

            // Attempt to open the explorer context menu for the application. If the file does not exist or
            // there is some other problem then a context menu (defined in the XAML) with just "Edit Entry"
            // and "Remove Entry" is opened instead.
            if (control != null && control.DataContext is ApplicationViewModel)
            {
                ApplicationViewModel application = (ApplicationViewModel)control.DataContext;

                if (File.Exists(application.FilePath))
                {
                    ContextMenuWrapper cmw = new ContextMenuWrapper();
                    cmw.OnQueryMenuItems += (QueryMenuItemsEventHandler)delegate(object s, QueryMenuItemsEventArgs args)
                    {
                        args.ExtraMenuItems = new string[] { "Edit Dock Entry", "Remove Dock Entry", "---" };

                        args.GrayedItems = new string[] { "delete", "rename", "cut", "copy" };
                        args.HiddenItems = new string[] { "link" };
                        args.DefaultItem = 1;
                    };
                    cmw.OnAfterPopup += (AfterPopupEventHandler) delegate(object s, AfterPopupEventArgs args)
                    {
                        Messenger.Default.Send<ShellContextMenuMessage>(ShellContextMenuMessage.Closed());
                    };

                    Messenger.Default.Send<ShellContextMenuMessage>(ShellContextMenuMessage.Opened());

                    try
                    {
                        FileSystemInfoEx[] files = new[] { FileInfoEx.FromString(application.FilePath) };
                        int[] position = Win32Mouse.GetMousePosition();
                        string command = cmw.Popup(files, new System.Drawing.Point(position[0], position[1]));

                        // Handle the click on the 'ExtraMenuItems'.
                        switch (command)
                        {
                            case "Edit Dock Entry":
                                Messenger.Default.Send<ApplicationMessage>(ApplicationMessage.Edit(application));
                                break;
                            case "Remove Dock Entry":
                                Messenger.Default.Send<ApplicationMessage>(ApplicationMessage.Remove(application));
                                break;
                        }
                        e.Handled = true; // Don't open the normal context menu.
                    }
                    catch (Exception ex)
                    {
                        Debug.Print("Problem displaying shell context menu: {0}", ex);
                    }
                }
            }
        }
开发者ID:notsonormal,项目名称:AstoundingDock,代码行数:57,代码来源:ShellContextMenuBehaviour.cs


示例18: HandlerForCMO2

 private void HandlerForCMO2(object sender, ContextMenuEventArgs e)
 {
     if (!_flagForCustomContextMenu)
     {
         e.Handled = true; //need to suppress empty menu
         var fe = e.Source as FrameworkElement;
         fe.ContextMenu = BuildMenu();
         _flagForCustomContextMenu = true;
         fe.ContextMenu.IsOpen = true;
     }
 }
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:11,代码来源:Pane.cs


示例19: position

 int mousepos_whenmenuopened = -1;  // The mouse position (as a text offset) upon context menu opening; -1 = could not be determined
 private void txtCodeContextMenu_ContextMenuOpening(object sender, ContextMenuEventArgs e)
 {
     // the mouse position upon context menu opening is stored in mousepos_whenmenuopened
     Nullable<TextViewPosition> vp = txtCode.TextArea.TextView.GetPosition(new Point(e.CursorLeft, e.CursorTop));
     if (vp != null)
     {
         mousepos_whenmenuopened = txtCode.Document.GetOffset(vp.Value.Line, vp.Value.Column);
     }
     else
         mousepos_whenmenuopened = -1;
 }
开发者ID:JoeyEremondi,项目名称:tikzedt,代码行数:12,代码来源:DocumentView.xaml.cs


示例20: MainTree_ContextMenuOpening

        private void MainTree_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            if (MainTree.SelectedItem == null)
            {
                e.Handled = true;
                return;
            }

            var item = (IMainTreeItem) ((TreeViewItem) MainTree.SelectedItem).Tag;
            item.CreateContextMenu();
        }
开发者ID:yonglehou,项目名称:ndist,代码行数:11,代码来源:MainWindow.xaml.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controls.Control类代码示例发布时间:2022-05-26
下一篇:
C# Controls.ContextMenu类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap