public virtual bool MouseDown(MouseEventArgs e, RoomEditorState state) { if (e.Button == MouseButtons.Middle) { return(false); } int x = state.WindowXToRoom(e.X); int y = state.WindowYToRoom(e.Y); AreaDrawMode drawMode = IsFilterOn() ? _drawMode : AreaDrawMode.Select; if (IsLocked(_selectedArea) && drawMode != AreaDrawMode.Select) { return(false); } if (drawMode == AreaDrawMode.Freehand) { Factory.NativeProxy.CreateUndoBuffer(_room, this.MaskToDraw); } _drawingWithArea = _selectedArea; if (e.Button == MouseButtons.Right) { _drawingWithArea = 0; } if ((drawMode == AreaDrawMode.Line) || (drawMode == AreaDrawMode.Freehand) || (drawMode == AreaDrawMode.Rectangle)) { if (_selectedArea == 0) { _tooltip.Show("You are currently using the eraser. To draw new areas, change the selection in the list above the Properties Pane.", _panel, e.X, e.Y - 70, 2000); } _mouseDown = true; _mouseDownX = x; _mouseDownY = y; _room.Modified = true; } else if (drawMode == AreaDrawMode.Fill) { Factory.NativeProxy.CreateUndoBuffer(_room, this.MaskToDraw); Factory.NativeProxy.DrawFillOntoMask(_room, this.MaskToDraw, x, y, _drawingWithArea); _room.Modified = true; UpdateUndoButtonEnabledState(); } else if (drawMode == AreaDrawMode.Select) { int area = Factory.NativeProxy.GetAreaMaskPixel(_room, this.MaskToDraw, x, y); if (area != 0 && !IsLocked(area)) { SelectedArea = area; SelectedAreaChanged(_selectedArea); } } return(true); }
public virtual bool MouseUp(MouseEventArgs e, RoomEditorState state) { _mouseDown = false; AreaDrawMode drawMode = Enabled ? _drawMode : AreaDrawMode.Select; if (IsLocked(_selectedArea) && drawMode != AreaDrawMode.Select) { return(false); } if (_shouldSetDrawModeOnMouseUp) { _shouldSetDrawModeOnMouseUp = false; SetDrawMode(); } else if (drawMode == AreaDrawMode.Line) { Factory.NativeProxy.CreateUndoBuffer(_room, this.MaskToDraw); Factory.NativeProxy.DrawLineOntoMask(_room, this.MaskToDraw, _mouseDownX, _mouseDownY, _currentMouseX, _currentMouseY, _drawingWithArea); _panel.Invalidate(); UpdateUndoButtonEnabledState(); } else if (drawMode == AreaDrawMode.Rectangle) { Factory.NativeProxy.CreateUndoBuffer(_room, this.MaskToDraw); Factory.NativeProxy.DrawFilledRectOntoMask(_room, this.MaskToDraw, _mouseDownX, _mouseDownY, _currentMouseX, _currentMouseY, _drawingWithArea); _panel.Invalidate(); UpdateUndoButtonEnabledState(); } else { return(false); } return(true); }
public void MouseDownAlways(MouseEventArgs e, RoomEditorState state) { if (!IsFilterOn()) { DeselectArea(); _drawingWithArea = 0; _drawMode = AreaDrawMode.Select; } }
private void SetDrawMode() { for (int i = 0; i < _toolbarIcons.Count; i++) { MenuCommand menuCommand = _toolbarIcons[i]; if (menuCommand.Checked) { _drawMode = (AreaDrawMode)i; return; } } }
public virtual bool MouseMove(int x, int y, RoomEditorState state) { _currentMouseX = state.WindowXToRoom(x); _currentMouseY = state.WindowYToRoom(y); AreaDrawMode drawMode = IsFilterOn() ? _drawMode : AreaDrawMode.Select; if (_mouseDown) { if (drawMode == AreaDrawMode.Freehand) { Factory.NativeProxy.DrawLineOntoMask(_room, this.MaskToDraw, _mouseDownX, _mouseDownY, _currentMouseX, _currentMouseY, _drawingWithArea); _mouseDownX = _currentMouseX; _mouseDownY = _currentMouseY; UpdateUndoButtonEnabledState(); } return(true); } return(false); }
public void CommandClick(string command) { foreach (MenuCommand menuCommand in _toolbarIcons) { menuCommand.Checked = false; } if (command == DRAW_LINE_COMMAND) { _drawMode = AreaDrawMode.Line; } else if (command == DRAW_FREEHAND_COMMAND) { _drawMode = AreaDrawMode.Freehand; } else if (command == DRAW_FILL_COMMAND) { _drawMode = AreaDrawMode.Fill; } _toolbarIcons[(int)_drawMode].Checked = true; Factory.ToolBarManager.RefreshCurrentPane(); }
public virtual void CommandClick(string command) { foreach (MenuCommand menuCommand in _toolbarIcons) { if (menuCommand.ID != GREYED_OUT_MASKS_COMMAND) { menuCommand.Checked = false; } } if (command == SELECT_AREA_COMMAND) { _drawMode = AreaDrawMode.Select; } else if (command == DRAW_LINE_COMMAND) { _drawMode = AreaDrawMode.Line; } else if (command == DRAW_FREEHAND_COMMAND) { _drawMode = AreaDrawMode.Freehand; } else if (command == DRAW_RECTANGLE_COMMAND) { _drawMode = AreaDrawMode.Rectangle; } else if (command == DRAW_FILL_COMMAND) { _drawMode = AreaDrawMode.Fill; } else if (command == UNDO_COMMAND) { Factory.NativeProxy.RestoreFromUndoBuffer(_room, this.MaskToDraw); Factory.NativeProxy.ClearUndoBuffer(); _room.Modified = true; _panel.Invalidate(); UpdateUndoButtonEnabledState(); } else if (command == IMPORT_MASK_COMMAND) { string fileName = Factory.GUIController.ShowOpenFileDialog("Select mask to import...", GUIController.IMAGE_FILE_FILTER); if (fileName != null) { ImportMaskFromFile(fileName); } } else if (command == EXPORT_MASK_COMMAND) { string fileName = Factory.GUIController.ShowSaveFileDialog("Save mask as...", GUIController.IMAGE_FILE_FILTER); if (fileName != null) { ExportMaskFromFile(fileName); } } else if (command == COPY_WALKABLE_AREA_MASK_COMMAND) { if (Factory.GUIController.ShowQuestion("This will overwrite your Regions mask with a copy of your Walkable Areas mask. Are you sure you want to do this?") == DialogResult.Yes) { Factory.NativeProxy.CopyWalkableAreaMaskToRegions(_room); _room.Modified = true; _panel.Invalidate(); } } else if (command == GREYED_OUT_MASKS_COMMAND) { _greyedOutMasks = !_greyedOutMasks; _toolbarIcons[TOOLBAR_INDEX_GREY_OUT_MASKS].Checked = _greyedOutMasks; Factory.NativeProxy.GreyOutNonSelectedMasks = _greyedOutMasks; _panel.Invalidate(); } _toolbarIcons[(int)_drawMode].Checked = true; Factory.ToolBarManager.RefreshCurrentPane(); }
public virtual void CommandClick(string command) { foreach (MenuCommand menuCommand in _toolbarIcons) { if (menuCommand.ID != GREYED_OUT_MASKS_COMMAND) { menuCommand.Checked = false; } } if (command == SELECT_AREA_COMMAND) { _drawMode = AreaDrawMode.Select; } else if (command == DRAW_LINE_COMMAND) { _drawMode = AreaDrawMode.Line; } else if (command == DRAW_FREEHAND_COMMAND) { _drawMode = AreaDrawMode.Freehand; } else if (command == DRAW_RECTANGLE_COMMAND) { _drawMode = AreaDrawMode.Rectangle; } else if (command == DRAW_FILL_COMMAND) { _drawMode = AreaDrawMode.Fill; } else if (command == UNDO_COMMAND) { Factory.NativeProxy.RestoreFromUndoBuffer(_room, this.MaskToDraw); Factory.NativeProxy.ClearUndoBuffer(); _room.Modified = true; _panel.Invalidate(); UpdateUndoButtonEnabledState(); } else if (command == IMPORT_MASK_COMMAND) { string fileName = Factory.GUIController.ShowOpenFileDialog("Select mask to import...", GUIController.IMAGE_FILE_FILTER); if (fileName != null) { ImportMaskFromFile(fileName); } } else if (command == COPY_WALKABLE_AREA_MASK_COMMAND) { if (Factory.GUIController.ShowQuestion("This will overwrite your Regions mask with a copy of your Walkable Areas mask. Are you sure you want to do this?") == DialogResult.Yes) { Factory.NativeProxy.CopyWalkableAreaMaskToRegions(_room); _room.Modified = true; _panel.Invalidate(); } } else if (command == GREYED_OUT_MASKS_COMMAND) { _greyedOutMasks = !_greyedOutMasks; _toolbarIcons[TOOLBAR_INDEX_GREY_OUT_MASKS].Checked = _greyedOutMasks; Factory.NativeProxy.GreyOutNonSelectedMasks = _greyedOutMasks; _panel.Invalidate(); } _toolbarIcons[(int)_drawMode].Checked = true; Factory.ToolBarManager.RefreshCurrentPane(); }