Calculator Class
Represents a calculator control.
[TemplateVisualState(Name = "Focused", GroupName = "FocusStates")]
[TemplateVisualState(Name = "PointerFocused", GroupName = "FocusStates")]
[TemplateVisualState(Name = "Unfocused", GroupName = "FocusStates")]
public class Calculator : Control, DUCE.IResource, IAnimatable, IFrameworkInputElement, IInputElement, ISupportInitialize, IHaveResources, IQueryAmbient
- Inheritance:
- System.Object System.Windows.Threading.DispatcherObject System.Windows.DependencyObject System.Windows.Media.Visual System.Windows.UIElement System.Windows.FrameworkElement System.Windows.Controls.Control Object
Constructors
Calculator()
Initializes an instance of the Calculator
class.
public Calculator()
Properties
AcceptsEscape
Gets or sets whether to accept the Escape
key for clearing the calculator's current entry and value.
public bool AcceptsEscape { get; set; }
Property Value
- System.Boolean:
true
if theEscape
key should be accepted; otherwise,false
. The default value istrue
.
Remarks
The Shift+Del
key can also be used to clear the calculator's current entry and value.
AddToMemoryCommand
Gets the System.Windows.Input.ICommand that can add to memory.
public ICommand AddToMemoryCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can add to memory.
BackspaceCommand
Gets the System.Windows.Input.ICommand that can backspace a digit.
public ICommand BackspaceCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can backspace a digit.
CalculateCommand
Gets the System.Windows.Input.ICommand that can calculate the result.
public ICommand CalculateCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can calculate the result.
ClearCommand
Gets the System.Windows.Input.ICommand that can clear the current entry and value.
public ICommand ClearCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can clear the current entry and value.
ClearEntryCommand
Gets the System.Windows.Input.ICommand that can clear the current entry.
public ICommand ClearEntryCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can clear the current entry.
ClearMemoryCommand
Gets the System.Windows.Input.ICommand that can clear memory.
public ICommand ClearMemoryCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can clear memory.
DigitButtonStyle
Gets or sets the System.Windows.Style to use for digit buttons.
public Style DigitButtonStyle { get; set; }
Property Value
- System.Windows.Style:
The System.Windows.Style to use for digit buttons.
DisplayFontSize
Gets or sets the display font size.
public double DisplayFontSize { get; set; }
Property Value
- System.Double:
The display font size.
DisplayText
Gets the text that represents the calculator output.
public string DisplayText { get; }
Property Value
- System.String:
The text that represents the calculator output. The default value is
"0"
.
HasDisplay
Gets or sets whether the calculator output is displayed.
public bool HasDisplay { get; set; }
Property Value
- System.Boolean:
true
if the calculator output is displayed; otherwise,false
. The default value istrue
.
HasMemoryButtons
Gets or sets whether the memory buttons are displayed.
public bool HasMemoryButtons { get; set; }
Property Value
- System.Boolean:
true
if the memory buttons are displayed; otherwise,false
. The default value istrue
.
InsertDecimalSeparatorCommand
Gets the System.Windows.Input.ICommand that can insert a decimal separator.
public ICommand InsertDecimalSeparatorCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can insert a decimal separator.
InsertDigitCommand
Gets the System.Windows.Input.ICommand that can insert a digit.
public ICommand InsertDigitCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can insert a digit.
IsOutOfRange
public bool IsOutOfRange { get; }
Property Value
- System.Boolean:
true
if the calculated value is outside the Minimum and Maximum range; otherwise,false
.
See Also
Maximum
Gets or sets the highest possible value.
public double Maximum { get; set; }
Property Value
- System.Double:
The highest possible value.
See Also
MemoryButtonStyle
Gets or sets the System.Windows.Style to use for memory buttons.
public Style MemoryButtonStyle { get; set; }
Property Value
- System.Windows.Style:
The System.Windows.Style to use for memory buttons.
Minimum
Gets or sets the lowest possible value.
public double Minimum { get; set; }
Property Value
- System.Double:
The lowest possible value.
See Also
OperationButtonStyle
Gets or sets the System.Windows.Style to use for operation buttons.
public Style OperationButtonStyle { get; set; }
Property Value
- System.Windows.Style:
The System.Windows.Style to use for operation buttons.
OperationCommand
Gets the System.Windows.Input.ICommand that can execute an operation.
public ICommand OperationCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can execute an operation.
RecallMemoryCommand
Gets the System.Windows.Input.ICommand that can recall memory.
public ICommand RecallMemoryCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can recall memory.
SetMemoryCommand
Gets the System.Windows.Input.ICommand that can set memory.
public ICommand SetMemoryCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can set memory.
SubtractFromMemoryCommand
Gets the System.Windows.Input.ICommand that can subtract from memory.
public ICommand SubtractFromMemoryCommand { get; }
Property Value
- System.Windows.Input.ICommand:
The System.Windows.Input.ICommand that can subtract from memory.
Value
Gets or sets the current calculated value.
public double Value { get; set; }
Property Value
- System.Double:
The current calculated value. The default value is
0.0
.
Methods
OnApplyTemplate()
Invoked whenever application code or internal processes call ApplyTemplate
.
public override void OnApplyTemplate()
OnCreateAutomationPeer()
Returns an System.Windows.Automation.Peers.AutomationPeer object for this control instance.
protected override AutomationPeer OnCreateAutomationPeer()
Returns
- System.Windows.Automation.Peers.AutomationPeer:
An System.Windows.Automation.Peers.AutomationPeer instance.
OnGotFocus(RoutedEventArgs)
Occurs when the control gains focus.
protected override void OnGotFocus(RoutedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | System.Windows.RoutedEventArgs | The System.Windows.RoutedEventArgs that contains the event data. |
OnKeyDown(KeyEventArgs)
Occurs when a key is pressed.
protected override void OnKeyDown(KeyEventArgs e)
Parameter | Type | Description |
---|---|---|
e | System.Windows.Input.KeyEventArgs | The System.Windows.Input.KeyEventArgs that contains the event data. |
OnLostFocus(RoutedEventArgs)
Occurs when the control loses focus.
protected override void OnLostFocus(RoutedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | System.Windows.RoutedEventArgs | The System.Windows.RoutedEventArgs that contains the event data. |
Events
ValueChanged
Occurs after the Value property value changes.
public event EventHandler ValueChanged
Event Type
- System.EventHandler
Fields
AcceptsEscapeProperty
Identifies the AcceptsEscape dependency property. This field is read-only.
public static readonly DependencyProperty AcceptsEscapeProperty
DigitButtonStyleProperty
Identifies the DigitButtonStyle dependency property. This field is read-only.
public static readonly DependencyProperty DigitButtonStyleProperty
DisplayFontSizeProperty
Identifies the DisplayFontSize dependency property. This field is read-only.
public static readonly DependencyProperty DisplayFontSizeProperty
DisplayTextProperty
Identifies the DisplayText dependency property. This field is read-only.
public static readonly DependencyProperty DisplayTextProperty
HasDisplayProperty
Identifies the HasDisplay dependency property. This field is read-only.
public static readonly DependencyProperty HasDisplayProperty
HasMemoryButtonsProperty
Identifies the HasMemoryButtons dependency property. This field is read-only.
public static readonly DependencyProperty HasMemoryButtonsProperty
IsOutOfRangeProperty
Identifies the IsOutOfRange dependency property. This field is read-only.
public static readonly DependencyProperty IsOutOfRangeProperty
MaximumProperty
Identifies the Maximum dependency property. This field is read-only.
public static readonly DependencyProperty MaximumProperty
MemoryButtonStyleProperty
Identifies the MemoryButtonStyle dependency property. This field is read-only.
public static readonly DependencyProperty MemoryButtonStyleProperty
MinimumProperty
Identifies the Minimum dependency property. This field is read-only.
public static readonly DependencyProperty MinimumProperty
OperationButtonStyleProperty
Identifies the OperationButtonStyle dependency property. This field is read-only.
public static readonly DependencyProperty OperationButtonStyleProperty
ValueProperty
Identifies the Value dependency property. This field is read-only.
public static readonly DependencyProperty ValueProperty
Inherited Members
- System.Object.ToString()
- System.Object.Equals(System.Object)
- System.Object.Equals(System.Object, System.Object)
- System.Object.ReferenceEquals(System.Object, System.Object)
- System.Object.GetHashCode()
- System.Object.GetType()
- System.Object.MemberwiseClone()
Extension Methods
- FrameworkElementExtensions.AnimateDoubleProperty(String, Double, Double, Double, Nullable<Double>, Nullable<Double>)
- FrameworkElementExtensions.BindToProperty(DependencyProperty, Object, String, BindingMode, IValueConverter, Object)
- FrameworkElementExtensions.BindToProperty(DependencyProperty, Object, DependencyProperty, BindingMode, IValueConverter, Object)
- FrameworkElementExtensions.GetCurrentSize()