Ejemplo n.º 1
0
        private void ExecuteToolCommand(string param)
        {
            if (param.Equals("Select"))
            {
                Tool = new ToolPointer();
            }

            if (param.Equals("Rectangle"))
            {
                Tool = new ToolRectangle();
            }

            if (param.Equals("Line"))
            {
                Tool = new ToolLine();
            }

            if (param.Equals("Polyline"))
            {
                Tool = new ToolPolyLine();
            }
        }
Ejemplo n.º 2
0
        public DrawingCanvas()
            : base()
        {
            graphicsList = new VisualCollection(this);

            this.FocusVisualStyle = null;
            this.Focusable        = true;           // to handle keyboard messages

            this.MouseDown        += new MouseButtonEventHandler(DrawingCanvas_MouseDown);
            this.MouseMove        += new MouseEventHandler(DrawingCanvas_MouseMove);
            this.MouseUp          += new MouseButtonEventHandler(DrawingCanvas_MouseUp);
            this.KeyDown          += new KeyEventHandler(DrawingCanvas_KeyDown);
            this.LostMouseCapture += new MouseEventHandler(DrawingCanvas_LostMouseCapture);
            this.MouseLeave       += new MouseEventHandler(DrawingCanvas_MouseLeave);
            this.Loaded           += DrawingCanvas_Loaded;
            this.MouseWheel       += DrawingCanvas_MouseWheel;

            // Create undo manager
            undoManager = new UndoManager(this);
            undoManager.StateChanged += new EventHandler(undoManager_StateChanged);

            CurrentTool = new ToolPointer();
        }
Ejemplo n.º 3
0
        public void Initialize(ContentManager contentManager, GraphicsDevice graphicsDevice)
        {
            if (!isInitialized)
            {
                Resources.Initialize(contentManager, graphicsDevice);
                GameData.Initialize();
                EditorResources.Initialize();

                this.inventory               = new Inventory(null);
                this.rewardManager           = new RewardManager(null);
                this.timer                   = Stopwatch.StartNew();
                this.ticks                   = 0;
                this.roomSpacing             = 1;
                this.playAnimations          = false;
                this.tileset                 = GameData.TILESET_CLIFFS;
                this.zone                    = GameData.ZONE_PRESENT;
                this.selectedTilesetTileData = this.tileset.GetTileData(0, 0);
                this.eventMode               = false;

                GameData.LoadInventory(inventory);
                GameData.LoadRewards(rewardManager);

                // Create tileset combo box.
                editorForm.ComboBoxTilesets.Items.Clear();
                foreach (KeyValuePair <string, Tileset> entry in Resources.GetResourceDictionary <Tileset>())
                {
                    editorForm.ComboBoxTilesets.Items.Add(entry.Key);
                }
                foreach (KeyValuePair <string, EventTileset> entry in Resources.GetResourceDictionary <EventTileset>())
                {
                    editorForm.ComboBoxTilesets.Items.Add(entry.Key);
                }
                editorForm.ComboBoxTilesets.SelectedIndex = 0;

                // Create zone combo box.
                editorForm.ComboBoxZones.Items.Clear();
                foreach (KeyValuePair <string, Zone> entry in Resources.GetResourceDictionary <Zone>())
                {
                    if (tileset.SpriteSheet.Image.HasVariant(entry.Key))
                    {
                        editorForm.ComboBoxZones.Items.Add(entry.Key);
                    }
                }
                editorForm.ComboBoxZones.SelectedIndex = 0;

                // Create tools.
                tools = new List <EditorTool>();
                AddTool(toolPointer   = new ToolPointer());
                AddTool(toolPlace     = new ToolPlace());
                AddTool(toolSquare    = new ToolSquare());
                AddTool(toolFill      = new ToolFill());
                AddTool(toolSelection = new ToolSelection());
                AddTool(toolEyedrop   = new ToolEyedrop());
                currentToolIndex      = 0;
                tools[currentToolIndex].OnBegin();

                this.isInitialized = true;

                Application.Idle += delegate {
                    Update();
                };
            }
        }