Skip to content

Commit

Permalink
Have added logging + fixed a wallpaper update bug
Browse files Browse the repository at this point in the history
  • Loading branch information
thepigeonfighter committed Nov 3, 2018
1 parent 0e2a01b commit 981700b
Show file tree
Hide file tree
Showing 135 changed files with 259,832 additions and 57 deletions.
Binary file modified .vs/AutomatedDesktopBackground/v15/.suo
Binary file not shown.
Binary file modified .vs/AutomatedDesktopBackground/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file not shown.
Binary file not shown.
1,022 changes: 1,022 additions & 0 deletions .vs/config/applicationhost.config

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions AutomatedDesktopBackgroundUI/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,18 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<appSettings>
<add key="log4net.Internal.Debug" value="false"/>
</appSettings>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="textWriterTraceListener"

type="System.Diagnostics.TextWriterTraceListener"

initializeData="C:\log4net_internal.log"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>
10 changes: 9 additions & 1 deletion AutomatedDesktopBackgroundUI/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using log4net;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
Expand All @@ -13,5 +14,12 @@ namespace AutomatedDesktopBackgroundUI
/// </summary>
public partial class App : Application
{
private static readonly ILog log = LogManager.GetLogger(typeof(App));
protected override void OnStartup(StartupEventArgs e)
{
log4net.Config.XmlConfigurator.Configure();
log.Info(" ============= Started Logging ============= ");
base.OnStartup(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<Reference Include="DeltaCompressionDotNet.PatchApi, Version=1.1.0.0, Culture=neutral, PublicKeyToken=3e8888ee913ed789, processorArchitecture=MSIL">
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.PatchApi.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -154,6 +157,9 @@
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Content Include="log4net.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down
53 changes: 45 additions & 8 deletions AutomatedDesktopBackgroundUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Windows.Forms;
using AutomatedDesktopBackgroundLibrary.Utility;
using System.Windows.Input;
using log4net;

namespace AutomatedDesktopBackgroundUI
{
Expand All @@ -15,10 +16,12 @@ namespace AutomatedDesktopBackgroundUI
public partial class MainWindow : Window
{
private readonly MainViewController viewController = new MainViewController();
private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public NotifyIcon ADIcon;

public MainWindow()
{
log.Debug("Entering the main window ctor");
InitializeComponent();
GetVersionNumber();
CheckSettings();
Expand All @@ -34,6 +37,7 @@ public MainWindow()
/// </summary>
private void BuildNotifyIcon()
{
log.Debug("Building notify icon");
ADIcon = new NotifyIcon
{
BalloonTipTitle = "Automated Desktop Backgrounds",
Expand All @@ -45,22 +49,26 @@ private void BuildNotifyIcon()
var myIcon = Properties.Resources.Icon1;
ADIcon.Icon = myIcon;
ADIcon.DoubleClick += OnNotifyIconDoubleClik;
log.Debug("Notify icon built");
}
private void GetVersionNumber()
{
log.Debug("Getting version number");
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
FileVersionInfo info = FileVersionInfo.GetVersionInfo(assembly.Location);
versionLabel.Content = $"v.{info.FileVersion}";
}

private void HideWindow()
{
log.Debug("Hide window requested");
Hide();
ADIcon.Visible = true;
}

private void OnNotifyIconDoubleClik(object sender, EventArgs e)
{
log.Debug("Notify icon has been double clicked");
Show();
this.WindowState = WindowState.Normal;
ADIcon.Visible = false;
Expand All @@ -70,18 +78,22 @@ private void RemoveInterestButton_Click(object sender, RoutedEventArgs e)
{
try
{
log.Debug($"The interest named {interestListView.SelectedValue.ToString()} is trying to be removed ");
viewController.RemoveInterest(interestListView.SelectedValue.ToString());
interestListView.ItemsSource = viewController.interests;
interestListView.Items.Refresh();
log.Info($"The interest named {interestListView.SelectedValue.ToString()} has been removed");
}
catch
{
log.Warn($"The interest named {interestListView.SelectedValue.ToString()} could not be found");
CustomMessageBox.Show("Couldn't remove this interest");
}
}

private void WireDependencies()
{
log.Debug("Setting window state to start state");
viewController.SetPageState(ButtonCommands.SetToStartState);
amountImagesDownloadedLabel.Visibility = Visibility.Hidden;
downloadProgressBar.Visibility = Visibility.Hidden;
Expand All @@ -93,9 +105,11 @@ private void WireDependencies()
removeInterestButton.IsEnabled = false;

queryTextBox.KeyUp += QueryTextBox_KeyUp;
log.Debug("Getting the current wallpaper");
ImageModel image = viewController.GetCurrentWallPaper();
if (image != null)
{
log.Info("Have found an existing wallpaper");
currentImageLabel.Content = $"Current image is {image.Name}";
HateImageButton.IsEnabled = true;
if (!viewController.IsFavorited())
Expand All @@ -105,7 +119,8 @@ private void WireDependencies()
}
else
{
currentImageLabel.Content = $"Unknown";
log.Info("No previous wallpaper found");
currentImageLabel.Content = "Unknown";
HateImageButton.IsEnabled = false;
LikeImageButton.IsEnabled = false;
}
Expand All @@ -125,6 +140,7 @@ private async void QuerySearchButton_Click(object sender, RoutedEventArgs e)
{
if (GlobalConfig.IsConnected())
{
log.Info($"user searched for {queryTextBox.Text} ");
querySearchButton.IsEnabled = false;
if (!string.IsNullOrEmpty(queryTextBox.Text))
{
Expand All @@ -146,13 +162,15 @@ private async void QuerySearchButton_Click(object sender, RoutedEventArgs e)
}
else
{
log.Info($"User attempted to search for {queryTextBox.Text} but was not connected");
CustomMessageBox.Show("No internet Connection");
}
}
catch (Exception ex)
{
CustomMessageBox.Show("Couldn't make this search");
CustomMessageBox.Show($"{ex.StackTrace}");
log.Error($"{queryTextBox.Text} was searched resulting in an error");
log.Info($"{ex.InnerException}");
}
}

Expand All @@ -164,30 +182,35 @@ private void DownloadButton_Click(object sender, RoutedEventArgs e)
{
if (GlobalConfig.IsConnected())
{
log.Debug($"User is downloading a collection associated with {interestListView.SelectedValue.ToString()}");
int totalImages = viewController.GetInterestTotalImages(interestListView.SelectedValue.ToString());
if (totalImages > 0)
{

viewController.DownloadNewCollection(interestListView.SelectedValue.ToString());
downloadButton.IsEnabled = false;
amountImagesDownloadedLabel.Visibility = Visibility.Visible;
downloadProgressBar.Visibility = Visibility.Visible;
}
else
{
log.Info("User attempted to download images that had zero images");
downloadButton.IsEnabled = false;
CustomMessageBox.Show("There are no images associated with that interest, please remove and try a different interest, Sent from MainWindow.cs");
}
}
else
{
log.Debug("User attempted to download without being connected to the internet");
CustomMessageBox.Show("No internet Connection");
}
}
}
catch (Exception ex)
{
log.Error($"Something exploded when the user attempted to download {interestListView.SelectedValue.ToString()}");
CustomMessageBox.Show("The Download Process encountered a bug");
CustomMessageBox.Show(ex.StackTrace);
log.Info(ex.InnerException);

}
}
Expand All @@ -206,11 +229,14 @@ private void CloseWindowButtonClick(object sender, RoutedEventArgs e)

private void DisplayWarningWindow()
{

if (viewController.ShouldDisplayWarning())
{
log.Info("User will be warned about the program running in background");
Window warningWindow = new WarningWindow();
warningWindow.Show();
}
else { log.Info("User will not be warned about the program running in background"); }
}
#region Background and Collection Buttons

Expand All @@ -233,7 +259,8 @@ private void StartBackgroundRefreshButton_Copy_Click(object sender, RoutedEventA
{

CustomMessageBox.Show("The background refreshing process failed to start");
CustomMessageBox.Show(ex.StackTrace);
log.Error("Background refresh has failed to start");
log.Info(ex.InnerException);
}
}

Expand All @@ -257,7 +284,8 @@ private void StartCollectionRefreshButton_Copy_Click(object sender, RoutedEventA
{

CustomMessageBox.Show("Failed to start the collection refreshing process");
CustomMessageBox.Show(ex.StackTrace);
log.Error("Collection refresh has failed to start");
log.Info(ex.InnerException);
}
}

Expand All @@ -266,14 +294,15 @@ private void StopCollectionRefreshButton_Click(object sender, RoutedEventArgs e)
try
{
this.Dispatcher.Invoke(() =>
viewController.StopCollectionChange());
viewController.StopCollectionChange());
viewController.SetPageState(ButtonCommands.StopCollections);
}
catch (Exception ex)
{

CustomMessageBox.Show("Failed to stop the collection refresh process");
CustomMessageBox.Show(ex.StackTrace);
log.Error("Collection refresh has failed to stop");
log.Info(ex.InnerException);
}
}

Expand All @@ -289,7 +318,8 @@ private void StopBackgroundRefreshButton_Click(object sender, RoutedEventArgs e)
{

CustomMessageBox.Show("Failed to stop the background refresh job");
CustomMessageBox.Show(ex.StackTrace);
log.Error("Background refresh has failed to stop");
log.Info(ex.InnerException);
}
}

Expand Down Expand Up @@ -338,6 +368,7 @@ private void InterestListView_MouseDoubleClick(object sender, System.Windows.Inp

private void EventSystem_ApplicationResetEvent(object sender, string e)
{
log.Info("Application reset has been triggered");
interestListView.ItemsSource = viewController.interests;
viewController.SetPageState(ButtonCommands.SetToStartState);
currentImageLabel.Content = "";
Expand All @@ -346,11 +377,13 @@ private void EventSystem_ApplicationResetEvent(object sender, string e)

private void EventSystem_ImageHatingHasCompleted(object sender, string e)
{
log.Info("Image has been successfully marked as hated");
this.Dispatcher.Invoke(() => HateImageButton.IsEnabled = true);
}

private void EventSystem_UpdateBackgroundEvent(object sender, string e)
{
log.Debug("Wallpaper changed");
ImageModel currentWallpaper = viewController.GetCurrentWallPaper();
if (currentWallpaper.Name != "Unknown")
{
Expand Down Expand Up @@ -417,11 +450,13 @@ private void EventSystem_DownloadPercentageEvent(object sender, int e)

private void EventSystem_DownloadedImageEvent(object sender, string e)
{
log.Debug("Downloaded an image");
this.Dispatcher.Invoke(() => amountImagesDownloadedLabel.Content = e);
}

private void EventSystem_DownloadCompleteEvent(object sender, bool e)
{
log.Debug("Collection has finished downloading");
if (e) { this.Dispatcher.Invoke(() => CustomMessageBox.Show("Download Complete!")); }
this.Dispatcher.Invoke(() => downloadButton.IsEnabled = true);
this.Dispatcher.Invoke(() => amountImagesDownloadedLabel.Content = "");
Expand Down Expand Up @@ -494,6 +529,7 @@ private void ColUpdating(bool status)

private void ExitApplicationButtonClick(object sender, RoutedEventArgs e)
{
log.Info("Application close requested");
this.Dispatcher.Invoke(() => viewController.CloseWindow());
}

Expand All @@ -506,6 +542,7 @@ private void CheckSettings()
{
if(viewController.ShowSettingsWindow())
{
log.Info("Setting window should be shown at start up");
Window window = new SettingsWindow();
window.Show();

Expand Down
5 changes: 3 additions & 2 deletions AutomatedDesktopBackgroundUI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.1")]
[assembly: AssemblyFileVersion("1.3.1")]
[assembly: AssemblyVersion("1.3.2")]
[assembly: AssemblyFileVersion("1.3.2")]
[assembly: NeutralResourcesLanguage("en")]


Loading

0 comments on commit 981700b

Please sign in to comment.