mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-23 06:25:19 -07:00
Add missing property changed handers
This commit is contained in:
parent
a1192f53b8
commit
ea8b112f94
6 changed files with 829 additions and 753 deletions
|
@ -22,8 +22,8 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
public Visibility ExpressionVisibility
|
public Visibility ExpressionVisibility
|
||||||
{
|
{
|
||||||
get { return (Visibility)GetValue(ExpressionVisibilityProperty); }
|
get => (Visibility)GetValue(ExpressionVisibilityProperty);
|
||||||
set { SetValue(ExpressionVisibilityProperty, value); }
|
set => SetValue(ExpressionVisibilityProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty ExpressionVisibilityProperty =
|
public static readonly DependencyProperty ExpressionVisibilityProperty =
|
||||||
|
@ -33,76 +33,99 @@ namespace CalculatorApp
|
||||||
|
|
||||||
public double MinFontSize
|
public double MinFontSize
|
||||||
{
|
{
|
||||||
get { return (double)GetValue(MinFontSizeProperty); }
|
get => (double)GetValue(MinFontSizeProperty);
|
||||||
set { SetValue(MinFontSizeProperty, value); }
|
set => SetValue(MinFontSizeProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty MinFontSizeProperty =
|
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
|
public double MaxFontSize
|
||||||
{
|
{
|
||||||
get { return (double)GetValue(MaxFontSizeProperty); }
|
get => (double)GetValue(MaxFontSizeProperty);
|
||||||
set { SetValue(MaxFontSizeProperty, value); }
|
set => SetValue(MaxFontSizeProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty MaxFontSizeProperty =
|
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
|
public Thickness DisplayMargin
|
||||||
{
|
{
|
||||||
get { return (Thickness)GetValue(DisplayMarginProperty); }
|
get => (Thickness)GetValue(DisplayMarginProperty);
|
||||||
set { SetValue(DisplayMarginProperty, value); }
|
set => SetValue(DisplayMarginProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty DisplayMarginProperty =
|
public static readonly DependencyProperty DisplayMarginProperty =
|
||||||
DependencyProperty.Register("DisplayMargin", typeof(Thickness), typeof(CalculationResult), new PropertyMetadata(default(Thickness)));
|
DependencyProperty.Register("DisplayMargin", typeof(Thickness), typeof(CalculationResult), new PropertyMetadata(default(Thickness)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int MaxExpressionHistoryCharacters
|
public int MaxExpressionHistoryCharacters
|
||||||
{
|
{
|
||||||
get { return (int)GetValue(MaxExpressionHistoryCharactersProperty); }
|
get => (int)GetValue(MaxExpressionHistoryCharactersProperty);
|
||||||
set { SetValue(MaxExpressionHistoryCharactersProperty, value); }
|
set => SetValue(MaxExpressionHistoryCharactersProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty MaxExpressionHistoryCharactersProperty =
|
public static readonly DependencyProperty MaxExpressionHistoryCharactersProperty =
|
||||||
DependencyProperty.Register("MaxExpressionHistoryCharacters", typeof(int), typeof(CalculationResult), new PropertyMetadata(0));
|
DependencyProperty.Register("MaxExpressionHistoryCharacters", typeof(int), typeof(CalculationResult), new PropertyMetadata(0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public bool IsActive
|
public bool IsActive
|
||||||
{
|
{
|
||||||
get { return (bool)GetValue(IsActiveProperty); }
|
get => (bool)GetValue(IsActiveProperty);
|
||||||
set { SetValue(IsActiveProperty, value); }
|
set => SetValue(IsActiveProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty IsActiveProperty =
|
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
|
public string DisplayValue
|
||||||
{
|
{
|
||||||
get { return (string)GetValue(DisplayValueProperty); }
|
get => (string)GetValue(DisplayValueProperty);
|
||||||
set { SetValue(DisplayValueProperty, value); }
|
set => SetValue(DisplayValueProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using a DependencyProperty as the backing store for DisplayValue. This enables animation, styling, binding, etc...
|
// Using a DependencyProperty as the backing store for DisplayValue. This enables animation, styling, binding, etc...
|
||||||
public static readonly DependencyProperty DisplayValueProperty =
|
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
|
public string DisplayStringExpression
|
||||||
{
|
{
|
||||||
get { return (string)GetValue(DisplayStringExpressionProperty); }
|
get => (string)GetValue(DisplayStringExpressionProperty);
|
||||||
set { SetValue(DisplayStringExpressionProperty, value); }
|
set => SetValue(DisplayStringExpressionProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using a DependencyProperty as the backing store for DisplayStringExpression. This enables animation, styling, binding, etc...
|
// Using a DependencyProperty as the backing store for DisplayStringExpression. This enables animation, styling, binding, etc...
|
||||||
|
@ -111,20 +134,26 @@ namespace CalculatorApp
|
||||||
|
|
||||||
public bool IsInError
|
public bool IsInError
|
||||||
{
|
{
|
||||||
get { return (bool)GetValue(IsInErrorProperty); }
|
get => (bool)GetValue(IsInErrorProperty);
|
||||||
set { SetValue(IsInErrorProperty, value); }
|
set => SetValue(IsInErrorProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using a DependencyProperty as the backing store for IsInError. This enables animation, styling, binding, etc...
|
// Using a DependencyProperty as the backing store for IsInError. This enables animation, styling, binding, etc...
|
||||||
public static readonly DependencyProperty IsInErrorProperty =
|
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
|
public bool IsOperatorCommand
|
||||||
{
|
{
|
||||||
get { return (bool)GetValue(IsOperatorCommandProperty); }
|
get => (bool)GetValue(IsOperatorCommandProperty);
|
||||||
set { SetValue(IsOperatorCommandProperty, value); }
|
set => SetValue(IsOperatorCommandProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using a DependencyProperty as the backing store for IsOperatorCommand. This enables animation, styling, binding, etc...
|
// Using a DependencyProperty as the backing store for IsOperatorCommand. This enables animation, styling, binding, etc...
|
||||||
|
|
|
@ -51,7 +51,15 @@ namespace CalculatorApp.Controls
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty AuditoryFeedbackProperty =
|
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
|
// HoverBackground
|
||||||
public Brush HoverBackground
|
public Brush HoverBackground
|
||||||
|
|
|
@ -13,7 +13,6 @@ namespace CalculatorApp.Controls
|
||||||
{
|
{
|
||||||
public partial class FlipButtons : ToggleButton
|
public partial class FlipButtons : ToggleButton
|
||||||
{
|
{
|
||||||
|
|
||||||
// NumbersAndOperatorsEnum
|
// NumbersAndOperatorsEnum
|
||||||
public NumbersAndOperatorsEnum ButtonId
|
public NumbersAndOperatorsEnum ButtonId
|
||||||
{
|
{
|
||||||
|
@ -22,7 +21,15 @@ namespace CalculatorApp.Controls
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty ButtonIdProperty =
|
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
|
// HoverBackground
|
||||||
public Brush HoverBackground
|
public Brush HoverBackground
|
||||||
|
|
|
@ -45,7 +45,16 @@ namespace CalculatorApp.Controls
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty TokensUpdatedProperty =
|
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
|
||||||
|
)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,16 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty IsErrorVisualStateProperty =
|
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
|
public bool IsWideLayout
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,28 +29,42 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty IsBitFlipCheckedProperty =
|
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
|
public bool IsErrorVisualState
|
||||||
{
|
{
|
||||||
get { return (bool)GetValue(IsErrorVisualStateProperty); }
|
get => (bool)GetValue(IsErrorVisualStateProperty);
|
||||||
set { SetValue(IsErrorVisualStateProperty, value); }
|
set => SetValue(IsErrorVisualStateProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using a DependencyProperty as the backing store for IsErrorVisualState. This enables animation, styling, binding, etc...
|
// Using a DependencyProperty as the backing store for IsErrorVisualState. This enables animation, styling, binding, etc...
|
||||||
public static readonly DependencyProperty IsErrorVisualStateProperty =
|
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()
|
public OperatorsPanel()
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
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)
|
if (newValue)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +72,7 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnIsErrorVisualStatePropertyChanged(bool oldValue, bool newValue)
|
private void OnIsErrorVisualStatePropertyChanged(bool oldValue, bool newValue)
|
||||||
{
|
{
|
||||||
if (Model.IsStandard)
|
if (Model.IsStandard)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue