Optimize BitFlipPanel to suppress flicker when users switch between bit lengths (#640)

* Optimize BitFlipPanel

* remove namespace in cpp file

* improve localization + add tests

* add helper to compare ivector

* Modify how the control manages AutomationProperties::Name
This commit is contained in:
Rudy Huyn 2019-08-26 09:31:13 -07:00 committed by Eric Wong
parent eb24c085bc
commit 41e2e97591
26 changed files with 793 additions and 621 deletions

View File

@ -951,7 +951,7 @@ int CCalcEngine::GetCurrentRadix()
return m_radix; return m_radix;
} }
wstring CCalcEngine::GetCurrentResultForRadix(uint32_t radix, int32_t precision) wstring CCalcEngine::GetCurrentResultForRadix(uint32_t radix, int32_t precision, bool groupDigitsPerRadix)
{ {
Rational rat = (m_bRecord ? m_input.ToRational(m_radix, m_precision) : m_currentVal); Rational rat = (m_bRecord ? m_input.ToRational(m_radix, m_precision) : m_currentVal);
@ -964,7 +964,14 @@ wstring CCalcEngine::GetCurrentResultForRadix(uint32_t radix, int32_t precision)
ChangeConstants(m_radix, m_precision); ChangeConstants(m_radix, m_precision);
} }
return GroupDigitsPerRadix(numberString, radix); if (groupDigitsPerRadix)
{
return GroupDigitsPerRadix(numberString, radix);
}
else
{
return numberString;
}
} }
wstring CCalcEngine::GetStringForDisplay(Rational const& rat, uint32_t radix) wstring CCalcEngine::GetStringForDisplay(Rational const& rat, uint32_t radix)

View File

@ -613,9 +613,9 @@ namespace CalculationManager
} }
} }
wstring CalculatorManager::GetResultForRadix(uint32_t radix, int32_t precision) wstring CalculatorManager::GetResultForRadix(uint32_t radix, int32_t precision, bool groupDigitsPerRadix)
{ {
return m_currentCalculatorEngine ? m_currentCalculatorEngine->GetCurrentResultForRadix(radix, precision) : L""; return m_currentCalculatorEngine ? m_currentCalculatorEngine->GetCurrentResultForRadix(radix, precision, groupDigitsPerRadix) : L"";
} }
void CalculatorManager::SetPrecision(int32_t precision) void CalculatorManager::SetPrecision(int32_t precision)

View File

@ -124,7 +124,7 @@ namespace CalculationManager
} }
void SetRadix(RADIX_TYPE iRadixType); void SetRadix(RADIX_TYPE iRadixType);
void SetMemorizedNumbersString(); void SetMemorizedNumbersString();
std::wstring GetResultForRadix(uint32_t radix, int32_t precision); std::wstring GetResultForRadix(uint32_t radix, int32_t precision, bool groupDigitsPerRadix);
void SetPrecision(int32_t precision); void SetPrecision(int32_t precision);
void UpdateMaxIntDigits(); void UpdateMaxIntDigits();
wchar_t DecimalSeparator(); wchar_t DecimalSeparator();

View File

