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

C# Controls.MenuItem类代码示例

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

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



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

示例1: WatchViewFullscreen

        public WatchViewFullscreen()
        {
            InitializeComponent();

            MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(view_MouseButtonIgnore);
            MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(view_MouseButtonIgnore);
            MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(view_MouseRightButtonUp);
            PreviewMouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(view_PreviewMouseRightButtonDown);

            MenuItem mi = new MenuItem();
            mi.Header = "Zoom to Fit";
            mi.Click += new RoutedEventHandler(mi_Click);

            MainContextMenu.Items.Add(mi);

            System.Windows.Shapes.Rectangle backgroundRect = new System.Windows.Shapes.Rectangle();
            Canvas.SetZIndex(backgroundRect, -10);
            backgroundRect.IsHitTestVisible = false;
            BrushConverter bc = new BrushConverter();
            Brush strokeBrush = (Brush)bc.ConvertFrom("#313131");
            backgroundRect.Stroke = strokeBrush;
            backgroundRect.StrokeThickness = 1;
            SolidColorBrush backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(250, 250, 216));
            backgroundRect.Fill = backgroundBrush;

            inputGrid.Children.Add(backgroundRect);
        }
开发者ID:romeo08437,项目名称:Dynamo,代码行数:27,代码来源:WatchViewFullscreen.xaml.cs


示例2: AddImageToEditPanel

        private void AddImageToEditPanel(string filename, BitmapImage bimage)
        {
            Image image = new Image();
            image.Margin = new Thickness(0, 5, 10, 5);
            image.MaxHeight = 150;
            image.MaxWidth = 150;
            image.Name = "QImage" + ImagesCount.ToString();
            RegisterName(image.Name, image);
            if (filename != null)
            {
                image.Source = new BitmapImage(new Uri(filename));
            }
            else
            {
                image.Source = bimage;
            }
            ContextMenu contextmenu = new ContextMenu();
            MenuItem delete = new MenuItem();
            delete.Header = "Delete";
            delete.Tag = ImagesCount.ToString();
            delete.Click += AddQRemoveImageCMClicked;
            contextmenu.Items.Add(delete);
            image.ContextMenu = contextmenu;

            ImagesStackPanel.Children.Add(image);
            ImageDictionary.Add(ImagesCount, image.Name);
            ImagesCount++;
        }
开发者ID:Jayendra88,项目名称:Questionnaire,代码行数:28,代码来源:AdminEditQuestionView.xaml.cs


示例3: NetworkContextMenu

 public NetworkContextMenu()
 {
     MenuItem item = new MenuItem {
         Header = "共有フォルダを持たないホストを非表示"
     };
     Items.Add(item);
 }
开发者ID:t-kojima,项目名称:ExplorerLibrary,代码行数:7,代码来源:NetworkContextMenu.cs


示例4: SetupContextMenu

        private void SetupContextMenu()
        {
            var ctm = new ContextMenu {Background = Brushes.DarkGray};
            var miSmall = new MenuItem();
            miSmall.Click += ChangetoSmall;
            miSmall.Header = "Small";
            miSmall.Foreground = Brushes.White;
            var miNormal = new MenuItem();
            miNormal.Click += ChangetoNormal;
            miNormal.Header = "Normal";
            miNormal.Foreground = Brushes.White;
            var miLarge = new MenuItem();
            miLarge.Click += ChangetoLarge;
            miLarge.Header = "Large";
            miLarge.Foreground = Brushes.White;
            var miChangeSize = new MenuItem
            {
                Header = "Change Size",
                Foreground = Brushes.White
            };
            miChangeSize.Items.Add(miSmall);
            miChangeSize.Items.Add(miNormal);
            miChangeSize.Items.Add(miLarge);
            ctm.Items.Add(miChangeSize);

            ContextMenu = ctm;
        }
开发者ID:Neakas,项目名称:ProjectSWN,代码行数:27,代码来源:Token.cs


