Skip to content

Commit 0f3b02a

Browse files
Merge pull request #114 from atc-net/feature/BasicApplicationSettings
Feature/basic application settings
2 parents 30bd8f2 + 2933754 commit 0f3b02a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+941
-197
lines changed

.github/workflows/post-integration.yml

+1
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@ jobs:
8383
cd ${GITHUB_WORKSPACE}/packages
8484
dotnet nuget push Atc.Wpf.${{ env.NBGV_NuGetPackageVersion }}.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate
8585
dotnet nuget push Atc.Wpf.Controls.${{ env.NBGV_NuGetPackageVersion }}.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate
86+
dotnet nuget push Atc.Wpf.Controls.Sample.${{ env.NBGV_NuGetPackageVersion }}.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate
8687
dotnet nuget push Atc.Wpf.FontIcons.${{ env.NBGV_NuGetPackageVersion }}.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate
8788
dotnet nuget push Atc.Wpf.Theming.${{ env.NBGV_NuGetPackageVersion }}.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate

.github/workflows/release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ jobs:
5858
cd ${GITHUB_WORKSPACE}/packages
5959
dotnet nuget push Atc.Wpf.${{ env.NBGV_NuGetPackageVersion }}.nupkg -k ${{ secrets.NUGET_KEY }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate --no-symbols
6060
dotnet nuget push Atc.Wpf.Controls.${{ env.NBGV_NuGetPackageVersion }}.nupkg -k ${{ secrets.NUGET_KEY }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate --no-symbols
61+
dotnet nuget push Atc.Wpf.Controls.Sample.${{ env.NBGV_NuGetPackageVersion }}.nupkg -k ${{ secrets.NUGET_KEY }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate --no-symbols
6162
dotnet nuget push Atc.Wpf.FontIcons.${{ env.NBGV_NuGetPackageVersion }}.nupkg -k ${{ secrets.NUGET_KEY }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate --no-symbols
6263
dotnet nuget push Atc.Wpf.Theming.${{ env.NBGV_NuGetPackageVersion }}.nupkg -k ${{ secrets.NUGET_KEY }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate --no-symbols

Atc.Wpf.sln

+8-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{133AFD8A-A
3434
EndProject
3535
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atc.Wpf.Theming.Tests", "test\Atc.Wpf.Theming.Tests\Atc.Wpf.Theming.Tests.csproj", "{4E2CF798-516C-4A4B-8240-04476E6A9F65}"
3636
EndProject
37+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atc.Wpf.Controls.Sample", "src\Atc.Wpf.Controls.Sample\Atc.Wpf.Controls.Sample.csproj", "{F4BE59B5-26CB-46DB-B290-2049EF656693}"
38+
EndProject
3739
Global
3840
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3941
Debug|Any CPU = Debug|Any CPU
@@ -76,6 +78,10 @@ Global
7678
{4E2CF798-516C-4A4B-8240-04476E6A9F65}.Debug|Any CPU.Build.0 = Debug|Any CPU
7779
{4E2CF798-516C-4A4B-8240-04476E6A9F65}.Release|Any CPU.ActiveCfg = Release|Any CPU
7880
{4E2CF798-516C-4A4B-8240-04476E6A9F65}.Release|Any CPU.Build.0 = Release|Any CPU
81+
{F4BE59B5-26CB-46DB-B290-2049EF656693}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
82+
{F4BE59B5-26CB-46DB-B290-2049EF656693}.Debug|Any CPU.Build.0 = Debug|Any CPU
83+
{F4BE59B5-26CB-46DB-B290-2049EF656693}.Release|Any CPU.ActiveCfg = Release|Any CPU
84+
{F4BE59B5-26CB-46DB-B290-2049EF656693}.Release|Any CPU.Build.0 = Release|Any CPU
7985
EndGlobalSection
8086
GlobalSection(SolutionProperties) = preSolution
8187
HideSolutionNode = FALSE
@@ -90,9 +96,10 @@ Global
9096
{A44E762D-9D36-462E-91DC-FDA18058556F} = {4E909F95-FAC5-4A3F-AEC6-DEAB535BEC64}
9197
{BB036D9C-2C70-40FD-B997-338A46EE91AC} = {0FA723AA-8BA7-42AD-9C08-6491F364A258}
9298
{4E2CF798-516C-4A4B-8240-04476E6A9F65} = {2C893B25-2401-44B7-9FDA-7DC496C00D2B}
99+
{F4BE59B5-26CB-46DB-B290-2049EF656693} = {0FA723AA-8BA7-42AD-9C08-6491F364A258}
93100
EndGlobalSection
94101
GlobalSection(ExtensibilityGlobals) = postSolution
95-
SolutionGuid = {7A92D7EC-F444-456B-A86C-D6683E016C35}
96102
RESX_Rules = {"EnabledRules":["StringFormat","WhiteSpaceLead","WhiteSpaceTail","PunctuationTail"]}
103+
SolutionGuid = {7A92D7EC-F444-456B-A86C-D6683E016C35}
97104
EndGlobalSection
98105
EndGlobal

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ This is a base libraries for building WPF application with the MVVM design patte
3232

3333
## NuGet Packages Provided in this Repository
3434

35-
| Nuget package | Description | Dependencies |
36-
|-------------------|-----------------------------------------------------|---------------------------|
37-
| Atc.Wpf | Base Controls, ValueConverters, Extensions etc. | Atc |
38-
| Atc.FontIcons | Render Svg and Img resources based on fonts | Atc.Wpf |
39-
| Atc.Theming | Theming for Light & Dark mode for WPF base controls | Atc.Wpf |
40-
| Atc.Controls | Miscellaneous UI Controls | Atc.Wpf & Atc.Wpf.Theming |
35+
| Nuget package | Description | Dependencies |
36+
|---------------------|-----------------------------------------------------|---------------------------|
37+
| Atc.Wpf | Base Controls, ValueConverters, Extensions etc. | Atc |
38+
| Atc.FontIcons | Render Svg and Img resources based on fonts | Atc.Wpf |
39+
| Atc.Theming | Theming for Light & Dark mode for WPF base controls | Atc.Wpf |
40+
| Atc.Controls | Miscellaneous UI Controls | Atc.Wpf & Atc.Wpf.Theming |
41+
| Atc.Controls.Sample | Controls for creating WPF sample apps | Atc.Wpf & Atc.Wpf.Theming |
4142

4243
## Demonstration Application
4344

@@ -119,7 +120,6 @@ Therefore run the `Atc.Wpf.Sample` application to explore all the controls and c
119120
- [SvgImage](src/Atc.Wpf/Controls/Media/SvgImage_Readme.md)
120121
- Control Helpers
121122
- [PanelHelper](src/Atc.Wpf/Helpers/PanelHelper_Readme.md)
122-
- [SampleViewer](src/Atc.Wpf/SampleControls/SampleViewerView_Readme.md)
123123

124124
#### Misc
125125

sample/Atc.Wpf.Sample/App.xaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
x:Class="Atc.Wpf.Sample.App"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:atc="https://github.com/atc-net/atc-wpf/tree/main/schemas"
5+
xmlns:atcSample="clr-namespace:Atc.Wpf.Controls.Sample;assembly=Atc.Wpf.Controls.Sample"
66
xmlns:sample="clr-namespace:Atc.Wpf.Sample"
77
Exit="ApplicationExit"
88
Startup="ApplicationStartup">
@@ -20,7 +20,7 @@
2020
<Setter Property="Foreground" Value="{DynamicResource AtcApps.Brushes.ThemeForeground4}" />
2121
</Style>
2222

23-
<Style BasedOn="{StaticResource AtcApps.Styles.TreeViewItem}" TargetType="{x:Type atc:SampleTreeViewItem}">
23+
<Style BasedOn="{StaticResource AtcApps.Styles.TreeViewItem}" TargetType="{x:Type atcSample:SampleTreeViewItem}">
2424
<Setter Property="IsExpanded" Value="True" />
2525
<Setter Property="FontWeight" Value="Normal" />
2626
<Setter Property="Foreground" Value="{DynamicResource AtcApps.Brushes.ThemeForeground}" />

sample/Atc.Wpf.Sample/App.xaml.cs

+23-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Atc.Wpf.Sample;
77
public partial class App
88
{
99
private readonly IHost host;
10+
private IConfiguration? configuration;
1011

1112
public App()
1213
{
@@ -17,8 +18,22 @@ public App()
1718
.AddDebug()
1819
.SetMinimumLevel(LogLevel.Trace);
1920
})
21+
.ConfigureAppConfiguration((_, configurationBuilder) =>
22+
{
23+
configuration = configurationBuilder.SetBasePath(Directory.GetCurrentDirectory())
24+
.AddJsonFile(AtcFileNameConstants.AppSettings, optional: false, reloadOnChange: true)
25+
.AddJsonFile(AtcFileNameConstants.AppSettingsCustom, optional: true, reloadOnChange: true)
26+
.AddEnvironmentVariables()
27+
.Build();
28+
})
2029
.ConfigureServices((_, services) =>
2130
{
31+
services
32+
.AddOptions<BasicApplicationOptions>()
33+
.Bind(configuration!.GetRequiredSection(BasicApplicationOptions.SectionName))
34+
.ValidateDataAnnotations()
35+
.ValidateOnStart();
36+
2237
services.AddSingleton<IMainWindowViewModel, MainWindowViewModel>();
2338
services.AddSingleton<MainWindow>();
2439
})
@@ -103,17 +118,18 @@ await host
103118
.StartAsync()
104119
.ConfigureAwait(false);
105120

106-
CultureManager.SetCultures(
107-
GlobalizationConstants.EnglishCultureInfo,
108-
GlobalizationConstants.EnglishCultureInfo);
121+
var applicationOptions = new BasicApplicationOptions();
122+
configuration!
123+
.GetRequiredSection(BasicApplicationOptions.SectionName)
124+
.Bind(applicationOptions);
125+
126+
CultureManager.SetCultures(applicationOptions.Language);
127+
128+
ThemeManagerHelper.SetThemeAndAccent(Current, applicationOptions.Theme);
109129

110130
ColorHelper.InitializeWithSupportedLanguages();
111131
SolidColorBrushHelper.InitializeWithSupportedLanguages();
112132

113-
ThemeManager.Current.ChangeTheme(
114-
Current,
115-
"Light.Blue");
116-
117133
var mainWindow = host
118134
.Services
119135
.GetService<MainWindow>()!;

sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj

+20
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11+
<Compile Remove="AssemblyInfo.cs" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Remove="appsettings.custom.json" />
16+
<None Remove="appsettings.json" />
1117
<None Remove="Assets\a.svg" />
1218
<None Remove="Assets\atc.png" />
1319
<None Remove="Assets\eggeaster.svg" />
@@ -19,6 +25,18 @@
1925
<None Remove="Assets\warning.png" />
2026
</ItemGroup>
2127

28+
<ItemGroup>
29+
<Content Include="appsettings.custom.json">
30+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
31+
</Content>
32+
<Content Include="appsettings.json">
33+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
34+
</Content>
35+
<Content Include="AssemblyInfo.cs">
36+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
37+
</Content>
38+
</ItemGroup>
39+
2240
<ItemGroup>
2341
<Resource Include="Assets\a.svg" />
2442
<Resource Include="Assets\atc.png" />
@@ -35,11 +53,13 @@
3553
<PackageReference Include="Atc" Version="2.0.433" />
3654
<PackageReference Include="ControlzEx" Version="6.0.0" />
3755
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
56+
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
3857
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
3958
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
4059
</ItemGroup>
4160

4261
<ItemGroup>
62+
<ProjectReference Include="..\..\src\Atc.Wpf.Controls.Sample\Atc.Wpf.Controls.Sample.csproj" />
4363
<ProjectReference Include="..\..\src\Atc.Wpf.Controls\Atc.Wpf.Controls.csproj" />
4464
<ProjectReference Include="..\..\src\Atc.Wpf.FontIcons\Atc.Wpf.FontIcons.csproj" />
4565
<ProjectReference Include="..\..\src\Atc.Wpf.Theming\Atc.Wpf.Theming.csproj" />

sample/Atc.Wpf.Sample/GlobalUsings.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,23 @@
2727
global using Atc.Wpf.Controls.LabelControls.Writers;
2828
global using Atc.Wpf.Controls.Media;
2929
global using Atc.Wpf.Controls.Notifications;
30+
global using Atc.Wpf.Controls.Options;
31+
global using Atc.Wpf.Controls.Sample;
32+
global using Atc.Wpf.Controls.SettingsControls;
33+
global using Atc.Wpf.Data;
3034
global using Atc.Wpf.Diagnostics;
3135
global using Atc.Wpf.FontIcons;
3236
global using Atc.Wpf.FontIcons.ValueConverters;
3337
global using Atc.Wpf.Helpers;
3438
global using Atc.Wpf.Messaging;
3539
global using Atc.Wpf.Mvvm;
3640
global using Atc.Wpf.Sample.Models;
37-
global using Atc.Wpf.SampleControls;
3841
global using Atc.Wpf.Serialization.JsonConverters;
42+
global using Atc.Wpf.Theming.Helpers;
3943
global using Atc.Wpf.Translation;
4044

4145
global using ControlzEx.Theming;
42-
46+
global using Microsoft.Extensions.Configuration;
4347
global using Microsoft.Extensions.DependencyInjection;
4448
global using Microsoft.Extensions.Hosting;
4549
global using Microsoft.Extensions.Logging;

sample/Atc.Wpf.Sample/MainWindow.xaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
88
xmlns:sample="clr-namespace:Atc.Wpf.Sample"
9+
xmlns:sampleControls="clr-namespace:Atc.Wpf.Controls.Sample;assembly=Atc.Wpf.Controls.Sample"
910
Title="..:: Atc.Wpf.Sample ::.."
1011
Width="1600"
1112
Height="1000"
@@ -84,7 +85,7 @@
8485
Width="500"
8586
LabelWidthNumber="50"
8687
LabelWidthSizeDefinition="Pixel" />
87-
<atc:SampleViewerView
88+
<sampleControls:SampleViewerView
8889
x:Name="SampleViewer"
8990
Grid.Row="1"
9091
Grid.ColumnSpan="5"

sample/Atc.Wpf.Sample/SamplesWpf/SampleControls/SampleViewerView.xaml

-26
This file was deleted.

sample/Atc.Wpf.Sample/SamplesWpf/SampleControls/SampleViewerView.xaml.cs

-12
This file was deleted.

sample/Atc.Wpf.Sample/SamplesWpfControls/DialogBoxes/StandardDialogBoxView.xaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
77
xmlns:dialogBoxes="clr-namespace:Atc.Wpf.Sample.SamplesWpfControls.DialogBoxes"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9-
d:DesignHeight="450"
10-
d:DesignWidth="800"
9+
d:DesignHeight="800"
10+
d:DesignWidth="1000"
1111
mc:Ignorable="d">
1212

1313
<UserControl.DataContext>
@@ -123,6 +123,7 @@
123123
Content="Input Form - Account model without data" />
124124
</atc:GridEx>
125125
<Button Command="{Binding Path=ShowInputForm1ColumnByLabelControlsDataDialogBoxCommand}" Content="Input Form 1 columns by LabelControlsData" />
126+
<Button Command="{Binding Path=ShowBasicApplicationSettingsDialogBoxCommand}" Content="ApplicationSettings" />
126127
</atc:UniformSpacingPanel>
127128
<atc:UniformSpacingPanel
128129
Grid.Column="2"

sample/Atc.Wpf.Sample/SamplesWpfControls/DialogBoxes/StandardDialogBoxViewModel.cs

+27
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public StandardDialogBoxViewModel()
4747
public IRelayCommand ShowInputFormAccountWithoutDataDialogBoxCommands => new RelayCommand(ShowInputFormAccountWithoutDataDialogBoxCommandHandler);
4848

4949
public IRelayCommand ShowInputForm1ColumnByLabelControlsDataDialogBoxCommand => new RelayCommand(ShowInputForm1ColumnByLabelControlsDataDialogBoxCommandHandler);
50+
public IRelayCommand ShowBasicApplicationSettingsDialogBoxCommand => new RelayCommand(ShowBasicApplicationSettingsDialogBoxCommandHandler);
5051

5152
public bool ShowResultAsKeyValues
5253
{
@@ -614,6 +615,32 @@ private void ShowInputForm1ColumnByLabelControlsDataDialogBoxCommandHandler()
614615
}
615616
}
616617

618+
private void ShowBasicApplicationSettingsDialogBoxCommandHandler()
619+
{
620+
var dialogBox = new BasicApplicationSettingsDialogBox
621+
{
622+
DataContext = new BasicApplicationSettingsDialogBoxViewModel(
623+
new DirectoryInfo(@"C:\Temp"),
624+
new BasicApplicationSettingsViewModel(
625+
new BasicApplicationOptions
626+
{
627+
Theme = ThemeManager.Current.DetectTheme(Application.Current)!.Name,
628+
Language = CultureManager.UiCulture.Name,
629+
OpenRecentFileOnStartup = true,
630+
})),
631+
};
632+
633+
var dialogResult = dialogBox.ShowDialog();
634+
if (dialogResult.HasValue && dialogResult.Value)
635+
{
636+
JsonResult = dialogBox.GetDataAsJson();
637+
}
638+
else
639+
{
640+
JsonResult = "{}";
641+
}
642+
}
643+
617644
private static List<ILabelControlBase> CreateLabelControlsColumn1()
618645
=> new()
619646
{

0 commit comments

Comments
 (0)