Skip to content

Commit

Permalink
about window and more work on post process chain
Browse files Browse the repository at this point in the history
  • Loading branch information
wiegell committed Nov 15, 2022
1 parent add2fb4 commit 3eff80f
Show file tree
Hide file tree
Showing 15 changed files with 354 additions and 62 deletions.
35 changes: 35 additions & 0 deletions AstroWall/AboutViewController.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions AstroWall/ApplicationLayer/Helpers/General.Macos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public class General
public General()
{
}
public static string currentVersion()
{
return NSBundle.MainBundle.InfoDictionary["CFBundleVersion"].ToString();
}

public static string getAstroDirectory()
{
Expand Down
56 changes: 56 additions & 0 deletions AstroWall/ApplicationLayer/View/AboutViewController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// This file has been autogenerated from a class added in the UI designer.

using System;

using Foundation;
using AppKit;

namespace AstroWall
{
public partial class AboutViewController : NSViewController
{


public AboutViewController(IntPtr handle) : base(handle)
{
}

public override void ViewDidLoad()
{
base.ViewDidLoad();
OutletVersion.StringValue = General.currentVersion();
}

//public override void
//{
// base.DidAddSubview(subview);
//}

partial void ActionGithub(NSObject sender)
{
openWebPage("https://github.com/wiegell/AstroWall/");
}
partial void ActionWeb(NSObject sender)
{
openWebPage("https://wiegell.github.io/AstroWall/");
}
partial void ActionIssues(NSObject sender)
{
openWebPage("https://github.com/wiegell/AstroWall/issues");
}

private void openWebPage(string url)
{
NSTask nstask = new NSTask();
nstask.LaunchPath = "/bin/bash";
nstask.Arguments = new string[]
{
"-c",
"open "+url
};
//+" "
nstask.Launch();
nstask.WaitUntilExit();
}
}
}
35 changes: 35 additions & 0 deletions AstroWall/ApplicationLayer/View/AboutViewController.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions AstroWall/AstroWall.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@
<Compile Include="BusinessLayer\Wallpaper\PostProcess\AddText.cs" />
<Compile Include="BusinessLayer\Wallpaper\PostProcess\ScaleAndCrop.cs" />
<Compile Include="ApplicationLayer\Helpers\Screen.Model.Macos.cs" />
<Compile Include="ApplicationLayer\View\AboutViewController.cs" />
<Compile Include="ApplicationLayer\View\AboutViewController.designer.cs">
<DependentUpon>AboutViewController.cs</DependentUpon>
</Compile>
<Compile Include="BusinessLayer\Wallpaper\PostProcess\Compose.cs" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="Main.storyboard" />
Expand Down
2 changes: 1 addition & 1 deletion AstroWall/BusinessLayer/ApplicationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ApplicationHandler

// Misc
public Version CurrentVersion { private set; get; }
private string currentVersionString = NSBundle.MainBundle.InfoDictionary["CFBundleVersion"].ToString();
private string currentVersionString = General.currentVersion();


public ApplicationHandler(AppDelegate del)
Expand Down
46 changes: 34 additions & 12 deletions AstroWall/BusinessLayer/ImgWrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using SkiaSharp;
using System.IO;
using System.Threading.Tasks;
using AstroWall.BusinessLayer.Preferences;
using AstroWall.BusinessLayer;
using System.Collections.Generic;
using System.Linq;
using AstroWall.ApplicationLayer.Helpers;
Expand Down Expand Up @@ -174,9 +174,11 @@ private async Task createPreviewFromFullSize(int width = 250, int height = 180)
return;
}

