Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
R: Bugfixes (crash, ..) and Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed May 2, 2017
1 parent 556d885 commit 5ff26df
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 47 deletions.
Binary file modified Downloads/ImgurSniper.zip
Binary file not shown.
Binary file modified Downloads/ImgurSniperSetup.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions ImgurSniper.UI/MainWindow.xaml.cs
Expand Up @@ -46,12 +46,12 @@ public partial class MainWindow {
//Command Line Args
private async void Arguments() {
string[] args = Environment.GetCommandLineArgs();
if (args.Contains("Help")) {
if (args.Contains("help")) {
Hide();
Help(null, null);
Close();
}
if (args.Contains("Update")) {
if (args.Contains("update")) {
Hide();
bool updateAvailable = await InstallerHelper.CheckForUpdates(this, true);
if (updateAvailable) {
Expand All @@ -60,7 +60,7 @@ public partial class MainWindow {
Close();
}
}
if (args.Contains("Troubleshooting")) {
if (args.Contains("troubleshooting")) {
//Task.Delay for Open/Close Animations
await Task.Delay(400);
await ShowOkDialog(str.troubleshooting, str.troubleshootingTips);
Expand Down
12 changes: 6 additions & 6 deletions ImgurSniper.UI/Pages/SettingsPages/CapturePage.xaml.cs
@@ -1,7 +1,7 @@
using System.Drawing.Imaging;
using ImgurSniper.UI.Properties;
using System.Drawing.Imaging;
using System.Windows;
using System.Windows.Controls;
using ImgurSniper.UI.Properties;

namespace ImgurSniper.UI.Pages.SettingsPages {
/// <summary>
Expand All @@ -21,10 +21,10 @@ public partial class CapturePage {

//Load all Config Params
private async void Load() {
_window.ShowProgressIndicator();
_window?.ShowProgressIndicator();

//Update Loading Indicator
_window.SetProgressStatus(strings.loadConf);
_window?.SetProgressStatus(strings.loadConf);

try {
Settings settings = ConfigHelper.JsonConfig;
Expand Down Expand Up @@ -76,7 +76,7 @@ public partial class CapturePage {
}

//Remove Loading Indicator
_window.HideProgressIndicator();
_window?.HideProgressIndicator();
}


Expand Down Expand Up @@ -146,7 +146,7 @@ public partial class CapturePage {

private void EnableSave() {
try {
_window.EnableSave();
_window?.EnableSave();
} catch {
// no parent found
}
Expand Down
12 changes: 6 additions & 6 deletions ImgurSniper.UI/Pages/SettingsPages/EventsPage.xaml.cs
@@ -1,8 +1,8 @@
using System.IO;
using ImgurSniper.UI.Properties;
using System.IO;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using ImgurSniper.UI.Properties;
using Application = System.Windows.Application;
using CheckBox = System.Windows.Controls.CheckBox;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
Expand All @@ -25,10 +25,10 @@ public partial class EventsPage {

//Load all Config Params
private async void Load() {
_window.ShowProgressIndicator();
_window?.ShowProgressIndicator();

//Update Loading Indicator
_window.SetProgressStatus(strings.loadConf);
_window?.SetProgressStatus(strings.loadConf);

try {
Settings settings = ConfigHelper.JsonConfig;
Expand Down Expand Up @@ -81,7 +81,7 @@ public partial class EventsPage {
}

//Remove Loading Indicator
_window.HideProgressIndicator();
_window?.HideProgressIndicator();
}

#region UI
Expand Down Expand Up @@ -174,7 +174,7 @@ public partial class EventsPage {

private void EnableSave() {
try {
_window.EnableSave();
_window?.EnableSave();
} catch {
// no parent found
}
Expand Down
22 changes: 13 additions & 9 deletions ImgurSniper.UI/Pages/SettingsPages/HomePage.xaml.cs
@@ -1,9 +1,9 @@
using System;
using ImgurSniper.UI.Properties;
using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using ImgurSniper.UI.Properties;
using Path = System.IO.Path;

namespace ImgurSniper.UI.Pages.SettingsPages {
Expand All @@ -26,7 +26,7 @@ public partial class HomePage {
}
}

private void Help(object sender, RoutedEventArgs e) { _window.Help(sender, e); }
private void Help(object sender, RoutedEventArgs e) { _window?.Help(sender, e); }

private async void Snipe(object sender, RoutedEventArgs e) {
string exe = Path.Combine(ConfigHelper.InstallDir, "ImgurSniper.exe");
Expand All @@ -35,14 +35,16 @@ public partial class HomePage {
Process snipeProc = new Process { StartInfo = new ProcessStartInfo(exe) };
snipeProc.Start();

_window.Visibility = Visibility.Hidden;
if (_window != null)
_window.Visibility = Visibility.Hidden;

await Task.Delay(500);
snipeProc.WaitForExit();

_window.Visibility = Visibility.Visible;
if (_window != null)
_window.Visibility = Visibility.Visible;
} else {
_window.ErrorToast.Show(strings.imgurSniperNotFound,
_window?.ErrorToast.Show(strings.imgurSniperNotFound,
TimeSpan.FromSeconds(3));
}
}
Expand All @@ -59,14 +61,16 @@ public partial class HomePage {
};
snipeProc.Start();

_window.Visibility = Visibility.Hidden;
if (_window != null)
_window.Visibility = Visibility.Hidden;

await Task.Delay(500);
snipeProc.WaitForExit();

_window.Visibility = Visibility.Visible;
if (_window != null)
_window.Visibility = Visibility.Visible;
} else {
_window.ErrorToast.Show(strings.imgurSniperNotFound,
_window?.ErrorToast.Show(strings.imgurSniperNotFound,
TimeSpan.FromSeconds(3));
}
}
Expand Down
14 changes: 6 additions & 8 deletions ImgurSniper.UI/Pages/SettingsPages/ImgurPage.xaml.cs
@@ -1,9 +1,7 @@
using System.Diagnostics;
using ImgurSniper.UI.Properties;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using ImgurSniper.UI.Properties;

namespace ImgurSniper.UI.Pages.SettingsPages {
/// <summary>
Expand All @@ -17,17 +15,17 @@ public partial class ImgurPage {
InitializeComponent();

_window = (MainWindow)Application.Current.MainWindow;
_imgurhelper = new ImgurLoginHelper(_window.ErrorToast, _window.SuccessToast);
_imgurhelper = new ImgurLoginHelper(_window?.ErrorToast, _window?.SuccessToast);

Load();
}

//Load all Config Params
private async void Load() {
_window.ShowProgressIndicator();
_window?.ShowProgressIndicator();

//Update Loading Indicator
_window.SetProgressStatus(strings.contactImgur);
_window?.SetProgressStatus(strings.contactImgur);

try {
string refreshToken = ConfigHelper.ReadRefreshToken();
Expand Down Expand Up @@ -55,7 +53,7 @@ public partial class ImgurPage {
}

//Remove Loading Indicator
_window.HideProgressIndicator();
_window?.HideProgressIndicator();
}


Expand Down
24 changes: 13 additions & 11 deletions ImgurSniper.UI/Pages/SettingsPages/OtherPage.xaml.cs
@@ -1,8 +1,8 @@
using System.Diagnostics;
using ImgurSniper.UI.Properties;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using ImgurSniper.UI.Properties;
using Application = System.Windows.Application;

namespace ImgurSniper.UI.Pages.SettingsPages {
Expand All @@ -20,10 +20,10 @@ public partial class OtherPage {
}

private async void Load() {
_window.ShowProgressIndicator();
_window?.ShowProgressIndicator();

//Update Loading Indicator
_window.SetProgressStatus(strings.loadConf);
_window?.SetProgressStatus(strings.loadConf);

try {
Settings settings = ConfigHelper.JsonConfig;
Expand Down Expand Up @@ -71,16 +71,18 @@ public partial class OtherPage {
}

//Search for Updates
_window.SetProgressStatus(strings.checkingUpdate);
BtnUpdate.IsEnabled = await InstallerHelper.CheckForUpdates(_window, false);
if (_window != null) {
_window.SetProgressStatus(strings.checkingUpdate);
BtnUpdate.IsEnabled = await InstallerHelper.CheckForUpdates(_window, false);
}

//Remove Loading Indicator
_window.HideProgressIndicator();
_window?.HideProgressIndicator();
}


#region UI
private void Update(object sender, RoutedEventArgs e) { _window.Update(sender, e); }
private void Update(object sender, RoutedEventArgs e) { _window?.Update(sender, e); }

private async void RunOnBoot_Checkbox(object sender, RoutedEventArgs e) {
if (sender is CheckBox box) {
Expand Down Expand Up @@ -110,12 +112,12 @@ public partial class OtherPage {
}

//Show Progress Indicator
_window.ShowProgressIndicator();
_window?.ShowProgressIndicator();

BtnUpdate.IsEnabled = await InstallerHelper.CheckForUpdates(_window, true);

//Hide Progress Indicator
_window.HideProgressIndicator();
_window?.HideProgressIndicator();

if (btn != null) {
btn.IsEnabled = true;
Expand Down Expand Up @@ -255,7 +257,7 @@ public partial class OtherPage {

private void EnableSave() {
try {
_window.EnableSave();
_window?.EnableSave();
} catch {
// no parent found
}
Expand Down
6 changes: 3 additions & 3 deletions ImgurSniper/Libraries/Start/StartTray.cs
@@ -1,7 +1,7 @@
using System;
using ImgurSniper.Libraries.Helper;
using ImgurSniper.Libraries.Helper;
using ImgurSniper.Libraries.Hotkeys;
using ImgurSniper.Properties;
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
Expand Down Expand Up @@ -66,7 +66,7 @@ public static class StartTray {
helpMenuItem.Image = _iconHelp;
helpMenuItem.Click += delegate {
try {
Process.Start(Path.Combine(ConfigHelper.InstallDir, "ImgurSniper.UI.exe"), "Help");
Process.Start(Path.Combine(ConfigHelper.InstallDir, "ImgurSniper.UI.exe"), "help");
} catch {
// ignored
}
Expand Down
2 changes: 1 addition & 1 deletion ImgurSniper/NotificationWindow.xaml.cs
Expand Up @@ -17,7 +17,7 @@ public partial class NotificationWindow : IDisposable {
public static bool IsShown { get; private set; }

public static readonly Action ActionTroubleshoot =
delegate { Process.Start(Path.Combine(ConfigHelper.InstallDir, "ImgurSniper.UI.exe"), "Troubleshooting"); };
delegate { Process.Start(Path.Combine(ConfigHelper.InstallDir, "ImgurSniper.UI.exe"), "troubleshooting"); };

public enum NotificationType {
Progress,
Expand Down

0 comments on commit 5ff26df

Please sign in to comment.