Add missing property changed handers

This commit is contained in:
Jérôme Laban 2019-05-24 09:23:10 -04:00
commit ea8b112f94
6 changed files with 829 additions and 753 deletions

View file

@ -22,8 +22,8 @@ namespace CalculatorApp
{
public Visibility ExpressionVisibility
{
get { return (Visibility)GetValue(ExpressionVisibilityProperty); }
set { SetValue(ExpressionVisibilityProperty, value); }
get => (Visibility)GetValue(ExpressionVisibilityProperty);
set => SetValue(ExpressionVisibilityProperty, value);
}
public static readonly DependencyProperty ExpressionVisibilityProperty =
@ -33,76 +33,99 @@ namespace CalculatorApp
public double MinFontSize
{
get { return (double)GetValue(MinFontSizeProperty); }
set { SetValue(MinFontSizeProperty, value); }
get => (double)GetValue(MinFontSizeProperty);
set => SetValue(MinFontSizeProperty, value);
}
public static readonly DependencyProperty MinFontSizeProperty =
DependencyProperty.Register("MinFontSize", typeof(double), typeof(CalculationResult), new PropertyMetadata(0.0));
DependencyProperty.Register(
name: "MinFontSize",
propertyType: typeof(double),
ownerType: typeof(CalculationResult),
typeMetadata: new PropertyMetadata(
defaultValue: 0.0,
propertyChangedCallback: (s, e) => (s as CalculationResult)?.OnMinFontSizePropertyChanged(
(double)e.OldValue,
(double)e.NewValue)));
public double MaxFontSize
{
get { return (double)GetValue(MaxFontSizeProperty); }
set { SetValue(MaxFontSizeProperty, value); }
get => (double)GetValue(MaxFontSizeProperty);
set => SetValue(MaxFontSizeProperty, value);
}
public static readonly DependencyProperty MaxFontSizeProperty =
DependencyProperty.Register("MaxFontSize", typeof(double), typeof(CalculationResult), new PropertyMetadata(30.0));
DependencyProperty.Register(
name: "MaxFontSize",
propertyType: typeof(double),
ownerType: typeof(CalculationResult),
typeMetadata: new PropertyMetadata(
defaultValue: 30.0,
propertyChangedCallback: (s, e) => (s as CalculationResult)?.OnMaxFontSizePropertyChanged(
(double)e.OldValue,
(double)e.NewValue)));
public Thickness DisplayMargin
{
get { return (Thickness)GetValue(DisplayMarginProperty); }
set { SetValue(DisplayMarginProperty, value); }
get => (Thickness)GetValue(DisplayMarginProperty);
set => SetValue(DisplayMarginProperty, value);
}
public static readonly DependencyProperty DisplayMarginProperty =
DependencyProperty.Register("DisplayMargin", typeof(Thickness), typeof(CalculationResult), new PropertyMetadata(default(Thickness)));
public int MaxExpressionHistoryCharacters
{
get { return (int)GetValue(MaxExpressionHistoryCharactersProperty); }
set { SetValue(MaxExpressionHistoryCharactersProperty, value); }
get => (int)GetValue(MaxExpressionHistoryCharactersProperty);
set => SetValue(MaxExpressionHistoryCharactersProperty, value);
}
public static readonly DependencyProperty MaxExpressionHistoryCharactersProperty =
DependencyProperty.Register("MaxExpressionHistoryCharacters", typeof(int), typeof(CalculationResult), new PropertyMetadata(0));
public bool IsActive
{
get { return (bool)GetValue(IsActiveProperty); }
set { SetValue(IsActiveProperty, value); }
get => (bool)GetValue(IsActiveProperty);
set => SetValue(IsActiveProperty, value);
}
public static readonly DependencyProperty IsActiveProperty =
DependencyProperty.Register("IsActive", typeof(bool), typeof(CalculationResult), new PropertyMetadata(false));
DependencyProperty.Register(
name: "IsActive",
propertyType: typeof(bool),
ownerType: typeof(CalculationResult),
typeMetadata: new PropertyMetadata(
defaultValue: false,
propertyChangedCallback: (s, e) => (s as CalculationResult)?.OnIsActivePropertyChanged(
(bool)e.OldValue,
(bool)e.NewValue)));
public string DisplayValue
{
get { return (string)GetValue(DisplayValueProperty); }
set { SetValue(DisplayValueProperty, value); }
get => (string)GetValue(DisplayValueProperty);
set => SetValue(DisplayValueProperty, value);
}
// Using a DependencyProperty as the backing store for DisplayValue. This enables animation, styling, binding, etc...
public static readonly DependencyProperty DisplayValueProperty =
DependencyProperty.Register("DisplayValue", typeof(string), typeof(CalculationResult), new PropertyMetadata(""));
DependencyProperty.Register(
name: "DisplayValue",
propertyType: typeof(string),
ownerType: typeof(CalculationResult),
typeMetadata: new PropertyMetadata(
defaultValue: "",
propertyChangedCallback: (s, e) => (s as CalculationResult)?.OnDisplayValuePropertyChanged(
oldValue: e.OldValue as string,
newValue: e.NewValue as string)));
public string DisplayStringExpression
{
get { return (string)GetValue(DisplayStringExpressionProperty); }
set { SetValue(DisplayStringExpressionProperty, value); }
get => (string)GetValue(DisplayStringExpressionProperty);
set => SetValue(DisplayStringExpressionProperty, value);
}
// Using a DependencyProperty as the backing store for DisplayStringExpression. This enables animation, styling, binding, etc...
@ -111,20 +134,26 @@ namespace CalculatorApp
public bool IsInError
{
get { return (bool)GetValue(IsInErrorProperty); }
set { SetValue(IsInErrorProperty, value); }
get => (bool)GetValue(IsInErrorProperty);
set => SetValue(IsInErrorProperty, value);
}
// Using a DependencyProperty as the backing store for IsInError. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsInErrorProperty =
DependencyProperty.Register("IsInError", typeof(bool), typeof(CalculationResult), new PropertyMetadata(false));
DependencyProperty.Register(
name: "IsInError",
propertyType: typeof(bool),
ownerType: typeof(CalculationResult),
typeMetadata: new PropertyMetadata(
defaultValue: false,
propertyChangedCallback: (s, e) => (s as CalculationResult)?.OnIsInErrorPropertyChanged(
oldValue: (bool)e.OldValue,
newValue: (bool)e.NewValue)));
public bool IsOperatorCommand
{
get { return (bool)GetValue(IsOperatorCommandProperty); }
set { SetValue(IsOperatorCommandProperty, value); }
get => (bool)GetValue(IsOperatorCommandProperty);
set => SetValue(IsOperatorCommandProperty, value);
}
// Using a DependencyProperty as the backing store for IsOperatorCommand. This enables animation, styling, binding, etc...

View file

@ -51,7 +51,15 @@ namespace CalculatorApp.Controls
}
public static readonly DependencyProperty AuditoryFeedbackProperty =
DependencyProperty.Register("AuditoryFeedback", typeof(string), typeof(CalculatorButton), new PropertyMetadata(null));
DependencyProperty.Register(
name: "AuditoryFeedback",
propertyType: typeof(string),
ownerType: typeof(CalculatorButton),
typeMetadata: new PropertyMetadata(
defaultValue: null,
propertyChangedCallback: (s, e) => (s as CalculatorButton)?.OnAuditoryFeedbackPropertyChanged(
oldValue: e.OldValue as string,
newValue: e.NewValue as string)));
// HoverBackground
public Brush HoverBackground

