mirror of
https://github.com/holgerb83/ModernWpfPlayground.git
synced 2025-06-29 17:30:52 +02:00
file-scoped namespaces and update of modernwpfui
This commit is contained in:
@ -14,9 +14,9 @@
|
|||||||
<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="ModernWpfUis" Version="1.2.0" />
|
<PackageReference Include="ModernWpfUI" Version="0.9.7-preview.2" />
|
||||||
<PackageReference Include="MvvmGen" Version="1.1.2" />
|
<PackageReference Include="MvvmGen" Version="1.1.5" />
|
||||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
<PackageReference Include="YamlDotNet" Version="12.0.2" />
|
||||||
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.11.0" />
|
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.11.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace ModernWpfPlayground.Types
|
namespace ModernWpfPlayground.Types;
|
||||||
|
|
||||||
|
public enum AccentColors
|
||||||
{
|
{
|
||||||
public enum AccentColors
|
|
||||||
{
|
|
||||||
Green,
|
Green,
|
||||||
Yellow,
|
Yellow,
|
||||||
Blue,
|
Blue,
|
||||||
Purple,
|
Purple,
|
||||||
Red
|
Red
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AccentColorExtension
|
public static class AccentColorExtension
|
||||||
{
|
{
|
||||||
public static Color ToWindowsColor(this AccentColors accentColor)
|
public static Color ToWindowsColor(this AccentColors accentColor)
|
||||||
{
|
{
|
||||||
return accentColor switch
|
return accentColor switch
|
||||||
@ -26,5 +26,4 @@ namespace ModernWpfPlayground.Types
|
|||||||
_ => throw new ArgumentOutOfRangeException(nameof(accentColor), accentColor, null)
|
_ => throw new ArgumentOutOfRangeException(nameof(accentColor), accentColor, null)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -6,13 +6,13 @@ using System.Linq;
|
|||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Markup;
|
using System.Windows.Markup;
|
||||||
|
|
||||||
namespace Controls
|
namespace Controls;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts enums to a List with KeyValuePairs.
|
||||||
|
/// </summary>
|
||||||
|
public class EnumToItemSourceConverter : MarkupExtension, IValueConverter
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Converts enums to a List with KeyValuePairs.
|
|
||||||
/// </summary>
|
|
||||||
public class EnumToItemSourceConverter : MarkupExtension, IValueConverter
|
|
||||||
{
|
|
||||||
private static EnumToItemSourceConverter? _converter;
|
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)
|
||||||
@ -45,5 +45,4 @@ namespace Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override object ProvideValue(IServiceProvider serviceProvider) => _converter ??= new EnumToItemSourceConverter();
|
public override object ProvideValue(IServiceProvider serviceProvider) => _converter ??= new EnumToItemSourceConverter();
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,14 +2,14 @@
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Markup;
|
using System.Windows.Markup;
|
||||||
|
|
||||||
namespace Controls
|
namespace Controls;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for <see cref="MagicSymbolControl"/>
|
||||||
|
/// </summary>
|
||||||
|
[ContentProperty(nameof(Symbol))]
|
||||||
|
public class MagicSymbolControl : ContentControl
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for <see cref="MagicSymbolControl"/>
|
|
||||||
/// </summary>
|
|
||||||
[ContentProperty(nameof(Symbol))]
|
|
||||||
public class MagicSymbolControl : ContentControl
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dependency property for <see cref="Symbol"/> property
|
/// Dependency property for <see cref="Symbol"/> property
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -39,5 +39,4 @@ namespace Controls
|
|||||||
{
|
{
|
||||||
Focusable = false;
|
Focusable = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,14 +8,14 @@ using System.Windows.Data;
|
|||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace Controls
|
namespace Controls;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Magically converts a text to
|
||||||
|
/// </summary>
|
||||||
|
[ValueConversion(typeof(string), typeof(FrameworkElement))]
|
||||||
|
public class MagicSymbolConverter : IValueConverter
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Magically converts a text to
|
|
||||||
/// </summary>
|
|
||||||
[ValueConversion(typeof(string), typeof(FrameworkElement))]
|
|
||||||
public class MagicSymbolConverter : IValueConverter
|
|
||||||
{
|
|
||||||
private const string NoParseKeyword = "noParse:";
|
private const string NoParseKeyword = "noParse:";
|
||||||
private const string PathKeyword = "path:";
|
private const string PathKeyword = "path:";
|
||||||
private const string DynResKeyword = "dynRes:";
|
private const string DynResKeyword = "dynRes:";
|
||||||
@ -148,5 +148,4 @@ namespace Controls
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
=> Binding.DoNothing;
|
=> Binding.DoNothing;
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,13 +2,13 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
||||||
namespace Controls
|
namespace Controls;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selects the right template on base of value-type.
|
||||||
|
/// </summary>
|
||||||
|
public class PropertyDataTemplateSelector : DataTemplateSelector
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Selects the right template on base of value-type.
|
|
||||||
/// </summary>
|
|
||||||
public class PropertyDataTemplateSelector : DataTemplateSelector
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default data template. (currently Textbox)
|
/// Default data template. (currently Textbox)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -35,5 +35,4 @@ namespace Controls
|
|||||||
_ => DefaultDataTemplate
|
_ => DefaultDataTemplate
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,15 +3,15 @@ using System.Windows.Controls;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Markup;
|
using System.Windows.Markup;
|
||||||
|
|
||||||
namespace Controls
|
namespace Controls;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ContentControl" />
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for PropertyPresenter.xaml
|
||||||
|
/// </summary>
|
||||||
|
[ContentProperty(nameof(Value))]
|
||||||
|
public sealed partial class PropertyPresenter
|
||||||
{
|
{
|
||||||
/// <inheritdoc cref="ContentControl" />
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for PropertyPresenter.xaml
|
|
||||||
/// </summary>
|
|
||||||
[ContentProperty(nameof(Value))]
|
|
||||||
public sealed partial class PropertyPresenter
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Button alignment property.
|
/// Button alignment property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -177,5 +177,4 @@ namespace Controls
|
|||||||
{
|
{
|
||||||
return $"{base.ToString()} {Value}";
|
return $"{base.ToString()} {Value}";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,39 +2,39 @@
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Controls
|
namespace Controls;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a TextBox that can update the binding on enter.
|
||||||
|
/// </summary>
|
||||||
|
public class TextBoxEx : TextBox
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a TextBox that can update the binding on enter.
|
|
||||||
/// </summary>
|
|
||||||
public class TextBoxEx : TextBox
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Identifies the <see cref="MoveFocusOnEnter"/> dependency property.
|
/// Identifies the <see cref="MoveFocusOnEnter"/> dependency property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly DependencyProperty MoveFocusOnEnterProperty =
|
public static readonly DependencyProperty MoveFocusOnEnterProperty =
|
||||||
DependencyProperty.Register(
|
DependencyProperty.Register(
|
||||||
"MoveFocusOnEnter", typeof(bool), typeof(TextBoxEx), new UIPropertyMetadata(true));
|
nameof(MoveFocusOnEnter), typeof(bool), typeof(TextBoxEx), new UIPropertyMetadata(true));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Identifies the <see cref="UpdateBindingOnEnter"/> dependency property.
|
/// Identifies the <see cref="UpdateBindingOnEnter"/> dependency property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly DependencyProperty UpdateBindingOnEnterProperty =
|
public static readonly DependencyProperty UpdateBindingOnEnterProperty =
|
||||||
DependencyProperty.Register(
|
DependencyProperty.Register(
|
||||||
"UpdateBindingOnEnter", typeof(bool), typeof(TextBoxEx), new UIPropertyMetadata(true));
|
nameof(UpdateBindingOnEnter), typeof(bool), typeof(TextBoxEx), new UIPropertyMetadata(true));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Identifies the <see cref="ScrollToHomeOnFocus"/> dependency property.
|
/// Identifies the <see cref="ScrollToHomeOnFocus"/> dependency property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly DependencyProperty ScrollToHomeOnFocusProperty =
|
public static readonly DependencyProperty ScrollToHomeOnFocusProperty =
|
||||||
DependencyProperty.Register("ScrollToHomeOnFocus", typeof(bool), typeof(TextBoxEx), new PropertyMetadata(true));
|
DependencyProperty.Register(nameof(ScrollToHomeOnFocus), typeof(bool), typeof(TextBoxEx), new PropertyMetadata(true));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Identifies the <see cref="SelectAllOnFocus"/> dependency property.
|
/// Identifies the <see cref="SelectAllOnFocus"/> dependency property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly DependencyProperty SelectAllOnFocusProperty =
|
public static readonly DependencyProperty SelectAllOnFocusProperty =
|
||||||
DependencyProperty.Register("SelectAllOnFocus", typeof(bool), typeof(TextBoxEx), new PropertyMetadata(true));
|
DependencyProperty.Register(nameof(SelectAllOnFocus), typeof(bool), typeof(TextBoxEx), new PropertyMetadata(true));
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -161,5 +161,4 @@ namespace Controls
|
|||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace Controls
|
namespace Controls;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A component of the symbol
|
||||||
|
/// </summary>
|
||||||
|
public readonly struct TextComponent
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A component of the symbol
|
|
||||||
/// </summary>
|
|
||||||
public readonly struct TextComponent
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -27,5 +27,4 @@ namespace Controls
|
|||||||
/// Style of the symbol component
|
/// Style of the symbol component
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly BaselineAlignment Style;
|
public readonly BaselineAlignment Style;
|
||||||
}
|
|
||||||
}
|
}
|
@ -11,13 +11,13 @@ using Brushes = System.Windows.Media.Brushes;
|
|||||||
using FontFamily = System.Windows.Media.FontFamily;
|
using FontFamily = System.Windows.Media.FontFamily;
|
||||||
using Point = System.Windows.Point;
|
using Point = System.Windows.Point;
|
||||||
|
|
||||||
namespace Controls
|
namespace Controls;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Makes an Bitmap from every Imageformat.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class ObjectImageConverter : IValueConverter
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Makes an Bitmap from every Imageformat.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class ObjectImageConverter : IValueConverter
|
|
||||||
{
|
|
||||||
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
const string dynResPrefix = "dynRes:";
|
const string dynResPrefix = "dynRes:";
|
||||||
@ -82,19 +82,18 @@ namespace Controls
|
|||||||
var geometry = formattedText.BuildGeometry(new Point(0, 0));
|
var geometry = formattedText.BuildGeometry(new Point(0, 0));
|
||||||
return GetIcon(geometry, null);
|
return GetIcon(geometry, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invert boolean converter
|
/// Invert boolean converter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ValueConversion(typeof(bool), typeof(bool))]
|
[ValueConversion(typeof(bool), typeof(bool))]
|
||||||
public class InverseBooleanConverter : IValueConverter
|
public class InverseBooleanConverter : IValueConverter
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||||
value is bool b ? !b : throw new InvalidOperationException("The target must be a boolean");
|
value is bool b ? !b : throw new InvalidOperationException("The target must be a boolean");
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => Binding.DoNothing;
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => Binding.DoNothing;
|
||||||
}
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user