Skip to content

Commit

Permalink
v4.5.0 rev2
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangKurz committed Sep 9, 2018
2 parents 26b0ee9 + 58b96b6 commit 7ed313f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 35 deletions.
9 changes: 2 additions & 7 deletions source/Grabacr07.KanColleViewer/Models/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ static Helper()
public static bool IsInDesignMode => DesignerProperties.GetIsInDesignMode(new DependencyObject());


public static string CreateScreenshotFilePath(SupportedImageFormat format, bool defaultPath = false)
public static string CreateScreenshotFilePath(SupportedImageFormat format)
{
var directory = "";

if (!defaultPath)
directory = Settings.ScreenshotSettings.Destination;
else
directory= Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
var directory = Settings.ScreenshotSettings.Destination;

var filePath = Path.Combine(
directory,
Expand Down
3 changes: 2 additions & 1 deletion source/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly)]

[assembly: AssemblyVersion("4.5.0.1")]
[assembly: AssemblyVersion("4.5.0.2")]
// CefSharp needs https://www.microsoft.com/en-us/download/details.aspx?id=48145
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,6 @@ public void Refresh()
}

public void TakeScreenshot()
{
TakeScreenshot(false);
}

public void TakeScreenshot(bool defaultPath)
{
var format = ScreenshotSettings.Format.Value;
var path = Helper.CreateScreenshotFilePath(format);
Expand All @@ -252,24 +247,6 @@ public void TakeScreenshot(bool defaultPath)
Format = format,
};
this.Messenger.Raise(message);

if (message.Response.IsSuccess)
{
// Succeeded
var notify = Resources.Screenshot_Saved + Path.GetFileName(path);
StatusService.Current.Notify(notify);
}
else if (!defaultPath)
{
// Retry with default directory (MyPictures)
TakeScreenshot(true);
}
else
{
// Failed even with default directory
var notify = Resources.Screenshot_Failed + message.Response.Exception.Message;
StatusService.Current.Notify(notify);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Grabacr07.KanColleViewer.ViewModels.Messages
{
internal class ScreenshotMessage : ResponsiveInteractionMessage<Processing>
internal class ScreenshotMessage : InteractionMessage
{
public ScreenshotMessage() { }
public ScreenshotMessage(string messageKey) : base(messageKey) { }
Expand All @@ -24,7 +24,6 @@ protected override Freezable CreateInstanceCore()
MessageKey = this.MessageKey,
Path = this.Path,
Format = this.Format,
Response = this.Response,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,31 @@ protected override async void InvokeAction(InteractionMessage message)
try
{
await this.TakeScreenshot(screenshotMessage.Path, screenshotMessage.Format);
screenshotMessage.Response = new Processing();
StatusService.Current.Notify(Resources.Screenshot_Saved + Path.GetFileName(screenshotMessage.Path));
}
catch (Exception ex)
{
screenshotMessage.Response = new Processing(ex);
StatusService.Current.Notify(Resources.Screenshot_Failed + ex.Message);
Application.TelemetryClient.TrackException(ex);

try
{
var dir = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
var path = Path.Combine(
dir,
Path.GetFileName(screenshotMessage.Path)
);

await this.TakeScreenshot(path, screenshotMessage.Format);
StatusService.Current.Notify(Resources.Screenshot_Saved + Path.GetFileName(screenshotMessage.Path));
}
catch (Exception ex2)
{
StatusService.Current.Notify(Resources.Screenshot_Failed + ex2.Message);
Application.TelemetryClient.TrackException(ex2);
}
}
message = screenshotMessage as InteractionMessage;
}
}

Expand Down

0 comments on commit 7ed313f

Please sign in to comment.