From 8e89f78dfdd1222dc6bf558c1a89ec2af4532380 Mon Sep 17 00:00:00 2001
From: counter185 <33550839+counter185@users.noreply.github.com>
Date: Tue, 22 Sep 2020 20:28:57 +0200
Subject: [PATCH] ui improvements
---
PSPSync/Config.xaml | 3 ++-
PSPSync/Config.xaml.cs | 25 ++++++++++++++++++++++---
PSPSync/MainWindow.xaml.cs | 26 ++++++++++++++++++++------
3 files changed, 44 insertions(+), 10 deletions(-)
diff --git a/PSPSync/Config.xaml b/PSPSync/Config.xaml
index 7f599b8..5244f5c 100644
--- a/PSPSync/Config.xaml
+++ b/PSPSync/Config.xaml
@@ -9,12 +9,13 @@
-
+
+
diff --git a/PSPSync/Config.xaml.cs b/PSPSync/Config.xaml.cs
index 1a0a33e..7beb1c3 100644
--- a/PSPSync/Config.xaml.cs
+++ b/PSPSync/Config.xaml.cs
@@ -7,6 +7,7 @@
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
+using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
@@ -38,22 +39,40 @@ private void AddPath_Click(object sender, RoutedEventArgs e)
if (PathName.Text == String.Empty || PathPath.Text == String.Empty) {
return;
}
- string path = PathPath.Text;
- path.Replace("\\", "/");
+ string path = PathPath.Text.Replace("\\", "/");
if (!path.EndsWith("/")) {
path += "/";
}
GlobalConfig.paths.Add(new SavePath(PathName.Text, path));
GlobalConfig.SaveConfig();
LoadPaths();
+ PathName.Text = String.Empty;
+ PathPath.Text = String.Empty;
}
private void DelSelected_Click(object sender, RoutedEventArgs e)
{
- if (PathList.SelectedIndex != -1) {
+ if (PathList.SelectedIndex != -1)
+ {
GlobalConfig.paths.RemoveAt(PathList.SelectedIndex);
+ GlobalConfig.SaveConfig();
LoadPaths();
}
+ else {
+ System.Windows.MessageBox.Show("Select a path to delete");
+ }
+ }
+
+ private void ThreeDot_Click(object sender, RoutedEventArgs e)
+ {
+ OpenFileDialog a = new OpenFileDialog();
+ a.ValidateNames = false;
+ a.CheckFileExists = false;
+ a.CheckPathExists = true;
+ a.FileName = "Select a folder";
+ a.ShowDialog();
+ PathPath.Text = a.FileName.Substring(0, a.FileName.Length - 15);
+ a.Dispose();
}
}
}
diff --git a/PSPSync/MainWindow.xaml.cs b/PSPSync/MainWindow.xaml.cs
index 3a04468..ff6c79e 100644
--- a/PSPSync/MainWindow.xaml.cs
+++ b/PSPSync/MainWindow.xaml.cs
@@ -233,7 +233,7 @@ public SaveMeta GetMetaFromID(List list, string ID) {
private void SD1toSD2_Click(object sender, RoutedEventArgs e)
{
- if (CannotCopy() || SD1s.SelectedIndex == -1) {
+ if (CannotCopy(SD1s)) {
return;
}
TaskbarItemInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Indeterminate;
@@ -243,15 +243,29 @@ private void SD1toSD2_Click(object sender, RoutedEventArgs e)
CopySave(currentmeta, GetMetaFromID(sd2Saves, GetGameID(currentmeta.directory)), files, storageDevices[StorageDevice2.SelectedIndex]);
}
- public bool CannotCopy() {
- return sd1offline || sd2offline || IsOnTheSameDevice() ||
- StorageDevice2.SelectedIndex == -1 ||
- StorageDevice1.SelectedIndex == -1;
+ public bool CannotCopy(ListBox savelist) {
+ if (sd1offline || sd2offline) {
+ MessageBox.Show("Device offline");
+ return true;
+ }
+ if (IsOnTheSameDevice()) {
+ MessageBox.Show("Cannot copy to the same device");
+ return true;
+ }
+ if (StorageDevice2.SelectedIndex == -1 || StorageDevice1.SelectedIndex == -1) {
+ MessageBox.Show("Select a device from the drop down menu");
+ return true;
+ }
+ if (savelist.SelectedIndex == -1) {
+ MessageBox.Show("Select a save to copy");
+ return true;
+ }
+ return false;
}
private void SD2toSD1_Click(object sender, RoutedEventArgs e)
{
- if (CannotCopy() || SD2s.SelectedIndex == -1)
+ if (CannotCopy(SD2s))
{
return;
}