Working MainWindow buttons, read license from file
This commit is contained in:
@ -57,24 +57,24 @@
|
||||
<TextBlock Text="🔊" TextWrapping="Wrap" HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" VerticalAlignment="Bottom" MinHeight="35">
|
||||
<Border BorderThickness="0,0,0,0" BorderBrush="Black" HorizontalAlignment="Stretch" VerticalAlignment="Top" SnapsToDevicePixels="True">
|
||||
<Border x:Name="BorderRandom" BorderThickness="0,0,0,0" BorderBrush="Black" HorizontalAlignment="Stretch" VerticalAlignment="Top" SnapsToDevicePixels="True">
|
||||
<Button x:Name="Random" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="{x:Null}" BorderBrush="{x:Null}" FontSize="18" Click="Random_Clicked">
|
||||
<emoji:TextBlock ColorBlend="True" Text="🔀" FontSize="18" Margin="0" Padding="0, 0, 0, 2" />
|
||||
</Button>
|
||||
</Border>
|
||||
<Border BorderThickness="0, 0, 0, 2" BorderBrush="Black" VerticalAlignment="Top" Margin="5,0,0,0">
|
||||
<Border x:Name="BorderRepeat" BorderThickness="0, 0, 0, 0" BorderBrush="Black" VerticalAlignment="Top" Margin="5,0,0,0">
|
||||
<Button x:Name="Repeat" Background="{x:Null}" FontSize="18" BorderBrush="{x:Null}" Click="Repeat_Clicked">
|
||||
<emoji:TextBlock ColorBlend="True" Text="🔁" FontSize="18" Margin="0" Padding="0, 0, 0, 2" />
|
||||
</Button>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" VerticalAlignment="Bottom" MinHeight="35">
|
||||
<Border BorderThickness="0,0,0,0" BorderBrush="Black" HorizontalAlignment="Stretch" VerticalAlignment="Top" SnapsToDevicePixels="True" Margin="0,0,5,0">
|
||||
<Border x:Name="BorderSingle" BorderThickness="0,0,0,0" BorderBrush="Black" HorizontalAlignment="Stretch" VerticalAlignment="Top" SnapsToDevicePixels="True" Margin="0,0,5,0">
|
||||
<Button x:Name="Single" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" BorderBrush="{x:Null}" Background="{x:Null}" Click="Single_Clicked">
|
||||
<emoji:TextBlock ColorBlend="True" Text="🔂" FontSize="18" Margin="0" Padding="0, 0, 0, 2" TextDecorations="{x:Null}"/>
|
||||
</Button>
|
||||
</Border>
|
||||
<Border BorderThickness="0,0,0,0" BorderBrush="Black" HorizontalAlignment="Stretch" VerticalAlignment="Top" SnapsToDevicePixels="True">
|
||||
<Border x:Name="BorderConsume" BorderThickness="0,0,0,0" BorderBrush="Black" HorizontalAlignment="Stretch" VerticalAlignment="Top" SnapsToDevicePixels="True">
|
||||
<Button x:Name="Consume" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" BorderBrush="{x:Null}" Background="{x:Null}" Click="Consume_Clicked">
|
||||
<emoji:TextBlock ColorBlend="True" Text="🆓" FontSize="18" Margin="0" Padding="0, 0, 0, 2"/>
|
||||
</Button>
|
||||
@ -107,12 +107,12 @@
|
||||
</Button>
|
||||
<TextBlock x:Name="Connection" HorizontalAlignment="Center" Text="Not connected" TextWrapping="Wrap" VerticalAlignment="Center" TextAlignment="Center" MinWidth="350" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"/>
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,10,0">
|
||||
<Button x:Name="Shuffle" Padding="5, 2" HorizontalAlignment="Right" Margin="0,0,10,0" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
|
||||
<!--<Button x:Name="Shuffle" Padding="5, 2" HorizontalAlignment="Right" Margin="0,0,10,0" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<emoji:TextBlock Text="🔁"/>
|
||||
<TextBlock Text="Shuffle" Margin="5, 0, 0, 0"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</Button>-->
|
||||
<Button x:Name="Settings" Padding="5, 2" Click="Settings_Clicked" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<emoji:TextBlock Text="🛠️"/>
|
||||
|
@ -8,7 +8,6 @@ using System.Windows.Controls;
|
||||
using System.Windows.Threading;
|
||||
using MPDCtrl.Models;
|
||||
using System.Windows.Interop;
|
||||
using unison.Views;
|
||||
|
||||
namespace unison
|
||||
{
|
||||
@ -29,6 +28,9 @@ namespace unison
|
||||
|
||||
Settings SettingsWindow = new Settings();
|
||||
|
||||
Thickness SelectedThickness;
|
||||
Thickness BaseThickness;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitHwnd();
|
||||
@ -41,6 +43,10 @@ namespace unison
|
||||
timer.Interval = TimeSpan.FromSeconds(0.2);
|
||||
timer.Tick += Timer_Tick;
|
||||
timer.Start();
|
||||
|
||||
SelectedThickness.Left = SelectedThickness.Right = SelectedThickness.Top = 0.0f;
|
||||
SelectedThickness.Bottom = 2.0f;
|
||||
BaseThickness.Left = BaseThickness.Right = BaseThickness.Top = BaseThickness.Bottom = 0.0f;
|
||||
}
|
||||
|
||||
public async void ConnectToMPD()
|
||||
@ -95,12 +101,12 @@ namespace unison
|
||||
await Task.Delay(5);
|
||||
}
|
||||
|
||||
public void UpdateButton(ref Button button, bool b)
|
||||
public void UpdateButton(ref Border border, bool b)
|
||||
{
|
||||
if (b)
|
||||
button.Foreground = SystemColors.GradientActiveCaptionBrush;
|
||||
border.BorderThickness = SelectedThickness;
|
||||
else
|
||||
button.Foreground = SystemColors.DesktopBrush;
|
||||
border.BorderThickness = BaseThickness;
|
||||
}
|
||||
|
||||
public string FormatSeconds(double time)
|
||||
@ -146,10 +152,10 @@ namespace unison
|
||||
|
||||
Connection.Text = (_connected ? "✔️" : "❌") + _mpd.MpdHost + ":" + _mpd.MpdPort;
|
||||
|
||||
UpdateButton(ref Random, _currentRandom);
|
||||
UpdateButton(ref Repeat, _currentRepeat);
|
||||
UpdateButton(ref Single, _currentSingle);
|
||||
UpdateButton(ref Consume, _currentConsume);
|
||||
UpdateButton(ref BorderRandom, _currentRandom);
|
||||
UpdateButton(ref BorderRepeat, _currentRepeat);
|
||||
UpdateButton(ref BorderSingle, _currentSingle);
|
||||
UpdateButton(ref BorderConsume, _currentConsume);
|
||||
}
|
||||
|
||||
public async void Pause_Clicked(object sender, RoutedEventArgs e)
|
||||
@ -206,15 +212,16 @@ namespace unison
|
||||
|
||||
public void Settings_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (SettingsWindow.WindowState == WindowState.Normal)
|
||||
{
|
||||
SettingsWindow.Hide();
|
||||
SettingsWindow.WindowState = WindowState.Minimized;
|
||||
}
|
||||
else if (SettingsWindow.WindowState == WindowState.Minimized)
|
||||
if (SettingsWindow.WindowState == WindowState.Minimized)
|
||||
{
|
||||
SettingsWindow.WindowState = WindowState.Normal;
|
||||
SettingsWindow.Show();
|
||||
SettingsWindow.Activate();
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsWindow.Hide();
|
||||
SettingsWindow.WindowState = WindowState.Minimized;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
<Window x:Class="unison.Views.Settings"
|
||||
<Window x:Class="unison.Settings"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
|
||||
xmlns:local="clr-namespace:unison.Views"
|
||||
xmlns:local="clr-namespace:unison"
|
||||
mc:Ignorable="d"
|
||||
Closing="Window_Closing" Title="Settings" ResizeMode="CanMinimize" Icon="/unison.ico" WindowStyle="ToolWindow" SizeToContent="WidthAndHeight">
|
||||
<Grid>
|
||||
|
@ -5,12 +5,30 @@ using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace unison.Views
|
||||
namespace unison
|
||||
{
|
||||
public partial class Settings : Window
|
||||
{
|
||||
public string GetVersion => Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
||||
|
||||
public string GetLicense
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
StreamReader Reader = new("LICENSE");
|
||||
string file = "";
|
||||
file = file + Reader.ReadToEnd();
|
||||
return file;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
return e.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Settings()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -33,23 +51,5 @@ namespace unison.Views
|
||||
WindowState = WindowState.Minimized;
|
||||
Hide();
|
||||
}
|
||||
|
||||
public string GetLicense
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
var Reader = new StreamReader("LICENSE");
|
||||
string file = "";
|
||||
file = file + Reader.ReadToEnd();
|
||||
return file;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
return e.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user