示例5: TablesContextMenu

        public TablesContextMenu(DatabaseMenuCommandParameters menuCommandParameters, ExplorerToolWindow parent)
        {
            var dcmd = new DatabaseMenuCommandsHandler(parent);

            var createTableCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                            dcmd.BuildTable);
            var createTableMenuItem = new MenuItem
            {
                Header = "Build Table (beta)...",
                Icon = ImageHelper.GetImageFromResource("../resources/AddTable_5632.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = menuCommandParameters
            };
            createTableMenuItem.CommandBindings.Add(createTableCommandBinding);
            Items.Add(createTableMenuItem);
            
            Items.Add(new Separator());

            var refreshCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                    dcmd.RefreshTables);
            var refreshMenuItem = new MenuItem
            {
                Header = "Refresh",
                Icon = ImageHelper.GetImageFromResource("../resources/refresh.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = menuCommandParameters
            };
            refreshMenuItem.CommandBindings.Add(refreshCommandBinding);
            Items.Add(refreshMenuItem);
        }
开发者ID:inickvel,项目名称:SqlCeToolbox,代码行数:30,代码来源:TablesContextMenu.cs


示例6: Item

			public Item(ToolWindow window, DockSite dockSite)
			{
				Window = window;

				MenuItem = new MenuItem
				{
					Header = window.Title,
					IsCheckable = true,
					IsChecked = window.IsOpen,
					Tag = window,
					Name = "MenuItem" + window.Name,
                    HorizontalContentAlignment = HorizontalAlignment.Left,
                    VerticalContentAlignment = VerticalAlignment.Center
				};

				MenuItem.Click += UpdateToolWindow;

				if (null == dockSite)
					return;

				DockSite = dockSite;

				DockSite.WindowClosed += WindowClosed;
				DockSite.WindowOpened += WindowOpened;
			}
开发者ID:reddream,项目名称:StockSharp,代码行数:25,代码来源:ToolWindowsManager.cs


示例7: NameTextBox_TextChanged

        private void NameTextBox_TextChanged(object sender, TextChangedEventArgs e)//Parsing, and Creating Auotcomplete list based on user input;
        {
            (sender as TextBox).ContextMenu.IsEnabled = true;
            (sender as TextBox).ContextMenu.PlacementTarget = (sender as TextBox);
            (sender as TextBox).ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
            List<MenuItem> autoCompleteItems = new List<MenuItem>();

            if ((sender as TextBox).Text != "")
            {
                foreach (Instructor instructor in instructors)
                {
                    if (CompareForAutoComplete((sender as TextBox).Text, instructor))
                    {//Parsing input to check if it matches name or lastname of any item in the list
                        MenuItem item = new MenuItem();
                        item.Header = instructor.ToString();
                        item.Tag = instructor;
                        item.Click += item_Click;
                        autoCompleteItems.Add(item);
                    }
                    Autocomplete.Items.Clear();
                    foreach (MenuItem item in autoCompleteItems)
                    {
                        Autocomplete.Items.Add(item);
                    }
                }
                Autocomplete.StaysOpen = true;
                (sender as TextBox).ContextMenu.IsOpen = true;
            }

        }
开发者ID:McArren,项目名称:GymApp,代码行数:30,代码来源:DeleteInstructor.xaml.cs


示例8: Initialize

			protected override void Initialize(ILSpyTreeNode[] nodes, MenuItem menuItem)
			{
				if (nodes.Length == 1)
					menuItem.Header = string.Format("Remove {0}", UIUtils.EscapeMenuItemHeader(nodes[0].ToString()));
				else
					menuItem.Header = string.Format("Remove {0} assemblies", nodes.Length);
			}
开发者ID:lisong521,项目名称:dnSpy,代码行数:7,代码来源:AssemblyCommands.cs


示例9: ExtendWithContextMenu

        public static void ExtendWithContextMenu(this TextEditor rtb)
        {
            ContextMenu ctx = new ContextMenu();

            MenuItem cut = new MenuItem();
            cut.Header = "Cut";
            cut.Click += (sender, e) => rtb.Cut();

            MenuItem copy = new MenuItem();
            copy.Header = "Copy";
            copy.Click += (sender, e) => rtb.Copy();

            MenuItem paste = new MenuItem();
            paste.Header = "Paste";
            paste.Click += (sender, e) => rtb.Paste();

            ctx.Items.Add(cut);
            ctx.Items.Add(copy);
            ctx.Items.Add(paste);

            rtb.ContextMenu = ctx;

            ctx.Opened +=
                (sender, e) =>
                {
                    bool noSelectedText = string.IsNullOrEmpty(rtb.SelectedText);

                    cut.IsEnabled = !noSelectedText;
                    copy.IsEnabled = !noSelectedText;

                    bool noClipboardText = string.IsNullOrEmpty(Clipboard.GetText());

                    paste.IsEnabled = !noClipboardText;
                };
        }