public async Task createPostProcessedImages(Dictionary<string, Screen> screens)
public async Task createPostProcessedImages(Dictionary<string, Screen> screens, Dictionary<Preferences.PostProcessType, Preferences.PostProcess> postProcessPrefsDictionary)
{
Console.WriteLine("creating postprocessed images");

// Load full res image
SKBitmap image;
try
{
Expand All @@ -188,17 +190,36 @@ public async Task createPostProcessedImages(Dictionary<string, Screen> screens)
return;
}

// Prep Dictionary vars for postprocess
Dictionary<Screen, SKBitmap> unProcessedImagesByScreenId =
screens.ToDictionary(
// Set Screen instance as key
screenKV => screenKV.Value,
// Value as unprocessed full res image loaded above
screenKV => image
);
Dictionary<Screen, SKBitmap> postProcessedImagesByScreenId;

// Prep postprocess chain
Func<Dictionary<Screen, SKBitmap>> postProcessChain =
Wallpaper.PostProcess.ComposePostProcess(
() => unProcessedImagesByScreenId,
//Wallpaper.PostProcess.AddTextCurry(
// (Preferences.AddText)postProcessPrefsDictionary[Preferences.PostProcessType.AddText],
// Title,
// Description
// ),
Wallpaper.PostProcess.AddTextCurry(
(Preferences.AddText)postProcessPrefsDictionary[Preferences.PostProcessType.AddText],
Title,
"TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST TEEEEEEEEEST "
)
);

// Do the postprocessing
Dictionary<string, SKBitmap> postProcessedImagesByScreenId;
try
{
postProcessedImagesByScreenId =
screens.ToDictionary(
screenKV =>
screenKV.Key,
screenKV =>
Wallpaper.PostProcess.AddText(image, Title, Description));

postProcessedImagesByScreenId = postProcessChain();
}
catch (Exception ex)
{
Expand All @@ -209,11 +230,12 @@ public async Task createPostProcessedImages(Dictionary<string, Screen> screens)
// Save files and register file paths
try
{
// This is the format saved in prefs
ImgLocalPostProcessedUrlsByScreenId = postProcessedImagesByScreenId.ToDictionary(
bitmapKV => bitmapKV.Key,
bitmapKV => bitmapKV.Key.Id,
bitmapKV =>
{
string path = $"{ImgLocalUrl}_postprocessed_{bitmapKV.Key}.{FileType}";
string path = $"{ImgLocalUrl}_postprocessed_{bitmapKV.Key.Id}.{FileType}";
FileStream f = File.Create(path);
bitmapKV.Value.Encode(f, (OnlineUrlIsJPG() ? SKEncodedImageFormat.Jpeg : SKEncodedImageFormat.Png), 90);
Console.WriteLine($"postprocess for screen {bitmapKV.Key} saved: {path}");
Expand Down
4 changes: 2 additions & 2 deletions AstroWall/BusinessLayer/Preferences/AddText.model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace AstroWall.BusinessLayer.Preferences
[JsonObject]
public class AddText : PostProcess
{
public AddText(bool isEnabled) : base("Add text", isEnabled)
public AddText(bool isEnabled) : base(PostProcessType.AddText, isEnabled)
{

}
public AddText(AddText otherObj, bool isEnabled) : base(otherObj, isEnabled)
{
Expand Down
11 changes: 8 additions & 3 deletions AstroWall/BusinessLayer/Preferences/PostProcess.model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@

namespace AstroWall.BusinessLayer.Preferences
{
public enum PostProcessType
{
AddText,
ScaleAndCrop
}

[JsonObject]
public abstract class PostProcess
{
[JsonProperty]
public readonly bool isEnabled;
[JsonProperty]
public readonly string name;
public readonly PostProcessType name;

public PostProcess(string name, bool isEnabled)
public PostProcess(PostProcessType name, bool isEnabled)
{
this.name = name;
this.isEnabled = isEnabled;
}
public PostProcess(PostProcess otherObj, string name)
public PostProcess(PostProcess otherObj, PostProcessType name)
{
this.name = name;
this.isEnabled = otherObj.isEnabled;
Expand Down
9 changes: 5 additions & 4 deletions AstroWall/BusinessLayer/Preferences/Preferences.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AppKit;
using Newtonsoft.Json;

Expand Down Expand Up @@ -37,13 +38,13 @@ public class Preferences
[JsonProperty]
public AddText AddTextPostProcess;

public List<PostProcess> PostProcesses
public Dictionary<PostProcessType, PostProcess> PostProcesses
{
get
{
var retList = new List<PostProcess>();
retList.Add(AddTextPostProcess);
return retList;
var retDict = new Dictionary<PostProcessType, PostProcess>();
retDict.Add(PostProcessType.AddText, AddTextPostProcess);
return retDict;
}
}

Expand Down
Loading

0 comments on commit 3eff80f

Please sign in to comment.