private void UpdateSerializerMenu() { Image defaultSerializerIcon = Serializer.DefaultType.GetEditorImage(); foreach (Type serializerType in Serializer.AvailableTypes) { string serializerName = serializerType.Name; if (serializerName.EndsWith(typeof(Serializer).Name)) { serializerName = serializerName.Substring(0, serializerName.Length - typeof(Serializer).Name.Length); } MenuModelItem item = this.serializerMenuModel.RequestItem(serializerName, newItem => { newItem.Name = serializerName; newItem.Icon = serializerType.GetEditorImage(); newItem.Tag = serializerType; newItem.ActionHandler = this.formatSetDefault_Click; }); item.Checked = Serializer.DefaultType == serializerType; } this.selectFormattingMethod.Image = defaultSerializerIcon; }
private void InitMenuItems(MainForm main) { MenuModelItem viewItem = main.MainMenu.RequestItem(GeneralRes.MenuName_View); viewItem.AddItem(new MenuModelItem { Name = "Sprite Viewer", ActionHandler = (o, e) => RequestSpriteEditorView() }); var spriteMenu = new MenuModelItem { Name = "Sprite" }; main.MainMenu.AddItem(spriteMenu); spriteMenu.AddItem(new MenuModelItem { Name = "Mirror Y", ActionHandler = (o, e) => SpriteOperations.MirrorY(), ShortcutKeys = Keys.Control | Keys.M }); spriteMenu.AddItem(new MenuModelItem { Name = "Increase Depth", ActionHandler = (o, e) => SpriteOperations.ChangeDepth(+1), ShortcutKeys = Keys.Control | Keys.PageDown }); spriteMenu.AddItem(new MenuModelItem { Name = "Decrease Depth", ActionHandler = (o, e) => SpriteOperations.ChangeDepth(-1), ShortcutKeys = Keys.Control | Keys.PageUp }); }
public static MenuModel FromCefMenu(CefMenuModel model) { var items = new MenuModelItem[model.Count]; CopyItems(model, items); return(new MenuModel(items)); }
protected override void InitPlugin(MainForm main) { base.InitPlugin(main); // Request menus MenuModelItem settingsItem = main.MainMenu.RequestItem(GeneralRes.MenuName_Settings); settingsItem.SortValue = MenuModelItem.SortValue_OverBottom; settingsItem.AddItems(new[] { new MenuModelItem { Name = EditorBaseRes.MenuItemName_AppData, ActionHandler = this.menuItemAppData_Click }, new MenuModelItem { Name = EditorBaseRes.MenuItemName_UserData, ActionHandler = this.menuItemUserData_Click }, new MenuModelItem { Name = EditorBaseRes.MenuItemName_EditorAppData, ActionHandler = this.menuItemProjectSettings_Click } }); DualityEditorApp.ObjectPropertyChanged += this.DualityEditorApp_ObjectPropertyChanged; }
protected override void InitPlugin(MainForm main) { base.InitPlugin(main); // Request menus MenuModelItem viewItem = main.MainMenu.RequestItem(GeneralRes.MenuName_View); viewItem.AddItem(new MenuModelItem { Name = TilemapsRes.MenuItemName_TilePalette, Icon = TilemapsResCache.IconTilePalette, ActionHandler = this.menuItemTilePalette_Click }); viewItem.AddItem(new MenuModelItem { Name = TilemapsRes.MenuItemName_TilesetEditor, Icon = TilemapsResCache.IconTilesetEditor, ActionHandler = this.menuItemTilesetEditor_Click }); // Register events FileEventManager.ResourceModified += this.FileEventManager_ResourceModified; FileEventManager.ResourceDeleted += this.FileEventManager_ResourceDeleted; FileEventManager.ResourceRenamed += this.FileEventManager_ResourceRenamed; FileEventManager.ResourceCreated += this.FileEventManager_ResourceCreated; FileEventManager.BeginGlobalRename += this.FileEventManager_BeginGlobalRename; DualityEditorApp.ObjectPropertyChanged += this.DualityEditorApp_ObjectPropertyChanged; }
private void formatSetDefault_Click(object sender, EventArgs e) { MenuModelItem item = sender as MenuModelItem; Type clickedSerializerType = item.Tag as Type; if (clickedSerializerType == null) { return; } if (clickedSerializerType == Serializer.DefaultType) { return; } Serializer.DefaultType = clickedSerializerType; this.UpdateToolbar(); ProcessingBigTaskDialog taskDialog = new ProcessingBigTaskDialog(this, Properties.GeneralRes.TaskChangeDataFormat_Caption, string.Format(Properties.GeneralRes.TaskChangeDataFormat_Desc, Serializer.DefaultType.ToString()), this.async_ChangeDataFormat, null); taskDialog.ShowDialog(); }
private void InitMenuItems(MainForm main) { MenuModelItem viewItem = main.MainMenu.RequestItem(GeneralRes.MenuName_View); viewItem.AddItem(new MenuModelItem { Name = "Sprite Viewer", ActionHandler = (o, e) => RequestSpriteEditorView() }); viewItem.AddItem(new MenuModelItem { Name = "Librocket Debugger", ActionHandler = (o, e) => LibRocketNet.Core.DebugMode = !LibRocketNet.Core.DebugMode }); var spriteMenu = new MenuModelItem { Name = "Sprite" }; main.MainMenu.AddItem(spriteMenu); spriteMenu.AddItem(new MenuModelItem { Name = "Mirror Y", ActionHandler = (o, e) => SpriteOperations.MirrorY(), ShortcutKeys = Keys.Control | Keys.M }); spriteMenu.AddItem(new MenuModelItem { Name = "Increase Depth", ActionHandler = (o, e) => SpriteOperations.ChangeDepth(+1), ShortcutKeys = Keys.Control | Keys.PageDown }); spriteMenu.AddItem(new MenuModelItem { Name = "Decrease Depth", ActionHandler = (o, e) => SpriteOperations.ChangeDepth(-1), ShortcutKeys = Keys.Control | Keys.PageUp }); var shipMenu = new MenuModelItem { Name = "Ship" }; main.MainMenu.AddItem(shipMenu); shipMenu.AddItem(new MenuModelItem { Name = "Load ship from CSV...", ActionHandler = (o, e) => ShipLoader.LoadShip() }); shipMenu.AddItem(new MenuModelItem { Name = "Show Thrusters as Active", Checkable = true, Checked = false, ActionHandler = (o, e) => Components.Ships.Thruster.Editor_ShowAsThrusting = ((MenuModelItem)o).Checked }); }
private void dropdownResolution_FixedSizeClicked(object sender, EventArgs e) { MenuModelItem item = sender as MenuModelItem; Point2 size = (Point2)item.Tag; this.TargetRenderSizeMode = SpecialRenderSize.Fixed; this.TargetRenderSize = size; }
private void InitMenuItems(MainForm main) { MenuModelItem viewItem = main.MainMenu.RequestItem(GeneralRes.MenuName_View); viewItem.AddItem(new MenuModelItem { Name = "Sprite Atlas Viewer", ActionHandler = (o, e) => RequestAtlasViewer() }); }
protected override void InitPlugin(MainForm main) { base.InitPlugin(main); // Request menu MenuModelItem fileItem = main.MainMenu.RequestItem(GeneralRes.MenuName_File); //fileItem.AddItem(new MenuModelItem //{ // Name = PackageManagerFrontendRes.MenuItemName_PackageView, // Icon = PackageManagerFrontendResCache.IconPackage.ToBitmap(), // ActionHandler = this.menuItemLogView_Click //}); }
protected override void InitPlugin(MainForm main) { base.InitPlugin(main); // Request menus MenuModelItem viewItem = main.MainMenu.RequestItem(GeneralRes.MenuName_Help); viewItem.AddItem(new MenuModelItem { Name = HelpAdvisorRes.MenuItemName_Advisor, Icon = HelpAdvisorResCache.IconHelp, ActionHandler = this.menuItemHelpAdvisor_Click }); }
protected override void InitPlugin(MainForm main) { base.InitPlugin(main); // Request menu MenuModelItem viewItem = main.MainMenu.RequestItem(GeneralRes.MenuName_View); viewItem.AddItem(new MenuModelItem { Name = LogViewRes.MenuItemName_LogView, Icon = LogViewResCache.IconLogView.ToBitmap(), ActionHandler = this.menuItemLogView_Click }); }
protected override void InitPlugin(MainForm main) { base.InitPlugin(main); // Request menu MenuModelItem viewItem = main.MainMenu.RequestItem(GeneralRes.MenuName_View); viewItem.AddItem(new MenuModelItem { Name = CamViewRes.MenuItemName_CamView, Icon = CamViewResCache.IconEye.ToBitmap(), ActionHandler = this.menuItemCamView_Click }); Sandbox.Entering += this.Sandbox_Entering; }
private static void CopyItems(CefMenuModel model, MenuModelItem[] dest) { for (int i = 0; i < dest.Length; i++) { var item = new MenuModelItem { Command = model.GetCommandIdAt(i), Label = model.GetLabelAt(i), Type = model.GetTypeAt(i), Group = model.GetGroupIdAt(i), Visible = model.IsVisibleAt(i), Enabled = model.IsEnabledAt(i), Checked = model.IsCheckedAt(i), }; CefColor color = default; item.Colors = new CefColor[(int)CefMenuColorType.Count]; for (int j = 0; j < item.Colors.Length; j++) { item.Colors[j] = model.GetColorAt(i, (CefMenuColorType)j, ref color) ? color : default; } int keycode = 0, alt = 0, ctrl = 0, shift = 0; if (model.GetAcceleratorAt(i, ref keycode, ref shift, ref ctrl, ref alt)) { item.Accelerator = new Accelerator { KeyCode = keycode, Alt = alt != 0, Ctrl = ctrl != 0, Shift = shift != 0 }; } if (item.Type == CefMenuItemType.Submenu) { CefMenuModel submenu = model.GetSubMenuAt(i); var items = new MenuModelItem[submenu.Count]; CopyItems(submenu, items); item.SubMenu = new MenuModel(items) { IsSubMenu = true }; } dest[i] = item; } }
protected override void InitPlugin(MainForm main) { base.InitPlugin(main); // Request menus MenuModelItem fileItem = main.MainMenu.RequestItem(GeneralRes.MenuName_File); fileItem.AddItem(new MenuModelItem { Name = PackageManagerFrontendRes.MenuItemName_PackageView, Icon = PackageManagerFrontendResCache.IconPackage.ToBitmap(), ActionHandler = this.menuItemManagePackages_Click }); MenuModelItem helpItem = main.MainMenu.RequestItem(GeneralRes.MenuName_Help); helpItem.AddItem(new MenuModelItem { Name = PackageManagerFrontendRes.MenuItemName_BrowseSamples, ActionHandler = this.menuItemBrowseSamples_Click }); }
private void InitMenuItems(MainForm main) { MenuModelItem viewItem = main.MainMenu.RequestItem(GeneralRes.MenuName_View); viewItem.AddItem(new MenuModelItem { Name = "Sprite Viewer", ActionHandler = (o, e) => RequestAtlasViewer() }); var spriteMenu = new MenuModelItem { Name = "Sprite" }; main.MainMenu.AddItem(spriteMenu); spriteMenu.AddItem(new MenuModelItem { Name = "Mirror Y", ActionHandler = (o, e) => SpriteOperations.MirrorY(), ShortcutKeys = Keys.Control | Keys.M }); spriteMenu.AddItem(new MenuModelItem { Name = "Increase Depth", ActionHandler = (o, e) => SpriteOperations.ChangeDepth(+1), ShortcutKeys = Keys.Control | Keys.Add }); spriteMenu.AddItem(new MenuModelItem { Name = "Decrease Depth", ActionHandler = (o, e) => SpriteOperations.ChangeDepth(-1), ShortcutKeys = Keys.Control | Keys.Subtract }); spriteMenu.AddItem(new MenuModelItem { Name = "Create Geometry out of sprites", ActionHandler = (o, e) => SpriteOperations.CreateGeometry(), }); }
protected void InitContextMenu() { this.nodeContextModel = new MenuModel(); this.nodeContextView = new MenuStripMenuView(this.contextMenuNode.Items); this.nodeContextView.ItemSortComparison = this.ContextMenuItemComparison; this.nodeContextView.Model = this.nodeContextModel; this.nodeContextModel.AddItems(new MenuModelItem[] { new MenuModelItem { Name = "TopSeparator", SortValue = MenuModelItem.SortValue_UnderTop - 1, TypeHint = MenuItemTypeHint.Separator }, this.nodeContextItemNew = new MenuModelItem { Name = Properties.ProjectViewRes.ProjectFolderView_ContextItemName_New, SortValue = MenuModelItem.SortValue_UnderTop, Items = new MenuModelItem[] { new MenuModelItem { Name = Properties.ProjectViewRes.ProjectFolderView_ContextItemName_Folder, Icon = Properties.Resources.folder, SortValue = MenuModelItem.SortValue_Top, ActionHandler = this.folderToolStripMenuItem_Click }, new MenuModelItem { Name = "TopSeparator", SortValue = MenuModelItem.SortValue_Top, TypeHint = MenuItemTypeHint.Separator } } }, new MenuModelItem { Name = "UnderTopSeparator", SortValue = MenuModelItem.SortValue_UnderTop, TypeHint = MenuItemTypeHint.Separator }, this.nodeContextItemCut = new MenuModelItem { Name = Properties.ProjectViewRes.ProjectFolderView_ContextItemName_Cut, Icon = Properties.Resources.cut, ShortcutKeys = Keys.Control | Keys.X, ActionHandler = this.cutToolStripMenuItem_Click }, this.nodeContextItemCopy = new MenuModelItem { Name = Properties.ProjectViewRes.ProjectFolderView_ContextItemName_Copy, Icon = Properties.Resources.page_copy, ShortcutKeys = Keys.Control | Keys.C, ActionHandler = this.copyToolStripMenuItem_Click }, this.nodeContextItemPaste = new MenuModelItem { Name = Properties.ProjectViewRes.ProjectFolderView_ContextItemName_Paste, Icon = Properties.Resources.page_paste, ShortcutKeys = Keys.Control | Keys.V, ActionHandler = this.pasteToolStripMenuItem_Click }, this.nodeContextItemDelete = new MenuModelItem { Name = Properties.ProjectViewRes.ProjectFolderView_ContextItemName_Delete, Icon = Properties.Resources.cross, ShortcutKeys = Keys.Delete, ActionHandler = this.deleteToolStripMenuItem_Click }, this.nodeContextItemRename = new MenuModelItem { Name = Properties.ProjectViewRes.ProjectFolderView_ContextItemName_Rename, ActionHandler = this.renameToolStripMenuItem_Click }, new MenuModelItem { Name = "BottomSeparator", SortValue = MenuModelItem.SortValue_Bottom, TypeHint = MenuItemTypeHint.Separator }, this.nodeContextItemShowInExplorer = new MenuModelItem { Name = Properties.ProjectViewRes.ProjectFolderView_ContextItemName_ShowInExplorer, SortValue = MenuModelItem.SortValue_Bottom, ActionHandler = this.showInExplorerToolStripMenuItem_Click } }); }
public void InitMenus() { this.mainMenuView = new MenuStripMenuView(this.mainMenuStrip.Items); this.mainMenuView.ItemInserted += this.mainMenuView_ItemInserted; this.mainMenuView.ItemRemoved += this.mainMenuView_ItemRemoved; this.mainMenuView.Model = this.mainMenuModel; MenuModelItem helpItem; this.mainMenuModel.AddItems(new[] { new MenuModelItem { Name = GeneralRes.MenuName_File, SortValue = MenuModelItem.SortValue_Top, Items = new[] { new MenuModelItem { Name = GeneralRes.MenuItemName_NewProject, SortValue = MenuModelItem.SortValue_Top, Icon = Properties.GeneralResCache.ImageAppCreate, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_NewProject, GeneralRes.MenuItemInfo_NewProject), ActionHandler = this.newProjectItem_Click }, new MenuModelItem { Name = GeneralRes.MenuItemName_PublishGame, SortValue = MenuModelItem.SortValue_Top, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_PublishGame, GeneralRes.MenuItemInfo_PublishGame), ActionHandler = this.actionPublishGame_Click }, new MenuModelItem { Name = "TopSeparator", SortValue = MenuModelItem.SortValue_Top, TypeHint = MenuItemTypeHint.Separator }, new MenuModelItem { Name = this.actionSaveAll.Text, Icon = this.actionSaveAll.Image, ShortcutKeys = Keys.Control | Keys.S, Tag = HelpInfo.FromText(this.actionSaveAll.Text, GeneralRes.MenuItemInfo_SaveAll), ActionHandler = this.actionSaveAll_Click }, new MenuModelItem { Name = "CodeSeparator", TypeHint = MenuItemTypeHint.Separator }, new MenuModelItem { Name = this.actionOpenCode.Text, Icon = this.actionOpenCode.Image, Tag = HelpInfo.FromText(this.actionOpenCode.Text, GeneralRes.MenuItemInfo_OpenProjectSource), ActionHandler = this.actionOpenCode_Click }, new MenuModelItem { Name = "BottomSeparator", SortValue = MenuModelItem.SortValue_Bottom, TypeHint = MenuItemTypeHint.Separator }, new MenuModelItem { Name = GeneralRes.MenuItemName_Quit, SortValue = MenuModelItem.SortValue_Bottom, ShortcutKeys = Keys.Alt | Keys.F4, ActionHandler = this.quitItem_Click } }}, new MenuModelItem { Name = GeneralRes.MenuName_Edit, SortValue = MenuModelItem.SortValue_Top, Items = new[] { this.menuEditUndo = new MenuModelItem { Name = GeneralRes.MenuItemName_Undo, SortValue = MenuModelItem.SortValue_Top, Icon = GeneralResCache.arrow_undo, ShortcutKeys = Keys.Z | Keys.Control, ActionHandler = this.menuEditUndo_Click }, this.menuEditRedo = new MenuModelItem { Name = GeneralRes.MenuItemName_Redo, SortValue = MenuModelItem.SortValue_Top, Icon = GeneralResCache.arrow_redo, ShortcutKeys = Keys.Y | Keys.Control, ActionHandler = this.menuEditRedo_Click } }}, new MenuModelItem { Name = GeneralRes.MenuName_Run, SortValue = MenuModelItem.SortValue_OverBottom, Items = new[] { this.menuRunApp = new MenuModelItem { Name = this.actionRunApp.Text, SortValue = MenuModelItem.SortValue_Top, Icon = this.actionRunApp.Image, ShortcutKeys = Keys.Alt | Keys.F5, Tag = HelpInfo.FromText(this.actionRunApp.Text, GeneralRes.MenuItemInfo_RunGame), ActionHandler = this.actionRunApp_Click }, this.menuDebugApp = new MenuModelItem { Name = this.actionDebugApp.Text, SortValue = MenuModelItem.SortValue_Top, Icon = this.actionDebugApp.Image, ShortcutKeys = Keys.Alt | Keys.F6, Tag = HelpInfo.FromText(this.actionDebugApp.Text, GeneralRes.MenuItemInfo_DebugGame), ActionHandler = this.actionDebugApp_Click }, this.menuProfileApp = new MenuModelItem { Name = GeneralRes.MenuItemName_ProfileGame, SortValue = MenuModelItem.SortValue_Top, Icon = Properties.Resources.application_stopwatch, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_ProfileGame, GeneralRes.MenuItemInfo_ProfileGame), ActionHandler = this.actionProfileApp_Click }, new MenuModelItem { Name = GeneralRes.MenuItemName_ConfigureLauncher, SortValue = MenuModelItem.SortValue_Top, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_ConfigureLauncher, GeneralRes.MenuItemInfo_ConfigureLauncher), ActionHandler = this.actionConfigureLauncher_Click }, new MenuModelItem { Name = "TopSeparator", SortValue = MenuModelItem.SortValue_Top, TypeHint = MenuItemTypeHint.Separator }, this.menuRunSandboxPlay = new MenuModelItem { Name = this.actionRunSandbox.Text, Icon = this.actionRunSandbox.Image, ShortcutKeys = Keys.F5, Tag = HelpInfo.FromText(this.actionRunSandbox.Text, GeneralRes.MenuItemInfo_SandboxPlay), ActionHandler = this.actionRunSandbox_Click }, this.menuRunSandboxStep = new MenuModelItem { Name = this.actionStepSandbox.Text, Icon = this.actionStepSandbox.Image, ShortcutKeys = Keys.F6, Tag = HelpInfo.FromText(this.actionStepSandbox.Text, GeneralRes.MenuItemInfo_SandboxStep), ActionHandler = this.actionStepSandbox_Click }, this.menuRunSandboxPause = new MenuModelItem { Name = this.actionPauseSandbox.Text, Icon = this.actionPauseSandbox.Image, ShortcutKeys = Keys.F7, Tag = HelpInfo.FromText(this.actionPauseSandbox.Text, GeneralRes.MenuItemInfo_SandboxPause), ActionHandler = this.actionPauseSandbox_Click }, this.menuRunSandboxStop = new MenuModelItem { Name = this.actionStopSandbox.Text, Icon = this.actionStopSandbox.Image, ShortcutKeys = Keys.F8, Tag = HelpInfo.FromText(this.actionStopSandbox.Text, GeneralRes.MenuItemInfo_SandboxStop), ActionHandler = this.actionStopSandbox_Click }, new MenuModelItem { Name = "BottomSeparator", SortValue = MenuModelItem.SortValue_Bottom, TypeHint = MenuItemTypeHint.Separator }, this.menuRunSandboxSlower = new MenuModelItem { Name = GeneralRes.MenuItemName_SandboxSlower, ShortcutKeys = Keys.F9, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_SandboxSlower, GeneralRes.MenuItemInfo_SandboxSlower), ActionHandler = this.menuRunSandboxSlower_Click }, this.menuRunSandboxFaster = new MenuModelItem { Name = GeneralRes.MenuItemName_SandboxFaster, ShortcutKeys = Keys.F10, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_SandboxFaster, GeneralRes.MenuItemInfo_SandboxFaster), ActionHandler = this.menuRunSandboxFaster_Click } }}, helpItem = new MenuModelItem { Name = GeneralRes.MenuName_Help, SortValue = MenuModelItem.SortValue_Bottom, Items = new[] { new MenuModelItem { Name = GeneralRes.MenuItemName_About, SortValue = MenuModelItem.SortValue_Top, ActionHandler = this.aboutItem_Click } }} }); // Set some view-specific properties ToolStripItem helpViewItem = this.mainMenuView.GetViewItem(helpItem); helpViewItem.Alignment = ToolStripItemAlignment.Right; // Attach help data to toolstrip actions this.actionOpenCode.Tag = HelpInfo.FromText(this.actionOpenCode.Text, GeneralRes.MenuItemInfo_OpenProjectSource); this.actionSaveAll.Tag = HelpInfo.FromText(this.actionSaveAll.Text, GeneralRes.MenuItemInfo_SaveAll); this.actionRunApp.Tag = HelpInfo.FromText(this.actionRunApp.Text, GeneralRes.MenuItemInfo_RunGame); this.actionDebugApp.Tag = HelpInfo.FromText(this.actionDebugApp.Text, GeneralRes.MenuItemInfo_DebugGame); this.actionRunSandbox.Tag = HelpInfo.FromText(this.actionRunSandbox.Text, GeneralRes.MenuItemInfo_SandboxPlay); this.actionStepSandbox.Tag = HelpInfo.FromText(this.actionStepSandbox.Text, GeneralRes.MenuItemInfo_SandboxStep); this.actionPauseSandbox.Tag = HelpInfo.FromText(this.actionPauseSandbox.Text, GeneralRes.MenuItemInfo_SandboxPause); this.actionStopSandbox.Tag = HelpInfo.FromText(this.actionStopSandbox.Text, GeneralRes.MenuItemInfo_SandboxStop); this.formatUpdateAll.Tag = HelpInfo.FromText(this.formatUpdateAll.Text, GeneralRes.MenuItemInfo_FormatUpdateAll); }
protected void InitContextMenu() { this.nodeContextModel = new MenuModel(); this.nodeContextView = new MenuStripMenuView(this.contextMenuNode.Items); this.nodeContextView.ItemSortComparison = this.ContextMenuItemComparison; this.nodeContextView.Model = this.nodeContextModel; this.nodeContextModel.AddItems(new MenuModelItem[] { new MenuModelItem { Name = "TopSeparator", SortValue = MenuModelItem.SortValue_UnderTop - 1, TypeHint = MenuItemTypeHint.Separator }, this.nodeContextItemNew = new MenuModelItem { Name = Properties.SceneViewRes.SceneView_ContextItemName_New, SortValue = MenuModelItem.SortValue_UnderTop, Items = new MenuModelItem[] { new MenuModelItem { Name = typeof(GameObject).Name, Icon = typeof(GameObject).GetEditorImage(), SortValue = MenuModelItem.SortValue_Top, ActionHandler = this.gameObjectToolStripMenuItem_Click }, new MenuModelItem { Name = "TopSeparator", SortValue = MenuModelItem.SortValue_Top, TypeHint = MenuItemTypeHint.Separator } } }, new MenuModelItem { Name = "UnderTopSeparator", SortValue = MenuModelItem.SortValue_UnderTop, TypeHint = MenuItemTypeHint.Separator }, this.nodeContextItemClone = new MenuModelItem { Name = Properties.SceneViewRes.SceneView_ContextItemName_Clone, Icon = Properties.Resources.page_copy, ShortcutKeys = Keys.Control | Keys.C, ActionHandler = this.cloneToolStripMenuItem_Click }, this.nodeContextItemDelete = new MenuModelItem { Name = Properties.SceneViewRes.SceneView_ContextItemName_Delete, Icon = Properties.Resources.cross, ShortcutKeys = Keys.Delete, ActionHandler = this.deleteToolStripMenuItem_Click }, this.nodeContextItemRename = new MenuModelItem { Name = Properties.SceneViewRes.SceneView_ContextItemName_Rename, ActionHandler = this.renameToolStripMenuItem_Click }, new MenuModelItem { Name = "BottomSeparator", SortValue = MenuModelItem.SortValue_Bottom, TypeHint = MenuItemTypeHint.Separator }, this.nodeContextItemLockHide = new MenuModelItem { Name = Properties.SceneViewRes.SceneView_ContextItemName_LockHide, SortValue = MenuModelItem.SortValue_Bottom, ActionHandler = this.lockedToolStripMenuItem_Click } }); }
public void InitMenus() { this.mainMenuView = new MenuStripMenuView(this.mainMenuStrip.Items); this.mainMenuView.ItemInserted += this.mainMenuView_ItemInserted; this.mainMenuView.ItemRemoved += this.mainMenuView_ItemRemoved; this.mainMenuView.Model = this.mainMenuModel; MenuModelItem helpItem; this.mainMenuModel.AddItems(new[] { new MenuModelItem { Name = GeneralRes.MenuName_File, SortValue = MenuModelItem.SortValue_Top, Items = new[] { new MenuModelItem { Name = GeneralRes.MenuItemName_NewProject, SortValue = MenuModelItem.SortValue_Top, Icon = Properties.GeneralResCache.ImageAppCreate, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_NewProject, GeneralRes.MenuItemInfo_NewProject), ActionHandler = this.newProjectItem_Click }, new MenuModelItem { Name = GeneralRes.MenuItemName_PublishGame, SortValue = MenuModelItem.SortValue_Top, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_PublishGame, GeneralRes.MenuItemInfo_PublishGame), ActionHandler = this.actionPublishGame_Click }, new MenuModelItem { Name = "TopSeparator", SortValue = MenuModelItem.SortValue_Top, TypeHint = MenuItemTypeHint.Separator }, new MenuModelItem { Name = this.actionSaveAll.Text, Icon = this.actionSaveAll.Image, ShortcutKeys = Keys.Control | Keys.S, Tag = HelpInfo.FromText(this.actionSaveAll.Text, GeneralRes.MenuItemInfo_SaveAll), ActionHandler = this.actionSaveAll_Click }, new MenuModelItem { Name = "CodeSeparator", TypeHint = MenuItemTypeHint.Separator }, new MenuModelItem { Name = this.actionOpenCode.Text, Icon = this.actionOpenCode.Image, Tag = HelpInfo.FromText(this.actionOpenCode.Text, GeneralRes.MenuItemInfo_OpenProjectSource), ActionHandler = this.actionOpenCode_Click }, new MenuModelItem { Name = "BottomSeparator", SortValue = MenuModelItem.SortValue_Bottom, TypeHint = MenuItemTypeHint.Separator }, new MenuModelItem { Name = GeneralRes.MenuItemName_Quit, SortValue = MenuModelItem.SortValue_Bottom, ShortcutKeys = Keys.Alt | Keys.F4, ActionHandler = this.quitItem_Click } } }, new MenuModelItem { Name = GeneralRes.MenuName_Edit, SortValue = MenuModelItem.SortValue_Top, Items = new[] { this.menuEditUndo = new MenuModelItem { Name = GeneralRes.MenuItemName_Undo, SortValue = MenuModelItem.SortValue_Top, Icon = GeneralResCache.arrow_undo, ShortcutKeys = Keys.Z | Keys.Control, ActionHandler = this.menuEditUndo_Click }, this.menuEditRedo = new MenuModelItem { Name = GeneralRes.MenuItemName_Redo, SortValue = MenuModelItem.SortValue_Top, Icon = GeneralResCache.arrow_redo, ShortcutKeys = Keys.Y | Keys.Control, ActionHandler = this.menuEditRedo_Click } } }, new MenuModelItem { Name = GeneralRes.MenuName_Run, SortValue = MenuModelItem.SortValue_OverBottom, Items = new[] { this.menuRunApp = new MenuModelItem { Name = this.actionRunApp.Text, SortValue = MenuModelItem.SortValue_Top, Icon = this.actionRunApp.Image, ShortcutKeys = Keys.Alt | Keys.F5, Tag = HelpInfo.FromText(this.actionRunApp.Text, GeneralRes.MenuItemInfo_RunGame), ActionHandler = this.actionRunApp_Click }, this.menuDebugApp = new MenuModelItem { Name = this.actionDebugApp.Text, SortValue = MenuModelItem.SortValue_Top, Icon = this.actionDebugApp.Image, ShortcutKeys = Keys.Alt | Keys.F6, Tag = HelpInfo.FromText(this.actionDebugApp.Text, GeneralRes.MenuItemInfo_DebugGame), ActionHandler = this.actionDebugApp_Click }, this.menuProfileApp = new MenuModelItem { Name = GeneralRes.MenuItemName_ProfileGame, SortValue = MenuModelItem.SortValue_Top, Icon = Properties.Resources.application_stopwatch, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_ProfileGame, GeneralRes.MenuItemInfo_ProfileGame), ActionHandler = this.actionProfileApp_Click }, new MenuModelItem { Name = GeneralRes.MenuItemName_ConfigureLauncher, SortValue = MenuModelItem.SortValue_Top, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_ConfigureLauncher, GeneralRes.MenuItemInfo_ConfigureLauncher), ActionHandler = this.actionConfigureLauncher_Click }, new MenuModelItem { Name = "TopSeparator", SortValue = MenuModelItem.SortValue_Top, TypeHint = MenuItemTypeHint.Separator }, this.menuRunSandboxPlay = new MenuModelItem { Name = this.actionRunSandbox.Text, Icon = this.actionRunSandbox.Image, ShortcutKeys = Keys.F5, Tag = HelpInfo.FromText(this.actionRunSandbox.Text, GeneralRes.MenuItemInfo_SandboxPlay), ActionHandler = this.actionRunSandbox_Click }, this.menuRunSandboxStep = new MenuModelItem { Name = this.actionStepSandbox.Text, Icon = this.actionStepSandbox.Image, ShortcutKeys = Keys.F6, Tag = HelpInfo.FromText(this.actionStepSandbox.Text, GeneralRes.MenuItemInfo_SandboxStep), ActionHandler = this.actionStepSandbox_Click }, this.menuRunSandboxPause = new MenuModelItem { Name = this.actionPauseSandbox.Text, Icon = this.actionPauseSandbox.Image, ShortcutKeys = Keys.F7, Tag = HelpInfo.FromText(this.actionPauseSandbox.Text, GeneralRes.MenuItemInfo_SandboxPause), ActionHandler = this.actionPauseSandbox_Click }, this.menuRunSandboxStop = new MenuModelItem { Name = this.actionStopSandbox.Text, Icon = this.actionStopSandbox.Image, ShortcutKeys = Keys.F8, Tag = HelpInfo.FromText(this.actionStopSandbox.Text, GeneralRes.MenuItemInfo_SandboxStop), ActionHandler = this.actionStopSandbox_Click }, new MenuModelItem { Name = "BottomSeparator", SortValue = MenuModelItem.SortValue_Bottom, TypeHint = MenuItemTypeHint.Separator }, this.menuRunSandboxSlower = new MenuModelItem { Name = GeneralRes.MenuItemName_SandboxSlower, ShortcutKeys = Keys.F9, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_SandboxSlower, GeneralRes.MenuItemInfo_SandboxSlower), ActionHandler = this.menuRunSandboxSlower_Click }, this.menuRunSandboxFaster = new MenuModelItem { Name = GeneralRes.MenuItemName_SandboxFaster, ShortcutKeys = Keys.F10, Tag = HelpInfo.FromText(GeneralRes.MenuItemName_SandboxFaster, GeneralRes.MenuItemInfo_SandboxFaster), ActionHandler = this.menuRunSandboxFaster_Click } } }, helpItem = new MenuModelItem { Name = GeneralRes.MenuName_Help, SortValue = MenuModelItem.SortValue_Bottom, Items = new[] { new MenuModelItem { Name = GeneralRes.MenuItemName_About, SortValue = MenuModelItem.SortValue_Top, ActionHandler = this.aboutItem_Click } } } }); // Set some view-specific properties ToolStripItem helpViewItem = this.mainMenuView.GetViewItem(helpItem); helpViewItem.Alignment = ToolStripItemAlignment.Right; // Attach help data to toolstrip actions this.actionOpenCode.Tag = HelpInfo.FromText(this.actionOpenCode.Text, GeneralRes.MenuItemInfo_OpenProjectSource); this.actionSaveAll.Tag = HelpInfo.FromText(this.actionSaveAll.Text, GeneralRes.MenuItemInfo_SaveAll); this.actionRunApp.Tag = HelpInfo.FromText(this.actionRunApp.Text, GeneralRes.MenuItemInfo_RunGame); this.actionDebugApp.Tag = HelpInfo.FromText(this.actionDebugApp.Text, GeneralRes.MenuItemInfo_DebugGame); this.actionRunSandbox.Tag = HelpInfo.FromText(this.actionRunSandbox.Text, GeneralRes.MenuItemInfo_SandboxPlay); this.actionStepSandbox.Tag = HelpInfo.FromText(this.actionStepSandbox.Text, GeneralRes.MenuItemInfo_SandboxStep); this.actionPauseSandbox.Tag = HelpInfo.FromText(this.actionPauseSandbox.Text, GeneralRes.MenuItemInfo_SandboxPause); this.actionStopSandbox.Tag = HelpInfo.FromText(this.actionStopSandbox.Text, GeneralRes.MenuItemInfo_SandboxStop); this.formatUpdateAll.Tag = HelpInfo.FromText(this.formatUpdateAll.Text, GeneralRes.MenuItemInfo_FormatUpdateAll); }
public DemoForm() { this.InitializeComponent(); // Generate some test / demo objects this.objA = new Test(); this.objA.IPropWithAVeryLongName = 42; this.objA.SomeString = "Blubdiwupp"; this.objA.SomeFloat = (float)Math.PI; this.objA.SomeByte = 128; this.objA.Substruct = new Test2(42); this.objA.ReflectedTypeTestA = new Test3[] { new Test3() }; this.objA.ReflectedTypeTestB = new Dictionary <string, object> { { "First", new Test3() } }; this.objA.ReflectedTypeTestD = new List <ISomeInterface> { new Test3(), new Test3() }; this.objA.stringListField = new List <string>() { "hallo", "welt" }; this.objB = new Test(); this.objB.IPropWithAVeryLongName = 17; this.objB.SomeString = "Kratatazong"; this.objB.SomeFloat = 3.0f; this.objB.SomeByte = 0; this.objB.Substruct = new Test2(100); this.objB.stringListField = new List <string>() { "hallo", "welt" }; this.propertyGrid1.SelectObject(this.objA); foreach (PropertyEditor childEditor in this.propertyGrid1.MainEditor.ChildEditors) { // Test the manual readonly-override on this property. if (childEditor.EditedMember != null && childEditor.EditedMember.Name == "ReadOnlySubstruct") { childEditor.ReadOnly = true; } } this.menuModel = new MenuModel(); this.menuView = new MenuStripMenuView(this.menuStrip.Items); this.menuView.Model = this.menuModel; { MenuModelItem file = new MenuModelItem("File", null, new[] { MenuModelItem.Separator, new MenuModelItem { Name = "Invisible", Visible = false }, MenuModelItem.Separator, new MenuModelItem { Name = "Quit", SortValue = MenuModelItem.SortValue_Bottom, ActionHandler = OnMenuItemClicked }, new MenuModelItem { Name = "New", Items = new[] { new MenuModelItem("Stuff", OnMenuItemClicked), new MenuModelItem("Awesome Stuff", OnMenuItemClicked) } }, new MenuModelItem("Open", bmpItemSmall, OnMenuItemClicked), new MenuModelItem("Close", OnMenuItemClicked), }); MenuModelItem edit = new MenuModelItem("Edit", null, new[] { new MenuModelItem("Undo", OnMenuItemClicked), new MenuModelItem("Redo", OnMenuItemClicked), new MenuModelItem("Checkable", OnMenuItemClicked) }); this.menuModel.AddItem(file); this.menuModel.AddItem(edit); this.menuModel.GetItem(@"File\Close").Enabled = false; this.menuModel.GetItem(@"Edit\Undo").ShortcutKeys = Keys.Control | Keys.Z; this.menuModel.GetItem(@"Edit\Checkable").Checkable = true; this.menuModel.GetItem(@"Edit\Checkable").Checked = true; this.menuModel.RequestItem(@"File\New Option\Blah").ActionHandler = OnMenuItemClicked; this.menuModel.RequestItem(@"file\New Option\blah"); this.menuModel.RequestItem(@"File\New Option\Blub"); this.menuModel.RequestItem(@"File\New option\blub").ActionHandler = OnMenuItemClicked; this.menuModel.RequestItem(@"A Menu\Stuff\Execute").ActionHandler = OnMenuItemClicked; } this.tiledViewModel = new ListModel <TiledModelItem>(); this.tiledViewModel.Add(new TiledModelItem { Name = "Frederick" }); this.tiledViewModel.Add(new TiledModelItem { Name = "Herbert" }); this.tiledViewModel.Add(new TiledModelItem { Name = "Mary" }); this.tiledViewModel.Add(new TiledModelItem { Name = "John" }); this.tiledViewModel.Add(new TiledModelItem { Name = "Sally" }); this.tiledView.Model = this.tiledViewModel; this.tiledView.ItemAppearance += this.tiledView_ItemAppearance; this.timelineViewModel = new TimelineModel(); this.timelineView1.Model = this.timelineViewModel; { TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel { TrackName = "Track A" }; graphTrack.Add(new TimelineLinearGraphModel(new TimelineLinearGraphModel.Key[] { new TimelineLinearGraphModel.Key(0.0f, 1.0f), new TimelineLinearGraphModel.Key(10.0f, 0.75f), new TimelineLinearGraphModel.Key(15.0f, 0.5f), new TimelineLinearGraphModel.Key(20.0f, 0.0f), new TimelineLinearGraphModel.Key(25.0f, -0.5f), new TimelineLinearGraphModel.Key(30.0f, -0.75f), new TimelineLinearGraphModel.Key(40.0f, -1.0f), new TimelineLinearGraphModel.Key(50.0f, 5.0f) })); this.timelineViewModel.Add(graphTrack); } { Func <float, float> func = x => (float)Math.Sin(0.005f * x * x); TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel { TrackName = "Track B" }; graphTrack.Add(new TimelineFunctionGraphModel( x => func(x), delegate(float a, float b) { float result = Math.Min(func(a), func(b)); int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f); int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f); for (int i = intervalIndexA; i <= intervalIndexB; i++) { float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d); result = Math.Min(result, func(x)); if (result <= -1.0f) { break; } } return(result); }, delegate(float a, float b) { float result = Math.Max(func(a), func(b)); int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f); int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f); for (int i = intervalIndexA; i <= intervalIndexB; i++) { float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d); result = Math.Max(result, func(x)); if (result >= 1.0f) { break; } } return(result); }, 0.0f, 500.0f)); this.timelineViewModel.Add(graphTrack); } { Func <float, float> func = x => (float)Math.Sin(0.005f * x * x) * (float)(0.5f + 0.5f * Math.Sin(0.1f * x)); TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel { TrackName = "Track C" }; graphTrack.Add(new TimelineFunctionGraphModel( x => func(x), delegate(float a, float b) { float result = Math.Min(func(a), func(b)); int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f); int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f); for (int i = intervalIndexA; i <= intervalIndexB; i++) { float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d); result = Math.Min(result, func(x)); if (result <= -1.0f) { break; } } return(result); }, delegate(float a, float b) { float result = Math.Max(func(a), func(b)); int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f); int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f); for (int i = intervalIndexA; i <= intervalIndexB; i++) { float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d); result = Math.Max(result, func(x)); if (result >= 1.0f) { break; } } return(result); }, 0.0f, 1500.0f)); this.timelineViewModel.Add(graphTrack); } { TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel { TrackName = "Track D" }; graphTrack.Add(new TimelineLinearGraphModel(Enumerable.Range(0, 360).Select(i => 0.5f + (float)Math.Sin((float)i * Math.PI / 180.0f)), 1.0f, 0.0f)); graphTrack.Add(new TimelineLinearGraphModel(Enumerable.Range(0, 360).Select(i => (float)Math.Sin((float)i * Math.PI / 180.0f)), 1.0f, 50.0f)); this.timelineViewModel.Add(graphTrack); } }
/// <summary> /// Initializes dropdown menu items for the rendering size preset toolbar button. /// Will clean up or update previous contents when called multiple times. /// </summary> private void InitResolutionDropDownItems() { // Remove old items this.resolutionMenuModel.ClearItems(); // Add dynamic presets MenuModelItem gameViewItem = this.resolutionMenuModel.RequestItem("GameView Size"); gameViewItem.ActionHandler = this.dropdownResolution_GameViewSizeClicked; gameViewItem.SortValue = MenuModelItem.SortValue_Top; gameViewItem.Checked = (this.targetRenderSizeMode == SpecialRenderSize.CamView); MenuModelItem targetSizeItem = this.resolutionMenuModel.RequestItem("Target Size"); targetSizeItem.ActionHandler = this.dropdownResolution_TargetSizeClicked; targetSizeItem.SortValue = MenuModelItem.SortValue_Top; targetSizeItem.Checked = (this.targetRenderSizeMode == SpecialRenderSize.GameTarget); this.resolutionMenuModel.AddItem(new MenuModelItem { Name = "TopSeparator", TypeHint = MenuItemTypeHint.Separator, SortValue = MenuModelItem.SortValue_Top + 1 }); // Add fixed presets Point2[] fixedPresets = new Point2[] { new Point2(1920, 1080), new Point2(1280, 1024), new Point2(800, 600), new Point2(320, 300) }; for (int i = 0; i < fixedPresets.Length; i++) { Point2 size = fixedPresets[i]; string itemName = string.Format("{0} x {1}", size.X, size.Y); MenuModelItem item = this.resolutionMenuModel.RequestItem(itemName); item.Tag = size; item.ActionHandler = this.dropdownResolution_FixedSizeClicked; item.SortValue = MenuModelItem.SortValue_UnderTop + i; item.Checked = (this.TargetRenderSize == size); } this.resolutionMenuModel.AddItem(new MenuModelItem { Name = "UnderTopSeparator", TypeHint = MenuItemTypeHint.Separator, SortValue = MenuModelItem.SortValue_UnderTop + fixedPresets.Length + 1 }); // Add recently used custom fixed resolutions int addedItemCount = 0; for (int i = 0; i < this.recentTargetRenderSizes.Count; i++) { Point2 size = this.recentTargetRenderSizes[i]; // Skip those that are already part of the fixed presets if (Array.IndexOf(fixedPresets, size) != -1) { continue; } string itemName = string.Format("{0} x {1}", size.X, size.Y); MenuModelItem item = this.resolutionMenuModel.RequestItem(itemName); item.Tag = size; item.ActionHandler = this.dropdownResolution_FixedSizeClicked; item.SortValue = MenuModelItem.SortValue_Main + i; item.Checked = (this.TargetRenderSize == size); // Add a maximum of three custom resolutions addedItemCount++; if (addedItemCount >= 3) { break; } } }