-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
207 changed files
with
2,168 additions
and
2,489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"version": "1.0", | ||
"components": [ | ||
"Microsoft.Component.MSBuild", | ||
"Microsoft.NetCore.Component.Runtime.7.0", | ||
"Microsoft.NetCore.Component.SDK", | ||
"Microsoft.VisualStudio.Component.ManagedDesktop.Core", | ||
"Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites", | ||
"Microsoft.VisualStudio.Component.NuGet", | ||
"Microsoft.VisualStudio.Component.Windows10SDK.19041", | ||
"Microsoft.VisualStudio.Component.Windows10SDK", | ||
"Microsoft.VisualStudio.ComponentGroup.MSIX.Packaging", | ||
"Microsoft.VisualStudio.ComponentGroup.WindowsAppSDK.Cs", | ||
"Microsoft.VisualStudio.Workload.ManagedDesktop" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace EasyPlot.Core.Contracts.Services; | ||
|
||
public interface IFileService | ||
{ | ||
T Read<T>(string folderPath, string fileName); | ||
|
||
void Save<T>(string folderPath, string fileName, T content); | ||
|
||
void Delete(string folderPath, string fileName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<RootNamespace>EasyPlot.Core</RootNamespace> | ||
<Platforms>x86;x64;arm64;AnyCPU</Platforms> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Models\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace EasyPlot.Core.Helpers; | ||
|
||
public static class Json | ||
{ | ||
public static async Task<T> ToObjectAsync<T>(string value) | ||
{ | ||
return await Task.Run<T>(() => | ||
{ | ||
return JsonConvert.DeserializeObject<T>(value); | ||
}); | ||
} | ||
|
||
public static async Task<string> StringifyAsync(object value) | ||
{ | ||
return await Task.Run<string>(() => | ||
{ | ||
return JsonConvert.SerializeObject(value); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*Recommended Markdown Viewer: [Markdown Editor](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor2)* | ||
|
||
## Getting Started | ||
|
||
The Core project contains code that can be [reused across multiple application projects](https://docs.microsoft.com/dotnet/standard/net-standard#net-5-and-net-standard). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Text; | ||
|
||
using EasyPlot.Core.Contracts.Services; | ||
|
||
using Newtonsoft.Json; | ||
|
||
namespace EasyPlot.Core.Services; | ||
|
||
public class FileService : IFileService | ||
{ | ||
public T Read<T>(string folderPath, string fileName) | ||
{ | ||
var path = Path.Combine(folderPath, fileName); | ||
if (File.Exists(path)) | ||
{ | ||
var json = File.ReadAllText(path); | ||
return JsonConvert.DeserializeObject<T>(json); | ||
} | ||
|
||
return default; | ||
} | ||
|
||
public void Save<T>(string folderPath, string fileName, T content) | ||
{ | ||
if (!Directory.Exists(folderPath)) | ||
{ | ||
Directory.CreateDirectory(folderPath); | ||
} | ||
|
||
var fileContent = JsonConvert.SerializeObject(content); | ||
File.WriteAllText(Path.Combine(folderPath, fileName), fileContent, Encoding.UTF8); | ||
} | ||
|
||
public void Delete(string folderPath, string fileName) | ||
{ | ||
if (fileName != null && File.Exists(Path.Combine(folderPath, fileName))) | ||
{ | ||
File.Delete(Path.Combine(folderPath, fileName)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,69 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31611.283 | ||
VisualStudioVersion = 17.6.33723.286 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyPlot", "EasyPlot\EasyPlot.csproj", "{DF00CE43-F52A-4692-B984-16BDAAABDEE0}" | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyPlot", "EasyPlot\EasyPlot.csproj", "{B5478F20-6EEA-4E63-A93D-ABA24B059B35}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyPlot.Core", "EasyPlot.Core\EasyPlot.Core.csproj", "{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|arm64 = Debug|arm64 | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|arm64 = Release|arm64 | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{DF00CE43-F52A-4692-B984-16BDAAABDEE0}.Debug|x64.ActiveCfg = Debug|x64 | ||
{DF00CE43-F52A-4692-B984-16BDAAABDEE0}.Debug|x64.Build.0 = Debug|x64 | ||
{DF00CE43-F52A-4692-B984-16BDAAABDEE0}.Debug|x64.Deploy.0 = Debug|x64 | ||
{DF00CE43-F52A-4692-B984-16BDAAABDEE0}.Release|x64.ActiveCfg = Release|x64 | ||
{DF00CE43-F52A-4692-B984-16BDAAABDEE0}.Release|x64.Build.0 = Release|x64 | ||
{DF00CE43-F52A-4692-B984-16BDAAABDEE0}.Release|x64.Deploy.0 = Release|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|Any CPU.ActiveCfg = Debug|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|Any CPU.Build.0 = Debug|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|Any CPU.Deploy.0 = Debug|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|arm64.ActiveCfg = Debug|arm64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|arm64.Build.0 = Debug|arm64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|arm64.Deploy.0 = Debug|arm64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|x64.ActiveCfg = Debug|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|x64.Build.0 = Debug|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|x64.Deploy.0 = Debug|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|x86.ActiveCfg = Debug|x86 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|x86.Build.0 = Debug|x86 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Debug|x86.Deploy.0 = Debug|x86 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|Any CPU.ActiveCfg = Release|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|Any CPU.Build.0 = Release|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|Any CPU.Deploy.0 = Release|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|arm64.ActiveCfg = Release|arm64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|arm64.Build.0 = Release|arm64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|arm64.Deploy.0 = Release|arm64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|x64.ActiveCfg = Release|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|x64.Build.0 = Release|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|x64.Deploy.0 = Release|x64 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|x86.ActiveCfg = Release|x86 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|x86.Build.0 = Release|x86 | ||
{B5478F20-6EEA-4E63-A93D-ABA24B059B35}.Release|x86.Deploy.0 = Release|x86 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Debug|arm64.ActiveCfg = Debug|arm64 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Debug|arm64.Build.0 = Debug|arm64 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Debug|x64.ActiveCfg = Debug|x64 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Debug|x64.Build.0 = Debug|x64 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Debug|x86.ActiveCfg = Debug|x86 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Debug|x86.Build.0 = Debug|x86 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Release|arm64.ActiveCfg = Release|arm64 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Release|arm64.Build.0 = Release|arm64 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Release|x64.ActiveCfg = Release|x64 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Release|x64.Build.0 = Release|x64 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Release|x86.ActiveCfg = Release|x86 | ||
{1436CA9A-B9B4-4C50-BD11-960FC8DB3CF4}.Release|x86.Build.0 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572} | ||
SolutionGuid = {A9795F5A-D0C1-4F90-ACAF-14819F4947D6} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace EasyPlot.Activation; | ||
|
||
// Extend this class to implement new ActivationHandlers. See DefaultActivationHandler for an example. | ||
// https://github.com/microsoft/TemplateStudio/blob/main/docs/WinUI/activation.md | ||
public abstract class ActivationHandler<T> : IActivationHandler | ||
where T : class | ||
{ | ||
// Override this method to add the logic for whether to handle the activation. | ||
protected virtual bool CanHandleInternal(T args) => true; | ||
|
||
// Override this method to add the logic for your activation handler. | ||
protected abstract Task HandleInternalAsync(T args); | ||
|
||
public bool CanHandle(object args) => args is T && CanHandleInternal((args as T)!); | ||
|
||
public async Task HandleAsync(object args) => await HandleInternalAsync((args as T)!); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using EasyPlot.Contracts.Services; | ||
using EasyPlot.ViewModels; | ||
|
||
using Microsoft.UI.Xaml; | ||
|
||
namespace EasyPlot.Activation; | ||
|
||
public class DefaultActivationHandler : ActivationHandler<LaunchActivatedEventArgs> | ||
{ | ||
private readonly INavigationService _navigationService; | ||
|
||
public DefaultActivationHandler(INavigationService navigationService) | ||
{ | ||
_navigationService = navigationService; | ||
} | ||
|
||
protected override bool CanHandleInternal(LaunchActivatedEventArgs args) | ||
{ | ||
// None of the ActivationHandlers has handled the activation. | ||
return _navigationService.Frame?.Content == null; | ||
} | ||
|
||
protected async override Task HandleInternalAsync(LaunchActivatedEventArgs args) | ||
{ | ||
_navigationService.NavigateTo(typeof(MainViewModel).FullName!, args.Arguments); | ||
|
||
await Task.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace EasyPlot.Activation; | ||
|
||
public interface IActivationHandler | ||
{ | ||
bool CanHandle(object args); | ||
|
||
Task HandleAsync(object args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,95 @@ | ||
namespace OUCC.EasyPlot; | ||
using EasyPlot.Activation; | ||
using EasyPlot.Contracts.Services; | ||
using EasyPlot.Core.Contracts.Services; | ||
using EasyPlot.Core.Services; | ||
using EasyPlot.Helpers; | ||
using EasyPlot.Models; | ||
using EasyPlot.Services; | ||
using EasyPlot.ViewModels; | ||
using EasyPlot.Views; | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.UI.Xaml; | ||
|
||
namespace EasyPlot; | ||
|
||
// To learn more about WinUI 3, see https://docs.microsoft.com/windows/apps/winui/winui3/. | ||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
// The .NET Generic Host provides dependency injection, configuration, logging, and other services. | ||
// https://docs.microsoft.com/dotnet/core/extensions/generic-host | ||
// https://docs.microsoft.com/dotnet/core/extensions/dependency-injection | ||
// https://docs.microsoft.com/dotnet/core/extensions/configuration | ||
// https://docs.microsoft.com/dotnet/core/extensions/logging | ||
public IHost Host | ||
{ | ||
get; | ||
} | ||
|
||
public static T GetService<T>() | ||
where T : class | ||
{ | ||
if ((App.Current as App)!.Host.Services.GetService(typeof(T)) is not T service) | ||
{ | ||
throw new ArgumentException($"{typeof(T)} needs to be registered in ConfigureServices within App.xaml.cs."); | ||
} | ||
|
||
return service; | ||
} | ||
|
||
public static WindowEx MainWindow { get; } = new MainWindow(); | ||
|
||
public static UIElement? AppTitlebar { get; set; } | ||
|
||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
Host = Microsoft.Extensions.Hosting.Host. | ||
CreateDefaultBuilder(). | ||
UseContentRoot(AppContext.BaseDirectory). | ||
ConfigureServices((context, services) => | ||
{ | ||
// Default Activation Handler | ||
services.AddTransient<ActivationHandler<LaunchActivatedEventArgs>, DefaultActivationHandler>(); | ||
// Other Activation Handlers | ||
// Services | ||
services.AddSingleton<ILocalSettingsService, LocalSettingsService>(); | ||
services.AddSingleton<IThemeSelectorService, ThemeSelectorService>(); | ||
services.AddSingleton<IActivationService, ActivationService>(); | ||
services.AddSingleton<IPageService, PageService>(); | ||
services.AddSingleton<INavigationService, NavigationService>(); | ||
// Core Services | ||
services.AddSingleton<IFileService, FileService>(); | ||
// Views and ViewModels | ||
services.AddTransient<SettingsViewModel>(); | ||
services.AddTransient<SettingsPage>(); | ||
services.AddSingleton<MainViewModel>(); | ||
services.AddTransient<MainPage>(); | ||
// Configuration | ||
services.Configure<LocalSettingsOptions>(context.Configuration.GetSection(nameof(LocalSettingsOptions))); | ||
}). | ||
Build(); | ||
|
||
UnhandledException += App_UnhandledException; | ||
} | ||
|
||
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) | ||
{ | ||
// TODO: Log and handle exceptions as appropriate. | ||
// https://docs.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.application.unhandledexception. | ||
} | ||
|
||
protected async override void OnLaunched(LaunchActivatedEventArgs args) | ||
{ | ||
base.OnLaunched(args); | ||
|
||
MainPage = new AppShell(); | ||
} | ||
await App.GetService<IActivationService>().ActivateAsync(args); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.