Browse Source

Remove the path picker from ImportFilePopup

Equbuxu 3 years ago
parent
commit
c539f117a0

+ 6 - 74
PixiEditor/ViewModels/ImportFilePopupViewModel.cs

@@ -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;
-        }
     }
     }
-}
+}

+ 1 - 5
PixiEditor/Views/Dialogs/ImportFilePopup.xaml

@@ -35,12 +35,8 @@
         <StackPanel Grid.Row="1">
         <StackPanel Grid.Row="1">
             <Label Height="40" Width="120" VerticalAlignment="Top" Content="Open" Foreground="Snow"
             <Label Height="40" Width="120" VerticalAlignment="Top" Content="Open" Foreground="Snow"
                        HorizontalContentAlignment="Center" FontSize="24" Margin="0,10,0,0" />
                        HorizontalContentAlignment="Center" FontSize="24" Margin="0,10,0,0" />
-            <Button Grid.Row="1" BorderThickness="1" Foreground="Snow" Height="40" Width="160" Margin="0,30,0,0"
-                        Content="File Path" Background="#303030" BorderBrush="{Binding PathButtonBorder}"
-                        Command="{Binding ChoosePathCommand}" />
             <StackPanel Background="{StaticResource MainColor}" Height="120" Width="225" Margin="0,30,0,0">
             <StackPanel Background="{StaticResource MainColor}" Height="120" Width="225" Margin="0,30,0,0">
-                <local:SizePicker EditingEnabled="{Binding PathIsCorrect}"
-                                  x:Name="sizePicker"
+                <local:SizePicker x:Name="sizePicker"
                                   ChosenWidth="{Binding ImportWidth, Mode=TwoWay}"
                                   ChosenWidth="{Binding ImportWidth, Mode=TwoWay}"
                                   ChosenHeight="{Binding ImportHeight,Mode=TwoWay}" />
                                   ChosenHeight="{Binding ImportHeight,Mode=TwoWay}" />
             </StackPanel>
             </StackPanel>

+ 0 - 3
PixiEditor/Views/Dialogs/ImportFilePopup.xaml.cs

@@ -4,9 +4,6 @@ using System.Windows.Input;
 
 
 namespace PixiEditor.Views
 namespace PixiEditor.Views
 {
 {
-    /// <summary>
-    ///     Interaction logic for ImportFilePopup.xaml
-    /// </summary>
     public partial class ImportFilePopup : Window
     public partial class ImportFilePopup : Window
     {
     {
         private readonly ImportFilePopupViewModel dc = new ImportFilePopupViewModel();
         private readonly ImportFilePopupViewModel dc = new ImportFilePopupViewModel();