Skip to content

Commit

Permalink
V2022.8.1
Browse files Browse the repository at this point in the history
- Design Updates
- Code Updates
  • Loading branch information
nlogozzo committed Aug 26, 2022
1 parent e3c5005 commit 850b53d
Show file tree
Hide file tree
Showing 17 changed files with 561 additions and 651 deletions.
92 changes: 45 additions & 47 deletions NickvisionSpotlight/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,65 +1,63 @@
using Microsoft.UI.Xaml;
using NickvisionSpotlight.Models;
using NickvisionSpotlight.UI;
using NickvisionSpotlight.UI.Controls;
using NickvisionSpotlight.UI.Views;
using System;
using System.Threading.Tasks;

namespace NickvisionSpotlight
namespace NickvisionSpotlight;

/// <summary>
/// The Application
/// </summary>
public partial class App : Application
{
private MainWindow? _window;

/// <summary>
/// The Application
/// Constructs an App
/// </summary>
public partial class App : Application
public App()
{
private MainWindow? _window;

/// <summary>
/// Constructs an App
/// </summary>
public App()
InitializeComponent();
//AppInfo
AppInfo.Current.Name = "Nickvision Spotlight";
AppInfo.Current.Description = "A utility for working with Windows Spotlight images.";
AppInfo.Current.Version = new Version("2022.8.1");
AppInfo.Current.Changelog = "- Design Updates\n- Code Cleanup";
AppInfo.Current.GitHubRepo = new Uri("https://github.com/nlogozzo/NickvisionSpotlight");
AppInfo.Current.IssueTracker = new Uri("https://github.com/nlogozzo/NickvisionSpotlight/issues/new");
//Load Config
if (Configuration.Current.Theme == Theme.Light)
{
InitializeComponent();
//AppInfo
AppInfo.Current.Name = "Nickvision Spotlight";
AppInfo.Current.Description = "A utility for working with Windows Spotlight images.";
AppInfo.Current.Version = new Version("2022.8.0");
AppInfo.Current.Changelog = "- Rewrite with Windows App SDK and C#";
AppInfo.Current.GitHubRepo = new Uri("https://github.com/nlogozzo/NickvisionSpotlight");
AppInfo.Current.IssueTracker = new Uri("https://github.com/nlogozzo/NickvisionSpotlight/issues/new");
//Load Config
if (Configuration.Current.Theme == Theme.Light)
{
RequestedTheme = ApplicationTheme.Light;
}
else if (Configuration.Current.Theme == Theme.Dark)
{
RequestedTheme = ApplicationTheme.Dark;
}
RequestedTheme = ApplicationTheme.Light;
}

/// <summary>
/// Occurs when the application is launched
/// </summary>
/// <param name="args">LaunchActivatedEventArgs</param>
protected override async void OnLaunched(LaunchActivatedEventArgs args)
else if (Configuration.Current.Theme == Theme.Dark)
{
_window = new MainWindow();
var windowContent = _window.Content;
var splashScreen = new SplashScreen();
_window.Content = splashScreen;
_window.Activate();
await StartupAsync(splashScreen);
_window.Content = windowContent;
RequestedTheme = ApplicationTheme.Dark;
}
}

private async Task StartupAsync(SplashScreen splashScreen)
{
splashScreen.Description = "Loading application...";
await Task.Delay(500);
splashScreen.Description = "Syncing spotlight images...";
await Messenger.Current.SendAsync("MainWindow.SyncSpotlightImagesAsync");
}
/// <summary>
/// Occurs when the application is launched
/// </summary>
/// <param name="args">LaunchActivatedEventArgs</param>
protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
_window = new MainWindow();
var windowContent = _window.Content;
var splashScreen = new SplashScreen();
_window.Content = splashScreen;
_window.Activate();
await StartupAsync(splashScreen);
_window.Content = windowContent;
}

private async Task StartupAsync(SplashScreen splashScreen)
{
splashScreen.Description = "Loading application...";
await Task.Delay(500);
splashScreen.Description = "Syncing spotlight images...";
await _window.SyncSpotlightImagesAsync();
}
}
70 changes: 45 additions & 25 deletions NickvisionSpotlight/Models/AppInfo.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,54 @@
using System;

namespace NickvisionSpotlight.Models
namespace NickvisionSpotlight.Models;

