diff --git a/App.config b/App.config
index b452a9ba..e37c1427 100644
--- a/App.config
+++ b/App.config
@@ -1,19 +1,9 @@
-
-
-
-
-
-
-
-
-
-
-
- Release_ANSI\\DiscImageCreator.exe
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DICUI.csproj b/DICUI.csproj
index 8a110a0b..4093fd3e 100644
--- a/DICUI.csproj
+++ b/DICUI.csproj
@@ -67,6 +67,7 @@
+
@@ -107,15 +108,6 @@
Code
-
- True
- True
- Resources.resx
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 29fde9ee..b23b4c47 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DICUI"
mc:Ignorable="d"
- Title="Disc Image Creator GUI" Height="400" Width="600">
+ Title="Disc Image Creator GUI" Height="450" Width="600">
@@ -13,16 +13,22 @@
+
-
-
-
+
+
+
+
+
+
+
+
-
+
@@ -56,7 +62,7 @@
-
+
@@ -69,7 +75,7 @@
-
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 86ee8823..067cc541 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
@@ -12,21 +13,26 @@ namespace DICUI
{
public partial class MainWindow : Window
{
- // TODO: Make configurable in UI or in Settings
- private const string defaultOutputPath = "ISO";
- private const string dicPath = "Programs\\DiscImageCreator.exe";
- private const string psxtPath = "psxt001z.exe";
- private const string sgRawPath = "sg_raw.exe";
+ // Private paths
+ private string defaultOutputPath;
+ private string dicPath;
+ private string psxtPath;
+ private string sgRawPath;
+ // Private UI-related variables
private List> _drives { get; set; }
private List _driveSpeeds { get { return new List { 1, 2, 3, 4, 6, 8, 12, 16, 20, 24, 32, 40, 44, 48, 52, 56, 72 }; } }
private List> _systems { get; set; }
private Process childProcess { get; set; }
+ private Window childWindow { get; set; }
public MainWindow()
{
InitializeComponent();
+ // Get all settings
+ GetSettings();
+
// Populate the list of systems
PopulateSystems();
@@ -83,6 +89,28 @@ namespace DICUI
EnsureDiscInformation();
}
+ private void tbr_Properties_Click(object sender, RoutedEventArgs e)
+ {
+ ShowSettings();
+ }
+
+ private void tbr_Properties_CanExecute(object sender, System.Windows.Input.CanExecuteRoutedEventArgs e)
+ {
+ e.CanExecute = true;
+ }
+
+ private void btn_Settings_Accept_Click(object sender, RoutedEventArgs e)
+ {
+ SaveSettings();
+ childWindow.Close();
+ GetSettings();
+ }
+
+ private void btn_Settings_Cancel_Click(object sender, RoutedEventArgs e)
+ {
+ childWindow.Close();
+ }
+
#endregion
#region Helpers
@@ -453,6 +481,163 @@ namespace DICUI
cmb_DriveSpeed.SelectedValue = speed;
}
+ ///
+ /// Show all user-configurable settings in a new window
+ ///
+ private void ShowSettings()
+ {
+ // Create the child window for settings
+ childWindow = new Window()
+ {
+ ShowInTaskbar = false,
+ Owner = Application.Current.MainWindow,
+ Width = 500,
+ Height = 250,
+ ResizeMode = ResizeMode.NoResize,
+ };
+
+ // Create the new Grid-based window
+ var grid = new Grid
+ {
+ Margin = new Thickness(5),
+ HorizontalAlignment = HorizontalAlignment.Stretch,
+ VerticalAlignment = VerticalAlignment.Stretch,
+ };
+ grid.ColumnDefinitions.Add(new ColumnDefinition { Width = (GridLength)(new GridLengthConverter().ConvertFromString("1.2*")) });
+ grid.ColumnDefinitions.Add(new ColumnDefinition { Width = (GridLength)(new GridLengthConverter().ConvertFromString("2.5*")) });
+ grid.RowDefinitions.Add(new RowDefinition());
+ grid.RowDefinitions.Add(new RowDefinition());
+ grid.RowDefinitions.Add(new RowDefinition());
+ grid.RowDefinitions.Add(new RowDefinition());
+ grid.RowDefinitions.Add(new RowDefinition());
+
+ // Create all of the individual items in the panel
+ Label dicPathLabel = new Label();
+ dicPathLabel.Content = "DiscImageCreator Path:";
+ dicPathLabel.FontWeight = (FontWeight)(new FontWeightConverter().ConvertFromString("Bold"));
+ dicPathLabel.VerticalAlignment = VerticalAlignment.Center;
+ dicPathLabel.HorizontalAlignment = HorizontalAlignment.Right;
+ Grid.SetRow(dicPathLabel, 0);
+ Grid.SetColumn(dicPathLabel, 0);
+
+ TextBox dicPathSetting = new TextBox();
+ dicPathSetting.Text = ConfigurationManager.AppSettings["dicPath"];
+ dicPathSetting.VerticalAlignment = VerticalAlignment.Center;
+ dicPathSetting.HorizontalAlignment = HorizontalAlignment.Stretch;
+ Grid.SetRow(dicPathSetting, 0);
+ Grid.SetColumn(dicPathSetting, 1);
+
+ Label psxt001zPathLabel = new Label();
+ psxt001zPathLabel.Content = "psxt001z Path:";
+ psxt001zPathLabel.FontWeight = (FontWeight)(new FontWeightConverter().ConvertFromString("Bold"));
+ psxt001zPathLabel.VerticalAlignment = VerticalAlignment.Center;
+ psxt001zPathLabel.HorizontalAlignment = HorizontalAlignment.Right;
+ Grid.SetRow(psxt001zPathLabel, 1);
+ Grid.SetColumn(psxt001zPathLabel, 0);
+
+ TextBox psxt001zPathSetting = new TextBox();
+ psxt001zPathSetting.Text = ConfigurationManager.AppSettings["psxt001zPath"];
+ psxt001zPathSetting.VerticalAlignment = VerticalAlignment.Center;
+ psxt001zPathSetting.HorizontalAlignment = HorizontalAlignment.Stretch;
+ Grid.SetRow(psxt001zPathSetting, 1);
+ Grid.SetColumn(psxt001zPathSetting, 1);
+
+ Label sgRawPathLabel = new Label();
+ sgRawPathLabel.Content = "sg-raw Path:";
+ sgRawPathLabel.FontWeight = (FontWeight)(new FontWeightConverter().ConvertFromString("Bold"));
+ sgRawPathLabel.VerticalAlignment = VerticalAlignment.Center;
+ sgRawPathLabel.HorizontalAlignment = HorizontalAlignment.Right;
+ Grid.SetRow(sgRawPathLabel, 2);
+ Grid.SetColumn(sgRawPathLabel, 0);
+
+ TextBox sgRawPathSetting = new TextBox();
+ sgRawPathSetting.Text = ConfigurationManager.AppSettings["sgRawPath"];
+ sgRawPathSetting.VerticalAlignment = VerticalAlignment.Center;
+ sgRawPathSetting.HorizontalAlignment = HorizontalAlignment.Stretch;
+ Grid.SetRow(sgRawPathSetting, 2);
+ Grid.SetColumn(sgRawPathSetting, 1);
+
+ Label defaultOutputPathLabel = new Label();
+ defaultOutputPathLabel.Content = "Default Output Path:";
+ defaultOutputPathLabel.FontWeight = (FontWeight)(new FontWeightConverter().ConvertFromString("Bold"));
+ defaultOutputPathLabel.VerticalAlignment = VerticalAlignment.Center;
+ defaultOutputPathLabel.HorizontalAlignment = HorizontalAlignment.Right;
+ Grid.SetRow(defaultOutputPathLabel, 3);
+ Grid.SetColumn(defaultOutputPathLabel, 0);
+
+ TextBox defaultOutputPathSetting = new TextBox();
+ defaultOutputPathSetting.Text = ConfigurationManager.AppSettings["defaultOutputPath"];
+ defaultOutputPathSetting.VerticalAlignment = VerticalAlignment.Center;
+ defaultOutputPathSetting.HorizontalAlignment = HorizontalAlignment.Stretch;
+ Grid.SetRow(defaultOutputPathSetting, 3);
+ Grid.SetColumn(defaultOutputPathSetting, 1);
+
+ Button acceptButton = new Button();
+ acceptButton.Name = "btn_Settings_Accept";
+ acceptButton.Content = "Accept";
+ acceptButton.Click += btn_Settings_Accept_Click;
+ Grid.SetRow(acceptButton, 4);
+ Grid.SetColumn(acceptButton, 0);
+
+ Button cancelButton = new Button();
+ cancelButton.Name = "btn_Settings_Cancel";
+ cancelButton.Content = "Cancel";
+ cancelButton.Click += btn_Settings_Cancel_Click;
+ Grid.SetRow(cancelButton, 4);
+ Grid.SetColumn(cancelButton, 1);
+
+ // Add all of the UI elements
+ grid.Children.Add(dicPathLabel);
+ grid.Children.Add(dicPathSetting);
+ grid.Children.Add(psxt001zPathLabel);
+ grid.Children.Add(psxt001zPathSetting);
+ grid.Children.Add(sgRawPathLabel);
+ grid.Children.Add(sgRawPathSetting);
+ grid.Children.Add(defaultOutputPathLabel);
+ grid.Children.Add(defaultOutputPathSetting);
+ grid.Children.Add(acceptButton);
+ grid.Children.Add(cancelButton);
+
+ // Now show the child window
+ childWindow.Content = grid;
+ childWindow.Show();
+ }
+
+ ///
+ /// Save settings from the child window, if possible
+ ///
+ private void SaveSettings()
+ {
+ // If the child window is disposed, we don't think about it
+ if (childWindow == null)
+ {
+ return;
+ }
+
+ // Clear the old settings and set new ones
+ var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
+ configFile.AppSettings.Settings.Remove("dicPath");
+ configFile.AppSettings.Settings.Add("dicPath", ((TextBox)(((Grid)childWindow.Content).Children[1])).Text);
+ configFile.AppSettings.Settings.Remove("psxt001zPath");
+ configFile.AppSettings.Settings.Add("psxt001zPath", ((TextBox)(((Grid)childWindow.Content).Children[3])).Text);
+ configFile.AppSettings.Settings.Remove("sgRawPath");
+ configFile.AppSettings.Settings.Add("sgRawPath", ((TextBox)(((Grid)childWindow.Content).Children[5])).Text);
+ configFile.AppSettings.Settings.Remove("defaultOutputPath");
+ configFile.AppSettings.Settings.Add("defaultOutputPath", ((TextBox)(((Grid)childWindow.Content).Children[7])).Text);
+ configFile.Save(ConfigurationSaveMode.Modified);
+ }
+
+ ///
+ /// Get settings from the configuration, if possible
+ ///
+ private void GetSettings()
+ {
+ dicPath = ConfigurationManager.AppSettings["dicPath"] ?? "Programs\\DiscImageCreator.exe";
+ psxtPath = ConfigurationManager.AppSettings["psxt001zPath"] ?? "psxt001z.exe";
+ sgRawPath = ConfigurationManager.AppSettings["sgRawPath"] ?? "sg_raw.exe";
+ defaultOutputPath = ConfigurationManager.AppSettings["defaultOutputPath"] ?? "ISO";
+ }
+
#endregion
}
}
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
deleted file mode 100644
index db93ee29..00000000
--- a/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace DICUI.Properties {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DICUI.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
- }
-}
diff --git a/Properties/Resources.resx b/Properties/Resources.resx
deleted file mode 100644
index af7dbebb..00000000
--- a/Properties/Resources.resx
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file