@ -75,7 +75,7 @@ public:
void SettingsChanged(); void SettingsChanged();
bool IsCurrentTooBigForTrig(); bool IsCurrentTooBigForTrig();
int GetCurrentRadix(); int GetCurrentRadix();
std::wstring GetCurrentResultForRadix(uint32_t radix, int32_t precision); std::wstring GetCurrentResultForRadix(uint32_t radix, int32_t precision, bool groupDigitsPerRadix);
void ChangePrecision(int32_t precision) void ChangePrecision(int32_t precision)
{ {
m_precision = precision; m_precision = precision;

View File

@ -322,6 +322,7 @@
<ClInclude Include="Common\Automation\NarratorNotifier.h" /> <ClInclude Include="Common\Automation\NarratorNotifier.h" />
<ClInclude Include="Common\Automation\NotificationHost.h" /> <ClInclude Include="Common\Automation\NotificationHost.h" />
<ClInclude Include="Common\BindableBase.h" /> <ClInclude Include="Common\BindableBase.h" />
<ClInclude Include="Common\BitLength.h" />
<ClInclude Include="Common\CalculatorButtonPressedEventArgs.h" /> <ClInclude Include="Common\CalculatorButtonPressedEventArgs.h" />
<ClInclude Include="Common\CalculatorButtonUser.h" /> <ClInclude Include="Common\CalculatorButtonUser.h" />
<ClInclude Include="Common\CalculatorDisplay.h" /> <ClInclude Include="Common\CalculatorDisplay.h" />

View File

@ -219,6 +219,9 @@
<ClInclude Include="DataLoaders\DataLoaderConstants.h"> <ClInclude Include="DataLoaders\DataLoaderConstants.h">
<Filter>DataLoaders</Filter> <Filter>DataLoaders</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Common\BitLength.h">
<Filter>Common</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="DataLoaders\DefaultFromToCurrency.json"> <None Include="DataLoaders\DefaultFromToCurrency.json">

View File

@ -0,0 +1,17 @@
#pragma once
namespace CalculatorApp
{
namespace Common
{
public
enum class BitLength : int
{
BitLengthUnknown = -1,
BitLengthByte = 8,
BitLengthWord = 16,
BitLengthDWord = 32,
BitLengthQWord = 64,
};
}
}

View File

@ -65,7 +65,7 @@ void CopyPasteManager::CopyToClipboard(String ^ stringToCopy)
Clipboard::SetContent(dataPackage); Clipboard::SetContent(dataPackage);
} }
task<String ^> CopyPasteManager::GetStringToPaste(ViewMode mode, CategoryGroupType modeType, int programmerNumberBase, int bitLengthType) task<String ^> CopyPasteManager::GetStringToPaste(ViewMode mode, CategoryGroupType modeType, int programmerNumberBase, BitLength bitLengthType)
{ {
// Retrieve the text in the clipboard // Retrieve the text in the clipboard
auto dataPackageView = Clipboard::GetContent(); auto dataPackageView = Clipboard::GetContent();
@ -97,14 +97,14 @@ int CopyPasteManager::ClipboardTextFormat()
return -1; return -1;
} }
String ^ CopyPasteManager::ValidatePasteExpression(String ^ pastedText, ViewMode mode, int programmerNumberBase, int bitLengthType) String ^ CopyPasteManager::ValidatePasteExpression(String ^ pastedText, ViewMode mode, int programmerNumberBase, BitLength bitLengthType)
{ {
return CopyPasteManager::ValidatePasteExpression(pastedText, mode, NavCategory::GetGroupType(mode), programmerNumberBase, bitLengthType); return CopyPasteManager::ValidatePasteExpression(pastedText, mode, NavCategory::GetGroupType(mode), programmerNumberBase, bitLengthType);
} }
// return "NoOp" if pastedText is invalid else return pastedText // return "NoOp" if pastedText is invalid else return pastedText
String ^ CopyPasteManager::ValidatePasteExpression(String ^ pastedText, ViewMode mode, CategoryGroupType modeType, int programmerNumberBase, int bitLengthType) String ^ CopyPasteManager::ValidatePasteExpression(String ^ pastedText, ViewMode mode, CategoryGroupType modeType, int programmerNumberBase, BitLength bitLengthType)
{ {
if (pastedText->Length() > MaxPasteableLength) if (pastedText->Length() > MaxPasteableLength)
{ {
@ -241,7 +241,7 @@ vector<wstring> CopyPasteManager::ExtractOperands(const wstring& pasteExpression
return operands; return operands;
} }
bool CopyPasteManager::ExpressionRegExMatch(vector<wstring> operands, ViewMode mode, CategoryGroupType modeType, int programmerNumberBase, int bitLengthType) bool CopyPasteManager::ExpressionRegExMatch(vector<wstring> operands, ViewMode mode, CategoryGroupType modeType, int programmerNumberBase, BitLength bitLengthType)
{ {
if (operands.empty()) if (operands.empty())
{ {
@ -317,7 +317,7 @@ bool CopyPasteManager::ExpressionRegExMatch(vector<wstring> operands, ViewMode m
return expMatched; return expMatched;
} }
pair<size_t, uint64_t> CopyPasteManager::GetMaxOperandLengthAndValue(ViewMode mode, CategoryGroupType modeType, int programmerNumberBase, int bitLengthType) pair<size_t, uint64_t> CopyPasteManager::GetMaxOperandLengthAndValue(ViewMode mode, CategoryGroupType modeType, int programmerNumberBase, BitLength bitLengthType)
{ {
constexpr size_t defaultMaxOperandLength = 0; constexpr size_t defaultMaxOperandLength = 0;
constexpr uint64_t defaultMaxValue = 0; constexpr uint64_t defaultMaxValue = 0;
@ -335,16 +335,16 @@ pair<size_t, uint64_t> CopyPasteManager::GetMaxOperandLengthAndValue(ViewMode mo
unsigned int bitLength = 0; unsigned int bitLength = 0;
switch (bitLengthType) switch (bitLengthType)
{ {
case QwordType: case BitLength::BitLengthQWord:
bitLength = 64; bitLength = 64;
break; break;
case DwordType: case BitLength::BitLengthDWord:
bitLength = 32; bitLength = 32;
break; break;
case WordType: case BitLength::BitLengthWord:
bitLength = 16; bitLength = 16;
break; break;
case ByteType: case BitLength::BitLengthByte:
bitLength = 8; bitLength = 8;
break; break;
} }

View File

@ -5,6 +5,7 @@
#include "AppResourceProvider.h" #include "AppResourceProvider.h"
#include "NavCategory.h" #include "NavCategory.h"
#include "BitLength.h"
namespace CalculatorUnitTests namespace CalculatorUnitTests
{ {
@ -13,10 +14,6 @@ namespace CalculatorUnitTests
namespace CalculatorApp namespace CalculatorApp
{ {
inline constexpr auto QwordType = 1;
inline constexpr auto DwordType = 2;
inline constexpr auto WordType = 3;
inline constexpr auto ByteType = 4;
inline constexpr auto HexBase = 5; inline constexpr auto HexBase = 5;
inline constexpr auto DecBase = 6; inline constexpr auto DecBase = 6;
inline constexpr auto OctBase = 7; inline constexpr auto OctBase = 7;
@ -30,7 +27,7 @@ namespace CalculatorApp
CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::ViewMode mode,
CalculatorApp::Common::CategoryGroupType modeType, CalculatorApp::Common::CategoryGroupType modeType,
int programmerNumberBase = -1, int programmerNumberBase = -1,
int bitLengthType = -1); CalculatorApp::Common::BitLength bitLengthType = CalculatorApp::Common::BitLength::BitLengthUnknown);
static bool HasStringToPaste() static bool HasStringToPaste()
{ {
return ClipboardTextFormat() >= 0; return ClipboardTextFormat() >= 0;
@ -41,14 +38,18 @@ namespace CalculatorApp
private: private:
static int ClipboardTextFormat(); static int ClipboardTextFormat();
static Platform::String static Platform::String
^ ValidatePasteExpression(Platform::String ^ pastedText, CalculatorApp::Common::ViewMode mode, int programmerNumberBase, int bitLengthType); ^ ValidatePasteExpression(
Platform::String ^ pastedText,
CalculatorApp::Common::ViewMode mode,
int programmerNumberBase,
CalculatorApp::Common::BitLength bitLengthType);
static Platform::String static Platform::String
^ ValidatePasteExpression( ^ ValidatePasteExpression(
Platform::String ^ pastedText, Platform::String ^ pastedText,
CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::ViewMode mode,
CalculatorApp::Common::CategoryGroupType modeType, CalculatorApp::Common::CategoryGroupType modeType,
int programmerNumberBase, int programmerNumberBase,
int bitLengthType); CalculatorApp::Common::BitLength bitLengthType);
static std::vector<std::wstring> static std::vector<std::wstring>
ExtractOperands(const std::wstring& pasteExpression, CalculatorApp::Common::ViewMode mode); ExtractOperands(const std::wstring& pasteExpression, CalculatorApp::Common::ViewMode mode);
@ -57,13 +58,13 @@ namespace CalculatorApp
CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::ViewMode mode,
CalculatorApp::Common::CategoryGroupType modeType, CalculatorApp::Common::CategoryGroupType modeType,
int programmerNumberBase = -1, int programmerNumberBase = -1,
int bitLengthType = -1); CalculatorApp::Common::BitLength bitLengthType = CalculatorApp::Common::BitLength::BitLengthUnknown);
static std::pair<size_t, uint64_t> GetMaxOperandLengthAndValue( static std::pair<size_t, uint64_t> GetMaxOperandLengthAndValue(
CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::ViewMode mode,
CalculatorApp::Common::CategoryGroupType modeType, CalculatorApp::Common::CategoryGroupType modeType,
int programmerNumberBase = -1, int programmerNumberBase = -1,
int bitLengthType = -1); CalculatorApp::Common::BitLength bitLengthType = CalculatorApp::Common::BitLength::BitLengthUnknown);
static std::wstring SanitizeOperand(const std::wstring& operand); static std::wstring SanitizeOperand(const std::wstring& operand);
static bool TryOperandToULL(const std::wstring& operand, int numberBase, unsigned long long int& result); static bool TryOperandToULL(const std::wstring& operand, int numberBase, unsigned long long int& result);
static size_t OperandLength( static size_t OperandLength(

View File

@ -67,6 +67,7 @@ StandardCalculatorViewModel::StandardCalculatorViewModel()
, m_HexDisplayValue(L"0") , m_HexDisplayValue(L"0")
, m_BinaryDisplayValue(L"0") , m_BinaryDisplayValue(L"0")
, m_OctalDisplayValue(L"0") , m_OctalDisplayValue(L"0")
, m_BinaryDigits(ref new Vector<bool>(64, false))
, m_standardCalculatorManager(&m_calculatorDisplay, &m_resourceProvider) , m_standardCalculatorManager(&m_calculatorDisplay, &m_resourceProvider)
, m_ExpressionTokens(ref new Vector<DisplayExpressionToken ^>()) , m_ExpressionTokens(ref new Vector<DisplayExpressionToken ^>())
, m_MemorizedNumbers(ref new Vector<MemoryItemViewModel ^>()) , m_MemorizedNumbers(ref new Vector<MemoryItemViewModel ^>())
@ -74,10 +75,7 @@ StandardCalculatorViewModel::StandardCalculatorViewModel()
, m_IsFToEChecked(false) , m_IsFToEChecked(false)
, m_isShiftChecked(false) , m_isShiftChecked(false)
, m_IsShiftProgrammerChecked(false) , m_IsShiftProgrammerChecked(false)
, m_IsQwordEnabled(true) , m_valueBitLength(BitLength::BitLengthQWord)
, m_IsDwordEnabled(true)
, m_IsWordEnabled(true)
, m_IsByteEnabled(true)
, m_isBitFlipChecked(false) , m_isBitFlipChecked(false)
, m_isBinaryBitFlippingEnabled(false) , m_isBinaryBitFlippingEnabled(false)
, m_CurrentRadixType(RADIX_TYPE::DEC_RADIX) , m_CurrentRadixType(RADIX_TYPE::DEC_RADIX)
@ -679,26 +677,6 @@ void StandardCalculatorViewModel::OnButtonPressed(Object ^ parameter)
} }
} }
int StandardCalculatorViewModel::GetBitLengthType()
{
if (IsQwordEnabled)
{
return QwordType;
}
else if (IsDwordEnabled)
{
return DwordType;
}
else if (IsWordEnabled)
{
return WordType;
}
else
{
return ByteType;
}
}
int StandardCalculatorViewModel::GetNumberBase() int StandardCalculatorViewModel::GetNumberBase()
{ {
if (CurrentRadixType == HEX_RADIX) if (CurrentRadixType == HEX_RADIX)
@ -729,9 +707,10 @@ void StandardCalculatorViewModel::OnCopyCommand(Object ^ parameter)
void StandardCalculatorViewModel::OnPasteCommand(Object ^ parameter) void StandardCalculatorViewModel::OnPasteCommand(Object ^ parameter)
{ {
auto that(this);
ViewMode mode; ViewMode mode;
int NumberBase = -1; int NumberBase = -1;
int bitLengthType = -1; BitLength bitLengthType = BitLength::BitLengthUnknown;
if (IsScientific) if (IsScientific)
{ {
mode = ViewMode::Scientific; mode = ViewMode::Scientific;
@ -740,7 +719,7 @@ void StandardCalculatorViewModel::OnPasteCommand(Object ^ parameter)
{ {
mode = ViewMode::Programmer; mode = ViewMode::Programmer;
NumberBase = GetNumberBase(); NumberBase = GetNumberBase();
bitLengthType = GetBitLengthType(); bitLengthType = m_valueBitLength;
} }
else else
{ {
@ -754,7 +733,7 @@ void StandardCalculatorViewModel::OnPasteCommand(Object ^ parameter)
// Ensure that the paste happens on the UI thread // Ensure that the paste happens on the UI thread
CopyPasteManager::GetStringToPaste(mode, NavCategory::GetGroupType(mode), NumberBase, bitLengthType) CopyPasteManager::GetStringToPaste(mode, NavCategory::GetGroupType(mode), NumberBase, bitLengthType)
.then([this, mode](String ^ pastedString) { OnPaste(pastedString); }, concurrency::task_continuation_context::use_current()); .then([that, mode](String ^ pastedString) { that->OnPaste(pastedString); }, concurrency::task_continuation_context::use_current());
} }
CalculationManager::Command StandardCalculatorViewModel::ConvertToOperatorsEnum(NumbersAndOperatorsEnum operation) CalculationManager::Command StandardCalculatorViewModel::ConvertToOperatorsEnum(NumbersAndOperatorsEnum operation)
@ -1642,6 +1621,7 @@ wstring StandardCalculatorViewModel::AddPadding(wstring binaryString)
void StandardCalculatorViewModel::UpdateProgrammerPanelDisplay() void StandardCalculatorViewModel::UpdateProgrammerPanelDisplay()
{ {
constexpr int32_t precision = 64;
wstring hexDisplayString; wstring hexDisplayString;
wstring decimalDisplayString; wstring decimalDisplayString;
wstring octalDisplayString; wstring octalDisplayString;
@ -1649,8 +1629,7 @@ void StandardCalculatorViewModel::UpdateProgrammerPanelDisplay()
if (!IsInError) if (!IsInError)
{ {
// we want the precision to be set to maximum value so that the autoconversions result as desired // we want the precision to be set to maximum value so that the autoconversions result as desired
int32_t precision = 64; if ((hexDisplayString = m_standardCalculatorManager.GetResultForRadix(16, precision, true)) == L"")
if (m_standardCalculatorManager.GetResultForRadix(16, precision) == L"")
{ {
hexDisplayString = DisplayValue->Data(); hexDisplayString = DisplayValue->Data();
decimalDisplayString = DisplayValue->Data(); decimalDisplayString = DisplayValue->Data();
@ -1659,10 +1638,9 @@ void StandardCalculatorViewModel::UpdateProgrammerPanelDisplay()
} }
else else
{ {
hexDisplayString = m_standardCalculatorManager.GetResultForRadix(16, precision); decimalDisplayString = m_standardCalculatorManager.GetResultForRadix(10, precision, true);
decimalDisplayString = m_standardCalculatorManager.GetResultForRadix(10, precision); octalDisplayString = m_standardCalculatorManager.GetResultForRadix(8, precision, true);
octalDisplayString = m_standardCalculatorManager.GetResultForRadix(8, precision); binaryDisplayString = m_standardCalculatorManager.GetResultForRadix(2, precision, true);
binaryDisplayString = m_standardCalculatorManager.GetResultForRadix(2, precision);
} }
} }
const auto& localizer = LocalizationSettings::GetInstance(); const auto& localizer = LocalizationSettings::GetInstance();
@ -1681,6 +1659,17 @@ void StandardCalculatorViewModel::UpdateProgrammerPanelDisplay()
DecDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedDecimalAutomationFormat, DecimalDisplayValue); DecDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedDecimalAutomationFormat, DecimalDisplayValue);
OctDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedOctalAutomationFormat, GetNarratorStringReadRawNumbers(OctalDisplayValue)); OctDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedOctalAutomationFormat, GetNarratorStringReadRawNumbers(OctalDisplayValue));
BinDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedBinaryAutomationFormat, GetNarratorStringReadRawNumbers(BinaryDisplayValue)); BinDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedBinaryAutomationFormat, GetNarratorStringReadRawNumbers(BinaryDisplayValue));
auto binaryValueArray = ref new Vector<bool>(64, false);
auto binaryValue = m_standardCalculatorManager.GetResultForRadix(2, precision, false);
int i = 0;
// To get bit 0, grab from opposite end of string.
for (std::wstring::reverse_iterator it = binaryValue.rbegin(); it != binaryValue.rend(); ++it)
{
binaryValueArray->SetAt(i++, *it == L'1');
}
BinaryDigits = binaryValueArray;
} }
void StandardCalculatorViewModel::SwitchAngleType(NumbersAndOperatorsEnum num) void StandardCalculatorViewModel::SwitchAngleType(NumbersAndOperatorsEnum num)
@ -1885,3 +1874,31 @@ ViewMode StandardCalculatorViewModel::GetCalculatorMode()
} }
return ViewMode::Programmer; return ViewMode::Programmer;
} }
void StandardCalculatorViewModel::ValueBitLength::set(CalculatorApp::Common::BitLength value)
{
if (m_valueBitLength != value)
{
m_valueBitLength = value;
RaisePropertyChanged(L"ValueBitLength");
switch (value)
{
case BitLength::BitLengthQWord:
ButtonPressed->Execute(NumbersAndOperatorsEnum::Qword);
break;
case BitLength::BitLengthDWord:
ButtonPressed->Execute(NumbersAndOperatorsEnum::Dword);
break;
case BitLength::BitLengthWord:
ButtonPressed->Execute(NumbersAndOperatorsEnum::Word);
break;
case BitLength::BitLengthByte:
ButtonPressed->Execute(NumbersAndOperatorsEnum::Byte);
break;
}
// update memory list according to bit length
SetMemorizedNumbersString();
}
}

View File

@ -9,6 +9,7 @@
#include "Common/CalculatorButtonUser.h" #include "Common/CalculatorButtonUser.h"
#include "HistoryViewModel.h" #include "HistoryViewModel.h"
#include "MemoryItemViewModel.h" #include "MemoryItemViewModel.h"
#include "Common/BitLength.h"
namespace CalculatorFunctionalTests namespace CalculatorFunctionalTests
{ {
@ -40,7 +41,6 @@ namespace CalculatorApp
StandardCalculatorViewModel(); StandardCalculatorViewModel();
void UpdateOperand(int pos, Platform::String ^ text); void UpdateOperand(int pos, Platform::String ^ text);
void UpdatecommandsInRecordingMode(); void UpdatecommandsInRecordingMode();
int GetBitLengthType();
int GetNumberBase(); int GetNumberBase();
OBSERVABLE_OBJECT_CALLBACK(OnPropertyChanged); OBSERVABLE_OBJECT_CALLBACK(OnPropertyChanged);
@ -54,6 +54,7 @@ namespace CalculatorApp
OBSERVABLE_PROPERTY_RW(Platform::String ^, HexDisplayValue); OBSERVABLE_PROPERTY_RW(Platform::String ^, HexDisplayValue);
OBSERVABLE_PROPERTY_RW(Platform::String ^, OctalDisplayValue); OBSERVABLE_PROPERTY_RW(Platform::String ^, OctalDisplayValue);
OBSERVABLE_NAMED_PROPERTY_RW(Platform::String ^, BinaryDisplayValue); OBSERVABLE_NAMED_PROPERTY_RW(Platform::String ^, BinaryDisplayValue);
OBSERVABLE_NAMED_PROPERTY_R(Windows::Foundation::Collections::IVector<bool> ^, BinaryDigits);
OBSERVABLE_PROPERTY_RW(Platform::String ^, HexDisplayValue_AutomationName); OBSERVABLE_PROPERTY_RW(Platform::String ^, HexDisplayValue_AutomationName);
OBSERVABLE_PROPERTY_RW(Platform::String ^, DecDisplayValue_AutomationName); OBSERVABLE_PROPERTY_RW(Platform::String ^, DecDisplayValue_AutomationName);
OBSERVABLE_PROPERTY_RW(Platform::String ^, OctDisplayValue_AutomationName); OBSERVABLE_PROPERTY_RW(Platform::String ^, OctDisplayValue_AutomationName);
@ -72,10 +73,6 @@ namespace CalculatorApp
OBSERVABLE_PROPERTY_RW(Platform::String ^, CalculationResultAutomationName); OBSERVABLE_PROPERTY_RW(Platform::String ^, CalculationResultAutomationName);
OBSERVABLE_PROPERTY_RW(Platform::String ^, CalculationExpressionAutomationName); OBSERVABLE_PROPERTY_RW(Platform::String ^, CalculationExpressionAutomationName);
OBSERVABLE_PROPERTY_RW(bool, IsShiftProgrammerChecked); OBSERVABLE_PROPERTY_RW(bool, IsShiftProgrammerChecked);
OBSERVABLE_PROPERTY_RW(bool, IsQwordEnabled);
OBSERVABLE_PROPERTY_RW(bool, IsDwordEnabled);
OBSERVABLE_PROPERTY_RW(bool, IsWordEnabled);
OBSERVABLE_PROPERTY_RW(bool, IsByteEnabled);
OBSERVABLE_PROPERTY_RW(int, CurrentRadixType); OBSERVABLE_PROPERTY_RW(int, CurrentRadixType);
OBSERVABLE_PROPERTY_RW(bool, AreTokensUpdated); OBSERVABLE_PROPERTY_RW(bool, AreTokensUpdated);
OBSERVABLE_PROPERTY_RW(bool, AreAlwaysOnTopResultsUpdated); OBSERVABLE_PROPERTY_RW(bool, AreAlwaysOnTopResultsUpdated);
@ -128,6 +125,13 @@ namespace CalculatorApp
} }
} }
} }
static property Platform::String ^ IsBitFlipCheckedPropertyName
{
Platform::String ^ get()
{
return Platform::StringReference(L"IsBitFlipChecked");
}
}
property bool IsBinaryBitFlippingEnabled property bool IsBinaryBitFlippingEnabled
{ {
@ -145,6 +149,15 @@ namespace CalculatorApp
} }
} }
property CalculatorApp::Common::BitLength ValueBitLength
{
CalculatorApp::Common::BitLength get()
{
return m_valueBitLength;
}
void set(CalculatorApp::Common::BitLength value);
}
property bool IsStandard property bool IsStandard
{ {
bool get() bool get()
@ -213,6 +226,13 @@ namespace CalculatorApp
} }
} }
} }
static property Platform::String ^ IsProgrammerPropertyName
{
Platform::String ^ get()
{
return Platform::StringReference(L"IsProgrammer");
}
}
property bool IsAlwaysOnTop property bool IsAlwaysOnTop
{ {
@ -433,6 +453,7 @@ namespace CalculatorApp
bool m_operandUpdated; bool m_operandUpdated;
bool m_completeTextSelection; bool m_completeTextSelection;
bool m_isLastOperationHistoryLoad; bool m_isLastOperationHistoryLoad;
CalculatorApp::Common::BitLength m_valueBitLength;
Platform::String ^ m_selectedExpressionLastData; Platform::String ^ m_selectedExpressionLastData;
Common::DisplayExpressionToken ^ m_selectedExpressionToken; Common::DisplayExpressionToken ^ m_selectedExpressionToken;

View File

@ -240,7 +240,6 @@
<ClInclude Include="Controls\OverflowTextBlock.h" /> <ClInclude Include="Controls\OverflowTextBlock.h" />
<ClInclude Include="Controls\RadixButton.h" /> <ClInclude Include="Controls\RadixButton.h" />
<ClInclude Include="Controls\SupplementaryItemsControl.h" /> <ClInclude Include="Controls\SupplementaryItemsControl.h" />
<ClInclude Include="Converters\BitFlipAutomationNameConverter.h" />
<ClInclude Include="Converters\BooleanNegationConverter.h" /> <ClInclude Include="Converters\BooleanNegationConverter.h" />
<ClInclude Include="Converters\BooleanToVisibilityConverter.h" /> <ClInclude Include="Converters\BooleanToVisibilityConverter.h" />
<ClInclude Include="Converters\ExpressionItemTemplateSelector.h" /> <ClInclude Include="Converters\ExpressionItemTemplateSelector.h" />
@ -370,7 +369,6 @@
<ClCompile Include="Controls\OverflowTextBlock.cpp" /> <ClCompile Include="Controls\OverflowTextBlock.cpp" />
<ClCompile Include="Controls\RadixButton.cpp" /> <ClCompile Include="Controls\RadixButton.cpp" />
<ClCompile Include="Controls\SupplementaryItemsControl.cpp" /> <ClCompile Include="Controls\SupplementaryItemsControl.cpp" />
<ClCompile Include="Converters\BitFlipAutomationNameConverter.cpp" />
<ClCompile Include="Converters\BooleanNegationConverter.cpp" /> <ClCompile Include="Converters\BooleanNegationConverter.cpp" />
<ClCompile Include="Converters\BooleanToVisibilityConverter.cpp" /> <ClCompile Include="Converters\BooleanToVisibilityConverter.cpp" />
<ClCompile Include="Converters\ExpressionItemTemplateSelector.cpp" /> <ClCompile Include="Converters\ExpressionItemTemplateSelector.cpp" />

View File

@ -318,9 +318,6 @@
<ClInclude Include="Controls\OverflowTextBlock.h"> <ClInclude Include="Controls\OverflowTextBlock.h">
<Filter>Controls</Filter> <Filter>Controls</Filter>
</ClInclude> </ClInclude>
<ClCompile Include="Converters\BitFlipAutomationNameConverter.cpp">
<Filter>Converters</Filter>
</ClCompile>
<ClInclude Include="Converters\BooleanNegationConverter.h"> <ClInclude Include="Converters\BooleanNegationConverter.h">
<Filter>Converters</Filter> <Filter>Converters</Filter>
</ClInclude> </ClInclude>
@ -362,9 +359,6 @@
</ClInclude> </ClInclude>
<ClInclude Include="WindowFrameService.h" /> <ClInclude Include="WindowFrameService.h" />
<ClInclude Include="Views\DateCalculator.xaml.h" /> <ClInclude Include="Views\DateCalculator.xaml.h" />
<ClInclude Include="Converters\BitFlipAutomationNameConverter.h">
<Filter>Converters</Filter>
</ClInclude>
<ClInclude Include="Controls\CalculationResultAutomationPeer.h"> <ClInclude Include="Controls\CalculationResultAutomationPeer.h">
<Filter>Controls</Filter> <Filter>Controls</Filter>
</ClInclude> </ClInclude>

View File

@ -1,80 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "CalcViewModel/Common/AppResourceProvider.h"
#include "CalcViewModel/Common/LocalizationSettings.h"
#include "BitFlipAutomationNameConverter.h"
using namespace CalculatorApp::Common;
using namespace CalculatorApp::Converters;
using namespace Platform;
using namespace std;
using namespace Windows::ApplicationModel::Resources;
using namespace Windows::Foundation;
using namespace Windows::UI::Xaml::Interop;
// returns automationName in form "Nth bit Value zero/one" depending if bit is set/unset at corresponding index of binary display
Object ^ BitFlipAutomationNameConverter::Convert(_In_ Object ^ value, TypeName targetType, _In_ Object ^ parameter, _In_ String ^ language)
{
auto resourceLoader = AppResourceProvider::GetInstance();
// initialising the updated display with 64 bits of zeros
wstring updatedBinaryDisplay(64, L'0');
const auto& localizationSettings = LocalizationSettings::GetInstance();
wchar_t ch0 = localizationSettings.GetDigitSymbolFromEnUsDigit('0');
wchar_t ch1 = localizationSettings.GetDigitSymbolFromEnUsDigit('1');
String ^ indexName = resourceLoader.GetResourceString(static_cast<String ^>(parameter));
String ^ bitName = resourceLoader.GetResourceString(L"BitAutomationName");
String ^ valueName = resourceLoader.GetResourceString(L"ValueAutomationName");
String ^ zero = resourceLoader.GetResourceString(L"BinaryZeroValueAutomationName");
String ^ one = resourceLoader.GetResourceString(L"BinaryOneValueAutomationName");
if ((value != nullptr) && (parameter != nullptr))
{
wstring binaryDisplay = (static_cast<String ^>(value))->Data();
wstring indexString = (static_cast<String ^>(parameter))->Data();
wstringstream converter;
converter << indexString;
unsigned int index;
converter >> index;
unsigned int binaryLength = 0;
// remove all the characters except 0 and 1 from the array.
for (wchar_t bit : binaryDisplay)
{
if ((bit == ch1) || (bit == ch0))
{
updatedBinaryDisplay[binaryLength++] = bit;
}
if (binaryLength == 63)
{
break;
}
}
// return if binaryDisplay is empty
if (binaryLength == 0)
{
return (indexName + bitName + valueName + zero);
}
// if index is more than the length of binary display return automation name with zero
if (index >= binaryLength)
{
return (indexName + bitName + valueName + zero);
}
// if bit is set return automation name with one else return zero
if (updatedBinaryDisplay[binaryLength - index - 1] == ch1)
{
return (indexName + bitName + valueName + one);
}
}
return (indexName + bitName + valueName + zero);
}
Object ^ BitFlipAutomationNameConverter::ConvertBack(_In_ Object ^ value, TypeName targetType, _In_ Object ^ parameter, _In_ String ^ language)
{
return value;
}

View File

@ -1,30 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
namespace CalculatorApp
{
namespace Converters
{
/// <summary>
/// Value converter that translates binary value to automation name for a bit.
/// </summary>
[Windows::Foundation::Metadata::WebHostHidden] public ref class BitFlipAutomationNameConverter sealed : Windows::UI::Xaml::Data::IValueConverter
{
public:
virtual Platform::Object
^ Convert(
_In_ Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
_In_ Platform::Object ^ parameter,
_In_ Platform::String ^ language);
virtual Platform::Object
^ ConvertBack(
_In_ Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
_In_ Platform::Object ^ parameter,
_In_ Platform::String ^ language);
};
}
}

View File

@ -545,276 +545,268 @@
<value>Insert</value> <value>Insert</value>
<comment>{Locked}This is the alternate shortcut for paste, SHIFT+Insert</comment> <comment>{Locked}This is the alternate shortcut for paste, SHIFT+Insert</comment>
</data> </data>
<data name="BitAutomationName" xml:space="preserve"> <data name="BitFlipItemAutomationName" xml:space="preserve">
<value>Bit </value> <value>%1, value %2</value>
<comment>Sub-string used in automation name for each bit in bit flip</comment> <comment>{Locked="%1","%2"}. String used in automation name for each bit in bit flip. %1 will be replaced by the position of the bit (1st bit, 3rd bit), %2 by a binary value (1 or 0)</comment>
</data> </data>
<data name="ValueAutomationName" xml:space="preserve"> <data name="BitPosition" xml:space="preserve">
<value>Value </value> <value>%1 bit</value>
<comment>Sub-string used in automation name for each bit in bit flip</comment> <comment>{Locked="%1"}. Sub-string used to indicate the position of a bit (e.g. 1st bit, 2nd bit...)</comment>
</data> </data>
<data name="BinaryZeroValueAutomationName" xml:space="preserve"> <data name="63" xml:space="preserve">
<value>Zero</value> <value>63rd</value>
<comment>Sub-string used in automation name for each bit in bit flip</comment>
</data>
<data name="BinaryOneValueAutomationName" xml:space="preserve">
<value>One</value>
<comment>Sub-string used in automation name for each bit in bit flip</comment>
</data>
<data name="63" xml:space="preserve">
<value>63rd </value>
<comment>Sub-string used in automation name for 63 bit in bit flip</comment> <comment>Sub-string used in automation name for 63 bit in bit flip</comment>
</data> </data>
<data name="62" xml:space="preserve"> <data name="62" xml:space="preserve">
<value>62nd </value> <value>62nd</value>
<comment>Sub-string used in automation name for 62 bit in bit flip</comment> <comment>Sub-string used in automation name for 62 bit in bit flip</comment>
</data> </data>
<data name="61" xml:space="preserve"> <data name="61" xml:space="preserve">
<value>61st </value> <value>61st</value>
<comment>Sub-string used in automation name for 61 bit in bit flip</comment> <comment>Sub-string used in automation name for 61 bit in bit flip</comment>
</data> </data>
<data name="60" xml:space="preserve"> <data name="60" xml:space="preserve">
<value>60th </value> <value>60th</value>
<comment>Sub-string used in automation name for 60 bit in bit flip</comment> <comment>Sub-string used in automation name for 60 bit in bit flip</comment>
</data> </data>
<data name="59" xml:space="preserve"> <data name="59" xml:space="preserve">
<value>59th </value> <value>59th</value>
<comment>Sub-string used in automation name for 59 bit in bit flip</comment> <comment>Sub-string used in automation name for 59 bit in bit flip</comment>
</data> </data>
<data name="58" xml:space="preserve"> <data name="58" xml:space="preserve">
<value>58th </value> <value>58th</value>
<comment>Sub-string used in automation name for 58 bit in bit flip</comment> <comment>Sub-string used in automation name for 58 bit in bit flip</comment>
</data> </data>
<data name="57" xml:space="preserve"> <data name="57" xml:space="preserve">
<value>57th </value> <value>57th</value>
<comment>Sub-string used in automation name for 57 bit in bit flip</comment> <comment>Sub-string used in automation name for 57 bit in bit flip</comment>
</data> </data>
<data name="56" xml:space="preserve"> <data name="56" xml:space="preserve">
<value>56th </value> <value>56th</value>
<comment>Sub-string used in automation name for 56 bit in bit flip</comment> <comment>Sub-string used in automation name for 56 bit in bit flip</comment>
</data> </data>
<data name="55" xml:space="preserve"> <data name="55" xml:space="preserve">
<value>55th </value> <value>55th</value>
<comment>Sub-string used in automation name for 55 bit in bit flip</comment> <comment>Sub-string used in automation name for 55 bit in bit flip</comment>
</data> </data>
<data name="54" xml:space="preserve"> <data name="54" xml:space="preserve">
<value>54th </value> <value>54th</value>
<comment>Sub-string used in automation name for 54 bit in bit flip</comment> <comment>Sub-string used in automation name for 54 bit in bit flip</comment>
</data> </data>
<data name="53" xml:space="preserve"> <data name="53" xml:space="preserve">
<value>53rd </value> <value>53rd</value>
<comment>Sub-string used in automation name for 53 bit in bit flip</comment> <comment>Sub-string used in automation name for 53 bit in bit flip</comment>
</data> </data>
<data name="52" xml:space="preserve"> <data name="52" xml:space="preserve">
<value>52nd </value> <value>52nd</value>
<comment>Sub-string used in automation name for 52 bit in bit flip</comment> <comment>Sub-string used in automation name for 52 bit in bit flip</comment>
</data> </data>
<data name="51" xml:space="preserve"> <data name="51" xml:space="preserve">
<value>51st </value> <value>51st</value>
<comment>Sub-string used in automation name for 51 bit in bit flip</comment> <comment>Sub-string used in automation name for 51 bit in bit flip</comment>
</data> </data>
<data name="50" xml:space="preserve"> <data name="50" xml:space="preserve">
<value>50th </value> <value>50th</value>
<comment>Sub-string used in automation name for 50 bit in bit flip</comment> <comment>Sub-string used in automation name for 50 bit in bit flip</comment>
</data> </data>
<data name="49" xml:space="preserve"> <data name="49" xml:space="preserve">
<value>49th </value> <value>49th</value>
<comment>Sub-string used in automation name for 49 bit in bit flip</comment> <comment>Sub-string used in automation name for 49 bit in bit flip</comment>
</data> </data>
<data name="48" xml:space="preserve"> <data name="48" xml:space="preserve">
<value>48th </value> <value>48th</value>
<comment>Sub-string used in automation name for 48 bit in bit flip</comment> <comment>Sub-string used in automation name for 48 bit in bit flip</comment>
</data> </data>
<data name="47" xml:space="preserve"> <data name="47" xml:space="preserve">
<value>47th </value> <value>47th</value>
<comment>Sub-string used in automation name for 47 bit in bit flip</comment> <comment>Sub-string used in automation name for 47 bit in bit flip</comment>
</data> </data>
<data name="46" xml:space="preserve"> <data name="46" xml:space="preserve">
<value>46th </value> <value>46th</value>
<comment>Sub-string used in automation name for 46 bit in bit flip</comment> <comment>Sub-string used in automation name for 46 bit in bit flip</comment>
</data> </data>
<data name="45" xml:space="preserve"> <data name="45" xml:space="preserve">
<value>45th </value> <value>45th</value>
<comment>Sub-string used in automation name for 45 bit in bit flip</comment> <comment>Sub-string used in automation name for 45 bit in bit flip</comment>
</data> </data>
<data name="44" xml:space="preserve"> <data name="44" xml:space="preserve">
<value>44th </value> <value>44th</value>
<comment>Sub-string used in automation name for 44 bit in bit flip</comment> <comment>Sub-string used in automation name for 44 bit in bit flip</comment>
</data> </data>
<data name="43" xml:space="preserve"> <data name="43" xml:space="preserve">
<value>43rd </value> <value>43rd</value>
<comment>Sub-string used in automation name for 43 bit in bit flip</comment> <comment>Sub-string used in automation name for 43 bit in bit flip</comment>
</data> </data>
<data name="42" xml:space="preserve"> <data name="42" xml:space="preserve">
<value>42nd </value> <value>42nd</value>
<comment>Sub-string used in automation name for 42 bit in bit flip</comment> <comment>Sub-string used in automation name for 42 bit in bit flip</comment>
</data> </data>
<data name="41" xml:space="preserve"> <data name="41" xml:space="preserve">
<value>41st </value> <value>41st</value>
<comment>Sub-string used in automation name for 41 bit in bit flip</comment> <comment>Sub-string used in automation name for 41 bit in bit flip</comment>
</data> </data>
<data name="40" xml:space="preserve"> <data name="40" xml:space="preserve">
<value>40th </value> <value>40th</value>
<comment>Sub-string used in automation name for 40 bit in bit flip</comment> <comment>Sub-string used in automation name for 40 bit in bit flip</comment>
</data> </data>
<data name="39" xml:space="preserve"> <data name="39" xml:space="preserve">
<value>39th </value> <value>39th</value>
<comment>Sub-string used in automation name for 39 bit in bit flip</comment> <comment>Sub-string used in automation name for 39 bit in bit flip</comment>
</data> </data>
<data name="38" xml:space="preserve"> <data name="38" xml:space="preserve">
<value>38th </value> <value>38th</value>
<comment>Sub-string used in automation name for 38 bit in bit flip</comment> <comment>Sub-string used in automation name for 38 bit in bit flip</comment>
</data> </data>
<data name="37" xml:space="preserve"> <data name="37" xml:space="preserve">
<value>37th </value> <value>37th</value>
<comment>Sub-string used in automation name for 37 bit in bit flip</comment> <comment>Sub-string used in automation name for 37 bit in bit flip</comment>
</data> </data>
<data name="36" xml:space="preserve"> <data name="36" xml:space="preserve">
<value>36th </value> <value>36th</value>
<comment>Sub-string used in automation name for 36 bit in bit flip</comment> <comment>Sub-string used in automation name for 36 bit in bit flip</comment>
</data> </data>
<data name="35" xml:space="preserve"> <data name="35" xml:space="preserve">
<value>35th </value> <value>35th</value>
<comment>Sub-string used in automation name for 35 bit in bit flip</comment> <comment>Sub-string used in automation name for 35 bit in bit flip</comment>
</data> </data>
<data name="34" xml:space="preserve"> <data name="34" xml:space="preserve">
<value>34th </value> <value>34th</value>
<comment>Sub-string used in automation name for 34 bit in bit flip</comment> <comment>Sub-string used in automation name for 34 bit in bit flip</comment>
</data> </data>
<data name="33" xml:space="preserve"> <data name="33" xml:space="preserve">
<value>33rd </value> <value>33rd</value>
<comment>Sub-string used in automation name for 33 bit in bit flip</comment> <comment>Sub-string used in automation name for 33 bit in bit flip</comment>
</data> </data>
<data name="32" xml:space="preserve"> <data name="32" xml:space="preserve">
<value>32nd </value> <value>32nd</value>
<comment>Sub-string used in automation name for 32 bit in bit flip</comment> <comment>Sub-string used in automation name for 32 bit in bit flip</comment>
</data> </data>
<data name="31" xml:space="preserve"> <data name="31" xml:space="preserve">
<value>31st </value> <value>31st</value>
<comment>Sub-string used in automation name for 31 bit in bit flip</comment> <comment>Sub-string used in automation name for 31 bit in bit flip</comment>
</data> </data>
<data name="30" xml:space="preserve"> <data name="30" xml:space="preserve">
<value>30th </value> <value>30th</value>
<comment>Sub-string used in automation name for 30 bit in bit flip</comment> <comment>Sub-string used in automation name for 30 bit in bit flip</comment>
</data> </data>
<data name="29" xml:space="preserve"> <data name="29" xml:space="preserve">
<value>29th </value> <value>29th</value>
<comment>Sub-string used in automation name for 29 bit in bit flip</comment> <comment>Sub-string used in automation name for 29 bit in bit flip</comment>
</data> </data>
<data name="28" xml:space="preserve"> <data name="28" xml:space="preserve">
<value>28th </value> <value>28th</value>
<comment>Sub-string used in automation name for 28 bit in bit flip</comment> <comment>Sub-string used in automation name for 28 bit in bit flip</comment>
</data> </data>
<data name="27" xml:space="preserve"> <data name="27" xml:space="preserve">
<value>27th </value> <value>27th</value>
<comment>Sub-string used in automation name for 27 bit in bit flip</comment> <comment>Sub-string used in automation name for 27 bit in bit flip</comment>
</data> </data>
<data name="26" xml:space="preserve"> <data name="26" xml:space="preserve">
<value>26th </value> <value>26th</value>
<comment>Sub-string used in automation name for 26 bit in bit flip</comment> <comment>Sub-string used in automation name for 26 bit in bit flip</comment>
</data> </data>
<data name="25" xml:space="preserve"> <data name="25" xml:space="preserve">
<value>25th </value> <value>25th</value>
<comment>Sub-string used in automation name for 25 bit in bit flip</comment> <comment>Sub-string used in automation name for 25 bit in bit flip</comment>
</data> </data>
<data name="24" xml:space="preserve"> <data name="24" xml:space="preserve">
<value>24th </value> <value>24th</value>
<comment>Sub-string used in automation name for 24 bit in bit flip</comment> <comment>Sub-string used in automation name for 24 bit in bit flip</comment>
</data> </data>
<data name="23" xml:space="preserve"> <data name="23" xml:space="preserve">
<value>23rd </value> <value>23rd</value>
<comment>Sub-string used in automation name for 23 bit in bit flip</comment> <comment>Sub-string used in automation name for 23 bit in bit flip</comment>
</data> </data>
<data name="22" xml:space="preserve"> <data name="22" xml:space="preserve">
<value>22nd </value> <value>22nd</value>
<comment>Sub-string used in automation name for 22 bit in bit flip</comment> <comment>Sub-string used in automation name for 22 bit in bit flip</comment>
</data> </data>
<data name="21" xml:space="preserve"> <data name="21" xml:space="preserve">
<value>21st </value> <value>21st</value>
<comment>Sub-string used in automation name for 21 bit in bit flip</comment> <comment>Sub-string used in automation name for 21 bit in bit flip</comment>
</data> </data>
<data name="20" xml:space="preserve"> <data name="20" xml:space="preserve">
<value>20th </value> <value>20th</value>
<comment>Sub-string used in automation name for 20 bit in bit flip</comment> <comment>Sub-string used in automation name for 20 bit in bit flip</comment>
</data> </data>
<data name="19" xml:space="preserve"> <data name="19" xml:space="preserve">
<value>19th </value> <value>19th</value>
<comment>Sub-string used in automation name for 19 bit in bit flip</comment> <comment>Sub-string used in automation name for 19 bit in bit flip</comment>
</data> </data>
<data name="18" xml:space="preserve"> <data name="18" xml:space="preserve">
<value>18th </value> <value>18th</value>
<comment>Sub-string used in automation name for 18 bit in bit flip</comment> <comment>Sub-string used in automation name for 18 bit in bit flip</comment>
</data> </data>
<data name="17" xml:space="preserve"> <data name="17" xml:space="preserve">
<value>17th </value> <value>17th</value>
<comment>Sub-string used in automation name for 17 bit in bit flip</comment> <comment>Sub-string used in automation name for 17 bit in bit flip</comment>
</data> </data>
<data name="16" xml:space="preserve"> <data name="16" xml:space="preserve">
<value>16th </value> <value>16th</value>
<comment>Sub-string used in automation name for 16 bit in bit flip</comment> <comment>Sub-string used in automation name for 16 bit in bit flip</comment>
</data> </data>
<data name="15" xml:space="preserve"> <data name="15" xml:space="preserve">
<value>15th </value> <value>15th</value>
<comment>Sub-string used in automation name for 15 bit in bit flip</comment> <comment>Sub-string used in automation name for 15 bit in bit flip</comment>
</data> </data>
<data name="14" xml:space="preserve"> <data name="14" xml:space="preserve">
<value>14th </value> <value>14th</value>
<comment>Sub-string used in automation name for 14 bit in bit flip</comment> <comment>Sub-string used in automation name for 14 bit in bit flip</comment>
</data> </data>
<data name="13" xml:space="preserve"> <data name="13" xml:space="preserve">
<value>13th </value> <value>13th</value>
<comment>Sub-string used in automation name for 13 bit in bit flip</comment> <comment>Sub-string used in automation name for 13 bit in bit flip</comment>
</data> </data>
<data name="12" xml:space="preserve"> <data name="12" xml:space="preserve">
<value>12th </value> <value>12th</value>
<comment>Sub-string used in automation name for 12 bit in bit flip</comment> <comment>Sub-string used in automation name for 12 bit in bit flip</comment>
</data> </data>
<data name="11" xml:space="preserve"> <data name="11" xml:space="preserve">
<value>11th </value> <value>11th</value>
<comment>Sub-string used in automation name for 11 bit in bit flip</comment> <comment>Sub-string used in automation name for 11 bit in bit flip</comment>
</data> </data>
<data name="10" xml:space="preserve"> <data name="10" xml:space="preserve">
<value>10th </value> <value>10th</value>
<comment>Sub-string used in automation name for 10 bit in bit flip</comment> <comment>Sub-string used in automation name for 10 bit in bit flip</comment>
</data> </data>
<data name="9" xml:space="preserve"> <data name="9" xml:space="preserve">
<value>9th </value> <value>9th</value>
<comment>Sub-string used in automation name for 9 bit in bit flip</comment> <comment>Sub-string used in automation name for 9 bit in bit flip</comment>
</data> </data>
<data name="8" xml:space="preserve"> <data name="8" xml:space="preserve">
<value>8th </value> <value>8th</value>
<comment>Sub-string used in automation name for 8 bit in bit flip</comment> <comment>Sub-string used in automation name for 8 bit in bit flip</comment>
</data> </data>
<data name="7" xml:space="preserve"> <data name="7" xml:space="preserve">
<value>7th </value> <value>7th</value>
<comment>Sub-string used in automation name for 7 bit in bit flip</comment> <comment>Sub-string used in automation name for 7 bit in bit flip</comment>
</data> </data>
<data name="6" xml:space="preserve"> <data name="6" xml:space="preserve">
<value>6th </value> <value>6th</value>
<comment>Sub-string used in automation name for 6 bit in bit flip</comment> <comment>Sub-string used in automation name for 6 bit in bit flip</comment>
</data> </data>
<data name="5" xml:space="preserve"> <data name="5" xml:space="preserve">
<value>5th </value> <value>5th</value>
<comment>Sub-string used in automation name for 5 bit in bit flip</comment> <comment>Sub-string used in automation name for 5 bit in bit flip</comment>
</data> </data>
<data name="4" xml:space="preserve"> <data name="4" xml:space="preserve">
<value>4th </value> <value>4th</value>
<comment>Sub-string used in automation name for 4 bit in bit flip</comment> <comment>Sub-string used in automation name for 4 bit in bit flip</comment>
</data> </data>
<data name="3" xml:space="preserve"> <data name="3" xml:space="preserve">
<value>3rd </value> <value>3rd</value>
<comment>Sub-string used in automation name for 3 bit in bit flip</comment> <comment>Sub-string used in automation name for 3 bit in bit flip</comment>
</data> </data>
<data name="2" xml:space="preserve"> <data name="2" xml:space="preserve">
<value>2nd </value> <value>2nd</value>
<comment>Sub-string used in automation name for 2 bit in bit flip</comment> <comment>Sub-string used in automation name for 2 bit in bit flip</comment>
</data> </data>
<data name="1" xml:space="preserve"> <data name="1" xml:space="preserve">
<value>1st </value> <value>1st</value>
<comment>Sub-string used in automation name for 1 bit in bit flip</comment> <comment>Sub-string used in automation name for 1 bit in bit flip</comment>
</data> </data>
<data name="0" xml:space="preserve"> <data name="0" xml:space="preserve">
<value>0th </value> <value>0th</value>
<comment>Sub-string used in automation name for 0 bit in bit flip</comment> <comment>Sub-string used in automation name for 0 bit in bit flip</comment>
</data> </data>
<data name="MemoryButton_Open" xml:space="preserve"> <data name="MemoryButton_Open" xml:space="preserve">

View File

@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="using:CalculatorApp.Common" xmlns:common="using:CalculatorApp.Common"
xmlns:controls="using:CalculatorApp.Controls" xmlns:controls="using:CalculatorApp.Controls"
xmlns:converters="using:CalculatorApp.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:CalculatorApp" xmlns:local="using:CalculatorApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -14,11 +13,6 @@
Unloaded="OnUnloaded" Unloaded="OnUnloaded"
mc:Ignorable="d"> mc:Ignorable="d">
<UserControl.Resources> <UserControl.Resources>
<converters:BooleanNegationConverter x:Key="BooleanNegationConverter"/>
<converters:BooleanToVisibilityNegationConverter x:Key="BooleanToVisibilityNegationConverter"/>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<converters:BitFlipAutomationNameConverter x:Key="BitFlipAutomationNameConverter"/>
<Style x:Key="FlippingToggleButtonStyle" TargetType="ToggleButton"> <Style x:Key="FlippingToggleButtonStyle" TargetType="ToggleButton">
<Setter Property="FontSize" Value="20"/> <Setter Property="FontSize" Value="20"/>
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}"/> <Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}"/>
@ -141,7 +135,6 @@
<Setter Property="Foreground" Value="{ThemeResource AppControlPageTextBaseMediumHighBrush}"/> <Setter Property="Foreground" Value="{ThemeResource AppControlPageTextBaseMediumHighBrush}"/>
<Setter Property="AutomationProperties.AccessibilityView" Value="Raw"/> <Setter Property="AutomationProperties.AccessibilityView" Value="Raw"/>
</Style> </Style>
</UserControl.Resources> </UserControl.Resources>
<Grid x:Name="BitFlipPanel" <Grid x:Name="BitFlipPanel"
x:Uid="BitFlipPanel" x:Uid="BitFlipPanel"
@ -304,569 +297,761 @@
<controls:FlipButtons x:Name="Bit63" <controls:FlipButtons x:Name="Bit63"
Grid.Column="1" Grid.Column="1"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='63', Mode=OneWay}"
ButtonId="BINPOS63" ButtonId="BINPOS63"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 63), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>63</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit62" <controls:FlipButtons x:Name="Bit62"
Grid.Column="2" Grid.Column="2"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='62', Mode=OneWay}"
ButtonId="BINPOS62" ButtonId="BINPOS62"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 62), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>62</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit61" <controls:FlipButtons x:Name="Bit61"
Grid.Column="3" Grid.Column="3"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='61', Mode=OneWay}"
ButtonId="BINPOS61" ButtonId="BINPOS61"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 61), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>61</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit60" <controls:FlipButtons x:Name="Bit60"
Grid.Column="4" Grid.Column="4"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='60', Mode=OneWay}"
ButtonId="BINPOS60" ButtonId="BINPOS60"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 60), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>60</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit59" <controls:FlipButtons x:Name="Bit59"
Grid.Column="6" Grid.Column="6"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='59', Mode=OneWay}"
ButtonId="BINPOS59" ButtonId="BINPOS59"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 59), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>59</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit58" <controls:FlipButtons x:Name="Bit58"
Grid.Column="7" Grid.Column="7"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='58', Mode=OneWay}"
ButtonId="BINPOS58" ButtonId="BINPOS58"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 58), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>58</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit57" <controls:FlipButtons x:Name="Bit57"
Grid.Column="8" Grid.Column="8"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='57', Mode=OneWay}"
ButtonId="BINPOS57" ButtonId="BINPOS57"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 57), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>57</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit56" <controls:FlipButtons x:Name="Bit56"
Grid.Column="9" Grid.Column="9"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='56', Mode=OneWay}"
ButtonId="BINPOS56" ButtonId="BINPOS56"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 56), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>56</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit55" <controls:FlipButtons x:Name="Bit55"
Grid.Column="11" Grid.Column="11"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='55', Mode=OneWay}"
ButtonId="BINPOS55" ButtonId="BINPOS55"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 55), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>55</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit54" <controls:FlipButtons x:Name="Bit54"
Grid.Column="12" Grid.Column="12"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='54', Mode=OneWay}"
ButtonId="BINPOS54" ButtonId="BINPOS54"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 54), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>54</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit53" <controls:FlipButtons x:Name="Bit53"
Grid.Column="13" Grid.Column="13"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='53', Mode=OneWay}"
ButtonId="BINPOS53" ButtonId="BINPOS53"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 53), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>53</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit52" <controls:FlipButtons x:Name="Bit52"
Grid.Column="14" Grid.Column="14"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='52', Mode=OneWay}"
ButtonId="BINPOS52" ButtonId="BINPOS52"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 52), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>52</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit51" <controls:FlipButtons x:Name="Bit51"
Grid.Column="16" Grid.Column="16"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='51', Mode=OneWay}"
ButtonId="BINPOS51" ButtonId="BINPOS51"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 51), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>51</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit50" <controls:FlipButtons x:Name="Bit50"
Grid.Column="17" Grid.Column="17"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='50', Mode=OneWay}"
ButtonId="BINPOS50" ButtonId="BINPOS50"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 50), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>50</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit49" <controls:FlipButtons x:Name="Bit49"
Grid.Column="18" Grid.Column="18"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='49', Mode=OneWay}"
ButtonId="BINPOS49" ButtonId="BINPOS49"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 49), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>49</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit48" <controls:FlipButtons x:Name="Bit48"
Grid.Column="19" Grid.Column="19"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='48', Mode=OneWay}"
ButtonId="BINPOS48" ButtonId="BINPOS48"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 48), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>48</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit47" <controls:FlipButtons x:Name="Bit47"
Grid.Row="2" Grid.Row="2"
Grid.Column="1" Grid.Column="1"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='47', Mode=OneWay}"
ButtonId="BINPOS47" ButtonId="BINPOS47"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 47), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>47</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit46" <controls:FlipButtons x:Name="Bit46"
Grid.Row="2" Grid.Row="2"
Grid.Column="2" Grid.Column="2"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='46', Mode=OneWay}"
ButtonId="BINPOS46" ButtonId="BINPOS46"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 46), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>46</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit45" <controls:FlipButtons x:Name="Bit45"
Grid.Row="2" Grid.Row="2"
Grid.Column="3" Grid.Column="3"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='45', Mode=OneWay}"
ButtonId="BINPOS45" ButtonId="BINPOS45"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 45), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>45</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit44" <controls:FlipButtons x:Name="Bit44"
Grid.Row="2" Grid.Row="2"
Grid.Column="4" Grid.Column="4"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='44', Mode=OneWay}"
ButtonId="BINPOS44" ButtonId="BINPOS44"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 44), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>44</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit43" <controls:FlipButtons x:Name="Bit43"
Grid.Row="2" Grid.Row="2"
Grid.Column="6" Grid.Column="6"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='43', Mode=OneWay}"
ButtonId="BINPOS43" ButtonId="BINPOS43"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 43), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>43</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit42" <controls:FlipButtons x:Name="Bit42"
Grid.Row="2" Grid.Row="2"
Grid.Column="7" Grid.Column="7"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='42', Mode=OneWay}"
ButtonId="BINPOS42" ButtonId="BINPOS42"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 42), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>42</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit41" <controls:FlipButtons x:Name="Bit41"
Grid.Row="2" Grid.Row="2"
Grid.Column="8" Grid.Column="8"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='41', Mode=OneWay}"
ButtonId="BINPOS41" ButtonId="BINPOS41"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 41), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>41</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit40" <controls:FlipButtons x:Name="Bit40"
Grid.Row="2" Grid.Row="2"
Grid.Column="9" Grid.Column="9"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='40', Mode=OneWay}"
ButtonId="BINPOS40" ButtonId="BINPOS40"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 40), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>40</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit39" <controls:FlipButtons x:Name="Bit39"
Grid.Row="2" Grid.Row="2"
Grid.Column="11" Grid.Column="11"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='39', Mode=OneWay}"
ButtonId="BINPOS39" ButtonId="BINPOS39"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 39), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>39</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit38" <controls:FlipButtons x:Name="Bit38"
Grid.Row="2" Grid.Row="2"
Grid.Column="12" Grid.Column="12"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='38', Mode=OneWay}"
ButtonId="BINPOS38" ButtonId="BINPOS38"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 38), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>38</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit37" <controls:FlipButtons x:Name="Bit37"
Grid.Row="2" Grid.Row="2"
Grid.Column="13" Grid.Column="13"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='37', Mode=OneWay}"
ButtonId="BINPOS37" ButtonId="BINPOS37"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 37), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>37</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit36" <controls:FlipButtons x:Name="Bit36"
Grid.Row="2" Grid.Row="2"
Grid.Column="14" Grid.Column="14"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='36', Mode=OneWay}"
ButtonId="BINPOS36" ButtonId="BINPOS36"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 36), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>36</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit35" <controls:FlipButtons x:Name="Bit35"
Grid.Row="2" Grid.Row="2"
Grid.Column="16" Grid.Column="16"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='35', Mode=OneWay}"
ButtonId="BINPOS35" ButtonId="BINPOS35"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 35), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>35</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit34" <controls:FlipButtons x:Name="Bit34"
Grid.Row="2" Grid.Row="2"
Grid.Column="17" Grid.Column="17"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='34', Mode=OneWay}"
ButtonId="BINPOS34" ButtonId="BINPOS34"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 34), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>34</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit33" <controls:FlipButtons x:Name="Bit33"
Grid.Row="2" Grid.Row="2"
Grid.Column="18" Grid.Column="18"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='33', Mode=OneWay}"
ButtonId="BINPOS33" ButtonId="BINPOS33"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 33), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>33</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit32" <controls:FlipButtons x:Name="Bit32"
Grid.Row="2" Grid.Row="2"
Grid.Column="19" Grid.Column="19"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='32', Mode=OneWay}"
ButtonId="BINPOS32" ButtonId="BINPOS32"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsQwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 32), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>32</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit31" <controls:FlipButtons x:Name="Bit31"
Grid.Row="4" Grid.Row="4"
Grid.Column="1" Grid.Column="1"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='31', Mode=OneWay}"
ButtonId="BINPOS31" ButtonId="BINPOS31"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 31), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>31</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit30" <controls:FlipButtons x:Name="Bit30"
Grid.Row="4" Grid.Row="4"
Grid.Column="2" Grid.Column="2"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='30', Mode=OneWay}"
ButtonId="BINPOS30" ButtonId="BINPOS30"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 30), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>30</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit29" <controls:FlipButtons x:Name="Bit29"
Grid.Row="4" Grid.Row="4"
Grid.Column="3" Grid.Column="3"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='29', Mode=OneWay}"
ButtonId="BINPOS29" ButtonId="BINPOS29"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 29), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>29</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit28" <controls:FlipButtons x:Name="Bit28"
Grid.Row="4" Grid.Row="4"
Grid.Column="4" Grid.Column="4"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='28', Mode=OneWay}"
ButtonId="BINPOS28" ButtonId="BINPOS28"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 28), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>28</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit27" <controls:FlipButtons x:Name="Bit27"
Grid.Row="4" Grid.Row="4"
Grid.Column="6" Grid.Column="6"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='27', Mode=OneWay}"
ButtonId="BINPOS27" ButtonId="BINPOS27"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 27), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>27</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit26" <controls:FlipButtons x:Name="Bit26"
Grid.Row="4" Grid.Row="4"
Grid.Column="7" Grid.Column="7"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='26', Mode=OneWay}"
ButtonId="BINPOS26" ButtonId="BINPOS26"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 26), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>26</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit25" <controls:FlipButtons x:Name="Bit25"
Grid.Row="4" Grid.Row="4"
Grid.Column="8" Grid.Column="8"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='25', Mode=OneWay}"
ButtonId="BINPOS25" ButtonId="BINPOS25"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 25), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>25</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit24" <controls:FlipButtons x:Name="Bit24"
Grid.Row="4" Grid.Row="4"
Grid.Column="9" Grid.Column="9"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='24', Mode=OneWay}"
ButtonId="BINPOS24" ButtonId="BINPOS24"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 24), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>24</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit23" <controls:FlipButtons x:Name="Bit23"
Grid.Row="4" Grid.Row="4"
Grid.Column="11" Grid.Column="11"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='23', Mode=OneWay}"
ButtonId="BINPOS23" ButtonId="BINPOS23"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 23), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>23</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit22" <controls:FlipButtons x:Name="Bit22"
Grid.Row="4" Grid.Row="4"
Grid.Column="12" Grid.Column="12"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='22', Mode=OneWay}"
ButtonId="BINPOS22" ButtonId="BINPOS22"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 22), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>22</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit21" <controls:FlipButtons x:Name="Bit21"
Grid.Row="4" Grid.Row="4"
Grid.Column="13" Grid.Column="13"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='21', Mode=OneWay}"
ButtonId="BINPOS21" ButtonId="BINPOS21"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 21), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>21</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit20" <controls:FlipButtons x:Name="Bit20"
Grid.Row="4" Grid.Row="4"
Grid.Column="14" Grid.Column="14"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='20', Mode=OneWay}"
ButtonId="BINPOS20" ButtonId="BINPOS20"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 20), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>20</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit19" <controls:FlipButtons x:Name="Bit19"
Grid.Row="4" Grid.Row="4"
Grid.Column="16" Grid.Column="16"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='19', Mode=OneWay}"
ButtonId="BINPOS19" ButtonId="BINPOS19"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 19), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>19</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit18" <controls:FlipButtons x:Name="Bit18"
Grid.Row="4" Grid.Row="4"
Grid.Column="17" Grid.Column="17"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='18', Mode=OneWay}"
ButtonId="BINPOS18" ButtonId="BINPOS18"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 18), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>18</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit17" <controls:FlipButtons x:Name="Bit17"
Grid.Row="4" Grid.Row="4"
Grid.Column="18" Grid.Column="18"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='17', Mode=OneWay}"
ButtonId="BINPOS17" ButtonId="BINPOS17"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 17), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>17</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit16" <controls:FlipButtons x:Name="Bit16"
Grid.Row="4" Grid.Row="4"
Grid.Column="19" Grid.Column="19"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='16', Mode=OneWay}"
ButtonId="BINPOS16" ButtonId="BINPOS16"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsDwordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 16), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>16</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit15" <controls:FlipButtons x:Name="Bit15"
Grid.Row="6" Grid.Row="6"
Grid.Column="1" Grid.Column="1"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='15', Mode=OneWay}"
ButtonId="BINPOS15" ButtonId="BINPOS15"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsWordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 15), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>15</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit14" <controls:FlipButtons x:Name="Bit14"
Grid.Row="6" Grid.Row="6"
Grid.Column="2" Grid.Column="2"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='14', Mode=OneWay}"
ButtonId="BINPOS14" ButtonId="BINPOS14"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsWordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 14), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>14</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit13" <controls:FlipButtons x:Name="Bit13"
Grid.Row="6" Grid.Row="6"
Grid.Column="3" Grid.Column="3"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='13', Mode=OneWay}"
ButtonId="BINPOS13" ButtonId="BINPOS13"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsWordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 13), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>13</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit12" <controls:FlipButtons x:Name="Bit12"
Grid.Row="6" Grid.Row="6"
Grid.Column="4" Grid.Column="4"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='12', Mode=OneWay}"
ButtonId="BINPOS12" ButtonId="BINPOS12"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsWordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 12), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>12</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit11" <controls:FlipButtons x:Name="Bit11"
Grid.Row="6" Grid.Row="6"
Grid.Column="6" Grid.Column="6"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='11', Mode=OneWay}"
ButtonId="BINPOS11" ButtonId="BINPOS11"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsWordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 11), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>11</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit10" <controls:FlipButtons x:Name="Bit10"
Grid.Row="6" Grid.Row="6"
Grid.Column="7" Grid.Column="7"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='10', Mode=OneWay}"
ButtonId="BINPOS10" ButtonId="BINPOS10"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsWordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 10), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>10</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit9" <controls:FlipButtons x:Name="Bit9"
Grid.Row="6" Grid.Row="6"
Grid.Column="8" Grid.Column="8"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='9', Mode=OneWay}"
ButtonId="BINPOS9" ButtonId="BINPOS9"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsWordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 9), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>9</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit8" <controls:FlipButtons x:Name="Bit8"
Grid.Row="6" Grid.Row="6"
Grid.Column="9" Grid.Column="9"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='8', Mode=OneWay}"
ButtonId="BINPOS8" ButtonId="BINPOS8"
Checked="OnBitToggled" Checked="OnBitToggled"
IsEnabled="{x:Bind Model.IsWordEnabled, Mode=OneWay}" IsEnabled="{x:Bind ShouldEnableBit(Model.ValueBitLength, 8), Mode=OneWay}"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>8</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit7" <controls:FlipButtons x:Name="Bit7"
Grid.Row="6" Grid.Row="6"
Grid.Column="11" Grid.Column="11"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='7', Mode=OneWay}"
ButtonId="BINPOS7" ButtonId="BINPOS7"
Checked="OnBitToggled" Checked="OnBitToggled"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>7</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit6" <controls:FlipButtons x:Name="Bit6"
Grid.Row="6" Grid.Row="6"
Grid.Column="12" Grid.Column="12"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='6', Mode=OneWay}"
ButtonId="BINPOS6" ButtonId="BINPOS6"
Checked="OnBitToggled" Checked="OnBitToggled"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>6</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit5" <controls:FlipButtons x:Name="Bit5"
Grid.Row="6" Grid.Row="6"
Grid.Column="13" Grid.Column="13"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='5', Mode=OneWay}"
ButtonId="BINPOS5" ButtonId="BINPOS5"
Checked="OnBitToggled" Checked="OnBitToggled"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>5</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit4" <controls:FlipButtons x:Name="Bit4"
Grid.Row="6" Grid.Row="6"
Grid.Column="14" Grid.Column="14"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='4', Mode=OneWay}"
ButtonId="BINPOS4" ButtonId="BINPOS4"
Checked="OnBitToggled" Checked="OnBitToggled"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>4</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit3" <controls:FlipButtons x:Name="Bit3"
Grid.Row="6" Grid.Row="6"
Grid.Column="16" Grid.Column="16"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='3', Mode=OneWay}"
ButtonId="BINPOS3" ButtonId="BINPOS3"
Checked="OnBitToggled" Checked="OnBitToggled"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>3</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit2" <controls:FlipButtons x:Name="Bit2"
Grid.Row="6" Grid.Row="6"
Grid.Column="17" Grid.Column="17"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='2', Mode=OneWay}"
ButtonId="BINPOS2" ButtonId="BINPOS2"
Checked="OnBitToggled" Checked="OnBitToggled"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>2</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit1" <controls:FlipButtons x:Name="Bit1"
Grid.Row="6" Grid.Row="6"
Grid.Column="18" Grid.Column="18"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='1', Mode=OneWay}"
ButtonId="BINPOS1" ButtonId="BINPOS1"
Checked="OnBitToggled" Checked="OnBitToggled"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>1</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
<controls:FlipButtons x:Name="Bit0" <controls:FlipButtons x:Name="Bit0"
Grid.Row="6" Grid.Row="6"
Grid.Column="19" Grid.Column="19"
Style="{StaticResource FlippingToggleButtonStyle}" Style="{StaticResource FlippingToggleButtonStyle}"
AutomationProperties.Name="{x:Bind Model.BinaryDisplayValue, Converter={StaticResource BitFlipAutomationNameConverter}, ConverterParameter='0', Mode=OneWay}"
ButtonId="BINPOS0" ButtonId="BINPOS0"
Checked="OnBitToggled" Checked="OnBitToggled"
Unchecked="OnBitToggled"/> Unchecked="OnBitToggled">
<controls:FlipButtons.Tag>
<x:Int32>0</x:Int32>
</controls:FlipButtons.Tag>
</controls:FlipButtons>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -11,6 +11,8 @@
#include "CalcViewModel/Common/TraceLogger.h" #include "CalcViewModel/Common/TraceLogger.h"
#include "CalcViewModel/Common/LocalizationSettings.h" #include "CalcViewModel/Common/LocalizationSettings.h"
#include "Converters/BooleanToVisibilityConverter.h" #include "Converters/BooleanToVisibilityConverter.h"
#include <CalcViewModel/Common/AppResourceProvider.h>
#include "CalcViewModel/Common/LocalizationStringUtil.h"
using namespace CalculatorApp; using namespace CalculatorApp;
using namespace CalculatorApp::Common; using namespace CalculatorApp::Common;
@ -19,6 +21,7 @@ using namespace CalculatorApp::ViewModel;
using namespace Platform; using namespace Platform;
using namespace std; using namespace std;
using namespace Windows::UI::Xaml; using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Automation;
using namespace Windows::UI::Xaml::Controls; using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Data; using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Input;
@ -29,15 +32,11 @@ CalculatorProgrammerBitFlipPanel::CalculatorProgrammerBitFlipPanel()
: m_updatingCheckedStates(false) : m_updatingCheckedStates(false)
{ {
InitializeComponent(); InitializeComponent();
auto booleanToVisibilityConverter = ref new Converters::BooleanToVisibilityConverter;
SetVisibilityBinding(BitFlipPanel, L"IsBinaryBitFlippingEnabled", booleanToVisibilityConverter);
AssignFlipButtons(); AssignFlipButtons();
} }
void CalculatorProgrammerBitFlipPanel::OnLoaded(Object ^ sender, RoutedEventArgs ^ e) void CalculatorProgrammerBitFlipPanel::OnLoaded(Object ^ sender, RoutedEventArgs ^ e)
{ {
UnsubscribePropertyChanged();
SubscribePropertyChanged(); SubscribePropertyChanged();
} }
@ -51,8 +50,7 @@ void CalculatorProgrammerBitFlipPanel::SubscribePropertyChanged()
if (Model != nullptr) if (Model != nullptr)
{ {
m_propertyChangedToken = Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &CalculatorProgrammerBitFlipPanel::OnPropertyChanged); m_propertyChangedToken = Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &CalculatorProgrammerBitFlipPanel::OnPropertyChanged);
UpdateCheckedStates(true);
UpdateCheckedStates();
} }
} }
@ -67,9 +65,19 @@ void CalculatorProgrammerBitFlipPanel::UnsubscribePropertyChanged()
void CalculatorProgrammerBitFlipPanel::OnPropertyChanged(Object ^ sender, PropertyChangedEventArgs ^ e) void CalculatorProgrammerBitFlipPanel::OnPropertyChanged(Object ^ sender, PropertyChangedEventArgs ^ e)
{ {
if (e->PropertyName == StandardCalculatorViewModel::BinaryDisplayValuePropertyName) if (e->PropertyName == StandardCalculatorViewModel::BinaryDigitsPropertyName)
{ {
UpdateCheckedStates(); UpdateCheckedStates(false);
}
else if (e->PropertyName == StandardCalculatorViewModel::IsBitFlipCheckedPropertyName
|| e->PropertyName == StandardCalculatorViewModel::IsProgrammerPropertyName)
{
if (Model->IsBitFlipChecked && Model->IsProgrammer)
{
// OnBitToggle won't update the automation properties when this control isn't displayed
// We need to update all automation properties names manually when the BitFlipPanel is displayed again
UpdateAutomationPropertiesNames();
}
} }
} }
@ -148,14 +156,6 @@ void CalculatorProgrammerBitFlipPanel::AssignFlipButtons()
m_flipButtons[63] = this->Bit63; m_flipButtons[63] = this->Bit63;
} }
void CalculatorProgrammerBitFlipPanel::SetVisibilityBinding(_In_ FrameworkElement ^ element, _In_ String ^ path, _In_ IValueConverter ^ converter)
{
Binding ^ commandBinding = ref new Binding();
commandBinding->Path = ref new PropertyPath(path);
commandBinding->Converter = converter;
element->SetBinding(VisibilityProperty, commandBinding);
}
void CalculatorProgrammerBitFlipPanel::OnBitToggled(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e) void CalculatorProgrammerBitFlipPanel::OnBitToggled(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
{ {
if (m_updatingCheckedStates) if (m_updatingCheckedStates)
@ -168,14 +168,16 @@ void CalculatorProgrammerBitFlipPanel::OnBitToggled(_In_ Object ^ sender, _In_ R
// Also, if the mode is switched to other Calculator modes when the BitFlip panel is open, // Also, if the mode is switched to other Calculator modes when the BitFlip panel is open,
// a race condition exists in which the IsProgrammerMode property is still true and the UpdatePrimaryResult() is called, // a race condition exists in which the IsProgrammerMode property is still true and the UpdatePrimaryResult() is called,
// which continuously alters the Display Value and the state of the Bit Flip buttons. // which continuously alters the Display Value and the state of the Bit Flip buttons.
if ((Model->IsBitFlipChecked) && Model->IsProgrammer) if (Model->IsBitFlipChecked && Model->IsProgrammer)
{ {
auto flipButton = static_cast<FlipButtons ^>(sender); auto flipButton = static_cast<FlipButtons ^>(sender);
int index = static_cast<int>(flipButton->Tag);
flipButton->SetValue(AutomationProperties::NameProperty, GenerateAutomationPropertiesName(index, flipButton->IsChecked->Value));
Model->ButtonPressed->Execute(flipButton->ButtonId); Model->ButtonPressed->Execute(flipButton->ButtonId);
} }
} }
void CalculatorProgrammerBitFlipPanel::UpdateCheckedStates() void CalculatorProgrammerBitFlipPanel::UpdateCheckedStates(bool updateAutomationPropertiesNames)
{ {
assert(!m_updatingCheckedStates); assert(!m_updatingCheckedStates);
assert(m_flipButtons.size() == s_numBits); assert(m_flipButtons.size() == s_numBits);
@ -185,35 +187,57 @@ void CalculatorProgrammerBitFlipPanel::UpdateCheckedStates()
return; return;
} }
static const wchar_t ch0 = LocalizationSettings::GetInstance().GetDigitSymbolFromEnUsDigit(L'0');
// Filter any unwanted characters from the displayed string.
static constexpr array<wchar_t, 4> unwantedChars = { L' ', Utils::LRE, Utils::PDF, Utils::LRO };
wstringstream stream;
wstring displayValue = Model->BinaryDisplayValue->Data();
for (const wchar_t& c : displayValue)
{
if (find(begin(unwantedChars), end(unwantedChars), c) == unwantedChars.end())
{
stream << c;
}
}
wstring rawDisplay = stream.str();
size_t paddingCount = s_numBits - rawDisplay.length();
wstring setBits = wstring(paddingCount, ch0) + rawDisplay;
assert(setBits.length() == s_numBits);
m_updatingCheckedStates = true; m_updatingCheckedStates = true;
for (unsigned int bitIndex = 0; bitIndex < s_numBits; bitIndex++) auto it = m_flipButtons.begin();
int index = 0;
for (bool val : Model->BinaryDigits)
{ {
// Highest bit (64) is at index 0 in bit string. FlipButtons ^ flipButton = *it;
// To get bit 0, grab from opposite end of string. if (updateAutomationPropertiesNames)
wchar_t bit = setBits[s_numBits - bitIndex - 1]; {
flipButton->SetValue(AutomationProperties::NameProperty, GenerateAutomationPropertiesName(index, flipButton->IsChecked->Value));
m_flipButtons[bitIndex]->IsChecked = (bit != ch0); }
flipButton->IsChecked = val;
++it;
++index;
} }
m_updatingCheckedStates = false; m_updatingCheckedStates = false;
} }
void CalculatorProgrammerBitFlipPanel::UpdateAutomationPropertiesNames()
{
for (FlipButtons ^ flipButton : m_flipButtons)
{
int index = static_cast<int>(flipButton->Tag);
flipButton->SetValue(AutomationProperties::NameProperty, GenerateAutomationPropertiesName(index, flipButton->IsChecked->Value));
}
}
bool CalculatorProgrammerBitFlipPanel::ShouldEnableBit(BitLength length, int index)
{
switch (length)
{
case BitLength::BitLengthQWord:
return index <= 63;
case BitLength::BitLengthDWord:
return index <= 31;
case BitLength::BitLengthWord:
return index <= 15;
case BitLength::BitLengthByte:
return index <= 7;
}
return false;
}
String ^ CalculatorProgrammerBitFlipPanel::GenerateAutomationPropertiesName(int position, bool value) const
{
auto resourceLoader = AppResourceProvider::GetInstance();
String ^ indexName = resourceLoader.GetResourceString(ref new Platform::String(to_wstring(position).c_str()));
String ^ automationNameTemplate = resourceLoader.GetResourceString(L"BitFlipItemAutomationName");
String ^ bitPositionTemplate = resourceLoader.GetResourceString(L"BitPosition");
wstring bitPosition = LocalizationStringUtil::GetLocalizedString(bitPositionTemplate->Data(), indexName->Data());
return ref new String(LocalizationStringUtil::GetLocalizedString(automationNameTemplate->Data(), bitPosition.c_str(), value ? L"1" : L"0").c_str());
}

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
// //
@ -10,9 +10,6 @@
#include "Views/CalculatorProgrammerBitFlipPanel.g.h" #include "Views/CalculatorProgrammerBitFlipPanel.g.h"
#include "Controls/FlipButtons.h" #include "Controls/FlipButtons.h"
#include "Converters/BitFlipAutomationNameConverter.h"
#include "Converters/BooleanNegationConverter.h"
#include "Converters/VisibilityNegationConverter.h"
#include "CalcViewModel/StandardCalculatorViewModel.h" #include "CalcViewModel/StandardCalculatorViewModel.h"
namespace CalculatorApp namespace CalculatorApp
@ -22,6 +19,8 @@ namespace CalculatorApp
public: public:
CalculatorProgrammerBitFlipPanel(); CalculatorProgrammerBitFlipPanel();
bool ShouldEnableBit(CalculatorApp::Common::BitLength length, int index);
property CalculatorApp::ViewModel::StandardCalculatorViewModel property CalculatorApp::ViewModel::StandardCalculatorViewModel
^ Model { CalculatorApp::ViewModel::StandardCalculatorViewModel ^ get(); } ^ Model { CalculatorApp::ViewModel::StandardCalculatorViewModel ^ get(); }
@ -34,15 +33,13 @@ namespace CalculatorApp
void AssignFlipButtons(); void AssignFlipButtons();
void SetVisibilityBinding(
_In_ Windows::UI::Xaml::FrameworkElement ^ element,
_In_ Platform::String ^ path,
_In_ Windows::UI::Xaml::Data::IValueConverter ^ converter);
void OnBitToggled(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e); void OnBitToggled(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
void UpdateCheckedStates();
private: private:
Windows::Foundation::EventRegistrationToken m_propertyChangedToken; Windows::Foundation::EventRegistrationToken m_propertyChangedToken;
Platform::String ^ GenerateAutomationPropertiesName(int position, bool value) const;
void UpdateCheckedStates(bool updateAutomationPropertiesNames);
void UpdateAutomationPropertiesNames();
static const unsigned int s_numBits = 64; static const unsigned int s_numBits = 64;
std::array<CalculatorApp::Controls::FlipButtons ^, s_numBits> m_flipButtons; std::array<CalculatorApp::Controls::FlipButtons ^, s_numBits> m_flipButtons;

View File

@ -37,42 +37,29 @@ void CalculatorProgrammerDisplayPanel::OnBitLengthButtonPressed(Object ^ paramet
ByteButton->Visibility = ::Visibility::Collapsed; ByteButton->Visibility = ::Visibility::Collapsed;
if (buttonId == "0") if (buttonId == "0")
{ {
Model->ButtonPressed->Execute(NumbersAndOperatorsEnum::Dword); Model->ValueBitLength = BitLength::BitLengthDWord;
DwordButton->Visibility = ::Visibility::Visible; DwordButton->Visibility = ::Visibility::Visible;
DwordButton->Focus(::FocusState::Programmatic); DwordButton->Focus(::FocusState::Programmatic);
Model->IsQwordEnabled = false;
Model->IsDwordEnabled = true;
Model->IsWordEnabled = true;
} }
else if (buttonId == "1") else if (buttonId == "1")
{ {
Model->ButtonPressed->Execute(NumbersAndOperatorsEnum::Word); Model->ValueBitLength = BitLength::BitLengthWord;
WordButton->Visibility = ::Visibility::Visible; WordButton->Visibility = ::Visibility::Visible;
WordButton->Focus(::FocusState::Programmatic); WordButton->Focus(::FocusState::Programmatic);
Model->IsQwordEnabled = false;
Model->IsDwordEnabled = false;
Model->IsWordEnabled = true;
} }
else if (buttonId == "2") else if (buttonId == "2")
{ {
Model->ButtonPressed->Execute(NumbersAndOperatorsEnum::Byte); Model->ValueBitLength = BitLength::BitLengthByte;
ByteButton->Visibility = ::Visibility::Visible; ByteButton->Visibility = ::Visibility::Visible;
ByteButton->Focus(::FocusState::Programmatic); ByteButton->Focus(::FocusState::Programmatic);
Model->IsQwordEnabled = false;
Model->IsDwordEnabled = false;
Model->IsWordEnabled = false;
} }
else if (buttonId == "3") else if (buttonId == "3")
{ {
Model->ButtonPressed->Execute(NumbersAndOperatorsEnum::Qword); Model->ValueBitLength = BitLength::BitLengthQWord;
QwordButton->Visibility = ::Visibility::Visible; QwordButton->Visibility = ::Visibility::Visible;
QwordButton->Focus(::FocusState::Programmatic); QwordButton->Focus(::FocusState::Programmatic);
Model->IsQwordEnabled = true;
Model->IsDwordEnabled = true;
Model->IsWordEnabled = true;
} }
// update memory list according to bit length
Model->SetMemorizedNumbersString();
} }
bool CalculatorProgrammerDisplayPanel::IsErrorVisualState::get() bool CalculatorProgrammerDisplayPanel::IsErrorVisualState::get()