/// <summary>
/// A model for the information about the application
/// </summary>
public class AppInfo
{
private static AppInfo? _instance;

/// <summary>
/// A model for the information about the application
/// Gets the singleton object
/// </summary>
public class AppInfo
{
private static AppInfo? _instance;
public static AppInfo Current => _instance ??= new AppInfo();

public static AppInfo Current => _instance ??= new AppInfo();

public string Name { get; set; }
public string Description { get; set; }
public Version Version { get; set; }
public string Changelog { get; set; }
public Uri GitHubRepo { get; set; }
public Uri IssueTracker { get; set; }
/// <summary>
/// The name of the application
/// </summary>
public string Name { get; set; }
/// <summary>
/// The description of the application
/// </summary>
public string Description { get; set; }
/// <summary>
/// The running version of the application
/// </summary>
public Version Version { get; set; }
/// <summary>
/// The changelog for the running version of the application
/// </summary>
public string Changelog { get; set; }
/// <summary>
/// The GitHub repo for the application
/// </summary>
public Uri GitHubRepo { get; set; }
/// <summary>
/// The issue tracker for the application
/// </summary>
public Uri IssueTracker { get; set; }

/// <summary>
/// Constructs an AppInfo
/// </summary>
private AppInfo()
{
Name = "";
Description = "";
Version = new Version("0.0.0");
Changelog = "";
GitHubRepo = new Uri("about:blank");
IssueTracker = new Uri("about:blank");
}
/// <summary>
/// Constructs an AppInfo
/// </summary>
private AppInfo()
{
Name = "";
Description = "";
Version = new Version("0.0.0");
Changelog = "";
GitHubRepo = new Uri("about:blank");
IssueTracker = new Uri("about:blank");
}
}
80 changes: 47 additions & 33 deletions NickvisionSpotlight/Models/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,67 @@
using System.IO;
using System.Text.Json;

namespace NickvisionSpotlight.Models
namespace NickvisionSpotlight.Models;

/// <summary>
/// A model for the configuration of the application
/// </summary>
public class Configuration
{
private static readonly string ConfigDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}{Path.DirectorySeparatorChar}Nickvision{Path.DirectorySeparatorChar}{AppInfo.Current.Name}";
private static readonly string ConfigPath = $"{ConfigDir}{Path.DirectorySeparatorChar}config.json";
private static Configuration? _instance;

/// <summary>
/// A model for the configuration of the application
/// The preferred theme for the application
/// </summary>
public class Configuration
{
private static readonly string ConfigDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}{Path.DirectorySeparatorChar}Nickvision{Path.DirectorySeparatorChar}{AppInfo.Current.Name}";
private static readonly string ConfigPath = $"{ConfigDir}{Path.DirectorySeparatorChar}config.json";
private static Configuration? _instance;
public Theme Theme { get; set; }

public Theme Theme { get; set; }
/// <summary>
/// Occurs when the configuration is saved to disk
/// </summary>
public event EventHandler? Saved;

/// <summary>
/// Constructs a Configuration
/// </summary>
public Configuration()
/// <summary>
/// Constructs a Configuration
/// </summary>
public Configuration()
{
if (!Directory.Exists(ConfigDir))
{
if (!Directory.Exists(ConfigDir))
{
Directory.CreateDirectory(ConfigDir);
}
Theme = Theme.System;
Directory.CreateDirectory(ConfigDir);
}
Theme = Theme.System;
}

public static Configuration Current
/// <summary>
/// Gets the singleton object
/// </summary>
public static Configuration Current
{
get
{
get
if (_instance == null)
{
if (_instance == null)
try
{
_instance = JsonSerializer.Deserialize<Configuration>(File.ReadAllText(ConfigPath)) ?? new Configuration();
}
catch
{
try
{
_instance = JsonSerializer.Deserialize<Configuration>(File.ReadAllText(ConfigPath)) ?? new Configuration();
}
catch
{
_instance = new Configuration();
}
_instance = new Configuration();
}
return _instance;
}
return _instance;
}
}

/// <summary>
/// Saves the configuration to disk
/// </summary>
public void Save() => File.WriteAllText(ConfigPath, JsonSerializer.Serialize(this));
/// <summary>
/// Saves the configuration to disk
/// </summary>
public void Save()
{
File.WriteAllText(ConfigPath, JsonSerializer.Serialize(this));
Saved?.Invoke(this, EventArgs.Empty);
}
}
6 changes: 6 additions & 0 deletions NickvisionSpotlight/Models/SpotlightManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public class SpotlightManager
/// </summary>
public List<string> SpotlightImages { get; init; }

/// <summary>
/// Occurs when the list of spotlight images is changed
/// </summary>
public event EventHandler? ImagesChanged;

/// <summary>
/// Constructs a SpotlightManager
/// </summary>
Expand Down Expand Up @@ -70,6 +75,7 @@ await Task.Run(() =>
}
}
});
ImagesChanged?.Invoke(this, EventArgs.Empty);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion NickvisionSpotlight/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity
Name="33875Nickvision.NickvisionSpotlight"
Publisher="CN=8E1C029A-AC23-4620-A30D-8F7C54CBEA3C"
Version="2022.8.0.0" />
Version="2022.8.1.0" />

<Properties>
<DisplayName>Nickvision Spotlight</DisplayName>
Expand Down
46 changes: 27 additions & 19 deletions NickvisionSpotlight/UI/Controls/InfoBarMessageInfo.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
using Microsoft.UI.Xaml.Controls;

namespace NickvisionSpotlight.UI.Controls
namespace NickvisionSpotlight.UI.Controls;

/// <summary>
/// A model of the properties to show in an InfoBar
/// </summary>
public class InfoBarMessageInfo
{
/// <summary>
/// A model of the properties to show in an InfoBar
/// The title of the InfoBar
/// </summary>
public class InfoBarMessageInfo
{
public string Title { get; set; }
public string Message { get; set; }
public InfoBarSeverity Severity { get; set; }
public string Title { get; set; }
/// <summary>
/// The message of the InfoBar
/// </summary>
public string Message { get; set; }
/// <summary>
/// The severity of the InfoBar
/// </summary>
public InfoBarSeverity Severity { get; set; }

/// <summary>
/// Constructs an InfoBarMessageInfo
/// </summary>
/// <param name="title">The title of the InfoBar</param>
/// <param name="message">The message of the InfoBar</param>
/// <param name="severity">The severity of the InfoBar</param>
public InfoBarMessageInfo(string title = "", string message = "", InfoBarSeverity severity = InfoBarSeverity.Informational)
{
Title = title;
Message = message;
Severity = severity;
}
/// <summary>
/// Constructs an InfoBarMessageInfo
/// </summary>
/// <param name="title">The title of the InfoBar</param>
/// <param name="message">The message of the InfoBar</param>
/// <param name="severity">The severity of the InfoBar</param>
public InfoBarMessageInfo(string title = "", string message = "", InfoBarSeverity severity = InfoBarSeverity.Informational)
{
Title = title;
Message = message;
Severity = severity;
}
}
Loading

0 comments on commit 850b53d

Please sign in to comment.