Code styling

This commit is contained in:
Théo Marchal 2022-11-17 23:41:03 +01:00
parent e80f06d8bf
commit 38a7856a0f
9 changed files with 39 additions and 39 deletions

View File

@ -49,12 +49,12 @@ namespace unison
private MpdStatus _currentStatus; private MpdStatus _currentStatus;
private IMpdFile _currentSong; private IMpdFile _currentSong;
private BitmapImage _cover; private BitmapImage _cover;
public Statistics _stats; private readonly Statistics _stats;
private readonly System.Timers.Timer _elapsedTimer; private readonly System.Timers.Timer _elapsedTimer;
private DispatcherTimer _retryTimer; private readonly DispatcherTimer _retryTimer;
bool _isUpdatingStatus = false; private bool _isUpdatingStatus = false;
bool _isUpdatingSong = false; private bool _isUpdatingSong = false;
public IPAddress _ipAddress; public IPAddress _ipAddress;
@ -70,6 +70,8 @@ namespace unison
public CancellationTokenSource _cancelCommand; public CancellationTokenSource _cancelCommand;
private CancellationTokenSource _cancelConnect; private CancellationTokenSource _cancelConnect;
private bool UpdateStarted = false;
public MPDHandler() public MPDHandler()
{ {
Startup(null, null); Startup(null, null);
@ -154,7 +156,7 @@ namespace unison
if (_commandConnection == null || !IsConnected()) if (_commandConnection == null || !IsConnected())
{ {
Trace.WriteLine("[SafelySendCommandAsync] no command connection"); Trace.WriteLine("[SafelySendCommandAsync] no command connection");
return default(T); return default;
} }
try try
@ -176,7 +178,7 @@ namespace unison
Trace.WriteLine($"Sending {command.GetType().Name} failed: {e.Message}"); Trace.WriteLine($"Sending {command.GetType().Name} failed: {e.Message}");
} }
return default(T); return default;
} }
public async void Startup(object sender, EventArgs e) public async void Startup(object sender, EventArgs e)
@ -334,8 +336,6 @@ 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
@ -637,12 +637,12 @@ namespace unison
{ {
if (_Playlist == null) if (_Playlist == null)
return 0; return 0;
return _Playlist.ToArray().Count(); return _Playlist.ToArray().Length;
} }
public void UpdateDB() => SendCommand(new UpdateCommand()); public void UpdateDB() => SendCommand(new UpdateCommand());
private string FormatTime(TimeSpan time) private static string FormatTime(TimeSpan time)
{ {
string FormattedTime = ""; string FormattedTime = "";

View File

@ -17,8 +17,8 @@ namespace unison
class ShuffleHandler class ShuffleHandler
{ {
private readonly MPDHandler _mpd; private readonly MPDHandler _mpd;
public int AddedSongs = 0;
public int AddedSongs = 0;
public List<string> SongList { get; } public List<string> SongList { get; }
public ShuffleHandler() public ShuffleHandler()

View File

@ -8,6 +8,7 @@ namespace unison
public class SnapcastHandler public class SnapcastHandler
{ {
private readonly Process _snapcast = new(); private readonly Process _snapcast = new();
public bool HasStarted { get; private set; } public bool HasStarted { get; private set; }
public void OnConnectionChanged(object sender, EventArgs e) public void OnConnectionChanged(object sender, EventArgs e)
@ -30,7 +31,7 @@ namespace unison
}); });
} }
public void UpdateInterface() public static void UpdateInterface()
{ {
TaskbarIcon Systray = (TaskbarIcon)Application.Current.Properties["systray"]; TaskbarIcon Systray = (TaskbarIcon)Application.Current.Properties["systray"];
SystrayViewModel DataContext = Systray.DataContext as SystrayViewModel; SystrayViewModel DataContext = Systray.DataContext as SystrayViewModel;

View File

@ -1,5 +1,4 @@
using System.Diagnostics; using System.Windows;
using System.Windows;
using AutoUpdaterDotNET; using AutoUpdaterDotNET;
namespace unison.Handlers namespace unison.Handlers
@ -9,10 +8,10 @@ namespace unison.Handlers
readonly string xmlFile = "https://raw.githubusercontent.com/ZetaKebab/unison/main/Installer/unison.xml"; readonly string xmlFile = "https://raw.githubusercontent.com/ZetaKebab/unison/main/Installer/unison.xml";
private bool _UpdateAvailable = false; private bool _UpdateAvailable = false;
public bool UpdateAvailable() => _UpdateAvailable;
private bool _RequestedCheck = false; private bool _RequestedCheck = false;
public bool UpdateAvailable() => _UpdateAvailable;
public UpdateHandler() public UpdateHandler()
{ {
AutoUpdater.CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent; AutoUpdater.CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent;
@ -25,7 +24,7 @@ namespace unison.Handlers
AutoUpdater.Start(xmlFile); AutoUpdater.Start(xmlFile);
} }
private string CutVersionNumber(string number) private static string CutVersionNumber(string number)
{ {
return number.Substring(0, number.LastIndexOf(".")); return number.Substring(0, number.LastIndexOf("."));
} }

View File

@ -224,12 +224,12 @@ namespace unison
border.Style = b ? (Style)Resources["SelectedButton"] : (Style)Resources["UnselectedButton"]; border.Style = b ? (Style)Resources["SelectedButton"] : (Style)Resources["UnselectedButton"];
} }
public string FormatSeconds(int time) public static string FormatSeconds(int time)
{ {
TimeSpan timespan = TimeSpan.FromSeconds(time); TimeSpan timespan = TimeSpan.FromSeconds(time);
return timespan.ToString(@"mm\:ss"); return timespan.ToString(@"mm\:ss");
} }
public string FormatSeconds(double time) public static string FormatSeconds(double time)
{ {
TimeSpan timespan = TimeSpan.FromSeconds(time); TimeSpan timespan = TimeSpan.FromSeconds(time);
return timespan.ToString(@"mm\:ss"); return timespan.ToString(@"mm\:ss");
@ -244,7 +244,7 @@ namespace unison
public void Consume_Clicked(object sender, RoutedEventArgs e) => _mpd.Consume(); public void Consume_Clicked(object sender, RoutedEventArgs e) => _mpd.Consume();
public void ChangeVolume(int value) => _mpd.SetVolume(value); public void ChangeVolume(int value) => _mpd.SetVolume(value);
public void Snapcast_Clicked(object sender, RoutedEventArgs e) public static void Snapcast_Clicked(object sender, RoutedEventArgs e)
{ {
SnapcastHandler snapcast = (SnapcastHandler)Application.Current.Properties["snapcast"]; SnapcastHandler snapcast = (SnapcastHandler)Application.Current.Properties["snapcast"];
snapcast.LaunchOrExit(); snapcast.LaunchOrExit();

View File

@ -15,7 +15,7 @@ namespace unison
public partial class Radios : Window public partial class Radios : Window
{ {
private MPDHandler _mpd; private MPDHandler _mpd;
RadioHandler _radio; private RadioHandler _radio;
public bool IsConnected() => _radio.IsConnected(); public bool IsConnected() => _radio.IsConnected();

View File

@ -85,7 +85,7 @@ namespace unison
} }
} }
private void NumberValidationTextBox(object sender, TextCompositionEventArgs e) private static void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
{ {
Regex regex = new Regex("[^0-9]+"); Regex regex = new Regex("[^0-9]+");
e.Handled = regex.IsMatch(e.Text); e.Handled = regex.IsMatch(e.Text);
@ -105,7 +105,7 @@ namespace unison
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{ {
ProcessStartInfo psi = new(e.Uri.AbsoluteUri); ProcessStartInfo psi = new ProcessStartInfo(e.Uri.AbsoluteUri);
psi.UseShellExecute = true; psi.UseShellExecute = true;
Process.Start(psi); Process.Start(psi);
e.Handled = true; e.Handled = true;
@ -149,7 +149,7 @@ namespace unison
MPDConnect_Clicked(null, null); MPDConnect_Clicked(null, null);
} }
private void MPDDatabaseUpdate_Clicked(object sender, RoutedEventArgs e) private static void MPDDatabaseUpdate_Clicked(object sender, RoutedEventArgs e)
{ {
MPDHandler mpd = (MPDHandler)Application.Current.Properties["mpd"]; MPDHandler mpd = (MPDHandler)Application.Current.Properties["mpd"];
if (mpd.IsConnected()) if (mpd.IsConnected())
@ -180,7 +180,7 @@ namespace unison
TimedText(UpdateDBMessage2, 2); TimedText(UpdateDBMessage2, 2);
} }
private void CheckUpdates(object sender, RoutedEventArgs e) private static void CheckUpdates(object sender, RoutedEventArgs e)
{ {
UpdateHandler updater = (UpdateHandler)Application.Current.Properties["updater"]; UpdateHandler updater = (UpdateHandler)Application.Current.Properties["updater"];
updater.Start(true); updater.Start(true);
@ -382,7 +382,7 @@ namespace unison
HotkeyChanged(); HotkeyChanged();
} }
private HotkeyHandler.VK GetVirtualKey(Key key) private static HotkeyHandler.VK GetVirtualKey(Key key)
{ {
foreach (object value in System.Enum.GetValues(typeof(HotkeyHandler.VK))) foreach (object value in System.Enum.GetValues(typeof(HotkeyHandler.VK)))
{ {
@ -392,7 +392,7 @@ namespace unison
return HotkeyHandler.VK.None; return HotkeyHandler.VK.None;
} }
private HotkeyHandler.MOD GetMOD(string str) private static HotkeyHandler.MOD GetMOD(string str)
{ {
foreach (object value in System.Enum.GetValues(typeof(HotkeyHandler.MOD))) foreach (object value in System.Enum.GetValues(typeof(HotkeyHandler.MOD)))
{ {
@ -424,12 +424,12 @@ namespace unison
InitializeShortcuts(); InitializeShortcuts();
} }
private uint GetMod(StackPanel stackPanel) private static uint GetMod(StackPanel stackPanel)
{ {
return (uint)(GetMOD(stackPanel.Children.OfType<ComboBox>().First().SelectedItem.ToString()) | GetMOD(stackPanel.Children.OfType<ComboBox>().Last().SelectedItem.ToString())); return (uint)(GetMOD(stackPanel.Children.OfType<ComboBox>().First().SelectedItem.ToString()) | GetMOD(stackPanel.Children.OfType<ComboBox>().Last().SelectedItem.ToString()));
} }
private uint GetVk(StackPanel stackPanel) private static uint GetVk(StackPanel stackPanel)
{ {
Button button = stackPanel.Children.OfType<Button>().First(); Button button = stackPanel.Children.OfType<Button>().First();
TextBlock textBlock = (TextBlock)button.Content; TextBlock textBlock = (TextBlock)button.Content;

View File

@ -47,7 +47,7 @@ namespace unison
ListFolder(_mpd._cancelCommand.Token); ListFolder(_mpd._cancelCommand.Token);
} }
public async void ListGenre(CancellationToken token) private async void ListGenre(CancellationToken token)
{ {
if (GenreList.Count != 0) if (GenreList.Count != 0)
return; return;
@ -64,7 +64,7 @@ namespace unison
GenreList.Add(genre); GenreList.Add(genre);
} }
public async void ListFolder(CancellationToken token) private async void ListFolder(CancellationToken token)
{ {
if (FolderList.Count != 0) if (FolderList.Count != 0)
return; return;
@ -83,7 +83,7 @@ namespace unison
private bool IsFilterEmpty() private bool IsFilterEmpty()
{ {
if (Filters.Count() == 0) if (Filters.Count == 0)
return true; return true;
return false; return false;
} }
@ -124,7 +124,7 @@ namespace unison
_shuffle.SongList.Clear(); _shuffle.SongList.Clear();
} }
private ITag FilterEquivalence_Type(string value) private static ITag FilterEquivalence_Type(string value)
{ {
if (value == "Song") if (value == "Song")
return MpdTags.Title; return MpdTags.Title;
@ -139,7 +139,7 @@ namespace unison
return MpdTags.Title; return MpdTags.Title;
} }
private FilterOperator FilterEquivalence_Operator(string value) private static FilterOperator FilterEquivalence_Operator(string value)
{ {
if (value == "contains") if (value == "contains")
return FilterOperator.Contains; return FilterOperator.Contains;
@ -224,7 +224,7 @@ namespace unison
TimedText(QueryFilterText2, 1); TimedText(QueryFilterText2, 1);
} }
private void TimedText(TextBlock textBlock, int time) private static void TimedText(TextBlock textBlock, int time)
{ {
DispatcherTimer Timer = new DispatcherTimer(); DispatcherTimer Timer = new DispatcherTimer();
Timer.Interval = TimeSpan.FromSeconds(time); Timer.Interval = TimeSpan.FromSeconds(time);

View File

@ -32,7 +32,7 @@ namespace unison
CanExecuteFunc = () => true CanExecuteFunc = () => true
}; };
public string SnapcastText public static string SnapcastText
{ {
get get
{ {
@ -59,7 +59,7 @@ namespace unison
} }
} }
public ICommand Radios public static ICommand Radios
{ {
get get
{ {
@ -71,7 +71,7 @@ namespace unison
} }
} }
public ICommand Shuffle public static ICommand Shuffle
{ {
get get
{ {
@ -83,7 +83,7 @@ namespace unison
} }
} }
public ICommand Settings public static ICommand Settings
{ {
get get
{ {