View File

@ -27,9 +27,6 @@ CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators()
: m_isErrorVisualState(false) : m_isErrorVisualState(false)
{ {
InitializeComponent(); InitializeComponent();
auto booleanToVisibilityNegationConverter = ref new Converters::BooleanToVisibilityNegationConverter;
SetVisibilityBinding(ProgRadixOps, L"IsBinaryBitFlippingEnabled", booleanToVisibilityNegationConverter);
} }
void CalculatorProgrammerRadixOperators::OnLoaded(Object ^, RoutedEventArgs ^) void CalculatorProgrammerRadixOperators::OnLoaded(Object ^, RoutedEventArgs ^)
@ -70,14 +67,6 @@ void CalculatorProgrammerRadixOperators::Shift_Clicked(Platform::Object ^ sender
} }
} }
void CalculatorProgrammerRadixOperators::SetVisibilityBinding(FrameworkElement ^ element, String ^ path, IValueConverter ^ converter)
{
Binding ^ commandBinding = ref new Binding();
commandBinding->Path = ref new PropertyPath(path);
commandBinding->Converter = converter;
element->SetBinding(VisibilityProperty, commandBinding);
}
void CalculatorProgrammerRadixOperators::ProgModeRadixChange() void CalculatorProgrammerRadixOperators::ProgModeRadixChange()
{ {
NumberPad->ProgModeRadixChange(); NumberPad->ProgModeRadixChange();

View File

@ -32,7 +32,6 @@ namespace CalculatorApp
private: private:
void Shift_Clicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); void Shift_Clicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void SetVisibilityBinding(Windows::UI::Xaml::FrameworkElement ^ element, Platform::String ^ path, Windows::UI::Xaml::Data::IValueConverter ^ converter);
void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnUnloaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); void OnUnloaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void ProgModeRadixChange(); void ProgModeRadixChange();

