MPD moved to its own class
This commit is contained in:
parent
a2f2af87cc
commit
f85eae1354
@ -8,6 +8,7 @@ namespace unison
|
|||||||
private TaskbarIcon Systray;
|
private TaskbarIcon Systray;
|
||||||
private HotkeyHandler Hotkeys;
|
private HotkeyHandler Hotkeys;
|
||||||
private SnapcastHandler Snapcast;
|
private SnapcastHandler Snapcast;
|
||||||
|
private MPDHandler MPD;
|
||||||
|
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
{
|
{
|
||||||
@ -19,10 +20,13 @@ namespace unison
|
|||||||
Snapcast = new SnapcastHandler();
|
Snapcast = new SnapcastHandler();
|
||||||
Current.Properties["snapcast"] = Snapcast;
|
Current.Properties["snapcast"] = Snapcast;
|
||||||
|
|
||||||
|
MPD = new MPDHandler();
|
||||||
|
Current.Properties["mpd"] = MPD;
|
||||||
|
|
||||||
Current.MainWindow = new MainWindow();
|
Current.MainWindow = new MainWindow();
|
||||||
|
|
||||||
Systray = (TaskbarIcon)FindResource("SystrayTaskbar");
|
Systray = (TaskbarIcon)FindResource("SystrayTaskbar");
|
||||||
Current.Properties["notify"] = Systray;
|
Current.Properties["systray"] = Systray;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnExit(ExitEventArgs e)
|
protected override void OnExit(ExitEventArgs e)
|
||||||
|
@ -34,8 +34,11 @@ namespace unison
|
|||||||
private IntPtr _windowHandle;
|
private IntPtr _windowHandle;
|
||||||
private HwndSource _source;
|
private HwndSource _source;
|
||||||
|
|
||||||
|
private readonly MPDHandler mpd;
|
||||||
|
|
||||||
public HotkeyHandler()
|
public HotkeyHandler()
|
||||||
{
|
{
|
||||||
|
mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(Window win)
|
public void Activate(Window win)
|
||||||
@ -66,22 +69,21 @@ namespace unison
|
|||||||
switch (vkey)
|
switch (vkey)
|
||||||
{
|
{
|
||||||
case VK_MEDIA_NEXT_TRACK:
|
case VK_MEDIA_NEXT_TRACK:
|
||||||
Trace.WriteLine("TEST super important");
|
mpd.Next();
|
||||||
AppWindow.Next_Clicked(null, null);
|
|
||||||
break;
|
break;
|
||||||
case VK_MEDIA_PREV_TRACK:
|
case VK_MEDIA_PREV_TRACK:
|
||||||
AppWindow.Previous_Clicked(null, null);
|
mpd.Prev();
|
||||||
break;
|
break;
|
||||||
case VK_VOLUME_DOWN:
|
case VK_VOLUME_DOWN:
|
||||||
AppWindow._currentVolume -= 5;
|
mpd._currentVolume -= 5;
|
||||||
AppWindow.ChangeVolume(AppWindow._currentVolume);
|
mpd.SetVolume(mpd._currentVolume);
|
||||||
break;
|
break;
|
||||||
case VK_VOLUME_UP:
|
case VK_VOLUME_UP:
|
||||||
AppWindow._currentVolume += 5;
|
mpd._currentVolume += 5;
|
||||||
AppWindow.ChangeVolume(AppWindow._currentVolume);
|
mpd.SetVolume(mpd._currentVolume);
|
||||||
break;
|
break;
|
||||||
case VK_MEDIA_PLAY_PAUSE:
|
case VK_MEDIA_PLAY_PAUSE:
|
||||||
AppWindow.Pause_Clicked(null, null);
|
mpd.PlayPause();
|
||||||
break;
|
break;
|
||||||
case VK_ENTER:
|
case VK_ENTER:
|
||||||
if (AppWindow.WindowState == WindowState.Minimized)
|
if (AppWindow.WindowState == WindowState.Minimized)
|
||||||
|
@ -1,9 +1,128 @@
|
|||||||
namespace unison
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using MPDCtrl.Models;
|
||||||
|
|
||||||
|
namespace unison
|
||||||
{
|
{
|
||||||
public class MPDHandler
|
public class MPDHandler
|
||||||
{
|
{
|
||||||
|
private readonly MPC _mpd = new();
|
||||||
|
|
||||||
|
public bool _connected;
|
||||||
|
public int _currentVolume;
|
||||||
|
public bool _currentRandom;
|
||||||
|
public bool _currentRepeat;
|
||||||
|
public bool _currentSingle;
|
||||||
|
public bool _currentConsume;
|
||||||
|
public double _currentElapsed;
|
||||||
|
|
||||||
|
private Status _currentStatus = null;
|
||||||
|
private SongInfoEx _currentSong = null;
|
||||||
|
|
||||||
public MPDHandler()
|
public MPDHandler()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void Connect()
|
||||||
|
{
|
||||||
|
_connected = await _mpd.MpdCommandConnectionStart(Properties.Settings.Default.mpd_host, Properties.Settings.Default.mpd_port, Properties.Settings.Default.mpd_password);
|
||||||
|
if (_connected)
|
||||||
|
{
|
||||||
|
await _mpd.MpdQueryStatus();
|
||||||
|
await Task.Delay(5);
|
||||||
|
_currentVolume = _mpd.MpdStatus.MpdVolume;
|
||||||
|
_currentRandom = _mpd.MpdStatus.MpdRandom;
|
||||||
|
_currentRepeat = _mpd.MpdStatus.MpdRepeat;
|
||||||
|
_currentSingle = _mpd.MpdStatus.MpdSingle;
|
||||||
|
_currentConsume = _mpd.MpdStatus.MpdConsume;
|
||||||
|
_currentElapsed = _mpd.MpdStatus.MpdSongElapsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CheckStatus<T>(ref T a, T b)
|
||||||
|
{
|
||||||
|
if (Comparer<T>.Default.Compare(a, b) != 0)
|
||||||
|
a = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Loop()
|
||||||
|
{
|
||||||
|
if (!_connected)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CommandResult status = await _mpd.MpdQueryStatus();
|
||||||
|
//Trace.WriteLine(status.ResultText);
|
||||||
|
await Task.Delay(5);
|
||||||
|
if (status != null)
|
||||||
|
{
|
||||||
|
_currentStatus = _mpd.MpdStatus;
|
||||||
|
|
||||||
|
CheckStatus(ref _currentVolume, _mpd.MpdStatus.MpdVolume);
|
||||||
|
CheckStatus(ref _currentRandom, _mpd.MpdStatus.MpdRandom);
|
||||||
|
CheckStatus(ref _currentRepeat, _mpd.MpdStatus.MpdRepeat);
|
||||||
|
CheckStatus(ref _currentSingle, _mpd.MpdStatus.MpdSingle);
|
||||||
|
CheckStatus(ref _currentConsume, _mpd.MpdStatus.MpdConsume);
|
||||||
|
CheckStatus(ref _currentElapsed, _mpd.MpdStatus.MpdSongElapsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandResult song = await _mpd.MpdQueryCurrentSong();
|
||||||
|
await Task.Delay(5);
|
||||||
|
if (song != null)
|
||||||
|
_currentSong = _mpd.MpdCurrentSong;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SongInfoEx GetCurrentSong() => _currentSong;
|
||||||
|
public Status GetStatus() => _currentStatus;
|
||||||
|
|
||||||
|
public async void Prev()
|
||||||
|
{
|
||||||
|
await _mpd.MpdPlaybackPrev(_currentVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Next()
|
||||||
|
{
|
||||||
|
await _mpd.MpdPlaybackNext(_currentVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void PlayPause()
|
||||||
|
{
|
||||||
|
if (_mpd.MpdStatus.MpdState == Status.MpdPlayState.Play)
|
||||||
|
await _mpd.MpdPlaybackPause();
|
||||||
|
else if (_mpd.MpdStatus.MpdState == Status.MpdPlayState.Pause)
|
||||||
|
await _mpd.MpdPlaybackPlay(_currentVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Random()
|
||||||
|
{
|
||||||
|
await _mpd.MpdSetRandom(!_currentRandom);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Repeat()
|
||||||
|
{
|
||||||
|
await _mpd.MpdSetRepeat(!_currentRepeat);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Single()
|
||||||
|
{
|
||||||
|
await _mpd.MpdSetSingle(!_currentSingle);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Consume()
|
||||||
|
{
|
||||||
|
await _mpd.MpdSetConsume(!_currentConsume);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void SetVolume(int value)
|
||||||
|
{
|
||||||
|
await _mpd.MpdSetVolume(value);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsPlaying() => _currentStatus?.MpdState == MPDCtrl.Models.Status.MpdPlayState.Play;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,31 +2,19 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using MPDCtrl.Models;
|
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace unison
|
namespace unison
|
||||||
{
|
{
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
private readonly MPC _mpd = new();
|
private readonly Settings SettingsWindow = new Settings();
|
||||||
private bool _connected;
|
|
||||||
public int _currentVolume;
|
|
||||||
private bool _currentRandom;
|
|
||||||
private bool _currentRepeat;
|
|
||||||
private bool _currentSingle;
|
|
||||||
private bool _currentConsume;
|
|
||||||
private double _currentElapsed;
|
|
||||||
|
|
||||||
private string _mpdHost = "192.168.1.13";
|
private readonly MPDHandler mpd;
|
||||||
private int _mpdPort = 6600;
|
|
||||||
private string _mpdPassword = null;
|
|
||||||
|
|
||||||
Settings SettingsWindow = new Settings();
|
|
||||||
|
|
||||||
Thickness SelectedThickness;
|
Thickness SelectedThickness;
|
||||||
Thickness BaseThickness;
|
Thickness BaseThickness;
|
||||||
@ -38,7 +26,9 @@ namespace unison
|
|||||||
|
|
||||||
WindowState = WindowState.Minimized;
|
WindowState = WindowState.Minimized;
|
||||||
|
|
||||||
ConnectToMPD();
|
mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||||
|
mpd.Connect();
|
||||||
|
|
||||||
DispatcherTimer timer = new DispatcherTimer();
|
DispatcherTimer timer = new DispatcherTimer();
|
||||||
timer.Interval = TimeSpan.FromSeconds(0.2);
|
timer.Interval = TimeSpan.FromSeconds(0.2);
|
||||||
timer.Tick += Timer_Tick;
|
timer.Tick += Timer_Tick;
|
||||||
@ -49,57 +39,14 @@ namespace unison
|
|||||||
BaseThickness.Left = BaseThickness.Right = BaseThickness.Top = BaseThickness.Bottom = 0.0f;
|
BaseThickness.Left = BaseThickness.Right = BaseThickness.Top = BaseThickness.Bottom = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void ConnectToMPD()
|
|
||||||
{
|
|
||||||
_connected = await _mpd.MpdCommandConnectionStart(_mpdHost, _mpdPort, _mpdPassword);
|
|
||||||
if (_connected)
|
|
||||||
{
|
|
||||||
await _mpd.MpdQueryStatus();
|
|
||||||
await Task.Delay(5);
|
|
||||||
_currentVolume = _mpd.MpdStatus.MpdVolume;
|
|
||||||
_currentRandom = _mpd.MpdStatus.MpdRandom;
|
|
||||||
_currentRepeat = _mpd.MpdStatus.MpdRepeat;
|
|
||||||
_currentSingle = _mpd.MpdStatus.MpdSingle;
|
|
||||||
_currentConsume = _mpd.MpdStatus.MpdConsume;
|
|
||||||
_currentElapsed = _mpd.MpdStatus.MpdSongElapsed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Timer_Tick(object sender, EventArgs e)
|
private void Timer_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoopMPD();
|
MPDHandler mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||||
|
mpd.Loop();
|
||||||
|
|
||||||
UpdateInterface();
|
UpdateInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckStatus<T>(ref T a, T b)
|
|
||||||
{
|
|
||||||
if (Comparer<T>.Default.Compare(a, b) != 0)
|
|
||||||
a = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void LoopMPD()
|
|
||||||
{
|
|
||||||
if (!_connected)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var status = await _mpd.MpdQueryStatus();
|
|
||||||
//Trace.WriteLine(status.ResultText);
|
|
||||||
await Task.Delay(5);
|
|
||||||
|
|
||||||
if (status != null)
|
|
||||||
{
|
|
||||||
CheckStatus(ref _currentVolume, _mpd.MpdStatus.MpdVolume);
|
|
||||||
CheckStatus(ref _currentRandom, _mpd.MpdStatus.MpdRandom);
|
|
||||||
CheckStatus(ref _currentRepeat, _mpd.MpdStatus.MpdRepeat);
|
|
||||||
CheckStatus(ref _currentSingle, _mpd.MpdStatus.MpdSingle);
|
|
||||||
CheckStatus(ref _currentConsume, _mpd.MpdStatus.MpdConsume);
|
|
||||||
CheckStatus(ref _currentElapsed, _mpd.MpdStatus.MpdSongElapsed);
|
|
||||||
}
|
|
||||||
|
|
||||||
await _mpd.MpdQueryCurrentSong();
|
|
||||||
await Task.Delay(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateButton(ref Border border, bool b)
|
public void UpdateButton(ref Border border, bool b)
|
||||||
{
|
{
|
||||||
if (b)
|
if (b)
|
||||||
@ -116,31 +63,33 @@ namespace unison
|
|||||||
|
|
||||||
public void UpdateInterface()
|
public void UpdateInterface()
|
||||||
{
|
{
|
||||||
if (_mpd.MpdCurrentSong != null)
|
if (mpd.GetCurrentSong() != null)
|
||||||
{
|
{
|
||||||
SongTitle.Text = _mpd.MpdCurrentSong.Title;
|
SongTitle.Text = mpd.GetCurrentSong().Title;
|
||||||
SongTitle.ToolTip = _mpd.MpdCurrentSong.File;
|
SongTitle.ToolTip = mpd.GetCurrentSong().File;
|
||||||
SongArtist.Text = _mpd.MpdCurrentSong.Artist;
|
SongArtist.Text = mpd.GetCurrentSong().Artist;
|
||||||
SongAlbum.Text = _mpd.MpdCurrentSong.Album + " (" + _mpd.MpdCurrentSong.Date + ")";
|
SongAlbum.Text = mpd.GetCurrentSong().Album;
|
||||||
Bitrate.Text = _mpd.MpdCurrentSong.File.Substring(_mpd.MpdCurrentSong.File.LastIndexOf(".") + 1);
|
if (mpd.GetCurrentSong().Date.Length > 0)
|
||||||
Bitrate.Text += " – ";
|
SongAlbum.Text += $" ({ mpd.GetCurrentSong().Date})";
|
||||||
Bitrate.Text += _mpd.MpdStatus.MpdBitrate + "kbps";
|
Bitrate.Text = mpd.GetCurrentSong().File.Substring(mpd.GetCurrentSong().File.LastIndexOf(".") + 1) + " – ";
|
||||||
|
Bitrate.Text += mpd.GetStatus().MpdBitrate + "kbps";
|
||||||
|
|
||||||
CurrentTime.Text = FormatSeconds(_currentElapsed);
|
CurrentTime.Text = FormatSeconds(mpd._currentElapsed);
|
||||||
EndTime.Text = FormatSeconds(_mpd.MpdStatus.MpdSongTime);
|
EndTime.Text = FormatSeconds(mpd.GetStatus().MpdSongTime);
|
||||||
|
|
||||||
TimeSlider.Value = _currentElapsed / _mpd.MpdCurrentSong.TimeSort * 100;
|
if (!System.Double.IsNaN(mpd.GetCurrentSong().TimeSort))
|
||||||
|
TimeSlider.Value = mpd._currentElapsed / mpd.GetCurrentSong().TimeSort * 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VolumeSlider.Value != _currentVolume)
|
if (VolumeSlider.Value != mpd._currentVolume)
|
||||||
{
|
{
|
||||||
VolumeSlider.Value = _currentVolume;
|
VolumeSlider.Value = mpd._currentVolume;
|
||||||
VolumeSlider.ToolTip = _currentVolume;
|
VolumeSlider.ToolTip = mpd._currentVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_mpd.MpdStatus.MpdState == Status.MpdPlayState.Play)
|
if (mpd.IsPlaying())
|
||||||
PauseButtonEmoji.Text = "⏸️";
|
PauseButtonEmoji.Text = "⏸️";
|
||||||
else if (_mpd.MpdStatus.MpdState == Status.MpdPlayState.Pause)
|
else
|
||||||
PauseButtonEmoji.Text = "▶️";
|
PauseButtonEmoji.Text = "▶️";
|
||||||
|
|
||||||
SnapcastHandler snapcast = (SnapcastHandler)Application.Current.Properties["snapcast"];
|
SnapcastHandler snapcast = (SnapcastHandler)Application.Current.Properties["snapcast"];
|
||||||
@ -149,56 +98,22 @@ namespace unison
|
|||||||
else
|
else
|
||||||
SnapcastText.Text = "Start Snapcast";
|
SnapcastText.Text = "Start Snapcast";
|
||||||
|
|
||||||
Connection.Text = (_connected ? "✔️" : "❌") + _mpd.MpdHost + ":" + _mpd.MpdPort;
|
Connection.Text = (mpd._connected ? "✔️" : "❌") + $"{Properties.Settings.Default.mpd_host}:{Properties.Settings.Default.mpd_port}";
|
||||||
|
|
||||||
UpdateButton(ref BorderRandom, _currentRandom);
|
UpdateButton(ref BorderRandom, mpd._currentRandom);
|
||||||
UpdateButton(ref BorderRepeat, _currentRepeat);
|
UpdateButton(ref BorderRepeat, mpd._currentRepeat);
|
||||||
UpdateButton(ref BorderSingle, _currentSingle);
|
UpdateButton(ref BorderSingle, mpd._currentSingle);
|
||||||
UpdateButton(ref BorderConsume, _currentConsume);
|
UpdateButton(ref BorderConsume, mpd._currentConsume);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void Pause_Clicked(object sender, RoutedEventArgs e)
|
public void Pause_Clicked(object sender, RoutedEventArgs e) => mpd.PlayPause();
|
||||||
{
|
public void Previous_Clicked(object sender, RoutedEventArgs e) => mpd.Prev();
|
||||||
if (_mpd.MpdStatus.MpdState == Status.MpdPlayState.Play)
|
public void Next_Clicked(object sender, RoutedEventArgs e) => mpd.Next();
|
||||||
await _mpd.MpdPlaybackPause();
|
public void Random_Clicked(object sender, RoutedEventArgs e) => mpd.Random();
|
||||||
else if (_mpd.MpdStatus.MpdState == Status.MpdPlayState.Pause)
|
public void Repeat_Clicked(object sender, RoutedEventArgs e) => mpd.Repeat();
|
||||||
await _mpd.MpdPlaybackPlay(_currentVolume);
|
public void Single_Clicked(object sender, RoutedEventArgs e) => mpd.Single();
|
||||||
}
|
public void Consume_Clicked(object sender, RoutedEventArgs e) => mpd.Consume();
|
||||||
|
public void ChangeVolume(int value) => mpd.SetVolume(value);
|
||||||
public async void Previous_Clicked(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
await _mpd.MpdPlaybackPrev(_currentVolume);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void Next_Clicked(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
await _mpd.MpdPlaybackNext(_currentVolume);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void Random_Clicked(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
await _mpd.MpdSetRandom(!_currentRandom);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void Repeat_Clicked(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
await _mpd.MpdSetRepeat(!_currentRepeat);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void Single_Clicked(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
await _mpd.MpdSetSingle(!_currentSingle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void Consume_Clicked(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
await _mpd.MpdSetConsume(!_currentConsume);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void ChangeVolume(int value)
|
|
||||||
{
|
|
||||||
await _mpd.MpdSetVolume(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Snapcast_Clicked(object sender, RoutedEventArgs e)
|
public void Snapcast_Clicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
<TextBlock Text="Password" TextWrapping="Wrap" Margin="5,0,0,0"/>
|
<TextBlock Text="Password" TextWrapping="Wrap" Margin="5,0,0,0"/>
|
||||||
<TextBox x:Name="MpdPassword" TextWrapping="Wrap" Width="250" Margin="10,2,0,0"/>
|
<TextBox x:Name="MpdPassword" TextWrapping="Wrap" Width="250" Margin="10,2,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Button Content="Connect" Margin="0,10,0,0" Width="120"/>
|
<Button Content="Connect" Margin="0,10,0,0" Width="120" Click="MPDConnect_Clicked"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -65,6 +66,17 @@ namespace unison
|
|||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MPDConnect_Clicked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Properties.Settings.Default.mpd_host = MpdHost.Text;
|
||||||
|
Properties.Settings.Default.mpd_port = int.Parse(MpdPort.Text, CultureInfo.InvariantCulture);
|
||||||
|
Properties.Settings.Default.mpd_password = MpdPassword.Text;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
|
||||||
|
var mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||||
|
mpd.Connect();
|
||||||
|
}
|
||||||
|
|
||||||
private void SnapcastReset_Clicked(object sender, RoutedEventArgs e)
|
private void SnapcastReset_Clicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
SnapcastPath.Text = defaultSnapcastPath;
|
SnapcastPath.Text = defaultSnapcastPath;
|
||||||
@ -76,11 +88,11 @@ namespace unison
|
|||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
|
|
||||||
Properties.Settings.Default.mpd_host = MpdHost.Text;
|
Properties.Settings.Default.mpd_host = MpdHost.Text;
|
||||||
Properties.Settings.Default.mpd_port = int.Parse(MpdPort.Text);
|
Properties.Settings.Default.mpd_port = int.Parse(MpdPort.Text, CultureInfo.InvariantCulture);
|
||||||
Properties.Settings.Default.mpd_password = MpdPassword.Text;
|
Properties.Settings.Default.mpd_password = MpdPassword.Text;
|
||||||
Properties.Settings.Default.snapcast_startup = (bool)SnapcastStartup.IsChecked;
|
Properties.Settings.Default.snapcast_startup = (bool)SnapcastStartup.IsChecked;
|
||||||
Properties.Settings.Default.snapcast_path = SnapcastPath.Text;
|
Properties.Settings.Default.snapcast_path = SnapcastPath.Text;
|
||||||
Properties.Settings.Default.snapcast_port = int.Parse(SnapcastPort.Text);
|
Properties.Settings.Default.snapcast_port = int.Parse(SnapcastPort.Text, CultureInfo.InvariantCulture);
|
||||||
Properties.Settings.Default.Save();
|
Properties.Settings.Default.Save();
|
||||||
|
|
||||||
WindowState = WindowState.Minimized;
|
WindowState = WindowState.Minimized;
|
||||||
|
Loading…
Reference in New Issue
Block a user