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


C# Controls.MenuItem类代码示例

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


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


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