View File

@ -108,9 +108,10 @@
DataContext="{x:Bind Model}" DataContext="{x:Bind Model}"
ExpandedModeThresholdWidth="Infinity" ExpandedModeThresholdWidth="Infinity"
IsBackButtonVisible="Collapsed" IsBackButtonVisible="Collapsed"
IsPaneToggleButtonVisible="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}"
IsEnabled="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}" IsEnabled="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}"
IsPaneToggleButtonVisible="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}"
IsSettingsVisible="False" IsSettingsVisible="False"
ItemInvoked="OnNavItemInvoked"
Loaded="OnNavLoaded" Loaded="OnNavLoaded"
MenuItemsSource="{x:Bind CreateUIElementsForCategories(Model.Categories), Mode=OneWay}" MenuItemsSource="{x:Bind CreateUIElementsForCategories(Model.Categories), Mode=OneWay}"
OpenPaneLength="{StaticResource SplitViewOpenPaneLength}" OpenPaneLength="{StaticResource SplitViewOpenPaneLength}"
@ -118,7 +119,6 @@
PaneOpened="OnNavPaneOpened" PaneOpened="OnNavPaneOpened"
PaneOpening="OnNavPaneOpening" PaneOpening="OnNavPaneOpening"
SelectionChanged="OnNavSelectionChanged" SelectionChanged="OnNavSelectionChanged"
ItemInvoked="OnNavItemInvoked"
TabIndex="1" TabIndex="1"
UseSystemFocusVisuals="True"> UseSystemFocusVisuals="True">
@ -156,29 +156,29 @@
</muxc:NavigationView.PaneFooter> </muxc:NavigationView.PaneFooter>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"></ColumnDefinition> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock x:Name="Header" <TextBlock x:Name="Header"
Grid.Column="0"
Margin="52,6,12,0" Margin="52,6,12,0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
Visibility="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanToVisibilityNegationConverter}, Mode=OneWay}"
Style="{StaticResource SubtitleTextBlockStyle}" Style="{StaticResource SubtitleTextBlockStyle}"
Text="{x:Bind Model.CategoryName, Mode=OneWay}" Text="{x:Bind Model.CategoryName, Mode=OneWay}"
Grid.Column="0"/> Visibility="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanToVisibilityNegationConverter}, Mode=OneWay}"/>
<Button x:Name="NormalAlwaysOnTopButton" <Button x:Name="NormalAlwaysOnTopButton"
x:Uid="EnterAlwaysOnTopButton" x:Uid="EnterAlwaysOnTopButton"
FontFamily="{StaticResource CalculatorFontFamily}" Grid.Column="1"
Style="{StaticResource SquareIconButtonStyle}"
Content="&#xEE49;"
Click="AlwaysOnTopButtonClick"
VerticalAlignment="Top" VerticalAlignment="Top"
HorizontalContentAlignment="Center" HorizontalContentAlignment="Center"
Style="{StaticResource SquareIconButtonStyle}"
Background="Transparent" Background="Transparent"
Visibility="{x:Bind Model.DisplayNormalAlwaysOnTopOption, Mode=OneWay}" FontFamily="{StaticResource CalculatorFontFamily}"
AutomationProperties.AutomationId="NormalAlwaysOnTopButton" AutomationProperties.AutomationId="NormalAlwaysOnTopButton"
Grid.Column="1"/> Click="AlwaysOnTopButtonClick"
Content="&#xEE49;"
Visibility="{x:Bind Model.DisplayNormalAlwaysOnTopOption, Mode=OneWay}"/>
</Grid> </Grid>
</muxc:NavigationView> </muxc:NavigationView>
</Grid> </Grid>

