本文整理汇总了C#中System.Windows.Controls.Menu类的典型用法代码示例。如果您正苦于以下问题:C# Menu类的具体用法?C# Menu怎么用?C# Menu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Menu类属于System.Windows.Controls命名空间,在下文中一共展示了Menu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckTheWindowStyle
public CheckTheWindowStyle()
{
Title = "Check the Window Style";
DockPanel dock = new DockPanel();
Content = dock;
Menu menu = new Menu();
dock.Children.Add(menu);
DockPanel.SetDock(menu, Dock.Top);
TextBlock text = new TextBlock();
text.Text = Title;
text.FontSize = 32;
text.TextAlignment = TextAlignment.Center;
dock.Children.Add(text);
MenuItem itemStyle = new MenuItem();
itemStyle.Header = "_Style";
menu.Items.Add(itemStyle);
itemStyle.Items.Add(CreateMenuItem("_No border or caption", WindowStyle.None));
itemStyle.Items.Add(CreateMenuItem("_Single-border window", WindowStyle.SingleBorderWindow));
itemStyle.Items.Add(CreateMenuItem("3_D-border window", WindowStyle.ThreeDBorderWindow));
itemStyle.Items.Add(CreateMenuItem("_Tool window", WindowStyle.ToolWindow));
}
示例2: ViewLoadedParams
internal ViewLoadedParams(DynamoView dynamoV, DynamoViewModel dynamoVM) :
base(dynamoVM.Model)
{
dynamoView = dynamoV;
dynamoViewModel = dynamoVM;
dynamoMenu = dynamoView.titleBar.ChildOfType<Menu>();
}
示例3: AddHelpMenu
//--------------- 메뉴바에 Help 컬렉션 만들기 -----------------
void AddHelpMenu(Menu menu)
{
//------------------------------------------------------------------
// 메뉴의 컨트롤의 선택가능한 부분 만들기 (Help 항목 생성)
MenuItem itemHelp = new MenuItem();
// 만들 메뉴 이름 설정
itemHelp.Header = "_Help";
// 메뉴바의 Help부분을 클릭 했을때 서브 메뉴가 열린다.
// ViewOnOpen => NotepadClone.View.cs
itemHelp.SubmenuOpened += ViewOnOpen;
// 메뉴에 추가
menu.Items.Add(itemHelp);
//------------------------------------------------------------------
//------------------------------------------------------------------
// About 메뉴 아이템 객체 생성
MenuItem itemAbout = new MenuItem();
// 만들 서브 메뉴의 이름 설정
itemAbout.Header = "_About" + strAppTitle + ". . .";
// 서브메뉴 클릭 이벤트
// AboutOnClick => NotepadClone.View.cs
itemAbout.Click += AboutOnClick;
// 위에서 만든 Help 메뉴 안에 서브메뉴 추가
itemHelp.Items.Add(itemAbout);
//------------------------------------------------------------------
}
示例4: UC_CONTROLE_Documents
public UC_CONTROLE_Documents()
{
InitializeComponent();
myDisplayArea = new DisplayArea(this);
myMenu = new Menu(this);
myMenu.changeMenuItems();
}
示例5: When_adding_menu_item_should_be_able_to_add_to_root_menu
public void When_adding_menu_item_should_be_able_to_add_to_root_menu()
{
Menu menu = new Menu { Name = "MainMenu" };
menu.AddMenuItems(new MenuItemData { Parent = "MainMenu" });
Assert.AreEqual(1, menu.Items.Count);
}
示例6: 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;
}
示例7: AddFormatMenu
void AddFormatMenu(Menu menu)
{
//탑 레벨 Format 항목 생성
MenuItem itemFormat = new MenuItem();
itemFormat.Header = "F_ormat";
menu.Items.Add(itemFormat);
//자동 줄바꿈 메뉴 항목 생성
WordWrapMenuItem itemWrap = new WordWrapMenuItem();
itemFormat.Items.Add(itemWrap);
//TextWrapping 프로퍼티 항목과 텍스트 박스를 바인딩
//TextWrapping 프로퍼티와 WordWramenuItem의 WordWrap프로퍼티를 바인딩하기 위해 Binding 객체 생성.
Binding bind = new Binding();
bind.Path = new PropertyPath(TextBox.TextWrappingProperty);
// 데이터 소스 설정.
bind.Source = txtbox;
//바인팅 모드 : 타킷도 소스에 반영할수 있도록 TwoWay 설정.
bind.Mode = BindingMode.TwoWay;
//TextBox의 SetBinding 메소드를 호출.
itemWrap.SetBinding(WordWrapMenuItem.WordWrapProperty, bind);
//Font 메뉴 항목생성
MenuItem itemFont = new MenuItem();
itemFont.Header = "_Font...";
itemFont.Click +=FontOnClick;
itemFormat.Items.Add(itemFont);
}
示例8: CutCopyPaste
//[STAThread]
//public static void Main()
//{
// Application app = new Application();
// app.Run(new CutCopyPaste());
//}
public CutCopyPaste()
{
Title = "Cut ,Copy,and Paste";
//DockPanel 생성
DockPanel dock = new DockPanel();
Content = dock;
//탑 메뉴가 될 Menu 생성
Menu menu = new Menu();
dock.Children.Add(menu);
DockPanel.SetDock(menu, Dock.Top);
//나머지 영역을 채울 TextBlock을 생성
text = new TextBlock();
text.Text = "Sample clipboard text";
text.FontSize = 32;
text.HorizontalAlignment = HorizontalAlignment.Center;
text.VerticalAlignment = VerticalAlignment.Center;
text.TextWrapping = TextWrapping.Wrap;
dock.Children.Add(text);
//Edit 메뉴 생성
MenuItem itemEdit = new MenuItem();
itemEdit.Header = "_Edit";
itemEdit.SubmenuOpened += EditOnOpened;
menu.Items.Add(itemEdit);
//Edit 메뉴 항목 생성
itemCut = new MenuItem();
itemCut.Header = "Cu_t";
itemCut.Click += CutOnClick;
Image img = new Image();
img.Source = new BitmapImage(new Uri("http://image-0.poco.cn/pic_center/img/099/0836c2fc677eb3400a0049b746a5b308_640.jpg"));
itemCut.Icon = img;
itemEdit.Items.Add(itemCut);
itemCopy = new MenuItem();
itemCopy.Header = "_Copy";
itemCopy.Click += CopyOnClick;
img = new Image();
img.Source = new BitmapImage(new Uri("http://www.onegreen.net/QQ/UploadFiles/200806/200861551027277.gif"));
itemCopy.Icon = img;
itemEdit.Items.Add(itemCopy);
itemPaste = new MenuItem();
itemPaste.Header = "_Paste";
itemPaste.Click += PasteOnClick;
img = new Image();
img.Source = new BitmapImage(new Uri("http://www.onegreen.net/QQ/UploadFiles/200806/200861551027422.gif"));
itemPaste.Icon = img;
itemEdit.Items.Add(itemPaste);
itemDelete = new MenuItem();
itemDelete.Header = "_Delete";
itemDelete.Click += DeleteOnClick;
img = new Image();
img.Source = new BitmapImage(new Uri("http://www.onegreen.net/QQ/UploadFiles/200806/200861551027518.jpg"));
itemDelete.Icon = img;
itemEdit.Items.Add(itemDelete);
}
示例9: 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;
};
}
示例10: Attach
protected override void Attach()
{
_control = ControlObject as Menu;
List<MenuItem> items = new List<MenuItem>();
HeaderedItemsControlUtility.GetChildren(_control, items);
foreach (var element in items)
{
var item = element;
string text = HeaderedItemsControlUtility.GetItemText(item);
if (string.IsNullOrEmpty(text))
{
continue;
}
RoutedEventHandler opened = (s, e) =>
{
SubmenuOpened(item, new string[] { text });
};
item.SubmenuOpened += opened;
RoutedEventHandler click = (s, e) =>
{
Click(item, new string[] { text });
};
item.Click += click;
_detach.Add(() =>
{
item.SubmenuOpened -= opened;
item.Click -= click;
});
}
}
示例11: CommandTheMenu
public CommandTheMenu()
{
Title = "Command The Menu";
DockPanel dock = new DockPanel();
Content = dock;
Menu menu = new Menu();
dock.Children.Add(menu);
DockPanel.SetDock(menu, Dock.Top);
text = new TextBlock();
text.Text = "Sample clipboard text";
text.HorizontalAlignment = HorizontalAlignment.Center;
text.VerticalAlignment = VerticalAlignment.Center;
text.FontSize = 32;
text.TextWrapping = TextWrapping.Wrap;
dock.Children.Add(text);
MenuItem itemEdit = new MenuItem();
itemEdit.Header = "_Edit";
menu.Items.Add(itemEdit);
MenuItem itemCut = new MenuItem();
itemCut.Header = "Cu_t";
itemCut.Command = ApplicationCommands.Cut;
itemEdit.Items.Add(itemCut);
MenuItem itemCopy = new MenuItem();
itemCopy.Header = "_Copy";
itemCopy.Command = ApplicationCommands.Copy;
itemEdit.Items.Add(itemCopy);
MenuItem itemPaste = new MenuItem();
itemPaste.Header = "_Paste";
itemPaste.Command = ApplicationCommands.Paste;
itemEdit.Items.Add(itemPaste);
MenuItem itemDelete = new MenuItem();
itemDelete.Header = "_Delete";
itemDelete.Command = ApplicationCommands.Delete;
itemEdit.Items.Add(itemDelete);
// new command
InputGestureCollection collGestures = new InputGestureCollection();
collGestures.Add(new KeyGesture(Key.R, ModifierKeys.Control));
RoutedUICommand commRestore = new RoutedUICommand("_Restore", "Restore", GetType(), collGestures);
MenuItem itemRestore = new MenuItem();
itemRestore.Header = "_Restore";
itemRestore.Command = commRestore;
itemEdit.Items.Add(itemRestore);
CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, CutOnExecute, CutCanExecute));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, CopyOnExecute, CutCanExecute));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, PasteOnExecute, PasteCanExecute));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, DeleteOnExecute, CutCanExecute));
CommandBindings.Add(new CommandBinding(commRestore, RestoreOnExecute));
}
示例12: AddFileMenu
// File �� �ʱ�ȭ
void AddFileMenu(Menu menu)
{
//============================================================
// ž ���� ���� �� ����
//============================================================
MenuItem itemFile = new MenuItem();
// ��� ����
itemFile.Header = "_File";
// Main ���� ������(Top Menu) ����
menu.Items.Add(itemFile);
// New �� �� ���� �� Top�� File�� �߰�
MenuItem itemNew = new MenuItem();
itemNew.Header = "_New";
itemNew.Command = ApplicationCommands.New;
itemFile.Items.Add(itemNew);
CommandBindings.Add(
new CommandBinding(ApplicationCommands.New, NewOnExecute));
// Open �� �� ���� �� Top�� File�� �߰�
MenuItem itemOpen = new MenuItem();
itemOpen.Header = "_Open...";
// Command ����
itemOpen.Command = ApplicationCommands.Open;
itemFile.Items.Add(itemOpen);
// CommandBing�� ���� �̺�Ʈ ��� Open�� OpenOnExecute�Լ� ����
CommandBindings.Add(
new CommandBinding(ApplicationCommands.Open, OpenOnExecute));
// Save �� �� ���� �� Top�� File�� �߰�
MenuItem itemSave = new MenuItem();
itemSave.Header = "_Save";
itemSave.Command = ApplicationCommands.Save;
itemFile.Items.Add(itemSave);
CommandBindings.Add(
new CommandBinding(ApplicationCommands.Save, SaveOnExecute));
// Save As �� �� ���� �� Top�� File�� �߰�
MenuItem itemSaveAs = new MenuItem();
itemSaveAs.Header = "Save _As...";
itemSaveAs.Command = ApplicationCommands.SaveAs;
itemFile.Items.Add(itemSaveAs);
CommandBindings.Add(
new CommandBinding(ApplicationCommands.SaveAs, SaveAsOnExecute));
// ������(Separators) ����
itemFile.Items.Add(new Separator());
// PrintMenu�� �߰��ϴ� �Լ� ȣ��(1������ �˾Ƽ�/ NotepadClone.Print.cs�� ����)
AddPrintMenuItems(itemFile);
itemFile.Items.Add(new Separator());
// Exit �� �� ���� �� Top�� File�� �߰�
MenuItem itemExit = new MenuItem();
itemExit.Header = "E_xit";
itemExit.Click += ExitOnClick;
itemFile.Items.Add(itemExit);
}
示例13: Restart
public Restart(Menu menuToReturnTo, int s)
{
InitializeComponent();
menu = menuToReturnTo;
Image image = new Image();
image.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory() + @"\..\..\Resources\[email protected]", UriKind.Absolute));
backgroundImage.ImageSource = image.Source;
Score.Text = s.ToString();
}
示例14: ViewLoadedParams
internal ViewLoadedParams(DynamoView dynamoV, DynamoViewModel dynamoVM) :
base(dynamoVM.Model)
{
dynamoView = dynamoV;
dynamoViewModel = dynamoVM;
dynamoMenu = dynamoView.titleBar.ChildOfType<Menu>();
DynamoSelection.Instance.Selection.CollectionChanged += OnSelectionCollectionChanged;
}
示例15: When_adding_menu_items_should_be_able_to_add_to_child_menu_item
public void When_adding_menu_items_should_be_able_to_add_to_child_menu_item()
{
Menu menu = new Menu { Name = "MainMenu" };
MenuItem child = new MenuItem { Name = "Child" };
menu.Items.Add(child);
menu.AddMenuItems(new MenuItemData { Parent = "Child" });
Assert.AreEqual(1, child.Items.Count);
}