Compare commits

..

9 Commits

18 changed files with 446 additions and 123 deletions

View File

@ -1,6 +1,6 @@
using System.Globalization;
using System.Windows;
using System.Windows;
using Hardcodet.Wpf.TaskbarNotification;
using unison.Handlers;
namespace unison
{
@ -11,12 +11,13 @@ namespace unison
private SnapcastHandler _snapcast;
private ShuffleHandler _shuffle;
private MPDHandler _mpd;
private UpdateHandler _updater;
protected override void OnStartup(StartupEventArgs e)
{
//debug language
//unison.Resources.Resources.Culture = CultureInfo.GetCultureInfo("fr-FR");
//unison.Resources.Resources.Culture = CultureInfo.GetCultureInfo("es-ES");
//unison.Resources.Resources.Culture = System.Globalization.CultureInfo.GetCultureInfo("fr-FR");
//unison.Resources.Resources.Culture = System.Globalization.CultureInfo.GetCultureInfo("es-ES");
base.OnStartup(e);
@ -32,6 +33,9 @@ namespace unison
_shuffle = new ShuffleHandler();
Current.Properties["shuffle"] = _shuffle;
_updater = new UpdateHandler();
Current.Properties["updater"] = _updater;
Current.MainWindow = new MainWindow();

View File

@ -48,7 +48,7 @@ namespace unison
private MpdStatus _currentStatus;
private IMpdFile _currentSong;
private BitmapFrame _cover;
private BitmapImage _cover;
public Statistics _stats;
private readonly System.Timers.Timer _elapsedTimer;
private DispatcherTimer _retryTimer;
@ -476,14 +476,12 @@ namespace unison
else
{
using MemoryStream stream = new MemoryStream(data.ToArray());
try
{
_cover = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
}
catch
{
_cover = null;
}
_cover = new BitmapImage();
_cover.BeginInit();
_cover.CacheOption = BitmapCacheOption.OnLoad;
_cover.StreamSource = stream;
_cover.EndInit();
_cover.Freeze();
}
UpdateCover();
}
@ -525,7 +523,7 @@ namespace unison
public IMpdFile GetCurrentSong() => _currentSong;
public MpdStatus GetStatus() => _currentStatus;
public BitmapFrame GetCover() => _cover;
public BitmapImage GetCover() => _cover;
public string GetVersion() => _version;
public Statistics GetStats() => _stats;
public double GetCurrentTime() => _currentTime;

82
Handlers/RadioHandler.cs Normal file
View File

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using RadioBrowser;
using RadioBrowser.Models;
namespace unison.Handlers
{
public class CountryListItem
{
public uint Count { get; set; }
public string Name { get; set; }
public override string ToString()
{
if (Name == "")
return "None";
return $"{Name} ({Count})";
}
}
public class StationListItem
{
public string Name { get; set; }
public string Codec { get; set; }
public string Tags { get; set; }
public int Bitrate { get; set; }
public Uri Url { get; set; }
private string _country;
public string Country
{
get
{
if (_country.Length == 0)
return "🏴‍☠️";
return string.Concat(_country.ToUpper().Select(x => char.ConvertFromUtf32(x + 0x1F1A5))); // return emoji
}
set
{
_country = value;
}
}
}
internal class RadioHandler
{
private readonly RadioBrowserClient _radioBrowser;
private readonly bool _connected = true;
public bool IsConnected() => _connected;
public RadioHandler()
{
try
{
_radioBrowser = new RadioBrowserClient();
}
catch (Exception e)
{
Trace.WriteLine("Exception while connecting to RadioBrowser: " + e.Message);
return;
}
_connected = true;
}
public async Task<List<NameAndCount>> GetCountries()
{
return await _radioBrowser.Lists.GetCountriesAsync();
}
public async Task<List<StationInfo>> AdvancedSearch(AdvancedSearchOptions options)
{
return await _radioBrowser.Search.AdvancedAsync(options);
}
}
}

View File

@ -20,6 +20,16 @@ namespace unison
}
}
private void HandleExit(object sender, EventArgs e)
{
_snapcast.Kill();
HasStarted = false;
Application.Current.Dispatcher.Invoke(() =>
{
UpdateInterface();
});
}
public void UpdateInterface()
{
TaskbarIcon Systray = (TaskbarIcon)Application.Current.Properties["systray"];
@ -42,16 +52,19 @@ namespace unison
_snapcast.StartInfo.FileName = Properties.Settings.Default.snapcast_path + @"\snapclient.exe";
_snapcast.StartInfo.Arguments = $"--host {mpd._ipAddress}";
_snapcast.StartInfo.CreateNoWindow = !Properties.Settings.Default.snapcast_window;
_snapcast.EnableRaisingEvents = true;
_snapcast.Exited += new EventHandler(HandleExit);
try
{
_snapcast.Start();
}
catch (Exception err)
{
MessageBox.Show($"[{unison.Resources.Resources.Snapcast_Popup1}]\n" +
$"{unison.Resources.Resources.Snapcast_Popup2} {err.Message}\n\n" +
$"{unison.Resources.Resources.Snapcast_Popup3} {Properties.Settings.Default.snapcast_path}\n" +
$"{unison.Resources.Resources.Snapcast_Popup4}",
MessageBox.Show($"[{Resources.Resources.Snapcast_Popup1}]\n" +
$"{Resources.Resources.Snapcast_Popup2} {err.Message}\n\n" +
$"{Resources.Resources.Snapcast_Popup3} {Properties.Settings.Default.snapcast_path}\n" +
$"{Resources.Resources.Snapcast_Popup4}",
"unison", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}

58
Handlers/UpdateHandler.cs Normal file
View File

@ -0,0 +1,58 @@
using System.Diagnostics;
using System.Windows;
using AutoUpdaterDotNET;
namespace unison.Handlers
{
internal class UpdateHandler
{
readonly string xmlFile = "https://raw.githubusercontent.com/ZetaKebab/unison/main/Installer/unison.xml";
private bool _UpdateAvailable = false;
public bool UpdateAvailable() => _UpdateAvailable;
private bool _RequestedCheck = false;
public UpdateHandler()
{
AutoUpdater.CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent;
Start();
}
public void Start(bool RequestCheck = false)
{
_RequestedCheck = RequestCheck;
AutoUpdater.Start(xmlFile);
}
private string CutVersionNumber(string number)
{
return number.Substring(0, number.LastIndexOf("."));
}
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args)
{
if (args.Error == null)
{
if (args.IsUpdateAvailable)
{
_UpdateAvailable = true;
string number = CutVersionNumber(args.CurrentVersion);
MainWindow MainWin = (MainWindow)Application.Current.MainWindow;
MainWin.UpdateUpdateStatus(number);
MessageBoxResult Result = MessageBox.Show($"{Resources.Resources.Update_Message1} {number}.\n{Resources.Resources.Update_Message2}",
"unison", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (Result == MessageBoxResult.Yes)
AutoUpdater.DownloadUpdate(args);
}
else
{
if (_RequestedCheck)
MessageBox.Show($"{Resources.Resources.Update_NoUpdate}", "unison", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
}
}

43
Installer/unison.iss Normal file
View File

@ -0,0 +1,43 @@
#define Name "unison"
#define Version "1.3.1"
#define Snapcast "snapclient_0.26.0-1_win64"
#define Publisher "Théo Marchal"
#define URL "https://github.com/ZetaKebab/unison"
#define ExeName "unison.exe"
[Setup]
AppName={#Name}
AppVersion={#Version}
AppVerName={#Name} v{#Version}
AppPublisher={#Publisher}
AppPublisherURL={#URL}
AppSupportURL={#URL}
AppUpdatesURL={#URL}
DefaultDirName={autopf}\{#Name}
DisableProgramGroupPage=yes
ArchitecturesInstallIn64BitMode=x64
OutputBaseFilename="{#Name}-v{#Version}-setup"
OutputDir=..\publish\installer
SetupIconFile=..\Resources\icon-full.ico
UninstallDisplayIcon = "{app}\{#Name}.exe"
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
[Files]
Source: "..\publish\{#ExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\publish\LICENSE"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\publish\unison.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\publish\{#Snapcast}\*"; DestDir: "{app}\{#Snapcast}"; Flags: ignoreversion recursesubdirs createallsubdirs
[Icons]
Name: "{group}\{#Name}"; Filename: "{app}\{#ExeName}"
[Run]
Filename: "{app}\{#Name}.exe"; Parameters: "-frominstaller"; Flags: nowait postinstall skipifsilent

7
Installer/unison.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.3.1.0</version>
<url>https://github.com/ZetaKebab/unison/releases/download/v1.3.1/unison-v1.3.1.zip</url>
<changelog>https://raw.githubusercontent.com/ZetaKebab/unison/main/CHANGELOG.md</changelog>
<mandatory>false</mandatory>
</item>

View File

@ -6,9 +6,8 @@
* lightweight window that can be toggled with shortcuts
* music control through rebindable shortcuts
* shuffle panel
* [Snapcast](https://mjaggard.github.io/snapcast/) integration
* radio stations
* [Snapcast](https://github.com/badaix/snapcast) integration
* Radio stations
## Features

View File

@ -19,7 +19,7 @@ namespace unison.Resources {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
@ -196,7 +196,7 @@ namespace unison.Resources {
}
/// <summary>
/// Looks up a localized string similar to Please note that since MPD passwords are not secure (they are sent in plain text to the server), there are saved as is in the setting file..
/// Looks up a localized string similar to Please note that since MPD passwords are not secure (they are sent in plain text to the server), they are saved as is in the setting file..
/// </summary>
public static string Settings_ConnectionPasswordInfo {
get {
@ -617,5 +617,68 @@ namespace unison.Resources {
return ResourceManager.GetString("StopSnapcast", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Check for updates.
/// </summary>
public static string Update_ButtonCheck {
get {
return ResourceManager.GetString("Update_ButtonCheck", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Start update.
/// </summary>
public static string Update_ButtonStart {
get {
return ResourceManager.GetString("Update_ButtonStart", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Update available! New version is.
/// </summary>
public static string Update_Message1 {
get {
return ResourceManager.GetString("Update_Message1", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Install now?.
/// </summary>
public static string Update_Message2 {
get {
return ResourceManager.GetString("Update_Message2", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No update available..
/// </summary>
public static string Update_NoUpdate {
get {
return ResourceManager.GetString("Update_NoUpdate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to New version.
/// </summary>
public static string Update_String1 {
get {
return ResourceManager.GetString("Update_String1", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to available!.
/// </summary>
public static string Update_String2 {
get {
return ResourceManager.GetString("Update_String2", resourceCulture);
}
}
}
}

View File

@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Exit" xml:space="preserve">
<value>Salir</value>
@ -303,4 +303,25 @@
<data name="StopSnapcast" xml:space="preserve">
<value>Parar Snapcast</value>
</data>
<data name="Update_ButtonCheck" xml:space="preserve">
<value>Buscar actualización</value>
</data>
<data name="Update_ButtonStart" xml:space="preserve">
<value>Actualizar</value>
</data>
<data name="Update_Message1" xml:space="preserve">
<value>¡Actualización disponible! La nueva versión es la</value>
</data>
<data name="Update_Message2" xml:space="preserve">
<value>¿Instalar ahora?</value>
</data>
<data name="Update_NoUpdate" xml:space="preserve">
<value>No actualización disponible.</value>
</data>
<data name="Update_String1" xml:space="preserve">
<value>¡Nueva versión</value>
</data>
<data name="Update_String2" xml:space="preserve">
<value>disponible!</value>
</data>
</root>

View File

@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Exit" xml:space="preserve">
<value>Quitter</value>
@ -298,9 +298,30 @@
<value>Temps d'écoute écoulé :</value>
</data>
<data name="Stats_Uptime" xml:space="preserve">
<value>MPD lancé depuis : </value>
<value>MPD lancé depuis :</value>
</data>
<data name="StopSnapcast" xml:space="preserve">
<value>Stopper Snapcast</value>
</data>
<data name="Update_ButtonCheck" xml:space="preserve">
<value>Vérifier les mises à jour</value>
</data>
<data name="Update_ButtonStart" xml:space="preserve">
<value>Mettre à jour</value>
</data>
<data name="Update_Message1" xml:space="preserve">
<value>Mise à jour disponible ! La nouvelle version est la</value>
</data>
<data name="Update_Message2" xml:space="preserve">
<value>Installer maintenant ?</value>
</data>
<data name="Update_NoUpdate" xml:space="preserve">
<value>Pas de mise à jour disponible.</value>
</data>
<data name="Update_String1" xml:space="preserve">
<value>Nouvelle version</value>
</data>
<data name="Update_String2" xml:space="preserve">
<value>disponible !</value>
</data>
</root>

View File

@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Exit" xml:space="preserve">
<value>Exit</value>
@ -163,7 +163,7 @@
<value>Connection</value>
</data>
<data name="Settings_ConnectionPasswordInfo" xml:space="preserve">
<value>Please note that since MPD passwords are not secure (they are sent in plain text to the server), there are saved as is in the setting file.</value>
<value>Please note that since MPD passwords are not secure (they are sent in plain text to the server), they are saved as is in the setting file.</value>
</data>
<data name="Settings_ConnectionStatus" xml:space="preserve">
<value>Status:</value>
@ -303,4 +303,25 @@
<data name="StopSnapcast" xml:space="preserve">
<value>Stop Snapcast</value>
</data>
<data name="Update_ButtonCheck" xml:space="preserve">
<value>Check for updates</value>
</data>
<data name="Update_ButtonStart" xml:space="preserve">
<value>Start update</value>
</data>
<data name="Update_Message1" xml:space="preserve">
<value>Update available! New version is</value>
</data>
<data name="Update_Message2" xml:space="preserve">
<value>Install now?</value>
</data>
<data name="Update_NoUpdate" xml:space="preserve">
<value>No update available.</value>
</data>
<data name="Update_String1" xml:space="preserve">
<value>New version</value>
</data>
<data name="Update_String2" xml:space="preserve">
<value>available!</value>
</data>
</root>

View File

@ -9,6 +9,7 @@ using System.Windows.Controls.Primitives;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using unison.Handlers;
namespace unison
{
@ -302,6 +303,11 @@ namespace unison
slider.ToolTip = (int)slider.Value;
}
public void UpdateUpdateStatus(string version)
{
_settingsWin.UpdateUpdateStatus(version);
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);

View File

@ -37,7 +37,7 @@
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Button Content="{x:Static properties:Resources.Radio_Search}" Click="Search_Clicked" Padding="5, 2"/>
<Button x:Name="SearchButton" Content="{x:Static properties:Resources.Radio_Search}" Click="Search_Clicked" Padding="5, 2"/>
<Button Content="{x:Static properties:Resources.Radio_Reset}" Click="Reset_Clicked" Margin="10,0,0,0" Padding="5, 2"/>
<TextBlock x:Name="SearchStatus" Margin="15,1,0,0" FontStyle="Italic" />
</StackPanel>

View File

@ -1,7 +1,4 @@
using RadioBrowser;
using RadioBrowser.Models;
using System.Diagnostics;
using System.Linq;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows;
using System;
@ -10,79 +7,36 @@ using System.Windows.Interop;
using System.Windows.Controls;
using System.Windows.Input;
using System.Collections.Generic;
using unison.Handlers;
using RadioBrowser.Models;
namespace unison
{
public class CountryListItem
{
public uint Count { get; set; }
public string Name { get; set; }
public override string ToString()
{
if (Name == "")
return "None";
return $"{Name} ({Count})";
}
}
public class StationListItem
{
public string Name { get; set; }
public string Codec { get; set; }
public string Tags { get; set; }
public int Bitrate { get; set; }
public Uri Url { get; set; }
private string _country;
public string Country
{
get
{
if (_country.Length == 0)
return "🏴‍☠️";
return string.Concat(_country.ToUpper().Select(x => char.ConvertFromUtf32(x + 0x1F1A5))); // return emoji
}
set
{
_country = value;
}
}
}
public partial class Radios : Window
{
private RadioBrowserClient _radioBrowser;
private MPDHandler _mpd;
private bool _connected = true;
RadioHandler _radio;
public bool IsConnected() => _connected;
public bool IsConnected() => _radio.IsConnected();
public Radios()
{
InitializeComponent();
try
{
_radioBrowser = new RadioBrowserClient();
Initialize();
}
catch (Exception e)
{
Debug.WriteLine("Exception while connecting to RadioBrowser: " + e.Message);
return;
}
_connected = true;
Initialize();
}
public async void Initialize()
{
_radio = new RadioHandler();
if (!_radio.IsConnected())
SearchButton.IsEnabled = false;
try
{
List<NameAndCount> Countries = await _radioBrowser.Lists.GetCountriesAsync();
CountryList.Items.Add(new CountryListItem { Name = "", Count = 0 });
List<NameAndCount> Countries = await _radio.GetCountries();
foreach (NameAndCount Country in Countries)
{
CountryList.Items.Add(new CountryListItem
@ -94,27 +48,49 @@ namespace unison
}
catch (Exception e)
{
Debug.WriteLine("Exception while getting countries in RadioBrowser: " + e.Message);
Trace.WriteLine("Exception while getting countries in RadioBrowser: " + e.Message);
return;
}
}
private string CleanString(string str)
private static string CleanString(string str)
{
return str.Replace("\r\n", "").Replace("\n", "").Replace("\r", "");
}
private void SearchHandler(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
Search_Clicked(null, null);
}
private async void Search_Clicked(object sender, RoutedEventArgs e)
{
try
{
CountryListItem a = (CountryListItem)CountryList.SelectedItem;
await SearchAdvanced(NameSearch.Text, a?.Name, TagSearch.Text);
}
catch (Exception except)
{
Trace.WriteLine("Error on RadioBrowser search: " + except.Message);
}
}
public async Task SearchAdvanced(string name, string country, string tags)
{
try
{
SearchStatus.Text = unison.Resources.Resources.Radio_Loading;
List<StationInfo> advancedSearch = await _radioBrowser.Search.AdvancedAsync(new AdvancedSearchOptions
List<StationInfo> advancedSearch = await Task.Run(async () =>
{
Name = name,
Country = country,
TagList = tags
return await _radio.AdvancedSearch(new AdvancedSearchOptions
{
Name = name,
Country = country,
TagList = tags
});
});
RadioListGrid.Items.Clear();
@ -140,7 +116,7 @@ namespace unison
}
catch (Exception except)
{
Debug.WriteLine("Error on RadioBrowser search advanced: " + except.Message);
Trace.WriteLine("Error on RadioBrowser search advanced: " + except.Message);
}
}
@ -160,13 +136,13 @@ namespace unison
}
catch (ArgumentOutOfRangeException)
{
Debug.WriteLine("Error: Invalid index.");
Trace.WriteLine("Error: Invalid index.");
return;
}
if (station.Url == null)
{
Debug.WriteLine("Error: Invalid station.");
Trace.WriteLine("Error: Invalid station.");
return;
}
@ -174,19 +150,6 @@ namespace unison
_mpd.ClearAddAndPlay(station.Url.AbsoluteUri);
}
private async void Search_Clicked(object sender, RoutedEventArgs e)
{
try
{
CountryListItem a = (CountryListItem)CountryList.SelectedItem;
await SearchAdvanced(NameSearch.Text, a?.Name, TagSearch.Text);
}
catch (Exception except)
{
Debug.WriteLine("Error on RadioBrowser search: " + except.Message);
}
}
private void Reset_Clicked(object sender, RoutedEventArgs e)
{
NameSearch.Text = "";
@ -194,12 +157,6 @@ namespace unison
CountryList.SelectedIndex = 0;
}
private void SearchHandler(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
Search_Clicked(null, null);
}
private void Window_Closing(object sender, CancelEventArgs e)
{
e.Cancel = true;

View File

@ -256,16 +256,24 @@
</GroupBox.Header>
<Grid VerticalAlignment="Top">
<StackPanel Orientation="Vertical">
<TextBlock TextWrapping="Wrap" Margin="0,0,0,10" VerticalAlignment="Top">
<TextBlock TextWrapping="Wrap" VerticalAlignment="Top">
<Run Text="{x:Static properties:Resources.Settings_Version}"/>
<Run Text="{Binding GetVersion, Mode = OneWay}"/>
</TextBlock>
<TextBlock x:Name="UpdateText" TextWrapping="Wrap" VerticalAlignment="Top">
<Run x:Name="UpdateText2" Text="New version X.X.X available!" FontWeight="Bold"/>
</TextBlock>
<Button x:Name="UpdateButton" Content="{x:Static properties:Resources.Update_ButtonCheck}" Margin="0,3,0,10" Width="150" Click="CheckUpdates" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" VerticalAlignment="Top">
<Run Text="{x:Static properties:Resources.Settings_AboutInfo}" /><LineBreak/>
※ <Hyperlink NavigateUri="https://github.com/Difegue/MpcNET" RequestNavigate="Hyperlink_RequestNavigate">MpcNET</Hyperlink><LineBreak/>
※ <Hyperlink NavigateUri="https://github.com/hardcodet/wpf-notifyicon" RequestNavigate="Hyperlink_RequestNavigate">wpf-notifyicon</Hyperlink><LineBreak/>
※ <Hyperlink NavigateUri="https://github.com/samhocevar/emoji.wpf" RequestNavigate="Hyperlink_RequestNavigate">Emoji.WPF</Hyperlink><LineBreak/>
※ <Hyperlink NavigateUri="https://github.com/tof4/RadioBrowser" RequestNavigate="Hyperlink_RequestNavigate">RadioBrowser</Hyperlink>
※ <Hyperlink NavigateUri="https://github.com/tof4/RadioBrowser" RequestNavigate="Hyperlink_RequestNavigate">RadioBrowser</Hyperlink><LineBreak/>
※ <Hyperlink NavigateUri="https://github.com/ravibpatel/AutoUpdater.NET" RequestNavigate="Hyperlink_RequestNavigate">AutoUpdater.NET</Hyperlink><LineBreak/>
※ <Hyperlink NavigateUri="https://github.com/badaix/snapcast" RequestNavigate="Hyperlink_RequestNavigate">Snapcast</Hyperlink>
</TextBlock>
<TextBlock Margin="0,10,0,0">
<Run Text="{x:Static properties:Resources.Settings_SourceCode1}" />
@ -282,7 +290,11 @@
</StackPanel>
</Grid>
</GroupBox>
</DockPanel>
</TabItem>
<TabItem Header="{x:Static properties:Resources.Settings_License}" Height="20" VerticalAlignment="Bottom">
<DockPanel Margin="8">
<GroupBox DockPanel.Dock="Top" Padding="0,4,0,0" Margin="0,10,0,0">
<GroupBox.Header>
<TextBlock>

View File

@ -5,11 +5,13 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Navigation;
using unison.Handlers;
namespace unison
{
@ -60,6 +62,8 @@ namespace unison
SnapcastPort.Text = Properties.Settings.Default.snapcast_port.ToString();
VolumeOffset.Text = Properties.Settings.Default.volume_offset.ToString();
UpdateText.Visibility = Visibility.Collapsed;
InitializeShortcuts();
}
@ -115,7 +119,7 @@ namespace unison
ConnectionStatus.Text = unison.Resources.Resources.Settings_ConnectionStatusConnecting;
MPDHandler mpd = (MPDHandler)Application.Current.Properties["mpd"];
System.Threading.Tasks.Task.Run(async () => { await mpd.Initialize(); });
Task.Run(async () => { await mpd.Initialize(); });
}
private void SnapcastReset_Clicked(object sender, RoutedEventArgs e)
@ -142,6 +146,19 @@ namespace unison
MPDConnect_Clicked(null, null);
}
private void CheckUpdates(object sender, RoutedEventArgs e)
{
UpdateHandler updater = (UpdateHandler)Application.Current.Properties["updater"];
updater.Start(true);
}
public void UpdateUpdateStatus(string version)
{
UpdateText.Visibility = Visibility.Visible;
UpdateText2.Text = unison.Resources.Resources.Update_String1 + " " + version + " " + unison.Resources.Resources.Update_String2;
UpdateButton.Content = unison.Resources.Resources.Update_ButtonStart;
}
private void Window_Closing(object sender, CancelEventArgs e)
{
e.Cancel = true;
@ -373,12 +390,12 @@ namespace unison
InitializeShortcuts();
}
public uint GetMod(StackPanel stackPanel)
private uint GetMod(StackPanel stackPanel)
{
return (uint)(GetMOD(stackPanel.Children.OfType<ComboBox>().First().SelectedItem.ToString()) | GetMOD(stackPanel.Children.OfType<ComboBox>().Last().SelectedItem.ToString()));
}
public uint GetVk(StackPanel stackPanel)
private uint GetVk(StackPanel stackPanel)
{
Button button = stackPanel.Children.OfType<Button>().First();
TextBlock textBlock = (TextBlock)button.Content;

View File

@ -52,6 +52,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autoupdater.NET.Official" Version="1.7.6" />
<PackageReference Include="Emoji.Wpf" Version="0.3.3" />
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
<PackageReference Include="RadioBrowser" Version="0.6.1" />