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

Additional SmartHint refactoring #3181

Merged
merged 25 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5923051
Initial work of respecting TextBox.Height - only done for TextBox so far
nicolaihenriksen Apr 25, 2023
ee18094
Aligning prefix/suffix texts
nicolaihenriksen Apr 27, 2023
860bcff
PasswordBox respects VerticalContentAlignment
nicolaihenriksen Apr 27, 2023
18d06d9
Fixes hint floating position for default offset
nicolaihenriksen May 1, 2023
539f009
DatePicker now respects VerticalContentAlignment
nicolaihenriksen May 1, 2023
0818e7b
TimePicker now respects VerticalContentAlignment
nicolaihenriksen May 1, 2023
c74f17f
Renamed element to match content
nicolaihenriksen May 1, 2023
31145a0
PasswordBox trailing icons/buttons now respect VerticalContentAlignment
nicolaihenriksen May 1, 2023
8c482ce
ComboBox clear button now respects VerticalContentAlignment
nicolaihenriksen May 1, 2023
00e4d34
ComboBox toggle button now respects VerticalContentAlignment
nicolaihenriksen May 1, 2023
bf2dedc
Improved 'Smart Hint' demo app page
nicolaihenriksen May 1, 2023
91f653c
Added FontSize to 'Smart Hint' demo app page
nicolaihenriksen May 1, 2023
2edf542
Change default VerticalContentAlignment of ComboBox to Center
nicolaihenriksen May 2, 2023
13dcc23
Apply red color to FontSize in 'Smart Hint' demo page
nicolaihenriksen May 2, 2023
9570007
Use FontFamily from "hint" as input to floating offset converter
nicolaihenriksen May 2, 2023
0580e60
Add support for controlling FontFamily in 'Smart Hint' demo page
nicolaihenriksen May 2, 2023
7b2a333
Add comment in demo app page regarding ShowMeTheXaml
nicolaihenriksen May 2, 2023
2d9e411
Fix typo
nicolaihenriksen May 2, 2023
5500491
Fix for broken UI tests for DatePicker and TimePicker
nicolaihenriksen May 2, 2023
884d312
Fix broken UI tests for PasswordBox
nicolaihenriksen May 2, 2023
91bd6a7
Apply same visibility fix for TextBox as was done to PasswordBox, etc.
nicolaihenriksen May 2, 2023
76d6f94
Align ComboBox prefix/suffix text margin and visibility with other ctrls
nicolaihenriksen May 2, 2023
b717ad5
Use HelperTextStyle in ComboBox, DatePicker, and TimePicker
nicolaihenriksen May 2, 2023
bef99f5
Set default VerticalContentAlignment=Center for Date- and TimePicker
nicolaihenriksen May 2, 2023
95d9075
Fixed failing unit tests for FloatingHintTransformConverter
nicolaihenriksen May 2, 2023
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
114 changes: 111 additions & 3 deletions MainDemo.Wpf/Domain/SmartHintViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
using MaterialDesignThemes.Wpf;
using System.Windows.Media;
using MaterialDesignThemes.Wpf;

namespace MaterialDesignDemo.Domain;

