Skip to content

Commit

Permalink
ui improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
counter185 committed Sep 22, 2020
1 parent 9af867d commit 8e89f78
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
3 changes: 2 additions & 1 deletion PSPSync/Config.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
<Grid Background="{StaticResource mainColor}">
<ListBox x:Name="PathList" Margin="10,10,357,8" Background="{StaticResource subColor}" BorderBrush="Transparent" Foreground="White"/>
<TextBox x:Name="PathName" Height="23" Margin="0,91,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Background="{StaticResource subColor}" Foreground="White" HorizontalAlignment="Right" Width="179"/>
<TextBox x:Name="PathPath" Height="23" Margin="0,119,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Background="{StaticResource subColor}" Foreground="White" HorizontalAlignment="Right" Width="255"/>
<TextBox x:Name="PathPath" Height="23" Margin="0,119,40,0" TextWrapping="Wrap" VerticalAlignment="Top" Background="{StaticResource subColor}" Foreground="White" HorizontalAlignment="Right" Width="225"/>
<Label Content="Name" Margin="0,87,310,0" VerticalAlignment="Top" Height="29" Foreground="White" HorizontalAlignment="Right" Width="42"/>
<Label Content="Path" Margin="0,116,319,0" VerticalAlignment="Top" Foreground="White" HorizontalAlignment="Right" Width="33"/>
<Button x:Name="AddPath" Content="Add path" Margin="0,147,10,0" VerticalAlignment="Top" Click="AddPath_Click" Background="{StaticResource subColor}" BorderBrush="Transparent" Foreground="White" HorizontalAlignment="Right" Width="75"/>
<Label Content="FTP paths must be in the following format: ftp://[IP]/[path]" Margin="0,203,10,0" VerticalAlignment="Top" Foreground="White" HorizontalAlignment="Right" Width="342"/>
<Button x:Name="DelSelected" Content="Delete selected" HorizontalAlignment="Right" Margin="0,0,258,8" Width="94" Background="{StaticResource subColor}" Foreground="White" BorderBrush="Transparent" Click="DelSelected_Click" Height="20" VerticalAlignment="Bottom"/>
<Button x:Name="ThreeDot" Content="..." Margin="0,119,10,0" VerticalAlignment="Top" Background="{StaticResource subColor}" Foreground="White" BorderBrush="Transparent" Height="23" Click="ThreeDot_Click" HorizontalAlignment="Right" Width="27"/>

</Grid>
</Window>
25 changes: 22 additions & 3 deletions PSPSync/Config.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
}
26 changes: 20 additions & 6 deletions PSPSync/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public SaveMeta GetMetaFromID(List<SaveMeta> 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;
Expand All @@ -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;
}
Expand Down

0 comments on commit 8e89f78

Please sign in to comment.