|
@@ -1,5 +1,4 @@
|
|
-using Microsoft.Win32;
|
|
|
|
-using PixiEditor.Exceptions;
|
|
|
|
|
|
+using PixiEditor.Exceptions;
|
|
using PixiEditor.Helpers;
|
|
using PixiEditor.Helpers;
|
|
using System;
|
|
using System;
|
|
using System.IO;
|
|
using System.IO;
|
|
@@ -15,53 +14,19 @@ namespace PixiEditor.ViewModels
|
|
private int importHeight = 16;
|
|
private int importHeight = 16;
|
|
|
|
|
|
private int importWidth = 16;
|
|
private int importWidth = 16;
|
|
-
|
|
|
|
- private string pathButtonBorder = "#f08080";
|
|
|
|
-
|
|
|
|
- private bool pathIsCorrect;
|
|
|
|
-
|
|
|
|
public ImportFilePopupViewModel()
|
|
public ImportFilePopupViewModel()
|
|
{
|
|
{
|
|
CloseButtonCommand = new RelayCommand(CloseWindow);
|
|
CloseButtonCommand = new RelayCommand(CloseWindow);
|
|
DragMoveCommand = new RelayCommand(MoveWindow);
|
|
DragMoveCommand = new RelayCommand(MoveWindow);
|
|
- ChoosePathCommand = new RelayCommand(ChoosePath);
|
|
|
|
- OkCommand = new RelayCommand(OkButton, CanClickOk);
|
|
|
|
|
|
+ OkCommand = new RelayCommand(OkButton);
|
|
}
|
|
}
|
|
|
|
|
|
public RelayCommand CloseButtonCommand { get; set; }
|
|
public RelayCommand CloseButtonCommand { get; set; }
|
|
|
|
|
|
public RelayCommand DragMoveCommand { get; set; }
|
|
public RelayCommand DragMoveCommand { get; set; }
|
|
|
|
|
|
- public RelayCommand ChoosePathCommand { get; set; }
|
|
|
|
-
|
|
|
|
public RelayCommand OkCommand { get; set; }
|
|
public RelayCommand OkCommand { get; set; }
|
|
|
|
|
|
- public string PathButtonBorder
|
|
|
|
- {
|
|
|
|
- get => pathButtonBorder;
|
|
|
|
- set
|
|
|
|
- {
|
|
|
|
- if (pathButtonBorder != value)
|
|
|
|
- {
|
|
|
|
- pathButtonBorder = value;
|
|
|
|
- RaisePropertyChanged("PathButtonBorder");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public bool PathIsCorrect
|
|
|
|
- {
|
|
|
|
- get => pathIsCorrect;
|
|
|
|
- set
|
|
|
|
- {
|
|
|
|
- if (pathIsCorrect != value)
|
|
|
|
- {
|
|
|
|
- pathIsCorrect = value;
|
|
|
|
- RaisePropertyChanged("PathIsCorrect");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public string FilePath
|
|
public string FilePath
|
|
{
|
|
{
|
|
get => filePath;
|
|
get => filePath;
|
|
@@ -71,7 +36,7 @@ namespace PixiEditor.ViewModels
|
|
{
|
|
{
|
|
filePath = value;
|
|
filePath = value;
|
|
CheckForPath(value);
|
|
CheckForPath(value);
|
|
- RaisePropertyChanged("FilePath");
|
|
|
|
|
|
+ RaisePropertyChanged(nameof(FilePath));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -84,7 +49,7 @@ namespace PixiEditor.ViewModels
|
|
if (importWidth != value)
|
|
if (importWidth != value)
|
|
{
|
|
{
|
|
importWidth = value;
|
|
importWidth = value;
|
|
- RaisePropertyChanged("ImportWidth");
|
|
|
|
|
|
+ RaisePropertyChanged(nameof(ImportWidth));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -97,33 +62,7 @@ namespace PixiEditor.ViewModels
|
|
if (importHeight != value)
|
|
if (importHeight != value)
|
|
{
|
|
{
|
|
importHeight = value;
|
|
importHeight = value;
|
|
- RaisePropertyChanged("ImportHeight");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// Command that handles Path choosing to save file.
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="parameter">Binding parameter.</param>
|
|
|
|
- private void ChoosePath(object parameter)
|
|
|
|
- {
|
|
|
|
- OpenFileDialog path = new OpenFileDialog
|
|
|
|
- {
|
|
|
|
- Title = "Import path",
|
|
|
|
- CheckPathExists = true,
|
|
|
|
- Filter = "Image Files|*.png;*.jpeg;*.jpg"
|
|
|
|
- };
|
|
|
|
- if (path.ShowDialog() == true)
|
|
|
|
- {
|
|
|
|
- if (string.IsNullOrEmpty(path.FileName) == false)
|
|
|
|
- {
|
|
|
|
- CheckForPath(path.FileName);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- PathButtonBorder = "#f08080";
|
|
|
|
- PathIsCorrect = false;
|
|
|
|
|
|
+ RaisePropertyChanged(nameof(ImportHeight));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -134,8 +73,6 @@ namespace PixiEditor.ViewModels
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- PathButtonBorder = "#b8f080";
|
|
|
|
- PathIsCorrect = true;
|
|
|
|
filePath = path;
|
|
filePath = path;
|
|
BitmapImage bitmap = new BitmapImage(new Uri(path));
|
|
BitmapImage bitmap = new BitmapImage(new Uri(path));
|
|
ImportHeight = bitmap.PixelHeight;
|
|
ImportHeight = bitmap.PixelHeight;
|
|
@@ -168,10 +105,5 @@ namespace PixiEditor.ViewModels
|
|
((Window)parameter).DialogResult = true;
|
|
((Window)parameter).DialogResult = true;
|
|
CloseButton(parameter);
|
|
CloseButton(parameter);
|
|
}
|
|
}
|
|
-
|
|
|
|
- private bool CanClickOk(object property)
|
|
|
|
- {
|
|
|
|
- return PathIsCorrect;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|