예제 #1
0
        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
                }
            });
        }
예제 #2
0
        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
                }
            });
        }
예제 #3
0
파일: MainForm.cs 프로젝트: JanChou/duality
        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);
        }
예제 #4
0
		private void InitObjectVisibilitySelector()
		{
			this.objectVisibilitySelector.DropDown.Closing -= this.objectVisibilitySelector_Closing;
			
			var typesWithCount = (
				from componentType in DualityApp.GetAvailDualityTypes(typeof(Component))
				where !componentType.IsAbstract && !componentType.GetAttributesCached<EditorHintFlagsAttribute>().Any(attrib => attrib.Flags.HasFlag(MemberFlags.Invisible))
				select new { Type = componentType, Count = Scene.Current.FindComponents(componentType).Count() }
				).ToArray();

			typesWithCount = (
				from typeInfo in typesWithCount
				where typeInfo.Count > 0
				orderby typeInfo.Count descending
				select typeInfo
				).ToArray();
			
			// Remove old items
			this.objectVisibilityMenuModel.ClearItems();

			// Add new items
			bool hierarchial = typesWithCount.Length > 8;
			int index = 0;
			foreach (var typeInfo in typesWithCount)
			{
				ObjectVisibilityEntry entry = new ObjectVisibilityEntry(typeInfo.Type);

				string itemPath;
				int sortVal = 0;
				if (hierarchial && index >= 5)
				{
					itemPath = typeInfo.Type.GetEditorCategory().Concat(new [] { entry.ComponentName }).ToString("/");
					sortVal = -typeInfo.Count;
				}
				else
				{
					itemPath = entry.ComponentName;
					sortVal = MenuModelItem.SortValue_Top - typeInfo.Count;
				}
				
				MenuModelItem typeItem = this.objectVisibilityMenuModel.RequestItem(itemPath);
				typeItem.Name = entry.ComponentName;
				typeItem.Icon = typeInfo.Type.GetEditorImage();
				typeItem.SortValue = sortVal;
				typeItem.Tag = entry;
				typeItem.Checkable = true;
				typeItem.Checked = this.objectVisibility != null && this.objectVisibility.Contains(typeInfo.Type);
				typeItem.ActionHandler = this.objectVisibilitySelector_ItemPerformAction;

				index++;
			}
			if (hierarchial)
			{
				this.objectVisibilityMenuModel.AddItem(new MenuModelItem
				{
					Name		= "TopSeparator",
					TypeHint	= MenuItemTypeHint.Separator,
					SortValue	= MenuModelItem.SortValue_Top + 1
				});
			}
			
			if (this.objectVisibilityMenuView == null)
			{
				this.objectVisibilityMenuView = new MenuStripMenuView(this.objectVisibilitySelector.DropDownItems);
				this.objectVisibilityMenuView.Model = this.objectVisibilityMenuModel;
			}

			this.objectVisibilitySelector.DropDown.Closing += this.objectVisibilitySelector_Closing;
		}
 public MenuStripMenuViewEventArgs(MenuStripMenuView view)
 {
     this.view = view;
 }
예제 #6
0
 public MenuStripMenuViewItemEventArgs(IMenuModelItem modelItem, ToolStripItem viewItem, MenuStripMenuView view) : base(view)
 {
     this.modelItem = modelItem;
     this.viewItem  = viewItem;
 }
 public MenuStripMenuViewItemEventArgs(IMenuModelItem modelItem, ToolStripItem viewItem, MenuStripMenuView view)
     : base(view)
 {
     this.modelItem = modelItem;
     this.viewItem = viewItem;
 }
예제 #8
0
 public MenuStripMenuViewEventArgs(MenuStripMenuView view)
 {
     this.view = view;
 }