View File

@ -1,15 +1,12 @@
<UserControl x:Class="CalculatorApp.OperatorsPanel" <UserControl x:Class="CalculatorApp.OperatorsPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="using:CalculatorApp.Common"
xmlns:controls="using:CalculatorApp.Controls"
xmlns:converters="using:CalculatorApp.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:CalculatorApp" xmlns:local="using:CalculatorApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
UseLayoutRounding="False"
d:DesignHeight="315" d:DesignHeight="315"
d:DesignWidth="235" d:DesignWidth="235"
UseLayoutRounding="False"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid> <Grid>
<local:CalculatorStandardOperators x:Name="StandardOperators" <local:CalculatorStandardOperators x:Name="StandardOperators"
@ -25,14 +22,12 @@
<local:CalculatorProgrammerBitFlipPanel x:Name="BitFlipPanel" <local:CalculatorProgrammerBitFlipPanel x:Name="BitFlipPanel"
x:Load="False" x:Load="False"
IsEnabled="{x:Bind Model.IsBinaryBitFlippingEnabled, Mode=OneWay}" Visibility="{x:Bind Model.IsBinaryBitFlippingEnabled, Mode=OneWay}"/>
Visibility="{x:Bind IsBitFlipChecked, Mode=OneWay}"/>
<local:CalculatorProgrammerRadixOperators x:Name="ProgrammerRadixOperators" <local:CalculatorProgrammerRadixOperators x:Name="ProgrammerRadixOperators"
x:Load="False" x:Load="False"
IsEnabled="{x:Bind Model.AreProgrammerRadixOperatorsEnabled, Mode=OneWay}"
TabIndex="16" TabIndex="16"
Visibility="{x:Bind Model.IsProgrammer, Mode=OneWay}"/> Visibility="{x:Bind Model.AreProgrammerRadixOperatorsEnabled, Mode=OneWay}"/>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -59,27 +59,30 @@ namespace CalculatorUnitTests
exp_TooLong += L"-1234567"; exp_TooLong += L"-1234567";
} }
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.ValidatePasteExpression(StringReference(exp_TooLong.c_str()), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1), m_CopyPasteManager.ValidatePasteExpression(StringReference(exp_TooLong.c_str()), ViewMode::Standard, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown),
StringReference(exp_TooLong.c_str()), StringReference(exp_TooLong.c_str()),
L"Verify ValidatePasteExpression handles expressions up to max length"); L"Verify ValidatePasteExpression handles expressions up to max length");
exp_TooLong += L"1"; exp_TooLong += L"1";
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.ValidatePasteExpression(StringReference(exp_TooLong.c_str()), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1), m_CopyPasteManager.ValidatePasteExpression(
StringReference(exp_TooLong.c_str()), ViewMode::Standard, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown),
StringReference(L"NoOp"), StringReference(L"NoOp"),
L"Verify ValidatePasteExpression returns NoOp for strings over max length"); L"Verify ValidatePasteExpression returns NoOp for strings over max length");
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.ValidatePasteExpression(StringReference(L""), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1), m_CopyPasteManager.ValidatePasteExpression(
StringReference(L""), ViewMode::Standard, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown),
StringReference(L"NoOp"), StringReference(L"NoOp"),
L"Verify empty string is invalid"); L"Verify empty string is invalid");
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.ValidatePasteExpression(StringReference(L"123e456"), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1), m_CopyPasteManager.ValidatePasteExpression(
StringReference(L"123e456"), ViewMode::Standard, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown),
StringReference(L"NoOp"), StringReference(L"NoOp"),
L"Verify pasting unsupported strings for the current mode is invalid"); L"Verify pasting unsupported strings for the current mode is invalid");
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.ValidatePasteExpression(StringReference(L"123"), ViewMode::None, CategoryGroupType::None, -1, -1), m_CopyPasteManager.ValidatePasteExpression(StringReference(L"123"), ViewMode::None, CategoryGroupType::None, -1, BitLength::BitLengthUnknown),
StringReference(L"NoOp"), StringReference(L"NoOp"),
L"Verify pasting without a ViewMode or Category is invalid"); L"Verify pasting without a ViewMode or Category is invalid");
}; };
@ -137,54 +140,60 @@ namespace CalculatorUnitTests
TEST_METHOD(ValidateExpressionRegExMatch) TEST_METHOD(ValidateExpressionRegExMatch)
{ {
VERIFY_IS_FALSE( VERIFY_IS_FALSE(
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{}, ViewMode::Standard, CategoryGroupType::Calculator, -1, -1), m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{}, ViewMode::Standard, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown),
L"Verify empty list of operands returns false."); L"Verify empty list of operands returns false.");
VERIFY_IS_FALSE( VERIFY_IS_FALSE(
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123" }, ViewMode::None, CategoryGroupType::Calculator, -1, -1), m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"123" }, ViewMode::None, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown),
L"Verify invalid ViewMode/CategoryGroups return false."); L"Verify invalid ViewMode/CategoryGroups return false.");
VERIFY_IS_FALSE( VERIFY_IS_FALSE(
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123" }, ViewMode::Currency, CategoryGroupType::None, -1, -1), m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"123" }, ViewMode::Currency, CategoryGroupType::None, -1, BitLength::BitLengthUnknown),
L"Verify invalid ViewMode/CategoryGroups return false."); L"Verify invalid ViewMode/CategoryGroups return false.");
Logger::WriteMessage(L"Verify operand lengths > max return false."); Logger::WriteMessage(L"Verify operand lengths > max return false.");
VERIFY_IS_FALSE(
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"12345678901234567" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, -1));
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch( VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"123456789012345678901234567890123" }, ViewMode::Scientific, CategoryGroupType::Calculator, -1, -1)); vector<wstring>{ L"12345678901234567" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown));
VERIFY_IS_FALSE(
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"12345678901234567" }, ViewMode::None, CategoryGroupType::Converter, -1, -1));
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch( VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"11111111111111111" }, ViewMode::Programmer, CategoryGroupType::Calculator, HexBase, QwordType)); vector<wstring>{ L"123456789012345678901234567890123" }, ViewMode::Scientific, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown));
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch( VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"12345678901234567890" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, QwordType)); vector<wstring>{ L"12345678901234567" }, ViewMode::None, CategoryGroupType::Converter, -1, BitLength::BitLengthUnknown));
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch( VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"11111111111111111111111" }, ViewMode::Programmer, CategoryGroupType::Calculator, OctBase, QwordType)); vector<wstring>{ L"11111111111111111" }, ViewMode::Programmer, CategoryGroupType::Calculator, HexBase, BitLength::BitLengthQWord));
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"12345678901234567890" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, BitLength::BitLengthQWord));
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"11111111111111111111111" }, ViewMode::Programmer, CategoryGroupType::Calculator, OctBase, BitLength::BitLengthQWord));
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch( VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"10000000000000000000000000000000000000000000000000000000000000000" }, vector<wstring>{ L"10000000000000000000000000000000000000000000000000000000000000000" },
ViewMode::Programmer, ViewMode::Programmer,
CategoryGroupType::Calculator, CategoryGroupType::Calculator,
BinBase, BinBase,
QwordType)); BitLength::BitLengthQWord));
VERIFY_IS_FALSE( VERIFY_IS_FALSE(
m_CopyPasteManager.ExpressionRegExMatch( m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"9223372036854775808" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, QwordType), vector<wstring>{ L"9223372036854775808" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, BitLength::BitLengthQWord),
L"Verify operand values > max return false."); L"Verify operand values > max return false.");
VERIFY_IS_TRUE( VERIFY_IS_TRUE(
m_CopyPasteManager.ExpressionRegExMatch( m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"((((((((((((((((((((123))))))))))))))))))))" }, ViewMode::Scientific, CategoryGroupType::Calculator, -1, -1), vector<wstring>{ L"((((((((((((((((((((123))))))))))))))))))))" },
ViewMode::Scientific,
CategoryGroupType::Calculator,
-1,
BitLength::BitLengthUnknown),
L"Verify sanitized operand is detected as within max length."); L"Verify sanitized operand is detected as within max length.");
VERIFY_IS_TRUE( VERIFY_IS_TRUE(
m_CopyPasteManager.ExpressionRegExMatch( m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"9223372036854775807" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, QwordType), vector<wstring>{ L"9223372036854775807" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, BitLength::BitLengthQWord),
L"Verify operand values == max return true."); L"Verify operand values == max return true.");
Logger::WriteMessage(L"Verify all operands must match patterns."); Logger::WriteMessage(L"Verify all operands must match patterns.");
VERIFY_IS_TRUE( VERIFY_IS_TRUE(m_CopyPasteManager.ExpressionRegExMatch(
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123", L"456" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, -1)); vector<wstring>{ L"123", L"456" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown));
VERIFY_IS_FALSE( VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123", L"1e23" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, -1)); vector<wstring>{ L"123", L"1e23" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown));
VERIFY_IS_TRUE( VERIFY_IS_TRUE(
m_CopyPasteManager.ExpressionRegExMatch( m_CopyPasteManager.ExpressionRegExMatch(
@ -192,16 +201,20 @@ namespace CalculatorUnitTests
ViewMode::Scientific, ViewMode::Scientific,
CategoryGroupType::Calculator, CategoryGroupType::Calculator,
-1, -1,
-1), BitLength::BitLengthUnknown),
L"Verify exponents are accepted in scientific mode."); L"Verify exponents are accepted in scientific mode.");
VERIFY_IS_FALSE( VERIFY_IS_FALSE(
m_CopyPasteManager.ExpressionRegExMatch( m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"123", L"12345678901234567" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, -1), vector<wstring>{ L"123", L"12345678901234567" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown),
L"Verify all operands must be within maxlength"); L"Verify all operands must be within maxlength");
VERIFY_IS_FALSE( VERIFY_IS_FALSE(
m_CopyPasteManager.ExpressionRegExMatch( m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"123", L"9223372036854775808" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, QwordType), vector<wstring>{ L"123", L"9223372036854775808" },
ViewMode::Programmer,
CategoryGroupType::Calculator,
DecBase,
BitLength::BitLengthQWord),
L"Verify all operand must be within max value."); L"Verify all operand must be within max value.");
}; };
@ -211,15 +224,15 @@ namespace CalculatorUnitTests
pair<size_t, unsigned long long int> scientificModeMaximums = make_pair(m_CopyPasteManager.MaxScientificOperandLength, 0); pair<size_t, unsigned long long int> scientificModeMaximums = make_pair(m_CopyPasteManager.MaxScientificOperandLength, 0);
pair<size_t, unsigned long long int> converterModeMaximums = make_pair(m_CopyPasteManager.MaxConverterInputLength, 0); pair<size_t, unsigned long long int> converterModeMaximums = make_pair(m_CopyPasteManager.MaxConverterInputLength, 0);
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Standard, CategoryGroupType::None, -1, -1), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Standard, CategoryGroupType::None, -1, BitLength::BitLengthUnknown),
standardModeMaximums, standardModeMaximums,
L"Verify Standard mode maximum values"); L"Verify Standard mode maximum values");
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Scientific, CategoryGroupType::None, -1, -1), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Scientific, CategoryGroupType::None, -1, BitLength::BitLengthUnknown),
scientificModeMaximums, scientificModeMaximums,
L"Verify Scientific mode maximum values"); L"Verify Scientific mode maximum values");
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::None, CategoryGroupType::Converter, -1, -1), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::None, CategoryGroupType::Converter, -1, BitLength::BitLengthUnknown),
converterModeMaximums, converterModeMaximums,
L"Verify Converter mode maximum values"); L"Verify Converter mode maximum values");
@ -229,62 +242,64 @@ namespace CalculatorUnitTests
unsigned long long int ullByteMax = UINT8_MAX; unsigned long long int ullByteMax = UINT8_MAX;
Logger::WriteMessage(L"Verify Programmer Mode HexBase maximum values"); Logger::WriteMessage(L"Verify Programmer Mode HexBase maximum values");
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, QwordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, BitLength::BitLengthQWord),
make_pair((size_t)16u, ullQwordMax)); make_pair((size_t)16u, ullQwordMax));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, DwordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, BitLength::BitLengthDWord),
make_pair((size_t)8u, ullDwordMax)); make_pair((size_t)8u, ullDwordMax));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, WordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, BitLength::BitLengthWord),
make_pair((size_t)4u, ullWordMax)); make_pair((size_t)4u, ullWordMax));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, ByteType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, BitLength::BitLengthByte),
make_pair((size_t)2u, ullByteMax)); make_pair((size_t)2u, ullByteMax));
Logger::WriteMessage(L"Verify Programmer Mode DecBase maximum values"); Logger::WriteMessage(L"Verify Programmer Mode DecBase maximum values");
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, QwordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, BitLength::BitLengthQWord),
make_pair((size_t)19u, ullQwordMax >> 1)); make_pair((size_t)19u, ullQwordMax >> 1));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, DwordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, BitLength::BitLengthDWord),
make_pair((size_t)10u, ullDwordMax >> 1)); make_pair((size_t)10u, ullDwordMax >> 1));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, WordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, BitLength::BitLengthWord),
make_pair((size_t)5u, ullWordMax >> 1)); make_pair((size_t)5u, ullWordMax >> 1));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, ByteType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, BitLength::BitLengthByte),
make_pair((size_t)3u, ullByteMax >> 1)); make_pair((size_t)3u, ullByteMax >> 1));
Logger::WriteMessage(L"Verify Programmer Mode OctBase maximum values"); Logger::WriteMessage(L"Verify Programmer Mode OctBase maximum values");
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, QwordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, BitLength::BitLengthQWord),
make_pair((size_t)22u, ullQwordMax)); make_pair((size_t)22u, ullQwordMax));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, DwordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, BitLength::BitLengthDWord),
make_pair((size_t)11u, ullDwordMax)); make_pair((size_t)11u, ullDwordMax));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, WordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, BitLength::BitLengthWord),
make_pair((size_t)6u, ullWordMax)); make_pair((size_t)6u, ullWordMax));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, ByteType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, BitLength::BitLengthByte),
make_pair((size_t)3u, ullByteMax)); make_pair((size_t)3u, ullByteMax));
Logger::WriteMessage(L"Verify Programmer Mode BinBase maximum values"); Logger::WriteMessage(L"Verify Programmer Mode BinBase maximum values");
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, QwordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, BitLength::BitLengthQWord),
make_pair((size_t)64u, ullQwordMax)); make_pair((size_t)64u, ullQwordMax));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, DwordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, BitLength::BitLengthDWord),
make_pair((size_t)32u, ullDwordMax)); make_pair((size_t)32u, ullDwordMax));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, WordType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, BitLength::BitLengthWord),
make_pair((size_t)16u, ullWordMax)); make_pair((size_t)16u, ullWordMax));
VERIFY_ARE_EQUAL( VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, ByteType), m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, BitLength::BitLengthByte),
make_pair((size_t)8u, ullByteMax)); make_pair((size_t)8u, ullByteMax));
Logger::WriteMessage(L"Verify invalid ViewModes/Categories return 0 for max values"); Logger::WriteMessage(L"Verify invalid ViewModes/Categories return 0 for max values");
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::None, CategoryGroupType::None, -1, -1), make_pair((size_t)0u, 0ull)); VERIFY_ARE_EQUAL(
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::None, CategoryGroupType::None, - 1, BitLength::BitLengthUnknown),
make_pair((size_t)0u, 0ull));
}; };
TEST_METHOD(ValidateSanitizeOperand) TEST_METHOD(ValidateSanitizeOperand)
@ -438,97 +453,97 @@ namespace CalculatorUnitTests
CopyPasteManager m_CopyPasteManager; CopyPasteManager m_CopyPasteManager;
String^ ValidateStandardPasteExpression(_In_ String^ pastedText) String^ ValidateStandardPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Standard, -1/*number base*/, -1/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Standard, -1/*number base*/, BitLength::BitLengthUnknown);
} }
String^ ValidateScientificPasteExpression(_In_ String^ pastedText) String^ ValidateScientificPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Scientific, -1/*number base*/, -1/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Scientific, -1/*number base*/, BitLength::BitLengthUnknown);
} }
String^ ValidateConverterPasteExpression(_In_ String^ pastedText) String^ ValidateConverterPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::None, CategoryGroupType::Converter, -1/*number base*/, -1/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::None, CategoryGroupType::Converter, -1/*number base*/, BitLength::BitLengthUnknown);
} }
String^ ValidateProgrammerHexQwordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerHexQwordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, HexBase/*number base*/, QwordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, HexBase/*number base*/, BitLength::BitLengthQWord);
} }
String^ ValidateProgrammerHexDwordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerHexDwordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, HexBase/*number base*/, DwordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, HexBase/*number base*/, BitLength::BitLengthDWord);
} }
String^ ValidateProgrammerHexWordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerHexWordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, HexBase/*number base*/, WordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, HexBase/*number base*/, BitLength::BitLengthWord);
} }
String^ ValidateProgrammerHexBytePasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerHexBytePasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, HexBase/*number base*/, ByteType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, HexBase/*number base*/, BitLength::BitLengthByte);
} }
String^ ValidateProgrammerDecQwordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerDecQwordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, DecBase/*number base*/, QwordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, DecBase/*number base*/, BitLength::BitLengthQWord);
} }
String^ ValidateProgrammerDecDwordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerDecDwordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, DecBase/*number base*/, DwordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, DecBase/*number base*/, BitLength::BitLengthDWord);
} }
String^ ValidateProgrammerDecWordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerDecWordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, DecBase/*number base*/, WordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, DecBase/*number base*/, BitLength::BitLengthWord);
} }
String^ ValidateProgrammerDecBytePasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerDecBytePasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, DecBase/*number base*/, ByteType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, DecBase/*number base*/, BitLength::BitLengthByte);
} }
String^ ValidateProgrammerOctQwordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerOctQwordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, OctBase/*number base*/, QwordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, OctBase/*number base*/, BitLength::BitLengthQWord);
} }
String^ ValidateProgrammerOctDwordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerOctDwordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, OctBase/*number base*/, DwordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, OctBase/*number base*/, BitLength::BitLengthDWord);
} }
String^ ValidateProgrammerOctWordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerOctWordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, OctBase/*number base*/, WordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, OctBase/*number base*/, BitLength::BitLengthWord);
} }
String^ ValidateProgrammerOctBytePasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerOctBytePasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, OctBase/*number base*/, ByteType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, OctBase/*number base*/, BitLength::BitLengthByte);
} }
String^ ValidateProgrammerBinQwordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerBinQwordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, BinBase/*number base*/, QwordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, BinBase/*number base*/, BitLength::BitLengthQWord);
} }
String^ ValidateProgrammerBinDwordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerBinDwordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, BinBase/*number base*/, DwordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, BinBase/*number base*/, BitLength::BitLengthDWord);
} }
String^ ValidateProgrammerBinWordPasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerBinWordPasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, BinBase/*number base*/, WordType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, BinBase/*number base*/, BitLength::BitLengthWord);
} }
String^ ValidateProgrammerBinBytePasteExpression(_In_ String^ pastedText) String^ ValidateProgrammerBinBytePasteExpression(_In_ String^ pastedText)
{ {
return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, BinBase/*number base*/, ByteType/*bitlength Type*/); return m_CopyPasteManager.ValidatePasteExpression(pastedText, ViewMode::Programmer, BinBase/*number base*/, BitLength::BitLengthByte);
} }
}; };

