|
@@ -2,6 +2,7 @@
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel;
|
|
|
|
+using System.Diagnostics;
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows;
|
|
@@ -23,22 +24,16 @@ using PixiEditor.Models.Tools.Tools;
|
|
|
|
|
|
namespace PixiEditor.ViewModels
|
|
namespace PixiEditor.ViewModels
|
|
{
|
|
{
|
|
- internal class ViewModelMain : ViewModelBase
|
|
|
|
|
|
+ public class ViewModelMain : ViewModelBase
|
|
{
|
|
{
|
|
private const string ConfirmationDialogMessage = "Document was modified. Do you want to save changes?";
|
|
private const string ConfirmationDialogMessage = "Document was modified. Do you want to save changes?";
|
|
|
|
|
|
- private double _mouseXonCanvas;
|
|
|
|
-
|
|
|
|
- private double _mouseYonCanvas;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
private Color _primaryColor = Colors.Black;
|
|
private Color _primaryColor = Colors.Black;
|
|
|
|
|
|
private bool _recenterZoombox;
|
|
private bool _recenterZoombox;
|
|
|
|
|
|
private Color _secondaryColor = Colors.White;
|
|
private Color _secondaryColor = Colors.White;
|
|
|
|
|
|
- private ToolType _selectedTool;
|
|
|
|
private Selection _selection;
|
|
private Selection _selection;
|
|
|
|
|
|
private Cursor _toolCursor;
|
|
private Cursor _toolCursor;
|
|
@@ -47,92 +42,6 @@ namespace PixiEditor.ViewModels
|
|
|
|
|
|
private bool _unsavedDocumentModified;
|
|
private bool _unsavedDocumentModified;
|
|
|
|
|
|
- public ViewModelMain()
|
|
|
|
- {
|
|
|
|
- FilesManager.InitializeTempDirectories();
|
|
|
|
- BitmapManager = new BitmapManager();
|
|
|
|
- BitmapManager.BitmapOperations.BitmapChanged += BitmapUtility_BitmapChanged;
|
|
|
|
- BitmapManager.MouseController.StoppedRecordingChanges += MouseController_StoppedRecordingChanges;
|
|
|
|
- BitmapManager.DocumentChanged += BitmapManager_DocumentChanged;
|
|
|
|
- ChangesController = new PixelChangesController();
|
|
|
|
- SelectToolCommand = new RelayCommand(SetTool, DocumentIsNotNull);
|
|
|
|
- OpenNewFilePopupCommand = new RelayCommand(OpenNewFilePopup);
|
|
|
|
- MouseMoveCommand = new RelayCommand(MouseMove);
|
|
|
|
- MouseDownCommand = new RelayCommand(MouseDown);
|
|
|
|
- SaveFileCommand = new RelayCommand(SaveFile, CanSave);
|
|
|
|
- UndoCommand = new RelayCommand(Undo, CanUndo);
|
|
|
|
- RedoCommand = new RelayCommand(Redo, CanRedo);
|
|
|
|
- MouseUpCommand = new RelayCommand(MouseUp);
|
|
|
|
- OpenFileCommand = new RelayCommand(Open);
|
|
|
|
- SetActiveLayerCommand = new RelayCommand(SetActiveLayer);
|
|
|
|
- NewLayerCommand = new RelayCommand(NewLayer, CanCreateNewLayer);
|
|
|
|
- DeleteLayerCommand = new RelayCommand(DeleteLayer, CanDeleteLayer);
|
|
|
|
- MoveToBackCommand = new RelayCommand(MoveLayerToBack, CanMoveToBack);
|
|
|
|
- MoveToFrontCommand = new RelayCommand(MoveLayerToFront, CanMoveToFront);
|
|
|
|
- SwapColorsCommand = new RelayCommand(SwapColors);
|
|
|
|
- KeyDownCommand = new RelayCommand(KeyDown);
|
|
|
|
- RenameLayerCommand = new RelayCommand(RenameLayer);
|
|
|
|
- DeselectCommand = new RelayCommand(Deselect, SelectionIsNotEmpty);
|
|
|
|
- SelectAllCommand = new RelayCommand(SelectAll, CanSelectAll);
|
|
|
|
- CopyCommand = new RelayCommand(Copy, SelectionIsNotEmpty);
|
|
|
|
- DuplicateCommand = new RelayCommand(Duplicate, SelectionIsNotEmpty);
|
|
|
|
- CutCommand = new RelayCommand(Cut, SelectionIsNotEmpty);
|
|
|
|
- PasteCommand = new RelayCommand(Paste, CanPaste);
|
|
|
|
- ClipCanvasCommand = new RelayCommand(ClipCanvas, DocumentIsNotNull);
|
|
|
|
- DeletePixelsCommand = new RelayCommand(DeletePixels, SelectionIsNotEmpty);
|
|
|
|
- OpenResizePopupCommand = new RelayCommand(OpenResizePopup, DocumentIsNotNull);
|
|
|
|
- SelectColorCommand = new RelayCommand(SelectColor);
|
|
|
|
- RemoveSwatchCommand = new RelayCommand(RemoveSwatch);
|
|
|
|
- SaveDocumentCommand = new RelayCommand(SaveDocument, DocumentIsNotNull);
|
|
|
|
- OnStartupCommand = new RelayCommand(OnStartup);
|
|
|
|
- CloseWindowCommand = new RelayCommand(CloseWindow);
|
|
|
|
- CenterContentCommand = new RelayCommand(CenterContent, DocumentIsNotNull);
|
|
|
|
- ToolSet = new ObservableCollection<Tool>
|
|
|
|
- {
|
|
|
|
- new MoveTool(), new PenTool(), new SelectTool(), new FloodFill(), new LineTool(),
|
|
|
|
- new CircleTool(), new RectangleTool(), new EarserTool(), new ColorPickerTool(), new 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, modifier: ModifierKeys.Control),
|
|
|
|
- new Shortcut(Key.E, SelectToolCommand, ToolType.Earser),
|
|
|
|
- new Shortcut(Key.O, SelectToolCommand, ToolType.ColorPicker),
|
|
|
|
- new Shortcut(Key.R, SelectToolCommand, ToolType.Rectangle),
|
|
|
|
- new Shortcut(Key.C, SelectToolCommand, ToolType.Circle),
|
|
|
|
- new Shortcut(Key.L, SelectToolCommand, ToolType.Line),
|
|
|
|
- new Shortcut(Key.G, SelectToolCommand, ToolType.Bucket),
|
|
|
|
- new Shortcut(Key.U, SelectToolCommand, ToolType.Brightness),
|
|
|
|
- new Shortcut(Key.V, SelectToolCommand, ToolType.Move),
|
|
|
|
- new Shortcut(Key.M, SelectToolCommand, ToolType.Select),
|
|
|
|
- new Shortcut(Key.Y, RedoCommand, modifier: ModifierKeys.Control),
|
|
|
|
- new Shortcut(Key.Z, UndoCommand),
|
|
|
|
- new Shortcut(Key.S, SaveFileCommand,
|
|
|
|
- modifier: ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt),
|
|
|
|
- new Shortcut(Key.S, SaveDocumentCommand, modifier: ModifierKeys.Control),
|
|
|
|
- new Shortcut(Key.S, SaveDocumentCommand, "AsNew", ModifierKeys.Control | ModifierKeys.Shift),
|
|
|
|
- new Shortcut(Key.N, OpenNewFilePopupCommand, modifier: ModifierKeys.Control),
|
|
|
|
- new Shortcut(Key.D, DeselectCommand, modifier: ModifierKeys.Control),
|
|
|
|
- new Shortcut(Key.A, SelectAllCommand, modifier: ModifierKeys.Control),
|
|
|
|
- new Shortcut(Key.C, CopyCommand, modifier: ModifierKeys.Control),
|
|
|
|
- new Shortcut(Key.V, PasteCommand, modifier: ModifierKeys.Control),
|
|
|
|
- new Shortcut(Key.J, DuplicateCommand, modifier: ModifierKeys.Control),
|
|
|
|
- new Shortcut(Key.X, CutCommand, modifier: ModifierKeys.Control),
|
|
|
|
- new Shortcut(Key.Delete, DeletePixelsCommand),
|
|
|
|
- new Shortcut(Key.I, OpenResizePopupCommand, modifier: ModifierKeys.Control | ModifierKeys.Shift),
|
|
|
|
- new Shortcut(Key.C, OpenResizePopupCommand, "canvas", ModifierKeys.Control | ModifierKeys.Shift)
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- UndoManager.SetMainRoot(this);
|
|
|
|
- ClipboardController = new ClipboardController();
|
|
|
|
- SetActiveTool(ToolType.Move);
|
|
|
|
- BitmapManager.PrimaryColor = PrimaryColor;
|
|
|
|
- Current = this;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public Action CloseAction { get; set; }
|
|
public Action CloseAction { get; set; }
|
|
|
|
|
|
public static ViewModelMain Current { get; set; }
|
|
public static ViewModelMain Current { get; set; }
|
|
@@ -141,7 +50,7 @@ namespace PixiEditor.ViewModels
|
|
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 KeyDownCommand { get; set; }
|
|
- public RelayCommand SaveFileCommand { get; set; } //Command that is used to save file
|
|
|
|
|
|
+ public RelayCommand ExportFileCommand { 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; }
|
|
public RelayCommand MouseUpCommand { get; set; }
|
|
public RelayCommand MouseUpCommand { get; set; }
|
|
@@ -168,6 +77,11 @@ namespace PixiEditor.ViewModels
|
|
public RelayCommand OnStartupCommand { get; set; }
|
|
public RelayCommand OnStartupCommand { get; set; }
|
|
public RelayCommand CloseWindowCommand { get; set; }
|
|
public RelayCommand CloseWindowCommand { get; set; }
|
|
public RelayCommand CenterContentCommand { get; set; }
|
|
public RelayCommand CenterContentCommand { get; set; }
|
|
|
|
+ public RelayCommand OpenHyperlinkCommand { get; set; }
|
|
|
|
+
|
|
|
|
+ private double _mouseXonCanvas;
|
|
|
|
+
|
|
|
|
+ private double _mouseYonCanvas;
|
|
|
|
|
|
public double MouseXOnCanvas //Mouse X coordinate relative to canvas
|
|
public double MouseXOnCanvas //Mouse X coordinate relative to canvas
|
|
{
|
|
{
|
|
@@ -226,30 +140,16 @@ namespace PixiEditor.ViewModels
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public ToolType SelectedTool
|
|
|
|
- {
|
|
|
|
- get => _selectedTool;
|
|
|
|
- set
|
|
|
|
- {
|
|
|
|
- if (_selectedTool != value)
|
|
|
|
- {
|
|
|
|
- _selectedTool = value;
|
|
|
|
- SetActiveTool(value);
|
|
|
|
- RaisePropertyChanged("SelectedTool");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public ObservableCollection<Tool> ToolSet { get; set; }
|
|
public ObservableCollection<Tool> ToolSet { get; set; }
|
|
|
|
|
|
- public LayerChange[] UndoChanges
|
|
|
|
|
|
+ public LayerChange[] UndoChanges //This acts like UndoManager process, but it was implemented before process system, so it can be transformed into it
|
|
{
|
|
{
|
|
get => _undoChanges;
|
|
get => _undoChanges;
|
|
set
|
|
set
|
|
{
|
|
{
|
|
_undoChanges = value;
|
|
_undoChanges = value;
|
|
for (int i = 0; i < value.Length; i++)
|
|
for (int i = 0; i < value.Length; i++)
|
|
- BitmapManager.ActiveDocument.Layers[value[i].LayerIndex].ApplyPixels(value[i].PixelChanges);
|
|
|
|
|
|
+ BitmapManager.ActiveDocument.Layers[value[i].LayerIndex].SetPixels(value[i].PixelChanges);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -278,7 +178,106 @@ namespace PixiEditor.ViewModels
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public ClipboardController ClipboardController { get; set; }
|
|
|
|
|
|
+ public ViewModelMain()
|
|
|
|
+ {
|
|
|
|
+ BitmapManager = new BitmapManager();
|
|
|
|
+ BitmapManager.BitmapOperations.BitmapChanged += BitmapUtility_BitmapChanged;
|
|
|
|
+ BitmapManager.MouseController.StoppedRecordingChanges += MouseController_StoppedRecordingChanges;
|
|
|
|
+ BitmapManager.DocumentChanged += BitmapManager_DocumentChanged;
|
|
|
|
+ ChangesController = new PixelChangesController();
|
|
|
|
+ SelectToolCommand = new RelayCommand(SetTool, DocumentIsNotNull);
|
|
|
|
+ OpenNewFilePopupCommand = new RelayCommand(OpenNewFilePopup);
|
|
|
|
+ MouseMoveCommand = new RelayCommand(MouseMove);
|
|
|
|
+ MouseDownCommand = new RelayCommand(MouseDown);
|
|
|
|
+ ExportFileCommand = new RelayCommand(ExportFile, CanSave);
|
|
|
|
+ UndoCommand = new RelayCommand(Undo, CanUndo);
|
|
|
|
+ RedoCommand = new RelayCommand(Redo, CanRedo);
|
|
|
|
+ MouseUpCommand = new RelayCommand(MouseUp);
|
|
|
|
+ OpenFileCommand = new RelayCommand(Open);
|
|
|
|
+ SetActiveLayerCommand = new RelayCommand(SetActiveLayer);
|
|
|
|
+ NewLayerCommand = new RelayCommand(NewLayer, CanCreateNewLayer);
|
|
|
|
+ DeleteLayerCommand = new RelayCommand(DeleteLayer, CanDeleteLayer);
|
|
|
|
+ MoveToBackCommand = new RelayCommand(MoveLayerToBack, CanMoveToBack);
|
|
|
|
+ MoveToFrontCommand = new RelayCommand(MoveLayerToFront, CanMoveToFront);
|
|
|
|
+ SwapColorsCommand = new RelayCommand(SwapColors);
|
|
|
|
+ KeyDownCommand = new RelayCommand(KeyDown);
|
|
|
|
+ RenameLayerCommand = new RelayCommand(RenameLayer);
|
|
|
|
+ DeselectCommand = new RelayCommand(Deselect, SelectionIsNotEmpty);
|
|
|
|
+ SelectAllCommand = new RelayCommand(SelectAll, CanSelectAll);
|
|
|
|
+ CopyCommand = new RelayCommand(Copy, SelectionIsNotEmpty);
|
|
|
|
+ DuplicateCommand = new RelayCommand(Duplicate, SelectionIsNotEmpty);
|
|
|
|
+ CutCommand = new RelayCommand(Cut, SelectionIsNotEmpty);
|
|
|
|
+ PasteCommand = new RelayCommand(Paste, CanPaste);
|
|
|
|
+ ClipCanvasCommand = new RelayCommand(ClipCanvas, DocumentIsNotNull);
|
|
|
|
+ DeletePixelsCommand = new RelayCommand(DeletePixels, SelectionIsNotEmpty);
|
|
|
|
+ OpenResizePopupCommand = new RelayCommand(OpenResizePopup, DocumentIsNotNull);
|
|
|
|
+ SelectColorCommand = new RelayCommand(SelectColor);
|
|
|
|
+ RemoveSwatchCommand = new RelayCommand(RemoveSwatch);
|
|
|
|
+ SaveDocumentCommand = new RelayCommand(SaveDocument, DocumentIsNotNull);
|
|
|
|
+ OnStartupCommand = new RelayCommand(OnStartup);
|
|
|
|
+ CloseWindowCommand = new RelayCommand(CloseWindow);
|
|
|
|
+ CenterContentCommand = new RelayCommand(CenterContent, DocumentIsNotNull);
|
|
|
|
+ OpenHyperlinkCommand = new RelayCommand(OpenHyperlink);
|
|
|
|
+ ToolSet = new ObservableCollection<Tool>
|
|
|
|
+ {
|
|
|
|
+ new MoveTool(), new PenTool(), new SelectTool(), new FloodFill(), new LineTool(),
|
|
|
|
+ new CircleTool(), new RectangleTool(), new EarserTool(), new ColorPickerTool(), new BrightnessTool()
|
|
|
|
+ };
|
|
|
|
+ ShortcutController = new ShortcutController
|
|
|
|
+ {
|
|
|
|
+ Shortcuts = new List<Shortcut>
|
|
|
|
+ {
|
|
|
|
+ //Tools
|
|
|
|
+ new Shortcut(Key.B, SelectToolCommand, ToolType.Pen),
|
|
|
|
+ new Shortcut(Key.E, SelectToolCommand, ToolType.Earser),
|
|
|
|
+ new Shortcut(Key.O, SelectToolCommand, ToolType.ColorPicker),
|
|
|
|
+ new Shortcut(Key.R, SelectToolCommand, ToolType.Rectangle),
|
|
|
|
+ new Shortcut(Key.C, SelectToolCommand, ToolType.Circle),
|
|
|
|
+ new Shortcut(Key.L, SelectToolCommand, ToolType.Line),
|
|
|
|
+ new Shortcut(Key.G, SelectToolCommand, ToolType.Bucket),
|
|
|
|
+ new Shortcut(Key.U, SelectToolCommand, ToolType.Brightness),
|
|
|
|
+ new Shortcut(Key.V, SelectToolCommand, ToolType.Move),
|
|
|
|
+ new Shortcut(Key.M, SelectToolCommand, ToolType.Select),
|
|
|
|
+ //Editor
|
|
|
|
+ new Shortcut(Key.X, SwapColorsCommand),
|
|
|
|
+ new Shortcut(Key.Y, RedoCommand, modifier: ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.Z, UndoCommand),
|
|
|
|
+ new Shortcut(Key.D, DeselectCommand, modifier: ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.A, SelectAllCommand, modifier: ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.C, CopyCommand, modifier: ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.V, PasteCommand, modifier: ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.J, DuplicateCommand, modifier: ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.X, CutCommand, modifier: ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.Delete, DeletePixelsCommand),
|
|
|
|
+ new Shortcut(Key.I, OpenResizePopupCommand, modifier: ModifierKeys.Control | ModifierKeys.Shift),
|
|
|
|
+ new Shortcut(Key.C, OpenResizePopupCommand, "canvas", ModifierKeys.Control | ModifierKeys.Shift),
|
|
|
|
+ //File
|
|
|
|
+ new Shortcut(Key.O, OpenFileCommand, modifier: ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.S, ExportFileCommand,
|
|
|
|
+ modifier: ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt),
|
|
|
|
+ new Shortcut(Key.S, SaveDocumentCommand, modifier: ModifierKeys.Control),
|
|
|
|
+ new Shortcut(Key.S, SaveDocumentCommand, "AsNew", ModifierKeys.Control | ModifierKeys.Shift),
|
|
|
|
+ new Shortcut(Key.N, OpenNewFilePopupCommand, modifier: ModifierKeys.Control),
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ UndoManager.SetMainRoot(this);
|
|
|
|
+ SetActiveTool(ToolType.Move);
|
|
|
|
+ BitmapManager.PrimaryColor = PrimaryColor;
|
|
|
|
+ ActiveSelection = new Selection(Array.Empty<Coordinates>());
|
|
|
|
+ Current = this;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void OpenHyperlink(object parameter)
|
|
|
|
+ {
|
|
|
|
+ if (parameter == null) return;
|
|
|
|
+ string url = (string) parameter;
|
|
|
|
+ var processInfo = new ProcessStartInfo()
|
|
|
|
+ {
|
|
|
|
+ FileName = url,
|
|
|
|
+ UseShellExecute = true
|
|
|
|
+ };
|
|
|
|
+ Process.Start(processInfo);
|
|
|
|
+ }
|
|
|
|
|
|
private void CenterContent(object property)
|
|
private void CenterContent(object property)
|
|
{
|
|
{
|
|
@@ -363,7 +362,7 @@ namespace PixiEditor.ViewModels
|
|
{
|
|
{
|
|
bool paramIsAsNew = parameter != null && parameter.ToString()?.ToLower() == "asnew";
|
|
bool paramIsAsNew = parameter != null && parameter.ToString()?.ToLower() == "asnew";
|
|
if (paramIsAsNew || Exporter.SaveDocumentPath == null)
|
|
if (paramIsAsNew || Exporter.SaveDocumentPath == null)
|
|
- Exporter.SaveAsNewEditableFile(BitmapManager.ActiveDocument, !paramIsAsNew);
|
|
|
|
|
|
+ Exporter.SaveAsEditableFileWithDialog(BitmapManager.ActiveDocument, !paramIsAsNew);
|
|
else
|
|
else
|
|
Exporter.SaveAsEditableFile(BitmapManager.ActiveDocument, Exporter.SaveDocumentPath);
|
|
Exporter.SaveAsEditableFile(BitmapManager.ActiveDocument, Exporter.SaveDocumentPath);
|
|
_unsavedDocumentModified = false;
|
|
_unsavedDocumentModified = false;
|
|
@@ -429,7 +428,7 @@ namespace PixiEditor.ViewModels
|
|
public void Cut(object parameter)
|
|
public void Cut(object parameter)
|
|
{
|
|
{
|
|
Copy(null);
|
|
Copy(null);
|
|
- BitmapManager.ActiveLayer.ApplyPixels(
|
|
|
|
|
|
+ BitmapManager.ActiveLayer.SetPixels(
|
|
BitmapPixelChanges.FromSingleColoredArray(ActiveSelection.SelectedPoints.ToArray(),
|
|
BitmapPixelChanges.FromSingleColoredArray(ActiveSelection.SelectedPoints.ToArray(),
|
|
Colors.Transparent));
|
|
Colors.Transparent));
|
|
}
|
|
}
|
|
@@ -447,13 +446,13 @@ namespace PixiEditor.ViewModels
|
|
private void Copy(object parameter)
|
|
private void Copy(object parameter)
|
|
{
|
|
{
|
|
ClipboardController.CopyToClipboard(BitmapManager.ActiveDocument.Layers.ToArray(),
|
|
ClipboardController.CopyToClipboard(BitmapManager.ActiveDocument.Layers.ToArray(),
|
|
- ActiveSelection.SelectedPoints.ToArray());
|
|
|
|
|
|
+ ActiveSelection.SelectedPoints.ToArray(), BitmapManager.ActiveDocument.Width, BitmapManager.ActiveDocument.Height);
|
|
}
|
|
}
|
|
|
|
|
|
public void SelectAll(object parameter)
|
|
public void SelectAll(object parameter)
|
|
{
|
|
{
|
|
SelectTool select = new SelectTool();
|
|
SelectTool select = new SelectTool();
|
|
- select.Use(select.GetAllSelection());
|
|
|
|
|
|
+ ActiveSelection.SetSelection(select.GetAllSelection(), SelectionType.New);
|
|
}
|
|
}
|
|
|
|
|
|
private bool CanSelectAll(object property)
|
|
private bool CanSelectAll(object property)
|
|
@@ -461,7 +460,7 @@ namespace PixiEditor.ViewModels
|
|
return BitmapManager.ActiveDocument != null && BitmapManager.ActiveDocument.Layers.Count > 0;
|
|
return BitmapManager.ActiveDocument != null && BitmapManager.ActiveDocument.Layers.Count > 0;
|
|
}
|
|
}
|
|
|
|
|
|
- private bool DocumentIsNotNull(object property)
|
|
|
|
|
|
+ public bool DocumentIsNotNull(object property)
|
|
{
|
|
{
|
|
return BitmapManager.ActiveDocument != null;
|
|
return BitmapManager.ActiveDocument != null;
|
|
}
|
|
}
|
|
@@ -473,8 +472,7 @@ namespace PixiEditor.ViewModels
|
|
|
|
|
|
private bool SelectionIsNotEmpty(object property)
|
|
private bool SelectionIsNotEmpty(object property)
|
|
{
|
|
{
|
|
- return ActiveSelection != null && ActiveSelection.SelectedPoints != null &&
|
|
|
|
- ActiveSelection.SelectedPoints.Count > 0;
|
|
|
|
|
|
+ return ActiveSelection?.SelectedPoints != null && ActiveSelection.SelectedPoints.Count > 0;
|
|
}
|
|
}
|
|
|
|
|
|
public void SetTool(object parameter)
|
|
public void SetTool(object parameter)
|
|
@@ -615,7 +613,7 @@ namespace PixiEditor.ViewModels
|
|
/// <param name="parameter"></param>
|
|
/// <param name="parameter"></param>
|
|
private void MouseMove(object parameter)
|
|
private void MouseMove(object parameter)
|
|
{
|
|
{
|
|
- Coordinates cords = new Coordinates((int) MouseXOnCanvas, (int) MouseYOnCanvas);
|
|
|
|
|
|
+ Coordinates cords = new Coordinates((int)MouseXOnCanvas, (int)MouseYOnCanvas);
|
|
MousePositionConverter.CurrentCoordinates = cords;
|
|
MousePositionConverter.CurrentCoordinates = cords;
|
|
|
|
|
|
|
|
|
|
@@ -653,7 +651,7 @@ namespace PixiEditor.ViewModels
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void NewDocument(int width, int height, bool addBaseLayer = true)
|
|
|
|
|
|
+ public void NewDocument(int width, int height, bool addBaseLayer = true)
|
|
{
|
|
{
|
|
BitmapManager.ActiveDocument = new Document(width, height);
|
|
BitmapManager.ActiveDocument = new Document(width, height);
|
|
if(addBaseLayer)
|
|
if(addBaseLayer)
|
|
@@ -734,7 +732,7 @@ namespace PixiEditor.ViewModels
|
|
/// Generates export dialog or saves directly if save data is known.
|
|
/// Generates export dialog or saves directly if save data is known.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="parameter"></param>
|
|
/// <param name="parameter"></param>
|
|
- private void SaveFile(object parameter)
|
|
|
|
|
|
+ private void ExportFile(object parameter)
|
|
{
|
|
{
|
|
WriteableBitmap bitmap = BitmapManager.GetCombinedLayersBitmap();
|
|
WriteableBitmap bitmap = BitmapManager.GetCombinedLayersBitmap();
|
|
Exporter.Export(bitmap, new Size(bitmap.PixelWidth, bitmap.PixelHeight));
|
|
Exporter.Export(bitmap, new Size(bitmap.PixelWidth, bitmap.PixelHeight));
|