This commit is contained in:
Holger Börchers 2020-02-28 21:32:32 +01:00
parent e6704c331f
commit 4293e60fa7
8 changed files with 17 additions and 1190 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<local:IntellisenseResources Source="/ModernWpf;component/DesignTime/DesignTimeResources.xaml" /> <local:IntellisenseResourceDictionary Source="/ModernWpf;component/DesignTime/DesignTimeResources.xaml" />
<ui:ThemeResources /> <ui:ThemeResources />
<ui:XamlControlsResources /> <ui:XamlControlsResources />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>

View File

@ -0,0 +1,7 @@
namespace ModernWpfPlayground
{
public class IntellisenseResourceDictionary : ModernWpf.DesignTime.IntellisenseResourcesBase
{
}
}

View File

@ -1,7 +0,0 @@
namespace ModernWpfPlayground
{
public class IntellisenseResources : ModernWpf.DesignTime.IntellisenseResourcesBase
{
}
}

View File

@ -8,10 +8,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ModernWpfUI" Version="0.8.1" /> <PackageReference Include="ModernWpfUI" Version="0.8.1" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" /> <PackageReference Include="System.Drawing.Common" Version="4.7.0" />
</ItemGroup> </ItemGroup>

View File

@ -1,11 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Windows;
using Microsoft.Win32;
namespace ModernWpfPlayground.MvvmStuff namespace ModernWpfPlayground.MvvmStuff
{ {
@ -13,7 +9,7 @@ namespace ModernWpfPlayground.MvvmStuff
{ {
private readonly Dictionary<string, object> _values = new Dictionary<string, object>(); private readonly Dictionary<string, object> _values = new Dictionary<string, object>();
public IReadOnlyDictionary<string, object> Values => _values; protected IReadOnlyDictionary<string, object> Values => _values;
protected bool SetProperty<T>(T value, Action<T>? onChanged = null, protected bool SetProperty<T>(T value, Action<T>? onChanged = null,
[CallerMemberName] string? propertyName = null) [CallerMemberName] string? propertyName = null)
@ -35,8 +31,6 @@ namespace ModernWpfPlayground.MvvmStuff
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
[NotifyPropertyChangedInvocator]
[PublicAPI]
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{ {
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName)); if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));

View File

@ -22,15 +22,16 @@ namespace ModernWpfPlayground.PropertyPresenter2
/// <summary> /// <summary>
/// Returns the content of a description attribute of an enum. /// Returns the content of a description attribute of an enum.
/// </summary> /// </summary>
/// <param name="enumValue"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>
private static string GetDescription(object enumValue) private static string GetDescription(object value)
{ {
if (!(value is Enum enumValue)) return string.Empty;
var descriptionAttribute = enumValue.GetType() var descriptionAttribute = enumValue.GetType()
.GetField(enumValue.ToString()).GetCustomAttributes(false) .GetField(enumValue.ToString()).GetCustomAttributes(false)
.OfType<DescriptionAttribute>().FirstOrDefault(); .OfType<DescriptionAttribute>().FirstOrDefault();
return descriptionAttribute?.Description ?? enumValue.ToString(); return descriptionAttribute?.Description ?? value.ToString();
} }
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

View File

@ -12,20 +12,20 @@ namespace ModernWpfPlayground.PropertyPresenter2
/// <summary> /// <summary>
/// Default data template. (currently Textbox) /// Default data template. (currently Textbox)
/// </summary> /// </summary>
public DataTemplate DefaultDataTemplate { private get; set; } public DataTemplate? DefaultDataTemplate { private get; set; }
/// <summary> /// <summary>
/// Data template for boolean. (currently Checkbox) /// Data template for boolean. (currently Checkbox)
/// </summary> /// </summary>
public DataTemplate BooleanDataTemplate { private get; set; } public DataTemplate? BooleanDataTemplate { private get; set; }
/// <summary> /// <summary>
/// Data template for enums. (currently Combobox) /// Data template for enums. (currently Combobox)
/// </summary> /// </summary>
public DataTemplate EnumComboBoxDataTemplate { private get; set; } public DataTemplate? EnumComboBoxDataTemplate { private get; set; }
/// <inheritdoc /> /// <inheritdoc />
public override DataTemplate SelectTemplate(object item, DependencyObject container) public override DataTemplate? SelectTemplate(object item, DependencyObject container)
{ {
return item switch return item switch
{ {