View File

@ -16,9 +16,22 @@ using namespace CalculatorApp::Common;
using namespace CalculatorApp::ViewModel; using namespace CalculatorApp::ViewModel;
using namespace Platform; using namespace Platform;
using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace Windows::Foundation::Collections;
namespace CalculatorUnitTests namespace CalculatorUnitTests
{ {
template <typename T>
void CompareVector(IVector<T> ^ vecA, IVector<T> ^ vecB)
{
if (vecA->Size != vecB->Size)
Assert::Fail();
for (unsigned int i = 0; i < vecA->Size; ++i)
{
VERIFY_ARE_EQUAL(vecA->GetAt(i), vecB->GetAt(i));
}
}
void ChangeMode(StandardCalculatorViewModel ^ viewModel, int mode) void ChangeMode(StandardCalculatorViewModel ^ viewModel, int mode)
{ {
if (mode == 0) if (mode == 0)
@ -496,6 +509,12 @@ namespace CalculatorUnitTests
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"15")); VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"15"));
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"17")); VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"17"));
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"1111")); VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"1111"));
auto val = ref new PC::Vector<bool>(64, false);
val->SetAt(0, true);
val->SetAt(1, true);
val->SetAt(2, true);
val->SetAt(3, true);
CompareVector<bool>(m_viewModel->BinaryDigits, val);
} }
// Test Button disabling in different Radixes // Test Button disabling in different Radixes
@ -543,6 +562,24 @@ namespace CalculatorUnitTests
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"123,456,789")); VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"123,456,789"));
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"726 746 425")); VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"726 746 425"));
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"0111 0101 1011 1100 1101 0001 0101")); VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"0111 0101 1011 1100 1101 0001 0101"));
auto val = ref new PC::Vector<bool>(64, false);
val->SetAt(0, true);
val->SetAt(2, true);
val->SetAt(4, true);
val->SetAt(8, true);
val->SetAt(10, true);
val->SetAt(11, true);
val->SetAt(14, true);
val->SetAt(15, true);
val->SetAt(16, true);
val->SetAt(17, true);
val->SetAt(19, true);
val->SetAt(20, true);
val->SetAt(22, true);
val->SetAt(24, true);
val->SetAt(25, true);
val->SetAt(26, true);
CompareVector<bool>(m_viewModel->BinaryDigits, val);
} }
// Test Not functionality // Test Not functionality
@ -562,6 +599,9 @@ namespace CalculatorUnitTests
Utils::GetStringValue(m_viewModel->BinaryDisplayValue), Utils::GetStringValue(m_viewModel->BinaryDisplayValue),
StringReference(L"1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1110")); StringReference(L"1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1110"));
VERIFY_ARE_EQUAL(m_viewModel->DisplayValue, StringReference(L"-2")); VERIFY_ARE_EQUAL(m_viewModel->DisplayValue, StringReference(L"-2"));
auto val = ref new PC::Vector<bool>(64, true);
val->SetAt(0, false);
CompareVector<bool>(m_viewModel->BinaryDigits, val);
} }
// Test And Or functionality // Test And Or functionality