diff --git a/App.xaml.cs b/App.xaml.cs
index efe2d6f..31095d5 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -1,12 +1,6 @@
using System.Windows;
using Hardcodet.Wpf.TaskbarNotification;
-// todo:
-//
-// * show mpd version
-// * change volume offset
-// * fix window resize (if it still happens?)
-
namespace unison
{
public partial class App : Application
diff --git a/Handlers/HotkeyHandler.cs b/Handlers/HotkeyHandler.cs
index e00d99c..9200173 100644
--- a/Handlers/HotkeyHandler.cs
+++ b/Handlers/HotkeyHandler.cs
@@ -75,11 +75,15 @@ namespace unison
mpd.Prev();
break;
case VK_VOLUME_DOWN:
- mpd._currentVolume -= 5;
+ mpd._currentVolume -= Properties.Settings.Default.volume_offset;
+ if (mpd._currentVolume < 0)
+ mpd._currentVolume = 0;
mpd.SetVolume(mpd._currentVolume);
break;
case VK_VOLUME_UP:
- mpd._currentVolume += 5;
+ mpd._currentVolume += Properties.Settings.Default.volume_offset;
+ if (mpd._currentVolume > 100)
+ mpd._currentVolume = 100;
mpd.SetVolume(mpd._currentVolume);
break;
case VK_MEDIA_PLAY_PAUSE:
@@ -94,8 +98,17 @@ namespace unison
}
else
{
- AppWindow.Hide();
- AppWindow.WindowState = WindowState.Minimized;
+ if (AppWindow.IsActive)
+ {
+ AppWindow.Hide();
+ AppWindow.WindowState = WindowState.Minimized;
+ }
+ else // not minimized but not in front
+ {
+ AppWindow.Show();
+ AppWindow.Activate();
+ AppWindow.WindowState = WindowState.Normal;
+ }
}
break;
}
diff --git a/Handlers/MPDHandler.cs b/Handlers/MPDHandler.cs
index 85aa1c1..01f740f 100644
--- a/Handlers/MPDHandler.cs
+++ b/Handlers/MPDHandler.cs
@@ -59,7 +59,6 @@ namespace unison
_elapsedTimer = new System.Timers.Timer(500);
_elapsedTimer.Elapsed += new System.Timers.ElapsedEventHandler(ElapsedTimer);
-
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(2);
timer.Tick += QueryStatus;
@@ -228,7 +227,8 @@ namespace unison
_elapsedTimer.Stop();
}
- await _mpd.MpdQueryAlbumArt(_currentSong.File, false);
+ if (_currentSong != null)
+ await _mpd.MpdQueryAlbumArt(_currentSong.File, false);
}
public SongInfoEx GetCurrentSong() => _currentSong;
@@ -291,5 +291,10 @@ namespace unison
{
return _currentStatus?.MpdState == MPDCtrl.Models.Status.MpdPlayState.Play;
}
+
+ public string GetVersion()
+ {
+ return _mpd.MpdVerText;
+ }
}
}
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 78e8bdf..a00c48a 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -94,5 +94,17 @@ namespace unison.Properties {
this["snapcast_port"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("5")]
+ public int volume_offset {
+ get {
+ return ((int)(this["volume_offset"]));
+ }
+ set {
+ this["volume_offset"] = value;
+ }
+ }
}
}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
index 24940ea..409e1b7 100644
--- a/Properties/Settings.settings
+++ b/Properties/Settings.settings
@@ -20,5 +20,8 @@
1704
+
+ 5
+
\ No newline at end of file
diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs
index 5cc72d7..ad0d27b 100644
--- a/Views/MainWindow.xaml.cs
+++ b/Views/MainWindow.xaml.cs
@@ -9,7 +9,7 @@ namespace unison
{
public partial class MainWindow : Window, INotifyPropertyChanged
{
- private readonly Settings SettingsWindow = new Settings();
+ public readonly Settings SettingsWindow = new Settings();
private MPDHandler mpd;
diff --git a/Views/Settings.xaml b/Views/Settings.xaml
index 1bdfbae..0af2144 100644
--- a/Views/Settings.xaml
+++ b/Views/Settings.xaml
@@ -34,7 +34,9 @@
-
+
+
+
@@ -79,33 +81,39 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/Views/Settings.xaml.cs b/Views/Settings.xaml.cs
index 9885c92..0caabbd 100644
--- a/Views/Settings.xaml.cs
+++ b/Views/Settings.xaml.cs
@@ -50,6 +50,7 @@ namespace unison
SnapcastStartup.IsChecked = Properties.Settings.Default.snapcast_startup;
SnapcastPath.Text = Properties.Settings.Default.snapcast_path;
SnapcastPort.Text = Properties.Settings.Default.snapcast_port.ToString();
+ VolumeOffset.Text = Properties.Settings.Default.volume_offset.ToString();
}
private void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
@@ -66,11 +67,22 @@ namespace unison
e.Handled = true;
}
+ public void UpdateConnectionStatus()
+ {
+ MPDHandler mpd = (MPDHandler)Application.Current.Properties["mpd"];
+ if (mpd._connected)
+ {
+ ConnectionStatus.Text = "Connected to MPD " + mpd.GetVersion() + ".";
+ ConnectButton.IsEnabled = false;
+ }
+ }
+
private void MPDConnect_Clicked(object sender, RoutedEventArgs e)
{
SaveSettings();
MPDHandler mpd = (MPDHandler)Application.Current.Properties["mpd"];
- //mpd.Connect();
+ mpd.Start();
+ UpdateConnectionStatus();
}
private void SnapcastReset_Clicked(object sender, RoutedEventArgs e)
@@ -87,6 +99,7 @@ namespace unison
Properties.Settings.Default.snapcast_startup = (bool)SnapcastStartup.IsChecked;
Properties.Settings.Default.snapcast_path = SnapcastPath.Text;
Properties.Settings.Default.snapcast_port = int.Parse(SnapcastPort.Text, CultureInfo.InvariantCulture);
+ Properties.Settings.Default.volume_offset = int.Parse(VolumeOffset.Text, CultureInfo.InvariantCulture);
Properties.Settings.Default.Save();
}
diff --git a/unison.csproj b/unison.csproj
index 05f72c7..1fb576e 100644
--- a/unison.csproj
+++ b/unison.csproj
@@ -8,6 +8,12 @@
unison.App
0.0.1
+
+ Théo Marchal
+ LICENSE
+ https://git.n700.ovh/keb/unison
+ https://git.n700.ovh/keb/unison
+ Théo Marchal
@@ -21,6 +27,10 @@
+
+ True
+
+