mirror of
https://github.com/holgerb83/ModernWpfPlayground.git
synced 2025-04-18 22:43:50 +02:00
features
This commit is contained in:
parent
48d244ea20
commit
ae6192bd1f
1
.gitignore
vendored
1
.gitignore
vendored
@ -338,3 +338,4 @@ ASALocalRun/
|
|||||||
|
|
||||||
# BeatPulse healthcheck temp database
|
# BeatPulse healthcheck temp database
|
||||||
healthchecksdb
|
healthchecksdb
|
||||||
|
.ionide
|
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -10,7 +10,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "build",
|
"preLaunchTask": "build",
|
||||||
// If you have changed target frameworks, make sure to update the program path.
|
// If you have changed target frameworks, make sure to update the program path.
|
||||||
"program": "${workspaceFolder}/App/bin/Debug/net5.0-windows10.0.18362.0/win-x64/ModernWpfPlayground.dll",
|
"program": "${workspaceFolder}/App/bin/Debug/net5.0-windows/win-x64/ModernWpfPlayground.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Windows;
|
using ModernWpf;
|
||||||
using ModernWpf;
|
|
||||||
using ModernWpfPlayground.Types;
|
using ModernWpfPlayground.Types;
|
||||||
|
|
||||||
namespace ModernWpfPlayground
|
namespace ModernWpfPlayground
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
using System.Windows;
|
|
||||||
|
|
||||||
[assembly:ThemeInfo(
|
[assembly:ThemeInfo(
|
||||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
//(used if a resource is not found in the page,
|
//(used if a resource is not found in the page,
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System.Windows;
|
namespace ModernWpfPlayground
|
||||||
|
|
||||||
namespace ModernWpfPlayground
|
|
||||||
{
|
{
|
||||||
public partial class ContentDialogExample
|
public partial class ContentDialogExample
|
||||||
{
|
{
|
||||||
|
3
App/GlobalUsings.cs
Normal file
3
App/GlobalUsings.cs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
global using System;
|
||||||
|
global using MvvmGen;
|
||||||
|
global using System.Windows;
|
@ -22,22 +22,10 @@
|
|||||||
<Window.DataContext>
|
<Window.DataContext>
|
||||||
<local:MainWindowViewModel />
|
<local:MainWindowViewModel />
|
||||||
</Window.DataContext>
|
</Window.DataContext>
|
||||||
<Window.Resources>
|
|
||||||
<local:PixelsToGridLengthConverter x:Key="PixelsToGridLength" />
|
|
||||||
</Window.Resources>
|
|
||||||
<Window.InputBindings>
|
<Window.InputBindings>
|
||||||
<KeyBinding
|
<KeyBinding Key="O" Modifiers="Control" />
|
||||||
Key="O"
|
<KeyBinding Key="S" Modifiers="Control" />
|
||||||
Command="{Binding OpenViewModelCommand}"
|
<KeyBinding Key="N" Modifiers="Control" />
|
||||||
Modifiers="Control" />
|
|
||||||
<KeyBinding
|
|
||||||
Key="S"
|
|
||||||
Command="{Binding SaveViewModelCommand}"
|
|
||||||
Modifiers="Control" />
|
|
||||||
<KeyBinding
|
|
||||||
Key="N"
|
|
||||||
Command="{Binding ResetViewModelCommand}"
|
|
||||||
Modifiers="Control" />
|
|
||||||
</Window.InputBindings>
|
</Window.InputBindings>
|
||||||
|
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
@ -58,7 +46,7 @@
|
|||||||
</Grid.Style>
|
</Grid.Style>
|
||||||
|
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="{Binding ElementName=Window, Path=(ui:TitleBar.SystemOverlayLeftInset), Converter={StaticResource PixelsToGridLength}}" />
|
<ColumnDefinition Width="{Binding ElementName=Window, Path=(ui:TitleBar.SystemOverlayLeftInset), Converter={local:PixelsToGridLengthConverter}}" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
@ -220,7 +208,7 @@
|
|||||||
</ui:SplitView.Pane>
|
</ui:SplitView.Pane>
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
<TabControl>
|
<TabControl>
|
||||||
<TabItem ui:ControlHelper.CornerRadius="0" Header="Bolt">
|
<TabItem Header="Bolt">
|
||||||
<ScrollViewer ui:ScrollViewerHelper.AutoHideScrollBars="True">
|
<ScrollViewer ui:ScrollViewerHelper.AutoHideScrollBars="True">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@ -246,12 +234,15 @@
|
|||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem
|
<TabItem
|
||||||
ui:ControlHelper.CornerRadius="0"
|
|
||||||
Header="General"
|
Header="General"
|
||||||
IsSelected="True">
|
IsSelected="True">
|
||||||
<ScrollViewer ui:ScrollViewerHelper.AutoHideScrollBars="True">
|
<ScrollViewer ui:ScrollViewerHelper.AutoHideScrollBars="True">
|
||||||
|
|
||||||
<ui:SimpleStackPanel Margin="5" Spacing="10">
|
<ui:SimpleStackPanel Margin="5" Spacing="10">
|
||||||
|
<ComboBox
|
||||||
|
DisplayMemberPath="Key"
|
||||||
|
ItemsSource="{Binding ThemeMode, Converter={controls:EnumToItemSourceConverter}}"
|
||||||
|
SelectedValue="{Binding ThemeMode}"
|
||||||
|
SelectedValuePath="Value" />
|
||||||
<controls:PropertyPresenter Label="Theme Mode" Value="{Binding ThemeMode}" />
|
<controls:PropertyPresenter Label="Theme Mode" Value="{Binding ThemeMode}" />
|
||||||
<controls:PropertyPresenter Label="Accent color" Value="{Binding AccentColors}" />
|
<controls:PropertyPresenter Label="Accent color" Value="{Binding AccentColors}" />
|
||||||
<controls:PropertyPresenter
|
<controls:PropertyPresenter
|
||||||
@ -264,10 +255,9 @@
|
|||||||
Label="Hallo"
|
Label="Hallo"
|
||||||
Symbol="x²"
|
Symbol="x²"
|
||||||
Value="{Binding ValidationTest, UpdateSourceTrigger=PropertyChanged}" />
|
Value="{Binding ValidationTest, UpdateSourceTrigger=PropertyChanged}" />
|
||||||
<controls:PropertyPresenter
|
<controls:PropertyPresenter Label="Good bye" Symbol="x²">
|
||||||
Label="Good bye"
|
<ui:NumberBox SpinButtonPlacementMode="Compact" Value="{Binding ValidationTest, UpdateSourceTrigger=PropertyChanged}" />
|
||||||
Symbol="x²"
|
</controls:PropertyPresenter>
|
||||||
Value="{Binding ValidationTest, UpdateSourceTrigger=PropertyChanged}" />
|
|
||||||
<Grid Margin="0,5">
|
<Grid Margin="0,5">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using ModernWpfPlayground.Types;
|
using ModernWpfPlayground.Types;
|
||||||
using MvvmGen;
|
|
||||||
using System.Windows;
|
|
||||||
using static ModernWpf.ThemeManager;
|
using static ModernWpf.ThemeManager;
|
||||||
|
|
||||||
namespace ModernWpfPlayground
|
namespace ModernWpfPlayground
|
||||||
@ -83,6 +81,5 @@ namespace ModernWpfPlayground
|
|||||||
//
|
//
|
||||||
// File.WriteAllText(Path, contents);
|
// File.WriteAllText(Path, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,27 +2,31 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net5.0-windows10.0.18362.0</TargetFramework>
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<PublishSingleFile>true</PublishSingleFile>
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
<SelfContained>true</SelfContained>
|
<SelfContained>true</SelfContained>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
<PublishTrimmed>true</PublishTrimmed>
|
|
||||||
<PublishReadyToRun>true</PublishReadyToRun>
|
<PublishReadyToRun>true</PublishReadyToRun>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FastMember" Version="1.5.0" />
|
<PackageReference Include="FastMember" Version="1.5.0" />
|
||||||
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
|
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
|
||||||
<PackageReference Include="ModernWpfUI" Version="0.9.4" />
|
<PackageReference Include="ModernWpfUis" Version="1.2.0" />
|
||||||
<PackageReference Include="MvvmGen" Version="1.1.1" />
|
<PackageReference Include="MvvmGen" Version="1.1.1" />
|
||||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||||
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.8.0" />
|
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.11.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Controls\Controls.csproj" />
|
<ProjectReference Include="..\Controls\Controls.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="MvvmStuff" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Globalization;
|
|
||||||
|
|
||||||
namespace ModernWpfPlayground.MvvmStuff
|
|
||||||
{
|
|
||||||
public static class DeserializationExtension
|
|
||||||
{
|
|
||||||
public static object? Convert(object? value, Type propertyType)
|
|
||||||
{
|
|
||||||
if (value is null) return Activator.CreateInstance(propertyType);
|
|
||||||
|
|
||||||
if (propertyType.IsEnum && value is string s)
|
|
||||||
{
|
|
||||||
return Enum.Parse(propertyType, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
return System.Convert.ChangeType(value, propertyType, CultureInfo.InvariantCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System.Globalization;
|
||||||
using System.Globalization;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Markup;
|
||||||
|
|
||||||
namespace ModernWpfPlayground
|
namespace ModernWpfPlayground
|
||||||
{
|
{
|
||||||
public class PixelsToGridLengthConverter : IValueConverter
|
public class PixelsToGridLengthConverter : MarkupExtension, IValueConverter
|
||||||
{
|
{
|
||||||
|
private static PixelsToGridLengthConverter? _converter;
|
||||||
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
return value is double d ? new GridLength(d) : new GridLength(1.0, GridUnitType.Auto);
|
return value is double d ? new GridLength(d) : new GridLength(1.0, GridUnitType.Auto);
|
||||||
@ -16,5 +17,8 @@ namespace ModernWpfPlayground
|
|||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override object ProvideValue(IServiceProvider serviceProvider) =>
|
||||||
|
_converter ??= new PixelsToGridLengthConverter();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace ModernWpfPlayground.Types
|
namespace ModernWpfPlayground.Types
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.ComponentModel;
|
||||||
using System.ComponentModel;
|
|
||||||
using ModernWpf;
|
using ModernWpf;
|
||||||
|
|
||||||
namespace ModernWpfPlayground.Types
|
namespace ModernWpfPlayground.Types
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0-windows</TargetFramework>
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -4,17 +4,20 @@ using System.ComponentModel;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Markup;
|
||||||
|
|
||||||
namespace Controls
|
namespace Controls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts enums to a List with KeyValuePairs.
|
/// Converts enums to a List with KeyValuePairs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EnumToKeyValueListConverter : IValueConverter
|
public class EnumToItemSourceConverter : MarkupExtension, IValueConverter
|
||||||
{
|
{
|
||||||
|
private static EnumToItemSourceConverter? _converter;
|
||||||
|
|
||||||
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
if (!(value is Enum)) return Binding.DoNothing;
|
if (value is not Enum) return Binding.DoNothing;
|
||||||
return (from object enumValue in Enum.GetValues(value.GetType())
|
return (from object enumValue in Enum.GetValues(value.GetType())
|
||||||
select new KeyValuePair<string, object>(GetDescription(enumValue), enumValue)).ToList();
|
select new KeyValuePair<string, object>(GetDescription(enumValue), enumValue)).ToList();
|
||||||
}
|
}
|
||||||
@ -40,5 +43,7 @@ namespace Controls
|
|||||||
{
|
{
|
||||||
return Binding.DoNothing;
|
return Binding.DoNothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override object ProvideValue(IServiceProvider serviceProvider) => _converter ??= new EnumToItemSourceConverter();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -86,12 +86,11 @@
|
|||||||
</CheckBox.Style>
|
</CheckBox.Style>
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<controls:EnumToKeyValueListConverter x:Key="EnumToKeyValuePairConverter" />
|
|
||||||
<DataTemplate x:Key="EnumComboBoxDataTemplate">
|
<DataTemplate x:Key="EnumComboBoxDataTemplate">
|
||||||
<ComboBox
|
<ComboBox
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
DisplayMemberPath="Key"
|
DisplayMemberPath="Key"
|
||||||
ItemsSource="{Binding Value, ElementName=LayoutRoot, Converter={StaticResource EnumToKeyValuePairConverter}}"
|
ItemsSource="{Binding Value, ElementName=LayoutRoot, Converter={controls:EnumToItemSourceConverter}}"
|
||||||
SelectedValue="{Binding Value, ElementName=LayoutRoot}"
|
SelectedValue="{Binding Value, ElementName=LayoutRoot}"
|
||||||
SelectedValuePath="Value"
|
SelectedValuePath="Value"
|
||||||
Validation.ErrorTemplate="{DynamicResource ValidationErrorTemplate}"
|
Validation.ErrorTemplate="{DynamicResource ValidationErrorTemplate}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user