Database update feature
This commit is contained in:
parent
8c9e1cd91c
commit
7d71d90538
@ -15,11 +15,12 @@ namespace unison
|
|||||||
|
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
{
|
{
|
||||||
|
unison.Resources.Resources.Culture = System.Globalization.CultureInfo.CurrentCulture;
|
||||||
|
|
||||||
//debug language
|
//debug language
|
||||||
//unison.Resources.Resources.Culture = System.Globalization.CultureInfo.GetCultureInfo("fr-FR");
|
//unison.Resources.Resources.Culture = System.Globalization.CultureInfo.GetCultureInfo("fr-FR");
|
||||||
//unison.Resources.Resources.Culture = System.Globalization.CultureInfo.GetCultureInfo("es-ES");
|
//unison.Resources.Resources.Culture = System.Globalization.CultureInfo.GetCultureInfo("es-ES");
|
||||||
|
|
||||||
|
|
||||||
base.OnStartup(e);
|
base.OnStartup(e);
|
||||||
|
|
||||||
_mpd = new MPDHandler();
|
_mpd = new MPDHandler();
|
||||||
|
@ -334,16 +334,21 @@ namespace unison
|
|||||||
}, token).ConfigureAwait(false);
|
}, token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool UpdateStarted = false;
|
||||||
|
|
||||||
private async Task HandleIdleResponseAsync(string subsystems)
|
private async Task HandleIdleResponseAsync(string subsystems)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (subsystems.Contains("player") || subsystems.Contains("mixer") || subsystems.Contains("output") || subsystems.Contains("options"))
|
if (subsystems.Contains("player") || subsystems.Contains("mixer") || subsystems.Contains("output") || subsystems.Contains("options") || subsystems.Contains("update"))
|
||||||
{
|
{
|
||||||
await UpdateStatusAsync();
|
await UpdateStatusAsync();
|
||||||
|
|
||||||
if (subsystems.Contains("player"))
|
if (subsystems.Contains("player"))
|
||||||
await UpdateSongAsync();
|
await UpdateSongAsync();
|
||||||
|
|
||||||
|
if (subsystems.Contains("update"))
|
||||||
|
UpdateDatabaseSync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -353,6 +358,30 @@ namespace unison
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateDatabaseSync()
|
||||||
|
{
|
||||||
|
if (!UpdateStarted)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
MainWindow MainWin = (MainWindow)Application.Current.MainWindow;
|
||||||
|
MainWin.GetSettings().MPDDatabaseUpdate_Start();
|
||||||
|
});
|
||||||
|
|
||||||
|
UpdateStarted = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
MainWindow MainWin = (MainWindow)Application.Current.MainWindow;
|
||||||
|
MainWin.GetSettings().MPDDatabaseUpdate_Stop();
|
||||||
|
MainWin.UpdateStats();
|
||||||
|
});
|
||||||
|
UpdateStarted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task UpdateStatusAsync()
|
private async Task UpdateStatusAsync()
|
||||||
{
|
{
|
||||||
if (_connection == null || _isUpdatingStatus)
|
if (_connection == null || _isUpdatingStatus)
|
||||||
@ -611,6 +640,8 @@ namespace unison
|
|||||||
return _Playlist.ToArray().Count();
|
return _Playlist.ToArray().Count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateDB() => SendCommand(new UpdateCommand());
|
||||||
|
|
||||||
private string FormatTime(TimeSpan time)
|
private string FormatTime(TimeSpan time)
|
||||||
{
|
{
|
||||||
string FormattedTime = "";
|
string FormattedTime = "";
|
||||||
|
45
Resources/Resources.Designer.cs
generated
45
Resources/Resources.Designer.cs
generated
@ -60,6 +60,15 @@ namespace unison.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Database.
|
||||||
|
/// </summary>
|
||||||
|
public static string Database {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Database", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to day.
|
/// Looks up a localized string similar to day.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -636,6 +645,15 @@ namespace unison.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Update database.
|
||||||
|
/// </summary>
|
||||||
|
public static string Settings_UpdateDatabase {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Settings_UpdateDatabase", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Version:.
|
/// Looks up a localized string similar to Version:.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -861,15 +879,6 @@ namespace unison.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Stats.
|
|
||||||
/// </summary>
|
|
||||||
public static string Stats {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("Stats", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Albums:.
|
/// Looks up a localized string similar to Albums:.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -924,6 +933,24 @@ namespace unison.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Updating database....
|
||||||
|
/// </summary>
|
||||||
|
public static string Stats_UpdateDBMessage1 {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Stats_UpdateDBMessage1", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to done!.
|
||||||
|
/// </summary>
|
||||||
|
public static string Stats_UpdateDBMessage2 {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Stats_UpdateDBMessage2", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to MPD uptime:.
|
/// Looks up a localized string similar to MPD uptime:.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -117,6 +117,9 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.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>
|
</resheader>
|
||||||
|
<data name="Database" xml:space="preserve">
|
||||||
|
<value>Base de datos</value>
|
||||||
|
</data>
|
||||||
<data name="Day" xml:space="preserve">
|
<data name="Day" xml:space="preserve">
|
||||||
<value>día</value>
|
<value>día</value>
|
||||||
</data>
|
</data>
|
||||||
@ -309,6 +312,9 @@
|
|||||||
<data name="Settings_SourceCode2" xml:space="preserve">
|
<data name="Settings_SourceCode2" xml:space="preserve">
|
||||||
<value>aquí</value>
|
<value>aquí</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Settings_UpdateDatabase" xml:space="preserve">
|
||||||
|
<value>Actualizar base de datos</value>
|
||||||
|
</data>
|
||||||
<data name="Settings_Version" xml:space="preserve">
|
<data name="Settings_Version" xml:space="preserve">
|
||||||
<value>Versión:</value>
|
<value>Versión:</value>
|
||||||
</data>
|
</data>
|
||||||
@ -384,9 +390,6 @@
|
|||||||
<data name="StartSnapcast" xml:space="preserve">
|
<data name="StartSnapcast" xml:space="preserve">
|
||||||
<value>Iniciar Snapcast</value>
|
<value>Iniciar Snapcast</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Stats" xml:space="preserve">
|
|
||||||
<value>Estadísticas</value>
|
|
||||||
</data>
|
|
||||||
<data name="Stats_Albums" xml:space="preserve">
|
<data name="Stats_Albums" xml:space="preserve">
|
||||||
<value>Álbumes:</value>
|
<value>Álbumes:</value>
|
||||||
</data>
|
</data>
|
||||||
@ -405,6 +408,12 @@
|
|||||||
<data name="Stats_TotalTimePlayed" xml:space="preserve">
|
<data name="Stats_TotalTimePlayed" xml:space="preserve">
|
||||||
<value>Tiempo total jugado:</value>
|
<value>Tiempo total jugado:</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Stats_UpdateDBMessage1" xml:space="preserve">
|
||||||
|
<value>Actualizando base de datos...</value>
|
||||||
|
</data>
|
||||||
|
<data name="Stats_UpdateDBMessage2" xml:space="preserve">
|
||||||
|
<value> ¡terminado!</value>
|
||||||
|
</data>
|
||||||
<data name="Stats_Uptime" xml:space="preserve">
|
<data name="Stats_Uptime" xml:space="preserve">
|
||||||
<value>Tiempo de actividad de MPD:</value>
|
<value>Tiempo de actividad de MPD:</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -117,6 +117,9 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.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>
|
</resheader>
|
||||||
|
<data name="Database" xml:space="preserve">
|
||||||
|
<value>Base de donnée</value>
|
||||||
|
</data>
|
||||||
<data name="Day" xml:space="preserve">
|
<data name="Day" xml:space="preserve">
|
||||||
<value>jour</value>
|
<value>jour</value>
|
||||||
</data>
|
</data>
|
||||||
@ -309,6 +312,9 @@
|
|||||||
<data name="Settings_SourceCode2" xml:space="preserve">
|
<data name="Settings_SourceCode2" xml:space="preserve">
|
||||||
<value>ici</value>
|
<value>ici</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Settings_UpdateDatabase" xml:space="preserve">
|
||||||
|
<value>Mettre à jour la base de donnée</value>
|
||||||
|
</data>
|
||||||
<data name="Settings_Version" xml:space="preserve">
|
<data name="Settings_Version" xml:space="preserve">
|
||||||
<value>Version :</value>
|
<value>Version :</value>
|
||||||
</data>
|
</data>
|
||||||
@ -384,9 +390,6 @@
|
|||||||
<data name="StartSnapcast" xml:space="preserve">
|
<data name="StartSnapcast" xml:space="preserve">
|
||||||
<value>Démarrer Snapcast</value>
|
<value>Démarrer Snapcast</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Stats" xml:space="preserve">
|
|
||||||
<value>Stats</value>
|
|
||||||
</data>
|
|
||||||
<data name="Stats_Albums" xml:space="preserve">
|
<data name="Stats_Albums" xml:space="preserve">
|
||||||
<value>Albums :</value>
|
<value>Albums :</value>
|
||||||
</data>
|
</data>
|
||||||
@ -405,6 +408,12 @@
|
|||||||
<data name="Stats_TotalTimePlayed" xml:space="preserve">
|
<data name="Stats_TotalTimePlayed" xml:space="preserve">
|
||||||
<value>Temps d'écoute écoulé :</value>
|
<value>Temps d'écoute écoulé :</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Stats_UpdateDBMessage1" xml:space="preserve">
|
||||||
|
<value>Mise à jour de la base de donnée...</value>
|
||||||
|
</data>
|
||||||
|
<data name="Stats_UpdateDBMessage2" xml:space="preserve">
|
||||||
|
<value> fini !</value>
|
||||||
|
</data>
|
||||||
<data name="Stats_Uptime" xml:space="preserve">
|
<data name="Stats_Uptime" xml:space="preserve">
|
||||||
<value>MPD lancé depuis :</value>
|
<value>MPD lancé depuis :</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -117,6 +117,9 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.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>
|
</resheader>
|
||||||
|
<data name="Database" xml:space="preserve">
|
||||||
|
<value>Database</value>
|
||||||
|
</data>
|
||||||
<data name="Day" xml:space="preserve">
|
<data name="Day" xml:space="preserve">
|
||||||
<value>day</value>
|
<value>day</value>
|
||||||
</data>
|
</data>
|
||||||
@ -309,6 +312,9 @@
|
|||||||
<data name="Settings_SourceCode2" xml:space="preserve">
|
<data name="Settings_SourceCode2" xml:space="preserve">
|
||||||
<value>here</value>
|
<value>here</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Settings_UpdateDatabase" xml:space="preserve">
|
||||||
|
<value>Update database</value>
|
||||||
|
</data>
|
||||||
<data name="Settings_Version" xml:space="preserve">
|
<data name="Settings_Version" xml:space="preserve">
|
||||||
<value>Version:</value>
|
<value>Version:</value>
|
||||||
</data>
|
</data>
|
||||||
@ -384,9 +390,6 @@
|
|||||||
<data name="StartSnapcast" xml:space="preserve">
|
<data name="StartSnapcast" xml:space="preserve">
|
||||||
<value>Start Snapcast</value>
|
<value>Start Snapcast</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Stats" xml:space="preserve">
|
|
||||||
<value>Stats</value>
|
|
||||||
</data>
|
|
||||||
<data name="Stats_Albums" xml:space="preserve">
|
<data name="Stats_Albums" xml:space="preserve">
|
||||||
<value>Albums:</value>
|
<value>Albums:</value>
|
||||||
</data>
|
</data>
|
||||||
@ -405,6 +408,12 @@
|
|||||||
<data name="Stats_TotalTimePlayed" xml:space="preserve">
|
<data name="Stats_TotalTimePlayed" xml:space="preserve">
|
||||||
<value>Total time played:</value>
|
<value>Total time played:</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Stats_UpdateDBMessage1" xml:space="preserve">
|
||||||
|
<value>Updating database...</value>
|
||||||
|
</data>
|
||||||
|
<data name="Stats_UpdateDBMessage2" xml:space="preserve">
|
||||||
|
<value> done!</value>
|
||||||
|
</data>
|
||||||
<data name="Stats_Uptime" xml:space="preserve">
|
<data name="Stats_Uptime" xml:space="preserve">
|
||||||
<value>MPD uptime:</value>
|
<value>MPD uptime:</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -7,6 +7,7 @@ using System.Windows.Interop;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Data;
|
||||||
|
|
||||||
namespace unison
|
namespace unison
|
||||||
{
|
{
|
||||||
@ -18,6 +19,8 @@ namespace unison
|
|||||||
private readonly DispatcherTimer _timer;
|
private readonly DispatcherTimer _timer;
|
||||||
private readonly MPDHandler _mpd;
|
private readonly MPDHandler _mpd;
|
||||||
|
|
||||||
|
public Settings GetSettings() => _settingsWin;
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitHwnd();
|
InitHwnd();
|
||||||
@ -45,12 +48,17 @@ namespace unison
|
|||||||
TimeSlider.Value = _mpd.GetCurrentTime() / _mpd.GetCurrentSong().Time * 100;
|
TimeSlider.Value = _mpd.GetCurrentTime() / _mpd.GetCurrentSong().Time * 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateStats()
|
||||||
|
{
|
||||||
|
_mpd.QueryStats();
|
||||||
|
_settingsWin.UpdateStats();
|
||||||
|
}
|
||||||
|
|
||||||
public void OnConnectionChanged(object sender, EventArgs e)
|
public void OnConnectionChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mpd.IsConnected())
|
if (_mpd.IsConnected())
|
||||||
{
|
{
|
||||||
_mpd.QueryStats();
|
UpdateStats();
|
||||||
_settingsWin.UpdateStats();
|
|
||||||
|
|
||||||
ConnectionOkIcon.Visibility = Visibility.Visible;
|
ConnectionOkIcon.Visibility = Visibility.Visible;
|
||||||
ConnectionFailIcon.Visibility = Visibility.Collapsed;
|
ConnectionFailIcon.Visibility = Visibility.Collapsed;
|
||||||
|
@ -188,7 +188,7 @@
|
|||||||
<TextBlock TextWrapping="Wrap" Margin="5,5,0,0" TextAlignment="Left" Width="390">
|
<TextBlock TextWrapping="Wrap" Margin="5,5,0,0" TextAlignment="Left" Width="390">
|
||||||
<Run Text="{x:Static properties:Resources.Settings_SnapcastInfo1}" /><Run Text="{x:Static properties:Resources.Settings_SnapcastInfo2}" FontStyle="Italic" FontWeight="DemiBold" /><Run Text="{x:Static properties:Resources.Settings_SnapcastInfo3}" />
|
<Run Text="{x:Static properties:Resources.Settings_SnapcastInfo1}" /><Run Text="{x:Static properties:Resources.Settings_SnapcastInfo2}" FontStyle="Italic" FontWeight="DemiBold" /><Run Text="{x:Static properties:Resources.Settings_SnapcastInfo3}" />
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<Button Content="{x:Static properties:Resources.Settings_SnapcastResetButton}" Margin="0,10,0,0" Width="120" Click="SnapcastReset_Clicked"/>
|
<Button Content="{x:Static properties:Resources.Settings_SnapcastResetButton}" Width="120" Click="SnapcastReset_Clicked" Margin="0,5,0,0" BorderThickness="1,1,1,1"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -225,15 +225,17 @@
|
|||||||
</DockPanel>
|
</DockPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
<TabItem Header="{x:Static properties:Resources.Stats}">
|
<TabItem Header="{x:Static properties:Resources.Database}">
|
||||||
<DockPanel Margin="8">
|
<DockPanel Margin="8">
|
||||||
<GroupBox DockPanel.Dock="Top" Padding="0,4,0,0">
|
<GroupBox DockPanel.Dock="Top" Padding="0,4,0,0">
|
||||||
<GroupBox.Header>
|
<GroupBox.Header>
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
<emoji:EmojiInline Text="📊"/>
|
<emoji:EmojiInline Text="📊"/>
|
||||||
<Run Text="{x:Static properties:Resources.Stats}"/>
|
<Run Text="{x:Static properties:Resources.Database}"/>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</GroupBox.Header>
|
</GroupBox.Header>
|
||||||
|
<StackPanel>
|
||||||
|
|
||||||
<Grid VerticalAlignment="Top">
|
<Grid VerticalAlignment="Top">
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
<Run Text="{x:Static properties:Resources.Stats_Songs}"/><Run Text=" "/><Run x:Name="StatSong"/><LineBreak/>
|
<Run Text="{x:Static properties:Resources.Stats_Songs}"/><Run Text=" "/><Run x:Name="StatSong"/><LineBreak/>
|
||||||
@ -245,6 +247,16 @@
|
|||||||
<Run Text="{x:Static properties:Resources.Stats_LastDatabaseUpdate}"/><Run Text=" "/><Run x:Name="StatDatabaseUpdate"/>
|
<Run Text="{x:Static properties:Resources.Stats_LastDatabaseUpdate}"/><Run Text=" "/><Run x:Name="StatDatabaseUpdate"/>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||||
|
<Button x:Name="UpdateDatabaseButton" Content="{x:Static properties:Resources.Settings_UpdateDatabase}" Click="MPDDatabaseUpdate_Clicked" MinWidth="120" Padding="3,1,3,1" FocusVisualStyle="{x:Null}"/>
|
||||||
|
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock x:Name="UpdateDBMessage" Text="{x:Static properties:Resources.Stats_UpdateDBMessage1}" Margin="15,3,0,0" FontStyle="Italic" Visibility="Collapsed" />
|
||||||
|
<TextBlock x:Name="UpdateDBMessage2" Text="{x:Static properties:Resources.Stats_UpdateDBMessage2}" Margin="0,3,0,0" FontStyle="Italic" Visibility="Collapsed" />
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -11,6 +12,7 @@ using System.Windows.Controls;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Threading;
|
||||||
using unison.Handlers;
|
using unison.Handlers;
|
||||||
|
|
||||||
namespace unison
|
namespace unison
|
||||||
@ -37,8 +39,7 @@ namespace unison
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HotkeyHandler _hotkeys = (HotkeyHandler)Application.Current.Properties["hotkeys"];
|
readonly HotkeyHandler _hotkeys = (HotkeyHandler)Application.Current.Properties["hotkeys"];
|
||||||
|
|
||||||
|
|
||||||
public Settings()
|
public Settings()
|
||||||
{
|
{
|
||||||
@ -74,11 +75,13 @@ namespace unison
|
|||||||
{
|
{
|
||||||
ConnectionStatus.Text = $"{unison.Resources.Resources.Settings_ConnectionStatusConnected} {mpd.GetVersion()}.";
|
ConnectionStatus.Text = $"{unison.Resources.Resources.Settings_ConnectionStatusConnected} {mpd.GetVersion()}.";
|
||||||
ConnectButton.IsEnabled = false;
|
ConnectButton.IsEnabled = false;
|
||||||
|
UpdateDatabaseButton.IsEnabled = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ConnectionStatus.Text = unison.Resources.Resources.Settings_ConnectionStatusOffline;
|
ConnectionStatus.Text = unison.Resources.Resources.Settings_ConnectionStatusOffline;
|
||||||
ConnectButton.IsEnabled = true;
|
ConnectButton.IsEnabled = true;
|
||||||
|
UpdateDatabaseButton.IsEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +149,37 @@ namespace unison
|
|||||||
MPDConnect_Clicked(null, null);
|
MPDConnect_Clicked(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MPDDatabaseUpdate_Clicked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
MPDHandler mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||||
|
if (mpd.IsConnected())
|
||||||
|
mpd.UpdateDB();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void TimedText(TextBlock textBlock, int time)
|
||||||
|
{
|
||||||
|
DispatcherTimer Timer = new DispatcherTimer();
|
||||||
|
Timer.Interval = TimeSpan.FromSeconds(time);
|
||||||
|
Timer.Tick += (sender, args) =>
|
||||||
|
{
|
||||||
|
Timer.Stop();
|
||||||
|
textBlock.Visibility = Visibility.Collapsed;
|
||||||
|
};
|
||||||
|
Timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MPDDatabaseUpdate_Start()
|
||||||
|
{
|
||||||
|
UpdateDBMessage.Visibility = Visibility.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MPDDatabaseUpdate_Stop()
|
||||||
|
{
|
||||||
|
UpdateDBMessage2.Visibility = Visibility.Visible;
|
||||||
|
TimedText(UpdateDBMessage, 2);
|
||||||
|
TimedText(UpdateDBMessage2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckUpdates(object sender, RoutedEventArgs e)
|
private void CheckUpdates(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
UpdateHandler updater = (UpdateHandler)Application.Current.Properties["updater"];
|
UpdateHandler updater = (UpdateHandler)Application.Current.Properties["updater"];
|
||||||
|
Loading…
Reference in New Issue
Block a user