Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9.0 SDK and Settings Refactor #25

Merged
merged 6 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

# Create the NuGet packages in the folder from the environment variable NuGetDirectory
- run: dotnet pack ./src/OneWare.Essentials/OneWare.Essentials.csproj --configuration Release --output ${{ env.NuGetDirectory }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-studio-linux-snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Build Snap
uses: snapcore/action-build@v1
id: build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-studio-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Publish
run: dotnet publish ./studio/OneWare.Studio.Desktop/OneWare.Studio.Desktop.csproj -c Release -r linux-x64 -o ./out
- name: Compress
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-studio-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-studio-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Install Wasm-Tools
run: dotnet workload install wasm-tools
- name: Publish
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-studio-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
# - name: Setup .NET
# uses: actions/setup-dotnet@v4
# with:
# dotnet-version: 8.0.x
# dotnet-version: 9.0.x
# - name: Install Wix
# run: dotnet tool install --global wix
- name: Publish
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Workload Restore
run: dotnet workload restore
- name: Restore dependencies
Expand Down
2 changes: 1 addition & 1 deletion build/props/OneWare.Module.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
14 changes: 7 additions & 7 deletions build/props/XUnit.props
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="xunit" Version="2.9.0"/>
<PackageReference Include="xunit" Version="2.9.2"/>
<PackageReference Include="xunit.abstractions" Version="2.0.3"/>
<PackageReference Include="xunit.assert" Version="2.9.0"/>
<PackageReference Include="xunit.core" Version="2.9.0"/>
<PackageReference Include="xunit.extensibility.core" Version="2.9.0"/>
<PackageReference Include="xunit.extensibility.execution" Version="2.9.0"/>
<PackageReference Include="xunit.runner.console" Version="2.9.0"/>
<PackageReference Include="xunit.assert" Version="2.9.2"/>
<PackageReference Include="xunit.core" Version="2.9.2"/>
<PackageReference Include="xunit.extensibility.core" Version="2.9.2"/>
<PackageReference Include="xunit.extensibility.execution" Version="2.9.2"/>
<PackageReference Include="xunit.runner.console" Version="2.9.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion demo/OneWare.Demo.Desktop/OneWare.Demo.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<OutputType Condition="'$(Configuration.toUpper())' != 'DEBUG'">WinExe</OutputType>
<OutputType Condition="'$(Configuration.toUpper())' == 'DEBUG'">Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ApplicationIcon>..\OneWare.Demo\Assets\icon.ico</ApplicationIcon>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand Down
58 changes: 33 additions & 25 deletions src/OneWare.Core/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using OneWare.Essentials.Commands;
using OneWare.Essentials.Helpers;
using OneWare.Essentials.LanguageService;
using OneWare.Essentials.Models;
using OneWare.Essentials.Services;
using OneWare.Essentials.ViewModels;
using OneWare.FolderProjectSystem;
Expand Down Expand Up @@ -129,30 +130,29 @@ protected override AvaloniaObject CreateShell()
settingsService.RegisterSettingCategory("Tools", 0, "FeatherIcons.Tool");

settingsService.RegisterSettingCategory("Languages", 0, "FluentIcons.ProofreadLanguageRegular");

settingsService.RegisterSetting("Editor", "Appearance", "Editor_FontFamily",
new ComboBoxSetting("Editor Font Family", "JetBrains Mono NL", ["JetBrains Mono NL", "IntelOne Mono", "Consolas", "Comic Sans MS", "Fira Code"]));

settingsService.RegisterSetting("Editor", "Appearance", "Editor_FontSize",
new ComboBoxSetting("Font Size", 15,Enumerable.Range(10, 30).Cast<object>()));

settingsService.RegisterTitledCombo("Editor", "Appearance", "Editor_FontFamily", "Font",
"Editor Font Family",
"JetBrains Mono NL",
"JetBrains Mono NL", "IntelOne Mono", "Consolas", "Comic Sans MS", "Fira Code");

settingsService.RegisterTitledCombo("Editor", "Appearance", "Editor_FontSize", "Font Size",
"Editor Font Size", 15, Enumerable.Range(10, 30).ToArray());

settingsService.RegisterTitledCombo("Editor", "Appearance", "Editor_SyntaxTheme_Dark", "Editor Theme Dark",
"Setts the theme for Syntax Highlighting in Dark Mode", ThemeName.DarkPlus,
Enum.GetValues<ThemeName>());

settingsService.RegisterTitledCombo("Editor", "Appearance", "Editor_SyntaxTheme_Light",
"Editor Theme Light",
"Setts the theme for Syntax Highlighting in Light Mode", ThemeName.LightPlus,
Enum.GetValues<ThemeName>());

//settingsService.RegisterTitled("Editor", "Appearance", "Editor_ErrorMarking_Mode", "Error Marking mode"); dfdf

settingsService.RegisterTitled("Editor", "Formatting", "Editor_UseAutoFormatting", "Use Auto Formatting",
"Use Auto Formatting in Editor", true);
settingsService.RegisterTitled("Editor", "Formatting", "Editor_UseAutoBracket", "Use Auto Bracket",
"Use Auto Bracket in Editor", true);
settingsService.RegisterSetting("Editor", "Appearance", "Editor_SyntaxTheme_Dark",
new ComboBoxSetting("Editor Theme Dark", ThemeName.DarkPlus,Enum.GetValues<ThemeName>().Cast<object>())
{
HoverDescription = "Sets the theme for Syntax Highlighting in Dark Mode"
});

settingsService.RegisterSetting("Editor", "Appearance", "Editor_SyntaxTheme_Light",
new ComboBoxSetting("Editor Theme Light", ThemeName.LightPlus,Enum.GetValues<ThemeName>().Cast<object>())
{
HoverDescription = "Sets the theme for Syntax Highlighting in Light Mode"
});

settingsService.RegisterSetting("Editor", "Formatting", "Editor_UseAutoFormatting",
new CheckBoxSetting("Use Auto Formatting", true));

settingsService.RegisterSetting("Editor", "Formatting", "Editor_UseAutoBracket", new CheckBoxSetting("Use Auto Bracket", true));

settingsService.RegisterTitled("Editor", "Folding", "Editor_UseFolding", "Use Folding",
"Use Folding in Editor", true);
Expand Down Expand Up @@ -256,11 +256,19 @@ protected override AvaloniaObject CreateShell()
var applicationCommandService = Container.Resolve<IApplicationCommandService>();

applicationCommandService.RegisterCommand(new SimpleApplicationCommand("Active light theme",
() => settingsService.SetSettingValue("General_SelectedTheme", "Light"),
() =>
{
settingsService.SetSettingValue("General_SelectedTheme", "Light");
settingsService.Save(paths.SettingsPath);
},
() => settingsService.GetSettingValue<string>("General_SelectedTheme") != "Light"));

applicationCommandService.RegisterCommand(new SimpleApplicationCommand("Active dark theme",
() => settingsService.SetSettingValue("General_SelectedTheme", "Dark"),
() =>
{
settingsService.SetSettingValue("General_SelectedTheme", "Dark");
settingsService.Save(paths.SettingsPath);
},
() => settingsService.GetSettingValue<string>("General_SelectedTheme") != "Dark"));

// applicationCommandService.RegisterCommand(new SimpleApplicationCommand("Show Success Notification",
Expand Down
56 changes: 37 additions & 19 deletions src/OneWare.Essentials/Models/Setting.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.ObjectModel;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Platform.Storage;
using CommunityToolkit.Mvvm.ComponentModel;
using DynamicData.Binding;
Expand Down Expand Up @@ -32,23 +33,34 @@ public virtual object Value
public object DefaultValue { get; }
}

