private void TreeNodeClickHandler(object sender, TreeNodeMouseClickEventArgs e) { _tree.SelectedNode = e.Node; if (_controller == null || !(e.Node.Tag is Guid)) { return; } Guid tag = (Guid)e.Node.Tag; if (e.Button == MouseButtons.Right) { ProjectPanelComponent targetComponent = ComponentManager.RegisteredInstances.FirstOrDefault(c => c.ShouldHandle(tag)); if (targetComponent != null) { targetComponent.ShowContextMenu(_commandController, e.Location, tag); return; } // TODO: Remove when fully on components ContextMenuStrip contextMenu = CommandMenuBuilder.BuildContextMenu(_controller.Menu(tag)); _commandController.BindCommandManager(_controller.CommandManager); _commandController.Clear(); _commandController.MapMenuItems(contextMenu.Items); contextMenu.Show(_tree, e.Location); } }
public void ShowContextMenu(UICommandController commandController, Point location, Guid tag) { ContextMenuStrip contextMenu = CommandMenuBuilder.BuildContextMenu(GetCommandMenu(tag)); commandController.BindCommandManager(CommandManager); commandController.Clear(); commandController.MapMenuItems(contextMenu.Items); contextMenu.Show(RootNode.TreeView, location); }
private void ContextMenuActivatedHandler(object sender, ContextMenuEventArgs e) { ContextMenuStrip menu = CommandMenuBuilder.BuildContextMenu(e.Menu); if (_contextController != null) { _contextController.Dispose(); } _contextController = new UICommandController(); _contextController.BindCommandManager(_controller.CommandManager); _contextController.MapMenuItems(menu.Items); menu.Show(this, _pointerController.UntranslatePosition(new Point(e.Location.X, e.Location.Y))); }
public ObjectPanel() { InitializeComponent(); // Load form elements _buttonRemoveObject.Image = Properties.Resources.GameMinus; _buttonAddObject.Image = Properties.Resources.GamePlus; _commandController = new UICommandController(); _commandController.MapButtons(new Dictionary <CommandKey, ToolStripButton>() { { CommandKey.ObjectProtoImport, _buttonAddObject }, { CommandKey.ObjectProtoDelete, _buttonRemoveObject }, }); _itemContextMenu = CommandMenuBuilder.BuildContextMenu(new CommandMenu("", new List <CommandMenuGroup>() { new CommandMenuGroup() { new CommandMenuEntry(CommandKey.ObjectProtoEdit) { Default = true }, }, new CommandMenuGroup() { CommandKey.ObjectProtoClone, CommandKey.ObjectProtoDelete, CommandKey.ObjectProtoRename, }, new CommandMenuGroup() { CommandKey.ObjectProtoProperties, }, })); _commandController.MapMenuItems(_itemContextMenu.Items); // Wire events _listView.ItemSelectionChanged += ListViewSelectionChangedHandler; _listView.MouseClick += ListViewMouseClickHandler; }
/* private ToolStripMenuItem _levelsExportRaster; * * private ToolStripMenuItem _objectsGroups; * private ToolStripMenuItem _objectsAlign; * private ToolStripMenuItem _objectsAlignTop; * private ToolStripMenuItem _objectsAlignBottom; * private ToolStripMenuItem _objectsAlignLeft; * private ToolStripMenuItem _objectsAlignRight; * private ToolStripMenuItem _objectsAlignCenterHorz; * private ToolStripMenuItem _objectsAlignCenterVert;*/ public StandardMenu() { _menuStrip = new MenuStrip(); _fileStrip = CommandMenuBuilder.BuildToolStripMenu(new CommandMenu("&File", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.NewProject, CommandKey.OpenProject, CommandKey.Save, CommandKey.SaveAs, }, new CommandMenuGroup() { CommandKey.Exit, }, })); _editStrip = CommandMenuBuilder.BuildToolStripMenu(new CommandMenu("&Edit", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.Undo, CommandKey.Redo, }, new CommandMenuGroup() { CommandKey.Cut, CommandKey.Copy, CommandKey.Paste, CommandKey.Delete, }, new CommandMenuGroup() { CommandKey.SelectAll, CommandKey.SelectNone, }, })); _viewStrip = CommandMenuBuilder.BuildToolStripMenu(new CommandMenu("&View", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.ViewZoomNormal, CommandKey.ViewZoomIn, CommandKey.ViewZoomOut, }, new CommandMenuGroup() { CommandKey.ViewGrid, }, })); _projectStrip = CommandMenuBuilder.BuildToolStripMenu(new CommandMenu("&Project", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.ProjectAddLevel, }, })); _levelStrip = CommandMenuBuilder.BuildToolStripMenu(new CommandMenu("&Level", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.LevelResize, }, })); _layerStrip = CommandMenuBuilder.BuildToolStripMenu(new CommandMenu("La&yers", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.NewTileLayer, CommandKey.NewObjectLayer, }, new CommandMenuGroup() { CommandKey.LayerEdit, CommandKey.LayerClone, CommandKey.LayerDelete, CommandKey.LayerProperties, }, new CommandMenuGroup() { new CommandMenuEntry(new CommandMenu("&Arrange", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.LayerMoveTop, CommandKey.LayerMoveUp, CommandKey.LayerMoveDown, CommandKey.LayerMoveBottom, }, })), new CommandMenuEntry(new CommandMenu("&View", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.LayerShowCurrentOnly, CommandKey.LayerShowAll, CommandKey.LayerShowNone, }, })), }, new CommandMenuGroup() { CommandKey.LayerExportRaster, }, })); _tileStrip = CommandMenuBuilder.BuildToolStripMenu(new CommandMenu("&Tiles", new List <CommandMenuGroup>() { new CommandMenuGroup() { new CommandMenuEntry(new CommandMenu("&Brushes", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.NewStaticTileBrush, CommandKey.NewDynamicTileBrush, }, new CommandMenuGroup() { CommandKey.TileBrushClone, CommandKey.TileBrushDelete, }, })), new CommandMenuEntry(new CommandMenu("&Selections", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.TileSelectionCreateBrush, CommandKey.TileSelectionPromoteLayer, }, new CommandMenuGroup() { CommandKey.TileSelectionFloat, CommandKey.TileSelectionDefloat, }, })), }, new CommandMenuGroup() { CommandKey.TilePoolExport, CommandKey.TilePoolImportOver, }, })); _objectStrip = CommandMenuBuilder.BuildToolStripMenu(new CommandMenu("&Objects", new List <CommandMenuGroup>() { new CommandMenuGroup() { new CommandMenuEntry(new CommandMenu("Object &Prototypes", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.ObjectProtoImport }, new CommandMenuGroup() { CommandKey.ObjectProtoEdit, CommandKey.ObjectProtoClone, CommandKey.ObjectProtoDelete, CommandKey.ObjectProtoRename, }, new CommandMenuGroup() { CommandKey.ObjectProtoProperties, }, })), }, new CommandMenuGroup() { new CommandMenuEntry(new CommandMenu("&Arrange", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.ObjectMoveTop, CommandKey.ObjectMoveUp, CommandKey.ObjectMoveDown, CommandKey.ObjectMoveBottom, }, })), }, new CommandMenuGroup() { new CommandMenuEntry(new CommandMenu("&Reference Point", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.ObjectReferenceImage, CommandKey.ObjectReferenceMask, CommandKey.ObjectReferenceOrigin, }, })), new CommandMenuEntry(new CommandMenu("&Snapping", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.ObjectSnappingNone, CommandKey.ObjectSnappingTopLeft, CommandKey.ObjectSnappingTopRight, CommandKey.ObjectSnappingBottomLeft, CommandKey.ObjectSnappingBottomRight, CommandKey.ObjectSnappingTop, CommandKey.ObjectSnappingBottom, CommandKey.ObjectSnappingLeft, CommandKey.ObjectSnappingRight, CommandKey.ObjectSnappingVert, CommandKey.ObjectSnappingHorz, CommandKey.ObjectSnappingCenter, }, })), }, })); _helpStrip = CommandMenuBuilder.BuildToolStripMenu(new CommandMenu("&Help")); _commandController = new UICommandController(); _commandController.MapMenuItems(new List <ToolStripMenuItem>() { _fileStrip, _editStrip, _viewStrip, _projectStrip, _levelStrip, _layerStrip, _tileStrip, _objectStrip, _helpStrip }); _menuStrip.Items.AddRange(new ToolStripItem[] { _fileStrip, _editStrip, _viewStrip, _projectStrip, _levelStrip, _layerStrip, _tileStrip, _objectStrip, _helpStrip, }); }
public LayerPane() { InitializeComponent(); ResetComponent(); // Load form elements _buttonAdd.Image = Properties.Resources.LayerPlus; _buttonRemove.Image = Properties.Resources.LayerMinus; _buttonUp.Image = Properties.Resources.Arrow90; _buttonDown.Image = Properties.Resources.Arrow270; _buttonCopy.Image = Properties.Resources.Layers; _buttonProperties.Image = Properties.Resources.Tags; _menuNewTileLayer.Image = Properties.Resources.Grid; _menuNewObjectLayer.Image = Properties.Resources.Game; _commandController = new UICommandController(); _commandController.MapButtons(new Dictionary <CommandKey, ToolStripButton>() { { CommandKey.LayerDelete, _buttonRemove }, { CommandKey.LayerClone, _buttonCopy }, { CommandKey.LayerProperties, _buttonProperties }, { CommandKey.LayerMoveUp, _buttonUp }, { CommandKey.LayerMoveDown, _buttonDown }, }); _commandController.MapMenuItems(new Dictionary <CommandKey, ToolStripMenuItem>() { { CommandKey.NewTileLayer, _menuNewTileLayer }, { CommandKey.NewObjectLayer, _menuNewObjectLayer }, }); _itemContextMenu = CommandMenuBuilder.BuildContextMenu(new CommandMenu("", new List <CommandMenuGroup>() { new CommandMenuGroup() { new CommandMenuEntry(CommandKey.LayerEdit) { Default = true }, }, new CommandMenuGroup() { CommandKey.LayerClone, CommandKey.LayerDelete, }, new CommandMenuGroup() { CommandKey.LayerMoveTop, CommandKey.LayerMoveUp, CommandKey.LayerMoveDown, CommandKey.LayerMoveBottom, }, new CommandMenuGroup() { CommandKey.LayerExportRaster, CommandKey.LayerProperties, }, })); _commandController.MapMenuItems(_itemContextMenu.Items); }
internal Main(Loader loader) { InitializeComponent(); FormClosing += FormClosingHandler; // Toolbars _menu = new StandardMenu(); _standardToolbar = new StandardToolbar(); _tileToolbar = new TileToolbar(); toolStripContainer1.TopToolStripPanel.Controls.AddRange(new Control[] { _standardToolbar.Strip, _tileToolbar.Strip }); Controls.Add(_menu.Strip); MainMenuStrip = _menu.Strip; _infoStatus = new InfoStatus(statusBar); //PresenterManager pm = new PresenterManager(); //_editor = new EditorPresenter(); //_editor.Initialize(pm); _pm = loader.InitializePresenterManager(); _editor = _pm.Lookup <EditorPresenter>(); loader.InitializeProjectPanelComponents(projectPanel1.ComponentManager); //pm.Register(_editor); //_editor.SyncContentTabs += SyncContentTabsHandler; _editor.SyncContentView += SyncContentViewHandler; _editor.SyncModified += SyncProjectModified; _editor.PanelActivation += PanelActivated; _editor.SyncCurrentLevel += SyncCurrentLevel; _editor.ContentWorkspace.ContentOpened += ContentWorkspaceContentOpened; _editor.ContentWorkspace.ContentClosed += ContentWorkspaceContentClosed; _editor.ContentWorkspace.ProjectReset += ContentWorkspaceReset; //_editor.CommandManager.Perform(Presentation.Commands.CommandKey.OpenProject); _editor.NewDefault(); tabControlEx1.ContextMenuStrip = CommandMenuBuilder.BuildContextMenu(new CommandMenu("", new List <CommandMenuGroup>() { new CommandMenuGroup() { CommandKey.LevelClose, CommandKey.LevelCloseAllOther, }, new CommandMenuGroup() { CommandKey.LevelRename, CommandKey.LevelResize, }, new CommandMenuGroup() { CommandKey.LevelProperties, }, })); tabControlEx1.ContextMenuStrip.Opening += contextMenuStrip1_Opening; _commandController = new UICommandController(); _commandController.BindCommandManager(_editor.CommandManager); _commandController.MapMenuItems(tabControlEx1.ContextMenuStrip.Items); }