Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        public TilePoolPane()
        {
            InitializeComponent();

            ResetComponent();

            // Load form elements

            _buttonRemove.Image     = Properties.Resources.Minus;
            _buttonAdd.Image        = Properties.Resources.Plus;
            _buttonProperties.Image = Properties.Resources.Tags;

            ToolStripMenuItem tilePropertiesItem = new ToolStripMenuItem("Tile Properties")
            {
                Image = Properties.Resources.Tags,
            };
            ToolStripMenuItem tileDeleteItem = new ToolStripMenuItem("Delete Tile")
            {
                Image = Properties.Resources.Cross,
            };

            _tileContextMenu = new ContextMenuStrip();
            _tileContextMenu.Items.AddRange(new ToolStripItem[] {
                tileDeleteItem,
                new ToolStripSeparator(),
                tilePropertiesItem,
            });

            _commandController = new UICommandController();
            _commandController.MapButtons(new Dictionary <CommandKey, ToolStripButton>()
            {
                { CommandKey.TilePoolDelete, _buttonRemove },
                { CommandKey.TilePoolProperties, _buttonProperties },
            });
            _commandController.MapMenuItems(new Dictionary <CommandKey, ToolStripMenuItem>()
            {
                { CommandKey.TilePoolImport, importNewToolStripMenuItem },
                { CommandKey.TilePoolImportMerge, importMergeToolStripMenuItem },
                { CommandKey.TileProperties, tilePropertiesItem },
                { CommandKey.TileDelete, tileDeleteItem },
            });

            _pointerController = new ControlPointerEventController(_layerControl, _layerControl);

            // Setup control

            _poolComboBox.ComboBox.DisplayMember = "Name";

            _layerControl.BackColor       = System.Drawing.Color.SlateGray;
            _layerControl.WidthSynced     = true;
            _layerControl.CanvasAlignment = CanvasAlignment.UpperLeft;

            // Wire events

            _poolComboBox.SelectedIndexChanged += SelectTilePoolHandler;
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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)));
        }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
        public TileBrushPanel()
        {
            InitializeComponent();

            ResetComponent();

            // Load form elements

            _buttonRemove.Image = Properties.Resources.PaintBrushMinus;
            _buttonAdd.Image    = Properties.Resources.PaintBrushPlus;
            _buttonFilter.Image = Properties.Resources.Funnel;

            ToolStripMenuItem buttonAddStatic = new ToolStripMenuItem("New Static Brush...")
            {
                Image = Properties.Resources.Stamp,
            };
            ToolStripMenuItem buttonAddDynamic = new ToolStripMenuItem("New Dynamic Brush...")
            {
                Image = Properties.Resources.TableDynamic,
            };

            _buttonAdd.DropDownItems.AddRange(new ToolStripItem[] {
                buttonAddStatic, buttonAddDynamic,
            });

            _commandController = new UICommandController();
            _commandController.MapButtons(new Dictionary <CommandKey, ToolStripButton>()
            {
                { CommandKey.TileBrushDelete, _buttonRemove },
            });
            _commandController.MapMenuItems(new Dictionary <CommandKey, ToolStripMenuItem>()
            {
                { CommandKey.NewStaticTileBrush, buttonAddStatic },
                { CommandKey.NewDynamicTileBrush, buttonAddDynamic },
            });

            // Wire Events

            _listView.ItemSelectionChanged += ListViewSelectionChangedHandler;
            _listView.MouseClick           += ListViewItemActivateHandler;
            _listView.MouseDoubleClick     += ListViewMouseDoubleClick;
        }
Esempio n. 7
0
/*        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,
            });
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }