|
@@ -23,6 +23,7 @@ namespace PixiEditor.ViewModels
|
|
public RelayCommand GenerateDrawAreaCommand { get; set; } //Command that generates draw area
|
|
public RelayCommand GenerateDrawAreaCommand { get; set; } //Command that generates draw area
|
|
public RelayCommand MouseMoveCommand { get; set; } //Command that is used to draw
|
|
public RelayCommand MouseMoveCommand { get; set; } //Command that is used to draw
|
|
public RelayCommand MouseDownCommand { get; set; }
|
|
public RelayCommand MouseDownCommand { get; set; }
|
|
|
|
+ public RelayCommand KeyDownCommand { get; set; }
|
|
public RelayCommand SaveFileCommand { get; set; } //Command that is used to save file
|
|
public RelayCommand SaveFileCommand { get; set; } //Command that is used to save file
|
|
public RelayCommand UndoCommand { get; set; }
|
|
public RelayCommand UndoCommand { get; set; }
|
|
public RelayCommand RedoCommand { get; set; }
|
|
public RelayCommand RedoCommand { get; set; }
|
|
@@ -35,6 +36,7 @@ namespace PixiEditor.ViewModels
|
|
public RelayCommand DeleteLayerCommand { get; set; }
|
|
public RelayCommand DeleteLayerCommand { get; set; }
|
|
public RelayCommand MoveToBackCommand { get; set; }
|
|
public RelayCommand MoveToBackCommand { get; set; }
|
|
public RelayCommand MoveToFrontCommand { get; set; }
|
|
public RelayCommand MoveToFrontCommand { get; set; }
|
|
|
|
+ public RelayCommand SwapColorsCommand { get; set; }
|
|
|
|
|
|
private double _mouseXonCanvas;
|
|
private double _mouseXonCanvas;
|
|
|
|
|
|
@@ -126,6 +128,8 @@ namespace PixiEditor.ViewModels
|
|
public BitmapOperationsUtility BitmapUtility { get; set; }
|
|
public BitmapOperationsUtility BitmapUtility { get; set; }
|
|
public PixelChangesController ChangesController { get; set; }
|
|
public PixelChangesController ChangesController { get; set; }
|
|
|
|
|
|
|
|
+ public ShortcutController ShortcutController { get; set; }
|
|
|
|
+
|
|
public ViewModelMain()
|
|
public ViewModelMain()
|
|
{
|
|
{
|
|
PixiFilesManager.InitializeTempDirectories();
|
|
PixiFilesManager.InitializeTempDirectories();
|
|
@@ -148,14 +152,38 @@ namespace PixiEditor.ViewModels
|
|
DeleteLayerCommand = new RelayCommand(DeleteLayer, CanDeleteLayer);
|
|
DeleteLayerCommand = new RelayCommand(DeleteLayer, CanDeleteLayer);
|
|
MoveToBackCommand = new RelayCommand(MoveLayerToBack, CanMoveToBack);
|
|
MoveToBackCommand = new RelayCommand(MoveLayerToBack, CanMoveToBack);
|
|
MoveToFrontCommand = new RelayCommand(MoveLayerToFront, CanMoveToFront);
|
|
MoveToFrontCommand = new RelayCommand(MoveLayerToFront, CanMoveToFront);
|
|
|
|
+ SwapColorsCommand = new RelayCommand(SwapColors);
|
|
|
|
+ KeyDownCommand = new RelayCommand(KeyDown);
|
|
ToolSet = new List<Tool> { new PixiTools.PenTool(), new PixiTools.FloodFill(), new PixiTools.LineTool(),
|
|
ToolSet = new List<Tool> { new PixiTools.PenTool(), new PixiTools.FloodFill(), new PixiTools.LineTool(),
|
|
- new PixiTools.CircleTool(), new PixiTools.RectangleTool(), new PixiTools.EarserTool(), new PixiTools.BrightnessTool() };
|
|
|
|
|
|
+ new PixiTools.CircleTool(), new PixiTools.RectangleTool(), new PixiTools.EarserTool(), new PixiTools.BrightnessTool() };
|
|
|
|
+ ShortcutController = new ShortcutController
|
|
|
|
+ {
|
|
|
|
+ Shortcuts = new List<Shortcut> {
|
|
|
|
+ new Shortcut(Key.B, SelectToolCommand, ToolType.Pen),
|
|
|
|
+ new Shortcut(Key.X, SwapColorsCommand),
|
|
|
|
+ new Shortcut(Key.O, OpenFileCommand, ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.E, SelectToolCommand, ToolType.Earser),
|
|
|
|
+ new Shortcut(Key.O, SelectToolCommand, ToolType.ColorPicker),
|
|
|
|
+ new Shortcut(Key.C, SelectToolCommand, ToolType.Rectangle),
|
|
|
|
+ new Shortcut(Key.L, SelectToolCommand, ToolType.Line),
|
|
|
|
+ new Shortcut(Key.G, SelectToolCommand, ToolType.Bucket),
|
|
|
|
+ new Shortcut(Key.Y, RedoCommand, ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.Z, UndoCommand),
|
|
|
|
+ new Shortcut(Key.S, UndoCommand, ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.N, GenerateDrawAreaCommand, ModifierKeys.Control),
|
|
|
|
+ }
|
|
|
|
+ };
|
|
UndoManager.SetMainRoot(this);
|
|
UndoManager.SetMainRoot(this);
|
|
SetActiveTool(ToolType.Pen);
|
|
SetActiveTool(ToolType.Pen);
|
|
BitmapUtility.PrimaryColor = PrimaryColor;
|
|
BitmapUtility.PrimaryColor = PrimaryColor;
|
|
ToolSize = 1;
|
|
ToolSize = 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void KeyDown(object parameter)
|
|
|
|
+ {
|
|
|
|
+ ShortcutController.KeyPressed(((KeyEventArgs)parameter).Key);
|
|
|
|
+ }
|
|
|
|
+
|
|
private void MouseController_StoppedRecordingChanges(object sender, EventArgs e)
|
|
private void MouseController_StoppedRecordingChanges(object sender, EventArgs e)
|
|
{
|
|
{
|
|
Tuple<LayerChanges, LayerChanges> changes = ChangesController.PopChanges();
|
|
Tuple<LayerChanges, LayerChanges> changes = ChangesController.PopChanges();
|
|
@@ -168,6 +196,13 @@ namespace PixiEditor.ViewModels
|
|
new LayerChanges(e.OldPixelsValues, e.ChangedLayerIndex));
|
|
new LayerChanges(e.OldPixelsValues, e.ChangedLayerIndex));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void SwapColors(object parameter)
|
|
|
|
+ {
|
|
|
|
+ var tmp = PrimaryColor;
|
|
|
|
+ PrimaryColor = SecondaryColor;
|
|
|
|
+ SecondaryColor = tmp;
|
|
|
|
+ }
|
|
|
|
+
|
|
public void MoveLayerToFront(object parameter)
|
|
public void MoveLayerToFront(object parameter)
|
|
{
|
|
{
|
|
int oldIndex = (int)parameter;
|
|
int oldIndex = (int)parameter;
|