Compare commits

..

2 Commits

Author SHA1 Message Date
86a652c170 Improvement on seek time slider 2021-08-31 01:53:52 +02:00
0aa80ed8b5 Option to show Snapcast window 2021-08-31 01:42:00 +02:00
7 changed files with 32 additions and 3 deletions

View File

@ -44,7 +44,7 @@ namespace unison
{
_snapcast.StartInfo.FileName = Properties.Settings.Default.snapcast_path + @"\snapclient.exe";
_snapcast.StartInfo.Arguments = $"--host {Properties.Settings.Default.mpd_host}";
_snapcast.StartInfo.CreateNoWindow = true;
_snapcast.StartInfo.CreateNoWindow = !Properties.Settings.Default.snapcast_window;
try
{
_snapcast.Start();

View File

@ -106,5 +106,17 @@ namespace unison.Properties {
this["volume_offset"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool snapcast_window {
get {
return ((bool)(this["snapcast_window"]));
}
set {
this["snapcast_window"] = value;
}
}
}
}

View File

@ -14,6 +14,9 @@
<Setting Name="snapcast_startup" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="snapcast_window" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="snapcast_path" Type="System.String" Scope="User">
<Value Profile="(Default)">snapclient_0.25.0-1_win64</Value>
</Setting>

View File

@ -37,7 +37,7 @@
<Grid HorizontalAlignment="Center" VerticalAlignment="Top">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="CurrentTime" Text="0:00" TextWrapping="Wrap" HorizontalAlignment="Left"/>
<Slider Style="{DynamicResource SliderTime}" x:Name="TimeSlider" MinWidth="320" Margin="5,0,5,0" HorizontalAlignment="Center" Maximum="100" PreviewMouseUp="TimeSlider_DragCompleted" FocusVisualStyle="{x:Null}"/>
<Slider Style="{DynamicResource SliderTime}" x:Name="TimeSlider" MinWidth="320" Margin="5,0,5,0" HorizontalAlignment="Center" Maximum="100" PreviewMouseUp="TimeSlider_DragCompleted" Thumb.DragStarted="TimeSlider_DragStarted" FocusVisualStyle="{x:Null}"/>
<TextBlock x:Name="EndTime" Text="0:00" TextWrapping="Wrap" Height="18" HorizontalAlignment="Right"/>
</StackPanel>
</Grid>

View File

@ -5,6 +5,7 @@ using System.Windows.Controls;
using System.Windows.Threading;
using System.Windows.Interop;
using System.Windows.Input;
using System.Windows.Controls.Primitives;
namespace unison
{
@ -14,6 +15,8 @@ namespace unison
private readonly MPDHandler mpd;
DispatcherTimer timer = new DispatcherTimer();
Thickness SelectedThickness;
Thickness BaseThickness;
@ -26,7 +29,7 @@ namespace unison
mpd = (MPDHandler)Application.Current.Properties["mpd"];
DispatcherTimer timer = new DispatcherTimer();
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(0.5);
timer.Tick += Timer_Tick;
timer.Start();
@ -174,6 +177,11 @@ namespace unison
Hide();
}
private void TimeSlider_DragStarted(object sender, DragStartedEventArgs e)
{
timer.Stop();
}
private void TimeSlider_DragCompleted(object sender, MouseButtonEventArgs e)
{
Slider slider = (Slider)sender;
@ -183,6 +191,7 @@ namespace unison
double SeekTime = SongPercentage / 100 * SongTime;
mpd.SetTime(SeekTime);
timer.Start();
}
private void VolumeSlider_DragCompleted(object sender, MouseButtonEventArgs e)

View File

@ -57,6 +57,9 @@
<CheckBox x:Name="SnapcastStartup" Margin="5, 5, 0, 0">
<TextBlock Text="Launch at startup" TextWrapping="Wrap"/>
</CheckBox>
<CheckBox x:Name="SnapcastWindow" Margin="5,2.5,0,0">
<TextBlock Text="Show Snapcast window" TextWrapping="Wrap"/>
</CheckBox>
<TextBlock Text="Port" TextWrapping="Wrap" Margin="5,5,0,0"/>
<TextBox x:Name="SnapcastPort" MaxLength="5" PreviewTextInput="NumberValidationTextBox" TextWrapping="Wrap" Width="250" Margin="10,2,5,0" HorizontalAlignment="Left"/>
<TextBlock Text="Executable path" TextWrapping="Wrap" Margin="5,5,0,0"/>

View File

@ -48,6 +48,7 @@ namespace unison
MpdPort.Text = Properties.Settings.Default.mpd_port.ToString();
MpdPassword.Text = Properties.Settings.Default.mpd_password;
SnapcastStartup.IsChecked = Properties.Settings.Default.snapcast_startup;
SnapcastWindow.IsChecked = Properties.Settings.Default.snapcast_window;
SnapcastPath.Text = Properties.Settings.Default.snapcast_path;
SnapcastPort.Text = Properties.Settings.Default.snapcast_port.ToString();
VolumeOffset.Text = Properties.Settings.Default.volume_offset.ToString();
@ -96,6 +97,7 @@ namespace unison
Properties.Settings.Default.mpd_port = int.Parse(MpdPort.Text, CultureInfo.InvariantCulture);
Properties.Settings.Default.mpd_password = MpdPassword.Text;
Properties.Settings.Default.snapcast_startup = (bool)SnapcastStartup.IsChecked;
Properties.Settings.Default.snapcast_window = (bool)SnapcastWindow.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);