Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aleab committed Sep 2, 2018
1 parent 64279e8 commit aafcd89
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 26 deletions.
6 changes: 3 additions & 3 deletions Toastify/src/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void Main(string[] args)
catch (Exception e)
{
App.EmergencyLog(e);
Debug.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} - {e}\n");
Debug.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} - {e}{Environment.NewLine}");
}

logger.Info($"Architecture: IntPtr = {IntPtr.Size * 8}bit, Is64BitProcess = {Environment.Is64BitProcess}, Is64BitOS = {Environment.Is64BitOperatingSystem}");
Expand All @@ -89,7 +89,7 @@ public static void Main(string[] args)
{
logger.Error("Unhandled exception while preparing to run.", e);
Analytics.TrackException(e);
MessageBox.Show($"Unhandled exception while preparing to run.\n{e.Message}", "Unhandled exception", MessageBoxButton.OK, MessageBoxImage.Error);
MessageBox.Show($"Unhandled exception while preparing to run.{Environment.NewLine}{e.Message}", "Unhandled exception", MessageBoxButton.OK, MessageBoxImage.Error);
}

RunApp();
Expand Down Expand Up @@ -715,7 +715,7 @@ private void Application_DispatcherUnhandledException(object sender, DispatcherU
{
logger.Error("Unhandled exception.", e.Exception);
Analytics.TrackException(e.Exception);
MessageBox.Show($"Unhandled exception.\n{e.Exception.Message}", "Unhandled exception", MessageBoxButton.OK, MessageBoxImage.Error);
MessageBox.Show($"Unhandled exception.{Environment.NewLine}{e.Exception.Message}", "Unhandled exception", MessageBoxButton.OK, MessageBoxImage.Error);
}

private void App_OnStartup(object sender, StartupEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion Toastify/src/Common/ConstraintFailedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Toastify.Common
{
public class ConstraintFailedException : ApplicationException
{
public ConstraintFailedException(Expression constraint) : base($"Constraint failed:\n {constraint}\n")
public ConstraintFailedException(Expression constraint) : base($"Constraint failed:{Environment.NewLine} {constraint}{Environment.NewLine}")
{
}
}
Expand Down
14 changes: 7 additions & 7 deletions Toastify/src/Core/Spotify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private void StartSpotify_WorkerTaskCompleted(object sender, RunWorkerCompletedE
logger.Error("Error while starting Spotify.", applicationStartupException);

string errorMsg = Properties.Resources.ERROR_STARTUP_SPOTIFY;
MessageBox.Show($"{errorMsg}\n{applicationStartupException.Message}", "Toastify", MessageBoxButton.OK, MessageBoxImage.Error);
MessageBox.Show($"{errorMsg}{Environment.NewLine}{applicationStartupException.Message}", "Toastify", MessageBoxButton.OK, MessageBoxImage.Error);

Analytics.TrackException(applicationStartupException, true);
}
Expand All @@ -196,8 +196,8 @@ private void StartSpotify_WorkerTaskCompleted(object sender, RunWorkerCompletedE
string status = $"{webException.Status}";
if (webException.Status == WebExceptionStatus.ProtocolError)
status += $" ({(webException.Response as HttpWebResponse)?.StatusCode}, \"{(webException.Response as HttpWebResponse)?.StatusDescription}\")";
string techDetails = $"Technical details: {webException.Message}\n{webException.HResult}, {status}";
MessageBox.Show($"{errorMsg}\n{techDetails}", "Toastify", MessageBoxButton.OK, MessageBoxImage.Error);
string techDetails = $"Technical details: {webException.Message}{Environment.NewLine}{webException.HResult}, {status}";
MessageBox.Show($"{errorMsg}{Environment.NewLine}{techDetails}", "Toastify", MessageBoxButton.OK, MessageBoxImage.Error);

Analytics.TrackException(webException, true);
}
Expand All @@ -206,8 +206,8 @@ private void StartSpotify_WorkerTaskCompleted(object sender, RunWorkerCompletedE
logger.Error("Unknown error while starting Spotify.", e.Error);

string errorMsg = Properties.Resources.ERROR_UNKNOWN;
string techDetails = $"Technical Details: {e.Error.Message}\n{e.Error.StackTrace}";
MessageBox.Show($"{errorMsg}\n{techDetails}", "Toastify", MessageBoxButton.OK, MessageBoxImage.Error);
string techDetails = $"Technical Details: {e.Error.Message}{Environment.NewLine}{e.Error.StackTrace}";
MessageBox.Show($"{errorMsg}{Environment.NewLine}{techDetails}", "Toastify", MessageBoxButton.OK, MessageBoxImage.Error);

Analytics.TrackException(e.Error, true);
}
Expand All @@ -221,7 +221,7 @@ private void StartSpotify_WorkerTaskCompleted(object sender, RunWorkerCompletedE
App.CallInSTAThread(() =>
{
choice = CustomMessageBox.ShowYesNo(
$"{errorMsg}\nDo you need to set up or change your proxy details?\n\nToastify will terminate regardless of your choice.",
$"{errorMsg}{Environment.NewLine}Do you need to set up or change your proxy details?{Environment.NewLine}{Environment.NewLine}Toastify will terminate regardless of your choice.",
"Toastify",
"Yes", // Yes
"No", // No
Expand Down Expand Up @@ -495,7 +495,7 @@ private void HandleConnectWithSpotifyException(WebException ex, ref bool proxySe
App.CallInSTAThread(() =>
{
choice = CustomMessageBox.ShowYesNoCancel(
$"Invalid proxy settings. {(errorCode != null ? $"Returned error code: {errorCode}" : "")}\nDo you want to retry?",
$"Invalid proxy settings. {(errorCode != null ? $"Returned error code: {errorCode}" : "")}{Environment.NewLine}Do you want to retry?",
"Toastify",
"Retry", // Yes
"Change settings", // No
Expand Down
6 changes: 3 additions & 3 deletions Toastify/src/Model/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ internal static string PrintSettings(int indentLevel = 0)
{
var sb = new StringBuilder();
for (int i = 0; i < indentLevel; ++i)
sb.Append("\t");
sb.Append(" ");
string indent = sb.ToString();

sb.Clear();
Expand All @@ -425,7 +425,7 @@ internal static string PrintSettings(int indentLevel = 0)
{
object current = property.GetValue(Current);
if (property.PropertyType.GetInterfaces().Contains(typeof(ISettingValue)))
sb.Append($"{indent}{property.Name}: {current}\n");
sb.Append($"{indent}{property.Name}: {current}{Environment.NewLine}");
else
{
if (property.PropertyType.GetInterfaces().Contains(typeof(ICollection)))
Expand All @@ -434,7 +434,7 @@ internal static string PrintSettings(int indentLevel = 0)
if (property.PropertyType == typeof(ProxyConfigAdapter))
{
var proxy = (ProxyConfigAdapter)current;
sb.Append($"{indent}{property.Name}: {proxy.ToString(true)}\n");
sb.Append($"{indent}{property.Name}: {proxy.ToString(true)}{Environment.NewLine}");
}
}
}
Expand Down
25 changes: 13 additions & 12 deletions Toastify/src/View/ToastView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public ToastView()
private void Init()
{
if (logger.IsDebugEnabled)
logger.Debug($"Current Settings:\n{Settings.PrintSettings(2)}");
logger.Debug($"Current Settings:{Environment.NewLine}{Settings.PrintSettings(2)}");

this.InitToast();
this.InitTrayIcon();
Expand Down Expand Up @@ -191,7 +191,8 @@ private void FinalizeInit()

// Subscribe to actions' events
var playPauseAction = this.ActionRegistry.GetAction(ToastifyActionEnum.PlayPause);
playPauseAction.ActionPerformed += this.ActionPlayPause_ActionPerformed;
if (playPauseAction != null)
playPauseAction.ActionPerformed += this.ActionPlayPause_ActionPerformed;

this.IsInitComplete = true;
}
Expand Down Expand Up @@ -897,8 +898,8 @@ internal void PrintInternalDebugInfo()
StringBuilder sb = new StringBuilder();
List<string> strings = new List<string>();

sb.Append("Internal Info:\n");
sb.Append($"\thWnd[{this.WindowHandle}]\n");
sb.Append($"Internal Info:{Environment.NewLine}");
sb.Append($"\thWnd[{this.WindowHandle}]{Environment.NewLine}");

// minimizeTimer
strings.Clear();
Expand All @@ -909,15 +910,15 @@ internal void PrintInternalDebugInfo()
strings.Add(this.minimizeTimer.Enabled ? "enabled" : "disabled");
strings.Add($"{this.minimizeTimer.Interval}");
}
sb.Append($"\tminimizeTimer: {string.Join(",", strings)}\n");
sb.Append($"\tminimizeTimer: {string.Join(",", strings)}{Environment.NewLine}");

// track
strings.Clear();
if (this.currentSong == null)
strings.Add("null");
else
strings.Add(this.currentSong.IsValid() ? "valid" : "invalid");
sb.Append($"\ttrack: {string.Join(",", strings)}\n");
sb.Append($"\ttrack: {string.Join(",", strings)}{Environment.NewLine}");

// state
strings.Clear();
Expand All @@ -926,7 +927,7 @@ internal void PrintInternalDebugInfo()
strings.Add(this.dragging ? "dragging" : string.Empty);
strings.Add(this.paused ? "paused" : "playing");
strings.RemoveAll(string.IsNullOrWhiteSpace);
sb.Append($"\tstate: {string.Join(",", strings)}\n");
sb.Append($"\tstate: {string.Join(",", strings)}{Environment.NewLine}");

// visibility
strings.Clear();
Expand All @@ -936,7 +937,7 @@ internal void PrintInternalDebugInfo()
strings.Add(this.Topmost ? "topmost" : string.Empty);
strings.Add($"{{{wPlacement}}}");
strings.RemoveAll(string.IsNullOrWhiteSpace);
sb.Append($"\tvisibility: {string.Join(",", strings)}\n");
sb.Append($"\tvisibility: {string.Join(",", strings)}{Environment.NewLine}");

// dispatcher
strings.Clear();
Expand All @@ -947,18 +948,18 @@ internal void PrintInternalDebugInfo()
strings.Add(this.Dispatcher.HasShutdownStarted ? "shutdown-started" : string.Empty);
strings.RemoveAll(string.IsNullOrWhiteSpace);
}
sb.Append($"\tdispatcher: {string.Join(",", strings)}\n");
sb.Append($"\tdispatcher: {string.Join(",", strings)}{Environment.NewLine}");

// settings
strings.Clear();
strings.Add(this.Settings.DisableToast ? "toast-disabled" : "toast-enabled");
strings.Add(this.Settings.OnlyShowToastOnHotkey ? "only-show-toast-on-hotkey" : string.Empty);
strings.Add($"{this.Settings.DisplayTime}");
strings.RemoveAll(string.IsNullOrWhiteSpace);
sb.Append($"\tsettings: {string.Join(",", strings)}\n");
sb.Append($"\tsettings: {string.Join(",", strings)}{Environment.NewLine}");

string internalInfo = sb.ToString();
logger.Debug($"{internalInfo}\tStack Trace:\n{Environment.StackTrace}");
logger.Debug($"{internalInfo}\tStack Trace:{Environment.NewLine}{Environment.StackTrace}");
}
}

Expand Down Expand Up @@ -1006,7 +1007,7 @@ public void DisplayAction(ToastifyActionEnum action)
string visibility = $"visibility[{(this.ShownOrFading ? '1' : '0')}{(this.IsVisible ? '1' : '0')}{this.Visibility.ToString().Substring(0, 1)}{(this.Topmost ? '1' : '0')}, {{{wPlacement}}}]";
string dispatcher = $"dispatcher[{(this.Dispatcher == null ? "null" : $"{(this.Dispatcher.HasShutdownStarted ? '1' : '0')}")}]";
string settings = $"settings[{(this.Settings.DisableToast ? '1' : '0')}{(this.Settings.OnlyShowToastOnHotkey ? '1' : '0')}, {this.Settings.DisplayTime}]";
logger.Info($"{hWnd}, {timer}, {song}, {state}, {visibility}, {dispatcher}, {settings}\n Stack Trace:\n{Environment.StackTrace}");
logger.Info($"{hWnd}, {timer}, {song}, {state}, {visibility}, {dispatcher}, {settings}{Environment.NewLine} Stack Trace:{Environment.NewLine}{Environment.StackTrace}");
}
#endif
this.ShowOrHideToast(force: true);
Expand Down

0 comments on commit aafcd89

Please sign in to comment.