diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..b18ba0b
--- /dev/null
+++ b/Properties/Settings.Designer.cs
@@ -0,0 +1,86 @@
+//------------------------------------------------------------------------------
+//
+// 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 unison.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("192.168.0.1")]
+ public string mpd_host {
+ get {
+ return ((string)(this["mpd_host"]));
+ }
+ set {
+ this["mpd_host"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("6600")]
+ public int mpd_port {
+ get {
+ return ((int)(this["mpd_port"]));
+ }
+ set {
+ this["mpd_port"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string mpd_password {
+ get {
+ return ((string)(this["mpd_password"]));
+ }
+ set {
+ this["mpd_password"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool snapcast_startup {
+ get {
+ return ((bool)(this["snapcast_startup"]));
+ }
+ set {
+ this["snapcast_startup"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("snapclient_0.25.0-1_win64")]
+ public string snapcast_path {
+ get {
+ return ((string)(this["snapcast_path"]));
+ }
+ set {
+ this["snapcast_path"] = value;
+ }
+ }
+ }
+}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
new file mode 100644
index 0000000..a4a83aa
--- /dev/null
+++ b/Properties/Settings.settings
@@ -0,0 +1,21 @@
+
+
+
+
+
+ 192.168.0.1
+
+
+ 6600
+
+
+
+
+
+ False
+
+
+ snapclient_0.25.0-1_win64
+
+
+
\ No newline at end of file
diff --git a/Views/Settings.xaml b/Views/Settings.xaml
index 07ff685..bb35767 100644
--- a/Views/Settings.xaml
+++ b/Views/Settings.xaml
@@ -22,17 +22,17 @@
-
+
-
+
-
+
@@ -52,15 +52,15 @@
-
+
-
-
+
+
You can change to your own locally installed version of the Snapcast client with an absolute path.
-
+
diff --git a/Views/Settings.xaml.cs b/Views/Settings.xaml.cs
index 121c2d8..4e9c3b6 100644
--- a/Views/Settings.xaml.cs
+++ b/Views/Settings.xaml.cs
@@ -2,16 +2,20 @@
using System.Diagnostics;
using System.IO;
using System.Reflection;
+using System.Text.RegularExpressions;
using System.Windows;
+using System.Windows.Input;
using System.Windows.Navigation;
namespace unison
{
public partial class Settings : Window
{
- public string GetVersion => Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion;
+ private string defaultSnapcast = "snapclient_0.25.0-1_win64";
- public string GetLicense
+ public static string GetVersion => Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion;
+
+ public static string GetLicense
{
get
{
@@ -19,7 +23,7 @@ namespace unison
{
StreamReader Reader = new("LICENSE");
string file = "";
- file = file + Reader.ReadToEnd();
+ file += Reader.ReadToEnd();
return file;
}
catch (IOException e)
@@ -35,6 +39,18 @@ namespace unison
DataContext = this;
WindowState = WindowState.Minimized;
+
+ MpdHost.Text = Properties.Settings.Default.mpd_host;
+ MpdPort.Text = Properties.Settings.Default.mpd_port.ToString();
+ MpdPassword.Text = Properties.Settings.Default.mpd_password;
+ SnapcastStartup.IsChecked = Properties.Settings.Default.snapcast_startup;
+ SnapcastPath.Text = Properties.Settings.Default.snapcast_path;
+ }
+
+ private void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^0-9]+");
+ e.Handled = regex.IsMatch(e.Text);
}
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
@@ -45,9 +61,22 @@ namespace unison
e.Handled = true;
}
+ private void SnapcastReset_Clicked(object sender, RoutedEventArgs e)
+ {
+ SnapcastPath.Text = defaultSnapcast;
+ }
+
private void Window_Closing(object sender, CancelEventArgs e)
{
e.Cancel = true;
+
+ Properties.Settings.Default.mpd_host = MpdHost.Text;
+ Properties.Settings.Default.mpd_port = int.Parse(MpdPort.Text);
+ Properties.Settings.Default.mpd_password = MpdPassword.Text;
+ Properties.Settings.Default.snapcast_startup = (bool)SnapcastStartup.IsChecked;
+ Properties.Settings.Default.snapcast_path = SnapcastPath.Text;
+ Properties.Settings.Default.Save();
+
WindowState = WindowState.Minimized;
Hide();
}
diff --git a/Views/SystrayViewModel.cs b/Views/SystrayViewModel.cs
index 9ed4871..3e4946b 100644
--- a/Views/SystrayViewModel.cs
+++ b/Views/SystrayViewModel.cs
@@ -8,9 +8,9 @@ namespace unison
{
public class SystrayViewModel : INotifyPropertyChanged
{
- public string GetAppText => "unison v" + Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion;
+ public static string GetAppText => "unison v" + Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion;
- public ICommand ShowWindowCommand => new DelegateCommand
+ public static ICommand ShowWindowCommand => new DelegateCommand
{
CommandAction = () =>
{
@@ -24,7 +24,7 @@ namespace unison
CanExecuteFunc = () => true
};
- public ICommand ExitApplicationCommand => new DelegateCommand
+ public static ICommand ExitApplicationCommand => new DelegateCommand
{
CommandAction = () =>
{
@@ -33,7 +33,7 @@ namespace unison
CanExecuteFunc = () => true
};
- public string SnapcastText
+ public static string SnapcastText
{
get
{
@@ -77,8 +77,7 @@ namespace unison
protected virtual void OnPropertyChanged(string propertyName)
{
- PropertyChangedEventHandler handler = PropertyChanged;
- if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
\ No newline at end of file
diff --git a/unison.csproj b/unison.csproj
index 91162df..f2eff24 100644
--- a/unison.csproj
+++ b/unison.csproj
@@ -65,4 +65,19 @@
+
+
+ True
+ True
+ Settings.settings
+
+
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+