Ejemplo n.º 1
0
        public void SelectTool(ToolType tool)
        {
            // select tool
            // end dragging
            _map_info.Selection.IsDragging = false;

            if (tool == ToolType.selection)
            {
                _map_info.SelectedTool = ToolType.selection;
                _map_info.Cursor = CursorType.selection;
                btnToolSelection.FlatStyle = FlatStyle.Flat;
                btnToolBrush.FlatStyle = FlatStyle.Popup;
                btnToolFill.FlatStyle = FlatStyle.Popup;
                btnToolSelectTile.FlatStyle = FlatStyle.Popup;
                btnToolEraser.FlatStyle = FlatStyle.Popup;
            }
            else if (tool == ToolType.brush)
            {
                _map_info.SelectedTool = ToolType.brush;
                _map_info.Cursor = CursorType.brush;
                btnToolSelection.FlatStyle = FlatStyle.Popup;
                btnToolBrush.FlatStyle = FlatStyle.Flat;
                btnToolFill.FlatStyle = FlatStyle.Popup;
                btnToolSelectTile.FlatStyle = FlatStyle.Popup;
                btnToolEraser.FlatStyle = FlatStyle.Popup;
            }
            else if (tool == ToolType.fill)
            {
                _map_info.SelectedTool = ToolType.fill;
                _map_info.Cursor = CursorType.fill;
                btnToolSelection.FlatStyle = FlatStyle.Popup;
                btnToolBrush.FlatStyle = FlatStyle.Popup;
                btnToolFill.FlatStyle = FlatStyle.Flat;
                btnToolSelectTile.FlatStyle = FlatStyle.Popup;
                btnToolEraser.FlatStyle = FlatStyle.Popup;
            }
            else if (tool == ToolType.selectTile)
            {
                _map_info.SelectedTool = ToolType.selectTile;
                _map_info.Cursor = CursorType.selectColor;
                btnToolSelection.FlatStyle = FlatStyle.Popup;
                btnToolBrush.FlatStyle = FlatStyle.Popup;
                btnToolFill.FlatStyle = FlatStyle.Popup;
                btnToolSelectTile.FlatStyle = FlatStyle.Flat;
                btnToolEraser.FlatStyle = FlatStyle.Popup;
            }
            else if (tool == ToolType.eraser)
            {
                _map_info.SelectedTool = ToolType.eraser;
                _map_info.Cursor = CursorType.eraser;
                btnToolSelection.FlatStyle = FlatStyle.Popup;
                btnToolBrush.FlatStyle = FlatStyle.Popup;
                btnToolFill.FlatStyle = FlatStyle.Popup;
                btnToolSelectTile.FlatStyle = FlatStyle.Popup;
                btnToolEraser.FlatStyle = FlatStyle.Flat;
            }

            // change mouse cursor
            if (_map_info.Cursor == CursorType.selection)
            {
                pbMap.Cursor = Cursors.Cross;
            }
            else if (_map_info.Cursor == CursorType.brush)
            {
                String filename = Path.GetDirectoryName(Application.ExecutablePath) + "\\System\\Graphics\\Cursors\\brush.png";
                if (File.Exists(filename))
                {
                    CustomCursor selectionCursor = new CustomCursor(filename, 3, 18);
                    pbMap.Cursor = selectionCursor.CursorGraphic;
                }
                else
                {
                    pbMap.Cursor = Cursors.Cross;
                }
            }
            else if (_map_info.Cursor == CursorType.fill)
            {
                String filename = Path.GetDirectoryName(Application.ExecutablePath) + "\\System\\Graphics\\Cursors\\fill.png";
                if (File.Exists(filename))
                {
                    CustomCursor selectionCursor = new CustomCursor(filename, 10, 10);
                    pbMap.Cursor = selectionCursor.CursorGraphic;
                }
                else
                {
                    pbMap.Cursor = Cursors.Cross;
                }
            }
            else if (_map_info.Cursor == CursorType.selectColor)
            {
                String filename = Path.GetDirectoryName(Application.ExecutablePath) + "\\System\\Graphics\\Cursors\\selecttile.png";
                if (File.Exists(filename))
                {
                    CustomCursor selectionCursor = new CustomCursor(filename, 3, 18);
                    pbMap.Cursor = selectionCursor.CursorGraphic;
                }
                else
                {
                    pbMap.Cursor = Cursors.Cross;
                }
            }
            else if (_map_info.Cursor == CursorType.eraser)
            {
                String filename = Path.GetDirectoryName(Application.ExecutablePath) + "\\System\\Graphics\\Cursors\\eraser.png";
                if (File.Exists(filename))
                {
                    CustomCursor selectionCursor = new CustomCursor(filename, 3, 15);
                    pbMap.Cursor = selectionCursor.CursorGraphic;
                }
                else
                {
                    pbMap.Cursor = Cursors.Cross;
                }
            }
        }