public class TitledSetting : Setting
public abstract class TitledSetting : Setting
{
public TitledSetting(string title, string description, object defaultValue) : base(defaultValue)
public TitledSetting(string title, object defaultValue) : base(defaultValue)
{
Title = title;
Description = description;
}

public string Title { get; }

public string? HoverDescription { get; init; }

public string? MarkdownDocumentation { get; init; }

public IObservable<bool>? IsEnabledObservable { get; init; }

public IObservable<bool>? IsVisibleObservable { get; init; }
}

public string Description { get; }
public class CheckBoxSetting : TitledSetting
{
public CheckBoxSetting(string title, bool defaultValue) : base(title, defaultValue)
{
}
}

public class TextBoxSetting : TitledSetting
{
public TextBoxSetting(string title, string description, object defaultValue, string? watermark) : base(title,
description, defaultValue)
public TextBoxSetting(string title, object defaultValue, string? watermark) : base(title, defaultValue)
{
Watermark = watermark;
}
Expand All @@ -58,8 +70,7 @@ public TextBoxSetting(string title, string description, object defaultValue, str

public class ComboBoxSetting : TitledSetting
{
public ComboBoxSetting(string title, string description, object defaultValue, IEnumerable<object> options) : base(
title, description, defaultValue)
public ComboBoxSetting(string title, object defaultValue, IEnumerable<object> options) : base(title, defaultValue)
{
Options = options.ToArray();
}
Expand All @@ -69,8 +80,7 @@ public ComboBoxSetting(string title, string description, object defaultValue, IE

public class ListBoxSetting : TitledSetting
{
public ListBoxSetting(string title, string description, params string[] defaultValue) : base(
title, description, new ObservableCollection<string>(defaultValue))
public ListBoxSetting(string title, params string[] defaultValue) : base(title, new ObservableCollection<string>(defaultValue))
{
}

Expand All @@ -81,13 +91,13 @@ public ObservableCollection<string> Items
}
}

public class ComboBoxSearchSetting(string title, string description, object defaultValue, IEnumerable<object> options)
: ComboBoxSetting(title, description, defaultValue, options);
public class ComboBoxSearchSetting(string title, object defaultValue, IEnumerable<object> options)
: ComboBoxSetting(title, defaultValue, options);

public class SliderSetting : TitledSetting
{
public SliderSetting(string title, string description, double defaultValue, double min, double max, double step) : base(
title, description, defaultValue)
title, defaultValue)
{
Min = min;
Max = max;
Expand All @@ -105,8 +115,8 @@ public abstract class PathSetting : TextBoxSetting
{
private bool _isValid = true;

protected PathSetting(string title, string description, object defaultValue, string? watermark,
string? startDirectory, Func<string, bool>? checkPath) : base(title, description, defaultValue, watermark)
protected PathSetting(string title, string defaultValue, string? watermark,
string? startDirectory, Func<string, bool>? checkPath) : base(title, defaultValue, watermark)
{
StartDirectory = startDirectory;

Expand All @@ -131,9 +141,9 @@ public bool IsValid

public class FolderPathSetting : PathSetting
{
public FolderPathSetting(string title, string description, object defaultValue, string? watermark,
public FolderPathSetting(string title, string defaultValue, string? watermark,
string? startDirectory, Func<string, bool>? checkPath)
: base(title, description, defaultValue, watermark, startDirectory, checkPath)
: base(title, defaultValue, watermark, startDirectory, checkPath)
{
}

Expand All @@ -146,9 +156,9 @@ public override async Task SelectPathAsync(TopLevel topLevel)

public class FilePathSetting : PathSetting
{
public FilePathSetting(string title, string description, object defaultValue, string? watermark,
public FilePathSetting(string title, string defaultValue, string? watermark,
string? startDirectory, Func<string, bool>? checkPath, params FilePickerFileType[] filters)
: base(title, description, defaultValue, watermark, startDirectory, checkPath)
: base(title, defaultValue, watermark, startDirectory, checkPath)
{
Filters = filters;
}
Expand All @@ -162,6 +172,14 @@ public override async Task SelectPathAsync(TopLevel topLevel)
}
}

public class ColorSetting : TitledSetting
{
public ColorSetting(string title, Color defaultValue) : base(title, defaultValue)
{

}
}

public abstract class CustomSetting : Setting
{
public CustomSetting(object defaultValue) : base(defaultValue)
Expand Down
13 changes: 9 additions & 4 deletions src/OneWare.Essentials/Services/ISettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,38 @@ public void RegisterSettingSubCategory(string category, string subCategory, int

public IObservable<T> Bind<T>(string key, IObservable<T> observable);

[Obsolete("Use RegisterSetting instead")]
public void RegisterTitled<T>(string category, string subCategory, string key, string title, string description,
T defaultValue);

[Obsolete("Use RegisterTitledFolderPath instead")]
public void RegisterTitledPath(string category, string subCategory, string key, string title, string description,
string defaultValue, string? watermark, string? startDir, Func<string, bool>? validate);

[Obsolete("Use RegisterSetting instead")]
public void RegisterTitledFolderPath(string category, string subCategory, string key, string title, string description,
string defaultValue, string? watermark, string? startDir, Func<string, bool>? validate);

[Obsolete("Use RegisterSetting instead")]
public void RegisterTitledFilePath(string category, string subCategory, string key, string title, string description,
string defaultValue, string? watermark, string? startDir, Func<string, bool>? validate, params FilePickerFileType[] fileTypes);

[Obsolete("Use RegisterSetting instead")]
public void RegisterTitledSlider(string category, string subCategory, string key, string title, string description,
double defaultValue, double min, double max, double step);

[Obsolete("Use RegisterSetting instead")]
public void RegisterTitledCombo<T>(string category, string subCategory, string key, string title,
string description,
T defaultValue, params T[] options);

[Obsolete("Use RegisterSetting instead")]
public void RegisterTitledComboSearch<T>(string category, string subCategory, string key, string title,
string description,
T defaultValue, params T[] options);

[Obsolete("Use RegisterSetting instead")]
public void RegisterTitledListBox(string category, string subCategory, string key, string title,
string description, params string[] defaultValue);

public void RegisterSetting(string cateogory, string subCategory, string key, TitledSetting setting);

public void RegisterCustom(string category, string subCategory, string key, CustomSetting customSetting);

public T GetSettingValue<T>(string key);
Expand Down
Loading
Loading