开发者ID:furesoft,项目名称:IntegratedJS,代码行数:35,代码来源:Extensions.cs


示例10: InitializeList

        public void InitializeList()
        {
            List<PropertyCheck> pclist = new List<PropertyCheck>();
            Type mte = typeof(MetricsTransactionsEntity);
            contextmenu1.Items.Clear();
            foreach (var prop in mte.GetProperties())
            {
                var pc = new PropertyCheck
                {
                    Name = prop.Name,
                };
                pclist.Add(pc);

                
                var item = new MenuItem
                    {
                        Header = prop.Name,
                        IsCheckable = true,
                        DataContext=pc
                    };
                item.Checked += new RoutedEventHandler(item_Checked);
                item.Unchecked += new RoutedEventHandler(item_Unchecked);
                contextmenu1.Items.Add(item);
            }
        }
开发者ID:mogliang,项目名称:Azure-Storage-Analytics-Viewer,代码行数:25,代码来源:TimelineChart.xaml.cs


示例11: Loaded

        public void Loaded(ViewLoadedParams p)
        {
            if (publishViewModel == null || inviteViewModel == null)
                return;

            publishViewModel.Workspaces = p.WorkspaceModels;
            publishViewModel.CurrentWorkspaceModel = p.CurrentWorkspaceModel;

            dynamoMenu = p.dynamoMenu;
            extensionMenuItem = GenerateMenuItem();
            p.AddMenuItem(MenuBarType.File, extensionMenuItem, 11);

            manageCustomizersMenuItem = GenerateManageCustomizersMenuItem();
            p.AddMenuItem(MenuBarType.File, manageCustomizersMenuItem, 12);

            inviteMenuItem = GenerateInviteMenuItem();
            p.AddMenuItem(MenuBarType.File, inviteMenuItem, 11);

            p.AddSeparator(MenuBarType.File, separator, 14);

            p.CurrentWorkspaceChanged += (ws) =>
            {
                publishViewModel.CurrentWorkspaceModel = ws;

                var isEnabled = ws is HomeWorkspaceModel && publishModel.HasAuthProvider;
                extensionMenuItem.IsEnabled = isEnabled;
            };

        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:29,代码来源:DynamoPublishExtension.cs


示例12: AddLabel

 private void AddLabel(TorrentLabel label)
 {
     var comboItem = new ComboBoxItem
     {
         Content = label.Name,
         Background = label.Brush,
         Foreground = label.ForegroundBrush,
         Tag = label
     };
     labelList.Items.Insert(labelList.Items.Count - 2, comboItem);
     var menuItem = new MenuItem
     {
         Header = label.Name,
         Background = label.Brush,
         Foreground = label.ForegroundBrush,
         Tag = label
     };
     menuItem.Click += setLabelOnTorrentClicked;
     torrentGridContextMenuSetLabelMenu.Items.Insert(0, menuItem);
     menuItem = new MenuItem
     {
         Header = label.Name,
         Background = label.Brush,
         Foreground = label.ForegroundBrush,
         Tag = label
     };
     menuItem.Click += setLabelOnTorrentClicked;
     menuSetLabelMenu.Items.Insert(0, menuItem);
 }
开发者ID:naiduv,项目名称:Patchy,代码行数:29,代码来源:MainWindow.Commands.cs


示例13: MainWindow

        public MainWindow(IContainer container)
        {
            InitializeComponent();
            _background = new SolidColorBrush(Color.FromRgb(0x24, 0x27, 0x28));

            //            _background =
            //                new ImageBrush(new BitmapImage(new Uri(@"Images/grid.jpg", UriKind.Relative)))
            //                {
            //                    Stretch = Stretch.None,
            //                    TileMode = TileMode.Tile,
            //                    AlignmentX = AlignmentX.Left,
            //                    AlignmentY = AlignmentY.Top,
            //                    Viewport = new Rect(0, 0, 128, 128),
            //                    ViewportUnits = BrushMappingMode.Absolute
            //                };

            Application.Current.Resources["Dunno"] = Application.Current.Resources["Dunno1"];

            var compositeNode = new CompositeNode(new NodeDispatcher("Graph Dispatcher"));// TestNodes.Test3(new NodeDispatcher("Graph Dispatcher"));
            _compositeNodeViewModel = new CompositeNodeViewModel(compositeNode, new Vector(), new ControlTypesResolver());
            MainNode.DataContext = _compositeNodeViewModel;

            var contextMenu = new ContextMenu();
            MainNode.ContextMenu = contextMenu;

            var nodeTypes = container != null ? container.ResolveNamed<IEnumerable<Type>>("NodeTypes") : Enumerable.Empty<Type>();

            foreach (var nodeType in nodeTypes)
            {
                var menuItem = new MenuItem { Header = nodeType.Name };
                menuItem.Click += (sender, args) => MenuItemOnClick(nodeType, MainNode.TranslatePosition(menuItem.TranslatePoint(new Point(), this)));
                contextMenu.Items.Add(menuItem);
            }
        }
开发者ID:misupov,项目名称:Turbina,代码行数:34,代码来源:MainWindow.xaml.cs


示例14: Match

 public InlineLink Match(string word, Brush lBrush, IStatusUpdate oStatusUpdate)
 {
     MatchCollection mc = _matcher.Matches(word);
     if (mc.Count <= 0)
         return null;
     var cm = new ContextMenu();
     var miIgnore = new MenuItem {Header = "Globally ignore " + mc[0].Value + " hashtag", Tag = mc[0].Value};
     cm.Items.Add(miIgnore);
     var il = new InlineLink
                  {
                      Text = mc[0].Value,
                      FontSize = _textProcessorEngine.FsDefault,
                      FontFamily = _textProcessorEngine.FfDefault,
                      Foreground = lBrush,
                      ToolTip = mc[0].Value,
                      Tag = mc[0].Value,
                      HoverColour = _textProcessorEngine.BrHover,
                      NormalColour = _textProcessorEngine.BrBase,
                      ContextMenu = cm
                  };
     il.ToolTip = "Search for " + word + " in your current tweet stream";
     il.MouseLeftButtonDown +=
         (s, e) => PluginEventHandler.FireEvent("searchHashtag", oStatusUpdate, mc[0].Value);
     miIgnore.Click += (s, e) => _textProcessorEngine.GlobalExcludeSettings.Add(word);
     return il;
 }
开发者ID:nickhodge,项目名称:MahTweets.LawrenceHargrave,代码行数:26,代码来源:TwitterHashtag.cs


示例15: switch

 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.topFour = ((System.Windows.Controls.MenuItem)(target));
     return;
     case 2:
     
     #line 604 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.Border)(target)).MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.OpenWindow);
     
     #line default
     #line hidden
     return;
     case 3:
     
     #line 623 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.Border)(target)).MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.OpenNavWindow);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }
开发者ID:FabioOstlind,项目名称:TestRepo,代码行数:25,代码来源:MainWindow.g.cs


示例16: AddTrayIconWpf

        private void AddTrayIconWpf() {
            Application.Current.Dispatcher.Invoke(() => {
                var rhm = new MenuItem { Header = "RHM Settings", Command = RhmService.Instance.ShowSettingsCommand };
                rhm.SetBinding(UIElement.VisibilityProperty, new Binding {
                    Source = RhmService.Instance,
                    Path = new PropertyPath(nameof(RhmService.Active))
                });

                var restore = new MenuItem { Header = UiStrings.Restore };
                var close = new MenuItem { Header = UiStrings.Close };

                restore.Click += RestoreMenuItem_Click;
                close.Click += CloseMenuItem_Click;

                _icon = new TaskbarIcon {
                    Icon = AppIconService.GetTrayIcon(),
                    ToolTipText = AppStrings.Hibernate_TrayText,
                    ContextMenu = new ContextMenu {
                        Items = {
                            rhm,
                            restore,
                            new Separator(),
                            close
                        }
                    },
                    DoubleClickCommand = new DelegateCommand(WakeUp)
                };

            });
        }
开发者ID:gro-ove,项目名称:actools,代码行数:30,代码来源:AppHibernator.TaskbarIcon.cs


示例17: AddContextMenu

        protected void AddContextMenu()
        {
            ContextMenu mainMenu = new ContextMenu();

            MenuItem item1 = new MenuItem() { Header = "Copy to Clipboard" };
            mainMenu.Items.Add(item1);

            MenuItem item1a = new MenuItem();
            item1a.Header = "96 dpi";
            item1.Items.Add(item1a);
            item1a.Click += OnClipboardCopy_96dpi;

            MenuItem item1b = new MenuItem();
            item1b.Header = "300 dpi";
            item1.Items.Add(item1b);
            item1b.Click += OnClipboardCopy_300dpi;

            MenuItem item1c = new MenuItem() { Header = "Enhanced Metafile" }; ;
            item1.Items.Add(item1c);
            item1c.Click += CopyToEMF;

            //MenuItem item2 = new MenuItem() { Header = "Print..." };
            //mainMenu.Items.Add(item2);
            //item2.Click += InvokePrint;
            windowsFormsHost.ContextMenu = mainMenu;
        }
开发者ID:goutkannan,项目名称:ironlab,代码行数:26,代码来源:MSChartHost.xaml.cs


示例18: MainWindow

        public MainWindow()
        {
            InitializeComponent();
            listbox1.ItemsSource = fac;
            textblock1.Visibility = Visibility.Hidden;
            textblock2.Visibility = Visibility.Hidden;
            textblock3.Visibility = Visibility.Hidden;
            textblock4.Visibility = Visibility.Hidden;
            textbox1.Visibility = Visibility.Hidden;
            textbox2.Visibility = Visibility.Hidden;
            textbox3.Visibility = Visibility.Hidden;
            textbox4.Visibility = Visibility.Hidden;
            button1.Visibility = Visibility.Hidden;
            button2.Visibility = Visibility.Hidden;
            button3.Visibility = Visibility.Hidden;

            App.LanguageChanged += LanguageChanged;
            CultureInfo currLang = App.Language;

            menuItemLanguage.Items.Clear();
            foreach (var lang in App.Languages)
            {
                MenuItem menuLang = new MenuItem();
                menuLang.Header = lang.DisplayName;
                menuLang.Tag = lang;
                menuLang.IsChecked = lang.Equals(currLang);
                menuLang.Click += ChangeLanguageClick;
                menuItemLanguage.Items.Add(menuLang);
            }
        }
开发者ID:AltumSpatium,项目名称:Labs,代码行数:30,代码来源:MainWindow.xaml.cs


示例19: Initialize

 public override void Initialize(ContextMenuEntryContext context, MenuItem menuItem)
 {
     var tokRef = GetTokenReference(context);
     menuItem.Header = string.Format("Go to MD Table Row ({0:X8})", tokRef.Token);
     if (context.Element == MainWindow.Instance.treeView || context.Element is DecompilerTextView)
         menuItem.InputGestureText = "Shift+Alt+R";
 }
开发者ID:kenwilcox,项目名称:dnSpy,代码行数:7,代码来源:ContextMenuCommands.cs


示例20: MainWindow

		public MainWindow ()
		{
			Title = "Mono Windows Presentation Foundation utility";

			MenuItem color_finder_menu = new MenuItem ();
			color_finder_menu.Header = "_Color finder";
			color_finder_menu.Click += delegate (object sender, RoutedEventArgs e)
			{
				new ColorFinder.ColorFinderWindow ().Show ();
			};

			MenuItem visual_structure_viewer_menu = new MenuItem ();
			visual_structure_viewer_menu.Header = "_Visual structure viewer";
			visual_structure_viewer_menu.Click += delegate (object sender, RoutedEventArgs e)
			{
				new VisualStructureViewer.VisualStructureViewerWindow ().Show ();
			};

			MenuItem utilities_menu = new MenuItem ();
			utilities_menu.Header = "_Utilities";
			utilities_menu.Items.Add (color_finder_menu);
			utilities_menu.Items.Add (visual_structure_viewer_menu);

			Menu menu = new Menu ();
			menu.Items.Add (utilities_menu);

			DockPanel contents = new DockPanel ();
			contents.LastChildFill = false;
			DockPanel.SetDock (menu, Dock.Top);
			contents.Children.Add (menu);

			Content = contents;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:33,代码来源:MainWindow.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Controls.NavigatingEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Controls.Menu类代码示例发布时间: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