View file

@ -13,7 +13,6 @@ namespace CalculatorApp.Controls
{
public partial class FlipButtons : ToggleButton
{
// NumbersAndOperatorsEnum
public NumbersAndOperatorsEnum ButtonId
{
@ -22,7 +21,15 @@ namespace CalculatorApp.Controls
}
public static readonly DependencyProperty ButtonIdProperty =
DependencyProperty.Register("ButtonId", typeof(NumbersAndOperatorsEnum), typeof(FlipButtons), new PropertyMetadata(null));
DependencyProperty.Register(
name: "ButtonId",
propertyType: typeof(NumbersAndOperatorsEnum),
ownerType: typeof(FlipButtons),
typeMetadata: new PropertyMetadata(
defaultValue: NumbersAndOperatorsEnum.None,
propertyChangedCallback: (s, e) => (s as FlipButtons)?.OnButtonIdPropertyChanged(
(NumbersAndOperatorsEnum)(e.OldValue ?? NumbersAndOperatorsEnum.None),
(NumbersAndOperatorsEnum)(e.NewValue ?? NumbersAndOperatorsEnum.None))));
// HoverBackground
public Brush HoverBackground

View file

@ -45,7 +45,16 @@ namespace CalculatorApp.Controls
}
public static readonly DependencyProperty TokensUpdatedProperty =
DependencyProperty.Register("TokensUpdated", typeof(bool), typeof(OverflowTextBlock), new PropertyMetadata(false));
DependencyProperty.Register(
name: "TokensUpdated",
propertyType: typeof(bool),
ownerType: typeof(OverflowTextBlock),
typeMetadata: new PropertyMetadata(
false,
(s, e) => (s as OverflowTextBlock)?.OnTokensUpdatedPropertyChanged(
oldValue: (bool)e.OldValue,
newValue: (bool)e.NewValue
)));

View file

@ -31,7 +31,16 @@ namespace CalculatorApp
}
public static readonly DependencyProperty IsErrorVisualStateProperty =
DependencyProperty.Register("IsErrorVisualState", typeof(bool), typeof(CalculatorScientificOperators), new PropertyMetadata(false));
DependencyProperty.Register(
name: "IsErrorVisualState",
propertyType: typeof(bool),
ownerType: typeof(CalculatorScientificOperators),
typeMetadata: new PropertyMetadata(
defaultValue: false,
propertyChangedCallback: (s, e) => (s as CalculatorScientificOperators)?.OnIsErrorVisualStatePropertyChanged(
(bool)e.OldValue,
(bool)e.NewValue
)));
public bool IsWideLayout
{

View file

@ -29,28 +29,42 @@ namespace CalculatorApp
}
public static readonly DependencyProperty IsBitFlipCheckedProperty =
DependencyProperty.Register("IsBitFlipChecked", typeof(bool), typeof(OperatorsPanel), new PropertyMetadata(false));
DependencyProperty.Register(
name: "IsBitFlipChecked",
propertyType: typeof(bool),
ownerType: typeof(OperatorsPanel),
typeMetadata: new PropertyMetadata(
defaultValue: false,
propertyChangedCallback: (s, e) => (s as OperatorsPanel)?.OnIsBitFlipCheckedPropertyChanged(
oldValue: (bool)e.OldValue,
newValue: (bool)e.NewValue)));
public bool IsErrorVisualState
{
get { return (bool)GetValue(IsErrorVisualStateProperty); }
set { SetValue(IsErrorVisualStateProperty, value); }
get => (bool)GetValue(IsErrorVisualStateProperty);
set => SetValue(IsErrorVisualStateProperty, value);
}
// Using a DependencyProperty as the backing store for IsErrorVisualState. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsErrorVisualStateProperty =
DependencyProperty.Register("IsErrorVisualState", typeof(bool), typeof(OperatorsPanel), new PropertyMetadata(false));
DependencyProperty.Register(
name: "IsErrorVisualState",
propertyType: typeof(bool),
ownerType: typeof(OperatorsPanel),
typeMetadata: new PropertyMetadata(
defaultValue: false,
propertyChangedCallback: (s, e) => (s as OperatorsPanel)?.OnIsErrorVisualStatePropertyChanged(
oldValue: (bool)e.OldValue,
newValue: (bool)e.NewValue)));
public OperatorsPanel()
{
this.InitializeComponent();
}
StandardCalculatorViewModel Model => (CalculatorApp.ViewModel.StandardCalculatorViewModel)(this.DataContext);
private StandardCalculatorViewModel Model => (CalculatorApp.ViewModel.StandardCalculatorViewModel)(this.DataContext);
void OnIsBitFlipCheckedPropertyChanged(bool oldValue, bool newValue)
private void OnIsBitFlipCheckedPropertyChanged(bool oldValue, bool newValue)
{
if (newValue)
{
@ -58,7 +72,7 @@ namespace CalculatorApp
}
}
void OnIsErrorVisualStatePropertyChanged(bool oldValue, bool newValue)
private void OnIsErrorVisualStatePropertyChanged(bool oldValue, bool newValue)
{
if (Model.IsStandard)
{