Code styling
This commit is contained in:
parent
e80f06d8bf
commit
38a7856a0f
@ -49,12 +49,12 @@ namespace unison
|
||||
private MpdStatus _currentStatus;
|
||||
private IMpdFile _currentSong;
|
||||
private BitmapImage _cover;
|
||||
public Statistics _stats;
|
||||
private readonly Statistics _stats;
|
||||
private readonly System.Timers.Timer _elapsedTimer;
|
||||
private DispatcherTimer _retryTimer;
|
||||
private readonly DispatcherTimer _retryTimer;
|
||||
|
||||
bool _isUpdatingStatus = false;
|
||||
bool _isUpdatingSong = false;
|
||||
private bool _isUpdatingStatus = false;
|
||||
private bool _isUpdatingSong = false;
|
||||
|
||||
public IPAddress _ipAddress;
|
||||
|
||||
@ -70,6 +70,8 @@ namespace unison
|
||||
public CancellationTokenSource _cancelCommand;
|
||||
private CancellationTokenSource _cancelConnect;
|
||||
|
||||
private bool UpdateStarted = false;
|
||||
|
||||
public MPDHandler()
|
||||
{
|
||||
Startup(null, null);
|
||||
@ -154,7 +156,7 @@ namespace unison
|
||||
if (_commandConnection == null || !IsConnected())
|
||||
{
|
||||
Trace.WriteLine("[SafelySendCommandAsync] no command connection");
|
||||
return default(T);
|
||||
return default;
|
||||
}
|
||||
|
||||
try
|
||||
@ -176,7 +178,7 @@ namespace unison
|
||||
Trace.WriteLine($"Sending {command.GetType().Name} failed: {e.Message}");
|
||||
}
|
||||
|
||||
return default(T);
|
||||
return default;
|
||||
}
|
||||
|
||||
public async void Startup(object sender, EventArgs e)
|
||||
@ -334,8 +336,6 @@ namespace unison
|
||||
}, token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private bool UpdateStarted = false;
|
||||
|
||||
private async Task HandleIdleResponseAsync(string subsystems)
|
||||
{
|
||||
try
|
||||
@ -637,12 +637,12 @@ namespace unison
|
||||
{
|
||||
if (_Playlist == null)
|
||||
return 0;
|
||||
return _Playlist.ToArray().Count();
|
||||
return _Playlist.ToArray().Length;
|
||||
}
|
||||
|
||||
public void UpdateDB() => SendCommand(new UpdateCommand());
|
||||
|
||||
private string FormatTime(TimeSpan time)
|
||||
private static string FormatTime(TimeSpan time)
|
||||
{
|
||||
string FormattedTime = "";
|
||||
|
||||
|
@ -17,8 +17,8 @@ namespace unison
|
||||
class ShuffleHandler
|
||||
{
|
||||
private readonly MPDHandler _mpd;
|
||||
public int AddedSongs = 0;
|
||||
|
||||
public int AddedSongs = 0;
|
||||
public List<string> SongList { get; }
|
||||
|
||||
public ShuffleHandler()
|
||||
|
@ -8,6 +8,7 @@ namespace unison
|
||||
public class SnapcastHandler
|
||||
{
|
||||
private readonly Process _snapcast = new();
|
||||
|
||||
public bool HasStarted { get; private set; }
|
||||
|
||||
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"];
|
||||
SystrayViewModel DataContext = Systray.DataContext as SystrayViewModel;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using AutoUpdaterDotNET;
|
||||
|
||||
namespace unison.Handlers
|
||||
@ -9,10 +8,10 @@ namespace unison.Handlers
|
||||
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 bool UpdateAvailable() => _UpdateAvailable;
|
||||
|
||||
public UpdateHandler()
|
||||
{
|
||||
AutoUpdater.CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent;
|
||||
@ -25,7 +24,7 @@ namespace unison.Handlers
|
||||
AutoUpdater.Start(xmlFile);
|
||||
}
|
||||
|
||||
private string CutVersionNumber(string number)
|
||||
private static string CutVersionNumber(string number)
|
||||
{
|
||||
return number.Substring(0, number.LastIndexOf("."));
|
||||
}
|
||||
|
@ -224,12 +224,12 @@ namespace unison
|
||||
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);
|
||||
return timespan.ToString(@"mm\:ss");
|
||||
}
|
||||
public string FormatSeconds(double time)
|
||||
public static string FormatSeconds(double time)
|
||||
{
|
||||
TimeSpan timespan = TimeSpan.FromSeconds(time);
|
||||
return timespan.ToString(@"mm\:ss");
|
||||
@ -244,7 +244,7 @@ namespace unison
|
||||
public void Consume_Clicked(object sender, RoutedEventArgs e) => _mpd.Consume();
|
||||
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"];
|
||||
snapcast.LaunchOrExit();
|
||||
|
@ -15,7 +15,7 @@ namespace unison
|
||||
public partial class Radios : Window
|
||||
{
|
||||
private MPDHandler _mpd;
|
||||
RadioHandler _radio;
|
||||
private RadioHandler _radio;
|
||||
|
||||
public bool IsConnected() => _radio.IsConnected();
|
||||
|
||||
|
@ -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]+");
|
||||
e.Handled = regex.IsMatch(e.Text);
|
||||
@ -105,7 +105,7 @@ namespace unison
|
||||
|
||||
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
ProcessStartInfo psi = new(e.Uri.AbsoluteUri);
|
||||
ProcessStartInfo psi = new ProcessStartInfo(e.Uri.AbsoluteUri);
|
||||
psi.UseShellExecute = true;
|
||||
Process.Start(psi);
|
||||
e.Handled = true;
|
||||
@ -149,7 +149,7 @@ namespace unison
|
||||
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"];
|
||||
if (mpd.IsConnected())
|
||||
@ -180,7 +180,7 @@ namespace unison
|
||||
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"];
|
||||
updater.Start(true);
|
||||
@ -382,7 +382,7 @@ namespace unison
|
||||
HotkeyChanged();
|
||||
}
|
||||
|
||||
private HotkeyHandler.VK GetVirtualKey(Key key)
|
||||
private static HotkeyHandler.VK GetVirtualKey(Key key)
|
||||
{
|
||||
foreach (object value in System.Enum.GetValues(typeof(HotkeyHandler.VK)))
|
||||
{
|
||||
@ -392,7 +392,7 @@ namespace unison
|
||||
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)))
|
||||
{
|
||||
@ -424,12 +424,12 @@ namespace unison
|
||||
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()));
|
||||
}
|
||||
|
||||
private uint GetVk(StackPanel stackPanel)
|
||||
private static uint GetVk(StackPanel stackPanel)
|
||||
{
|
||||
Button button = stackPanel.Children.OfType<Button>().First();
|
||||
TextBlock textBlock = (TextBlock)button.Content;
|
||||
|
@ -47,7 +47,7 @@ namespace unison
|
||||
ListFolder(_mpd._cancelCommand.Token);
|
||||
}
|
||||
|
||||
public async void ListGenre(CancellationToken token)
|
||||
private async void ListGenre(CancellationToken token)
|
||||
{
|
||||
if (GenreList.Count != 0)
|
||||
return;
|
||||
@ -64,7 +64,7 @@ namespace unison
|
||||
GenreList.Add(genre);
|
||||
}
|
||||
|
||||
public async void ListFolder(CancellationToken token)
|
||||
private async void ListFolder(CancellationToken token)
|
||||
{
|
||||
if (FolderList.Count != 0)
|
||||
return;
|
||||
@ -83,7 +83,7 @@ namespace unison
|
||||
|
||||
private bool IsFilterEmpty()
|
||||
{
|
||||
if (Filters.Count() == 0)
|
||||
if (Filters.Count == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@ -124,7 +124,7 @@ namespace unison
|
||||
_shuffle.SongList.Clear();
|
||||
}
|
||||
|
||||
private ITag FilterEquivalence_Type(string value)
|
||||
private static ITag FilterEquivalence_Type(string value)
|
||||
{
|
||||
if (value == "Song")
|
||||
return MpdTags.Title;
|
||||
@ -139,7 +139,7 @@ namespace unison
|
||||
return MpdTags.Title;
|
||||
}
|
||||
|
||||
private FilterOperator FilterEquivalence_Operator(string value)
|
||||
private static FilterOperator FilterEquivalence_Operator(string value)
|
||||
{
|
||||
if (value == "contains")
|
||||
return FilterOperator.Contains;
|
||||
@ -224,7 +224,7 @@ namespace unison
|
||||
TimedText(QueryFilterText2, 1);
|
||||
}
|
||||
|
||||
private void TimedText(TextBlock textBlock, int time)
|
||||
private static void TimedText(TextBlock textBlock, int time)
|
||||
{
|
||||
DispatcherTimer Timer = new DispatcherTimer();
|
||||
Timer.Interval = TimeSpan.FromSeconds(time);
|
||||
|
@ -32,7 +32,7 @@ namespace unison
|
||||
CanExecuteFunc = () => true
|
||||
};
|
||||
|
||||
public string SnapcastText
|
||||
public static string SnapcastText
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -59,7 +59,7 @@ namespace unison
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand Radios
|
||||
public static ICommand Radios
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -71,7 +71,7 @@ namespace unison
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand Shuffle
|
||||
public static ICommand Shuffle
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -83,7 +83,7 @@ namespace unison
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand Settings
|
||||
public static ICommand Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user