internal class SmartHintViewModel : ViewModelBase
{
public static Point DefaultFloatingOffset { get; } = new(0, -16);
public static FontFamily DefaultFontFamily = (FontFamily)new MaterialDesignFontExtension().ProvideValue(null!);

private bool _floatHint = true;
private FloatingHintHorizontalAlignment _selectedAlignment = FloatingHintHorizontalAlignment.Inherit;
private double _selectedFloatingScale = 0.75;
private bool _showClearButton = true;
private bool _showLeadingIcon = true;
private bool _showTrailingIcon = true;
private string _hintText = "Hint text";
private string _helperText = "Helper text";
private Point _selectedFloatingOffset = new(0, -16);
private Point _selectedFloatingOffset = DefaultFloatingOffset;
private bool _applyCustomPadding;
private Thickness _selectedCustomPadding = new(5);
private double _selectedCustomHeight = double.NaN;
private VerticalAlignment _selectedVerticalAlignment = VerticalAlignment.Center;
private double _selectedLeadingIconSize = 20;
private double _selectedTrailingIconSize = 20;
private string? _prefixText;
private string? _suffixText;
private double _selectedFontSize = double.NaN;
private FontFamily? _selectedFontFamily = DefaultFontFamily;

public IEnumerable<FloatingHintHorizontalAlignment> HorizontalAlignmentOptions { get; } = Enum.GetValues(typeof(FloatingHintHorizontalAlignment)).OfType<FloatingHintHorizontalAlignment>();
public IEnumerable<double> FloatingScaleOptions { get; } = new[] {0.25, 0.5, 0.75, 1.0};
public IEnumerable<Point> FloatingOffsetOptions { get; } = new[] { new Point(0, -16), new Point(0, 16), new Point(16, 16), new Point(-16, -16) };
public IEnumerable<Point> FloatingOffsetOptions { get; } = new[] { DefaultFloatingOffset, new Point(0, -25), new Point(16, -16), new Point(-16, -16), new Point(0, -50) };
public IEnumerable<string> ComboBoxOptions { get; } = new[] {"Option 1", "Option 2", "Option 3"};
public IEnumerable<Thickness> CustomPaddingOptions { get; } = new [] { new Thickness(0), new Thickness(5), new Thickness(10), new Thickness(15) };
public IEnumerable<double> CustomHeightOptions { get; } = new[] { double.NaN, 50, 75, 100 };
public IEnumerable<VerticalAlignment> VerticalAlignmentOptions { get; } = (VerticalAlignment[])Enum.GetValues(typeof(VerticalAlignment));
public IEnumerable<double> IconSizeOptions { get; } = new[] { 10.0, 15, 20, 30, 50, 75 };
public IEnumerable<double> FontSizeOptions { get; } = new[] { double.NaN, 8, 12, 16, 20, 24, 28 };
public IEnumerable<FontFamily> FontFamilyOptions { get; } = new FontFamily[] { DefaultFontFamily }.Concat(Fonts.SystemFontFamilies.OrderBy(f => f.Source));

public bool FloatHint
{
Expand Down Expand Up @@ -81,6 +99,16 @@ public bool ShowLeadingIcon
}
}

public bool ShowTrailingIcon
{
get => _showTrailingIcon;
set
{
_showTrailingIcon = value;
OnPropertyChanged();
}
}

public string HintText
{
get => _hintText;
Expand Down Expand Up @@ -120,4 +148,84 @@ public Thickness SelectedCustomPadding
OnPropertyChanged();
}
}

public double SelectedCustomHeight
{
get => _selectedCustomHeight;
set
{
_selectedCustomHeight = value;
OnPropertyChanged();
}
}

public VerticalAlignment SelectedVerticalAlignment
{
get => _selectedVerticalAlignment;
set
{
_selectedVerticalAlignment = value;
OnPropertyChanged();
}
}

public double SelectedLeadingIconSize
{
get => _selectedLeadingIconSize;
set
{
_selectedLeadingIconSize = value;
OnPropertyChanged();
}
}

public double SelectedTrailingIconSize
{
get => _selectedTrailingIconSize;
set
{
_selectedTrailingIconSize = value;
OnPropertyChanged();
}
}

public string? PrefixText
{
get => _prefixText;
set
{
_prefixText = value;
OnPropertyChanged();
}
}

public string? SuffixText
{
get => _suffixText;
set
{
_suffixText = value;
OnPropertyChanged();
}
}

public double SelectedFontSize
{
get => _selectedFontSize;
set
{
_selectedFontSize = value;
OnPropertyChanged();
}
}

public FontFamily? SelectedFontFamily
{
get => _selectedFontFamily;
set
{
_selectedFontFamily = value;
OnPropertyChanged();
}
}
}
2 changes: 1 addition & 1 deletion MainDemo.Wpf/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="clr-namespace:System;assembly=mscorlib"
Title="Material Design in XAML"
Width="1100"
Width="1150"
MaxHeight="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenHeight}}"
d:DataContext="{d:DesignInstance domain:MainWindowViewModel}"
AutomationProperties.Name="{Binding Title, RelativeSource={RelativeSource Self}}"
Expand Down
Loading