Overview
TheStandardCalculatorViewModel class manages calculator operations for Standard, Scientific, and Programmer modes. It handles expression evaluation, memory operations, number base conversions, and provides data binding for UI elements.
Namespace: CalculatorApp.ViewModel
Implements: Windows::UI::Xaml::Data::INotifyPropertyChanged
Declared in: StandardCalculatorViewModel.h:40
Observable Properties
The ViewModel uses property macros for automatic change notification. Properties are defined using:OBSERVABLE_PROPERTY_RW(type, name)- Read-write with change notificationOBSERVABLE_PROPERTY_R(type, name)- Read-only with private setterOBSERVABLE_NAMED_PROPERTY_R(type, name)- Read-only with static property name
Display Properties
DisplayValue
ExpressionTokens
IsInError
OpenParenthesisCount
Programmer Mode Properties
DecimalDisplayValue
HexDisplayValue
OctalDisplayValue
BinaryDisplayValue
BinaryDigits
CurrentRadixType
IsBinaryBitFlippingEnabled
AreProgrammerRadixOperatorsVisible
Button State Properties
IsBinaryOperatorEnabled
IsUnaryOperatorEnabled
IsNegateEnabled
IsDecimalEnabled
AreHEXButtonsEnabled
Memory Properties
MemorizedNumbers
IsMemoryEmpty
History
HistoryVM
Accessibility Properties
CalculationResultAutomationName
CalculationExpressionAutomationName
Announcement
Mode Properties
These properties determine the active calculator mode:true automatically sets the others to false.
IsBitFlipChecked
ValueBitLength
Always-on-Top
IsAlwaysOnTop
Commands
Commands are defined using theCOMMAND_FOR_METHOD macro:
ButtonPressed
Platform::Object^ - Button identifier
CopyCommand
PasteCommand
Memory Commands
Key Methods
SetCalculatorType
UpdateOperand
SwitchProgrammerModeBase
FtoEButtonToggled
OnPaste
SelectHistoryItem
SetPrecision
Property Macro Usage Examples
Read-Write Observable Property
Read-Only Observable Property
Command Definition
INotifyPropertyChanged Implementation
The ViewModel uses theOBSERVABLE_OBJECT_CALLBACK macro:
OnPropertyChanged callback is invoked for every property change, allowing custom logic.
Usage Example
See Also
- ApplicationViewModel - Application-level state management
- HistoryViewModel - Calculation history
- MemoryItemViewModel - Memory items