Fix the project code style, as it is not consistent. (#236)
Fixes #202 This PR fixes code style for the project files. The Problem Different files in the project use different code style. That is not consistent and leads to harder maintenance of the project. Description of the changes: Have investigated and determined the most used code style across the given codebase Have configured IDE and applied code style to all project files. Have crafted clang-formatter config. see https://clang.llvm.org/docs/ClangFormat.html https://clang.llvm.org/docs/ClangFormatStyleOptions.html Some cases were fixed manually How changes were validated: manual/ad-hoc testing, automated testing All tests pass as before because these are only code style changes. Additional Please review, and let me know if I have any mistake in the code style. In case of any mistake, I will change the configuration and re-apply it to the project.
This commit is contained in:
committed by
Daniel Belcher
parent
c77f1de84c
commit
2826d37056
@@ -41,11 +41,7 @@ DEPENDENCY_PROPERTY_INITIALIZATION(Calculator, IsStandard);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Calculator, IsScientific);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Calculator, IsProgrammer);
|
||||
|
||||
Calculator::Calculator() :
|
||||
m_doAnimate(false),
|
||||
m_isLastAnimatedInScientific(false),
|
||||
m_isLastAnimatedInProgrammer(false),
|
||||
m_resultAnimate(false)
|
||||
Calculator::Calculator() : m_doAnimate(false), m_isLastAnimatedInScientific(false), m_isLastAnimatedInProgrammer(false), m_resultAnimate(false)
|
||||
{
|
||||
SetFontSizeResources();
|
||||
InitializeComponent();
|
||||
@@ -56,7 +52,7 @@ m_resultAnimate(false)
|
||||
HistoryButton->HorizontalAlignment = ::HorizontalAlignment::Left;
|
||||
}
|
||||
|
||||
m_displayFlyout = static_cast<MenuFlyout^>(Resources->Lookup(L"DisplayContextMenu"));
|
||||
m_displayFlyout = static_cast<MenuFlyout ^>(Resources->Lookup(L"DisplayContextMenu"));
|
||||
auto resLoader = AppResourceProvider::GetInstance();
|
||||
CopyMenuItem->Text = resLoader.GetResourceString(L"copyMenuItem");
|
||||
PasteMenuItem->Text = resLoader.GetResourceString(L"pasteMenuItem");
|
||||
@@ -73,7 +69,7 @@ void Calculator::LoadResourceStrings()
|
||||
AutomationProperties::SetName(HistoryButton, m_openHistoryFlyoutAutomationName);
|
||||
}
|
||||
|
||||
void Calculator::InitializeHistoryView(_In_ HistoryViewModel^ historyVM)
|
||||
void Calculator::InitializeHistoryView(_In_ HistoryViewModel ^ historyVM)
|
||||
{
|
||||
if (m_historyList == nullptr)
|
||||
{
|
||||
@@ -89,30 +85,18 @@ void Calculator::SetFontSizeResources()
|
||||
// Since we need different font sizes for different numeric system,
|
||||
// we use a table of optimal font sizes for each numeric system.
|
||||
static const FontTable fontTables[] = {
|
||||
{ L"Arab", 104, 29.333, 23, 40, 56, 40, 56 },
|
||||
{ L"ArabExt", 104, 29.333, 23, 40, 56, 40, 56 },
|
||||
{ L"Beng", 104, 26, 17, 40, 56, 40, 56 },
|
||||
{ L"Deva", 104, 29.333, 20.5, 40, 56, 40, 56 },
|
||||
{ L"Gujr", 104, 29.333, 18.5, 40, 56, 40, 56 },
|
||||
{ L"Khmr", 104, 29.333, 19.5, 40, 56, 40, 56 },
|
||||
{ L"Knda", 104, 25, 17, 40, 56, 40, 56 },
|
||||
{ L"Laoo", 104, 28, 18, 40, 56, 40, 56 },
|
||||
{ L"Latn", 104, 29.333, 23, 40, 56, 40, 56 },
|
||||
{ L"Mlym", 80, 22, 15.5, 30, 56, 35, 48 },
|
||||
{ L"Mymr", 104, 29.333, 20, 35, 48, 36, 48 },
|
||||
{ L"Orya", 88, 26, 20, 40, 56, 40, 56 },
|
||||
{ L"TamlDec", 77, 25, 16, 28, 48, 34, 48 },
|
||||
{ L"Telu", 104, 25, 16.5, 40, 56, 40, 56 },
|
||||
{ L"Thai", 104, 28, 18, 40, 56, 40, 56 },
|
||||
{ L"Tibt", 104, 29.333, 20, 40, 56, 40, 56 },
|
||||
{ L"Default", 104, 29.333, 23, 40, 56, 40, 56 }
|
||||
{ L"Arab", 104, 29.333, 23, 40, 56, 40, 56 }, { L"ArabExt", 104, 29.333, 23, 40, 56, 40, 56 }, { L"Beng", 104, 26, 17, 40, 56, 40, 56 },
|
||||
{ L"Deva", 104, 29.333, 20.5, 40, 56, 40, 56 }, { L"Gujr", 104, 29.333, 18.5, 40, 56, 40, 56 }, { L"Khmr", 104, 29.333, 19.5, 40, 56, 40, 56 },
|
||||
{ L"Knda", 104, 25, 17, 40, 56, 40, 56 }, { L"Laoo", 104, 28, 18, 40, 56, 40, 56 }, { L"Latn", 104, 29.333, 23, 40, 56, 40, 56 },
|
||||
{ L"Mlym", 80, 22, 15.5, 30, 56, 35, 48 }, { L"Mymr", 104, 29.333, 20, 35, 48, 36, 48 }, { L"Orya", 88, 26, 20, 40, 56, 40, 56 },
|
||||
{ L"TamlDec", 77, 25, 16, 28, 48, 34, 48 }, { L"Telu", 104, 25, 16.5, 40, 56, 40, 56 }, { L"Thai", 104, 28, 18, 40, 56, 40, 56 },
|
||||
{ L"Tibt", 104, 29.333, 20, 40, 56, 40, 56 }, { L"Default", 104, 29.333, 23, 40, 56, 40, 56 }
|
||||
};
|
||||
|
||||
DecimalFormatter^ formatter = LocalizationService::GetRegionalSettingsAwareDecimalFormatter();
|
||||
DecimalFormatter ^ formatter = LocalizationService::GetRegionalSettingsAwareDecimalFormatter();
|
||||
|
||||
const FontTable* currentItem = fontTables;
|
||||
while (currentItem->numericSystem.compare(std::wstring(L"Default")) != 0 &&
|
||||
currentItem->numericSystem.compare(formatter->NumeralSystem->Data()) != 0)
|
||||
while (currentItem->numericSystem.compare(std::wstring(L"Default")) != 0 && currentItem->numericSystem.compare(formatter->NumeralSystem->Data()) != 0)
|
||||
{
|
||||
currentItem++;
|
||||
}
|
||||
@@ -126,36 +110,36 @@ void Calculator::SetFontSizeResources()
|
||||
this->Resources->Insert(StringReference(L"CalcButtonScientificPortraitCaptionSizeOverride"), currentItem->portraitScientificNumPadFont);
|
||||
}
|
||||
|
||||
void Calculator::OnLoaded(_In_ Object^, _In_ RoutedEventArgs^)
|
||||
void Calculator::OnLoaded(_In_ Object ^, _In_ RoutedEventArgs ^)
|
||||
{
|
||||
Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &Calculator::OnCalcPropertyChanged);
|
||||
Model->HideMemoryClicked += ref new HideMemoryClickedHandler(this, &Calculator::OnHideMemoryClicked);
|
||||
|
||||
InitializeHistoryView(Model->HistoryVM);
|
||||
String^ historyPaneName = AppResourceProvider::GetInstance().GetResourceString(L"HistoryPane");
|
||||
String ^ historyPaneName = AppResourceProvider::GetInstance().GetResourceString(L"HistoryPane");
|
||||
HistoryFlyout->FlyoutPresenterStyle->Setters->Append(ref new Setter(AutomationProperties::NameProperty, historyPaneName));
|
||||
String^ memoryPaneName = AppResourceProvider::GetInstance().GetResourceString(L"MemoryPane");
|
||||
String ^ memoryPaneName = AppResourceProvider::GetInstance().GetResourceString(L"MemoryPane");
|
||||
MemoryFlyout->FlyoutPresenterStyle->Setters->Append(ref new Setter(AutomationProperties::NameProperty, memoryPaneName));
|
||||
|
||||
if (Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.UI.Xaml.Controls.Primitives.FlyoutBase", L"Closing"))
|
||||
{
|
||||
HistoryFlyout->Closing += ref new TypedEventHandler<FlyoutBase^, FlyoutBaseClosingEventArgs^>(this, &Calculator::HistoryFlyout_Closing);
|
||||
MemoryFlyout->Closing += ref new TypedEventHandler<FlyoutBase^, FlyoutBaseClosingEventArgs^>(this, &Calculator::OnMemoryFlyoutClosing);
|
||||
HistoryFlyout->Closing += ref new TypedEventHandler<FlyoutBase ^, FlyoutBaseClosingEventArgs ^>(this, &Calculator::HistoryFlyout_Closing);
|
||||
MemoryFlyout->Closing += ref new TypedEventHandler<FlyoutBase ^, FlyoutBaseClosingEventArgs ^>(this, &Calculator::OnMemoryFlyoutClosing);
|
||||
}
|
||||
|
||||
// Delay load things later when we get a chance.
|
||||
WeakReference weakThis(this);
|
||||
this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([weakThis]()
|
||||
{
|
||||
if (TraceLogger::GetInstance().UpdateWindowIdLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())))
|
||||
{
|
||||
auto refThis = weakThis.Resolve<Calculator>();
|
||||
if (refThis != nullptr)
|
||||
this->Dispatcher->RunAsync(
|
||||
CoreDispatcherPriority::Normal, ref new DispatchedHandler([weakThis]() {
|
||||
if (TraceLogger::GetInstance().UpdateWindowIdLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())))
|
||||
{
|
||||
refThis->GetMemory();
|
||||
auto refThis = weakThis.Resolve<Calculator>();
|
||||
if (refThis != nullptr)
|
||||
{
|
||||
refThis->GetMemory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}));
|
||||
}
|
||||
|
||||
std::wstring Calculator::GetCurrentLayoutState()
|
||||
@@ -203,17 +187,17 @@ void Calculator::UpdateViewState()
|
||||
CloseHistoryFlyout();
|
||||
CloseMemoryFlyout();
|
||||
|
||||
VisualStateManager::GoToState(this, ref new String(state.c_str()), true/*useTransitions*/);
|
||||
VisualStateManager::GoToState(this, ref new String(state.c_str()), true /*useTransitions*/);
|
||||
}
|
||||
|
||||
|
||||
void Calculator::AnimateCalculator(bool resultAnimate)
|
||||
{
|
||||
if (App::IsAnimationEnabled())
|
||||
{
|
||||
m_doAnimate = true;
|
||||
m_resultAnimate = resultAnimate;
|
||||
if (((m_isLastAnimatedInScientific && IsScientific) || (!m_isLastAnimatedInScientific && !IsScientific)) && ((m_isLastAnimatedInProgrammer && IsProgrammer) || (!m_isLastAnimatedInProgrammer && !IsProgrammer)))
|
||||
if (((m_isLastAnimatedInScientific && IsScientific) || (!m_isLastAnimatedInScientific && !IsScientific))
|
||||
&& ((m_isLastAnimatedInProgrammer && IsProgrammer) || (!m_isLastAnimatedInProgrammer && !IsProgrammer)))
|
||||
{
|
||||
// We are forcing the animation here
|
||||
// It's because if last animation was in standard, then go to unit converter, then comes back to standard
|
||||
@@ -223,9 +207,9 @@ void Calculator::AnimateCalculator(bool resultAnimate)
|
||||
}
|
||||
}
|
||||
|
||||
void Calculator::OnContextRequested(UIElement^ sender, ContextRequestedEventArgs^ e)
|
||||
void Calculator::OnContextRequested(UIElement ^ sender, ContextRequestedEventArgs ^ e)
|
||||
{
|
||||
auto requestedElement = safe_cast<FrameworkElement^>(e->OriginalSource);
|
||||
auto requestedElement = safe_cast<FrameworkElement ^>(e->OriginalSource);
|
||||
|
||||
PasteMenuItem->IsEnabled = CopyPasteManager::HasStringToPaste();
|
||||
|
||||
@@ -243,12 +227,12 @@ void Calculator::OnContextRequested(UIElement^ sender, ContextRequestedEventArgs
|
||||
e->Handled = true;
|
||||
}
|
||||
|
||||
void Calculator::OnContextCanceled(UIElement^ sender, RoutedEventArgs^ e)
|
||||
void Calculator::OnContextCanceled(UIElement ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
m_displayFlyout->Hide();
|
||||
}
|
||||
|
||||
void Calculator::OnLayoutStateChanged(_In_ Object^ sender, _In_ Object^ e)
|
||||
void Calculator::OnLayoutStateChanged(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
UpdatePanelViewState();
|
||||
}
|
||||
@@ -275,7 +259,7 @@ void Calculator::OnIsProgrammerPropertyChanged(bool /*oldValue*/, bool newValue)
|
||||
if (newValue)
|
||||
{
|
||||
EnsureProgrammer();
|
||||
m_pivotItem = static_cast<Windows::UI::Xaml::Controls::PivotItem^>(DockPivot->Items->GetAt(0));
|
||||
m_pivotItem = static_cast<Windows::UI::Xaml::Controls::PivotItem ^>(DockPivot->Items->GetAt(0));
|
||||
DockPivot->Items->RemoveAt(0);
|
||||
}
|
||||
else
|
||||
@@ -295,7 +279,7 @@ void Calculator::OnIsInErrorPropertyChanged()
|
||||
{
|
||||
bool isError = Model->IsInError;
|
||||
|
||||
String^ newState = isError ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = isError ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
|
||||
if (m_memory != nullptr)
|
||||
@@ -316,7 +300,7 @@ void Calculator::OnIsInErrorPropertyChanged()
|
||||
|
||||
// Once the storyboard that rearranges the buttons completed,
|
||||
// We do the animation based on the Mode or Orientation change.
|
||||
void Calculator::OnStoryboardCompleted(_In_ Object^ sender, _In_ Object^ e)
|
||||
void Calculator::OnStoryboardCompleted(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
m_isLastAnimatedInScientific = IsScientific;
|
||||
m_isLastAnimatedInProgrammer = IsProgrammer;
|
||||
@@ -361,9 +345,9 @@ void Calculator::EnsureProgrammer()
|
||||
ProgrammerOperators->SetRadixButton(Model->GetCurrentRadixType());
|
||||
}
|
||||
|
||||
void Calculator::OnCalcPropertyChanged(_In_ Object^ sender, _In_ PropertyChangedEventArgs^ e)
|
||||
void Calculator::OnCalcPropertyChanged(_In_ Object ^ sender, _In_ PropertyChangedEventArgs ^ e)
|
||||
{
|
||||
String^ prop = e->PropertyName;
|
||||
String ^ prop = e->PropertyName;
|
||||
if (prop == StandardCalculatorViewModel::IsMemoryEmptyPropertyName)
|
||||
{
|
||||
UpdateMemoryState();
|
||||
@@ -382,7 +366,7 @@ void Calculator::UpdatePanelViewState()
|
||||
|
||||
void Calculator::UpdateHistoryState()
|
||||
{
|
||||
String^ viewState = App::GetAppViewState();
|
||||
String ^ viewState = App::GetAppViewState();
|
||||
if (viewState == ViewState::DockedView)
|
||||
{
|
||||
// docked view
|
||||
@@ -396,7 +380,7 @@ void Calculator::UpdateHistoryState()
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // flyout view
|
||||
{ // flyout view
|
||||
DockHistoryHolder->Child = nullptr;
|
||||
if (!IsProgrammer)
|
||||
{
|
||||
@@ -418,7 +402,7 @@ void Calculator::UpdateMemoryState()
|
||||
ClearMemoryButton->IsEnabled = false;
|
||||
}
|
||||
|
||||
String^ viewState = App::GetAppViewState();
|
||||
String ^ viewState = App::GetAppViewState();
|
||||
if (viewState == ViewState::DockedView)
|
||||
{
|
||||
CloseMemoryFlyout();
|
||||
@@ -457,7 +441,7 @@ void Calculator::OnHideHistoryClicked()
|
||||
ToggleHistoryFlyout(nullptr);
|
||||
}
|
||||
|
||||
void Calculator::OnHistoryItemClicked(_In_ HistoryItemViewModel^ e)
|
||||
void Calculator::OnHistoryItemClicked(_In_ HistoryItemViewModel ^ e)
|
||||
{
|
||||
unsigned int tokenSize;
|
||||
assert(e->GetTokens() != nullptr);
|
||||
@@ -473,7 +457,7 @@ void Calculator::OnHistoryItemClicked(_In_ HistoryItemViewModel^ e)
|
||||
this->Focus(::FocusState::Programmatic);
|
||||
}
|
||||
|
||||
void Calculator::HistoryFlyout_Opened(_In_ Object ^sender, _In_ Object ^args)
|
||||
void Calculator::HistoryFlyout_Opened(_In_ Object ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
m_fIsHistoryFlyoutOpen = true;
|
||||
m_IsLastFlyoutMemory = false;
|
||||
@@ -484,13 +468,13 @@ void Calculator::HistoryFlyout_Opened(_In_ Object ^sender, _In_ Object ^args)
|
||||
TraceLogger::GetInstance().LogHistoryBodyOpened();
|
||||
}
|
||||
|
||||
void Calculator::HistoryFlyout_Closing(_In_ FlyoutBase^ sender, _In_ FlyoutBaseClosingEventArgs^ args)
|
||||
void Calculator::HistoryFlyout_Closing(_In_ FlyoutBase ^ sender, _In_ FlyoutBaseClosingEventArgs ^ args)
|
||||
{
|
||||
// Set in the Closing event so the new name is available when the Flyout has Closed.
|
||||
AutomationProperties::SetName(HistoryButton, m_openHistoryFlyoutAutomationName);
|
||||
}
|
||||
|
||||
void Calculator::HistoryFlyout_Closed(_In_ Object ^sender, _In_ Object ^args)
|
||||
void Calculator::HistoryFlyout_Closed(_In_ Object ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
// Ideally, this would be renamed in the Closing event because the Closed event is too late.
|
||||
// Closing is not available until RS1+ so we set the name again here for TH2 support.
|
||||
@@ -526,9 +510,9 @@ void Calculator::SetDefaultFocus()
|
||||
Results->Focus(::FocusState::Programmatic);
|
||||
}
|
||||
|
||||
void Calculator::ToggleHistoryFlyout(Object^ /*parameter*/)
|
||||
void Calculator::ToggleHistoryFlyout(Object ^ /*parameter*/)
|
||||
{
|
||||
String^ viewState = App::GetAppViewState();
|
||||
String ^ viewState = App::GetAppViewState();
|
||||
// If app starts correctly in snap mode and shortcut is used for history then we need to load history if not yet initialized.
|
||||
if (viewState != ViewState::DockedView)
|
||||
{
|
||||
@@ -548,7 +532,7 @@ void Calculator::ToggleHistoryFlyout(Object^ /*parameter*/)
|
||||
|
||||
void Calculator::ToggleMemoryFlyout()
|
||||
{
|
||||
String^ viewState = App::GetAppViewState();
|
||||
String ^ viewState = App::GetAppViewState();
|
||||
if (viewState != ViewState::DockedView)
|
||||
{
|
||||
if (m_fIsMemoryFlyoutOpen)
|
||||
@@ -565,7 +549,7 @@ void Calculator::ToggleMemoryFlyout()
|
||||
}
|
||||
}
|
||||
|
||||
void Calculator::OnMemoryFlyoutOpened(_In_ Object ^sender, _In_ Object ^args)
|
||||
void Calculator::OnMemoryFlyoutOpened(_In_ Object ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
TraceLogger::GetInstance().LogMemoryFlyoutOpenEnd(Model->MemorizedNumbers->Size);
|
||||
m_IsLastFlyoutMemory = true;
|
||||
@@ -576,13 +560,13 @@ void Calculator::OnMemoryFlyoutOpened(_In_ Object ^sender, _In_ Object ^args)
|
||||
TraceLogger::GetInstance().LogMemoryBodyOpened();
|
||||
}
|
||||
|
||||
void Calculator::OnMemoryFlyoutClosing(_In_ FlyoutBase^ sender, _In_ FlyoutBaseClosingEventArgs^ args)
|
||||
void Calculator::OnMemoryFlyoutClosing(_In_ FlyoutBase ^ sender, _In_ FlyoutBaseClosingEventArgs ^ args)
|
||||
{
|
||||
// Set in the Closing event so the new name is available when the Flyout has Closed.
|
||||
AutomationProperties::SetName(MemoryButton, m_openMemoryFlyoutAutomationName);
|
||||
}
|
||||
|
||||
void Calculator::OnMemoryFlyoutClosed(_In_ Object ^sender, _In_ Object ^args)
|
||||
void Calculator::OnMemoryFlyoutClosed(_In_ Object ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
// Ideally, this would be renamed in the Closing event because the Closed event is too late.
|
||||
// Closing is not available until RS1+ so we set the name again here for TH2 support.
|
||||
@@ -597,12 +581,12 @@ void Calculator::OnMemoryFlyoutClosed(_In_ Object ^sender, _In_ Object ^args)
|
||||
FullscreenFlyoutClosed();
|
||||
}
|
||||
|
||||
Memory^ Calculator::GetMemory()
|
||||
Memory ^ Calculator::GetMemory()
|
||||
{
|
||||
if (m_memory == nullptr)
|
||||
{
|
||||
m_memory = ref new Memory();
|
||||
VisualStateManager::GoToState(m_memory, ref new String(GetCurrentLayoutState().c_str()), true/*useTransitions*/);
|
||||
VisualStateManager::GoToState(m_memory, ref new String(GetCurrentLayoutState().c_str()), true /*useTransitions*/);
|
||||
}
|
||||
|
||||
return m_memory;
|
||||
@@ -636,9 +620,9 @@ void Calculator::EnableControls(bool enable)
|
||||
EnableMemoryControls(enable);
|
||||
}
|
||||
|
||||
void Calculator::OnMemoryFlyOutTapped(_In_ Object^ sender, _In_ TappedRoutedEventArgs^ e)
|
||||
void Calculator::OnMemoryFlyOutTapped(_In_ Object ^ sender, _In_ TappedRoutedEventArgs ^ e)
|
||||
{
|
||||
Grid^ grid = safe_cast<Grid^> (sender);
|
||||
Grid ^ grid = safe_cast<Grid ^>(sender);
|
||||
Point point = e->GetPosition(nullptr);
|
||||
|
||||
if (point.Y < (grid->ActualHeight - NumpadPanel->ActualHeight))
|
||||
@@ -647,10 +631,9 @@ void Calculator::OnMemoryFlyOutTapped(_In_ Object^ sender, _In_ TappedRoutedEven
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Calculator::OnHistoryFlyOutTapped(_In_ Object^ sender, _In_ TappedRoutedEventArgs^ e)
|
||||
void Calculator::OnHistoryFlyOutTapped(_In_ Object ^ sender, _In_ TappedRoutedEventArgs ^ e)
|
||||
{
|
||||
Grid^ grid = safe_cast<Grid^> (sender);
|
||||
Grid ^ grid = safe_cast<Grid ^>(sender);
|
||||
Point point = e->GetPosition(nullptr);
|
||||
|
||||
if (point.Y < (grid->ActualHeight - NumpadPanel->ActualHeight))
|
||||
@@ -668,7 +651,7 @@ bool Calculator::IsValidRegularExpression(std::wstring str)
|
||||
regexPatterns[2] = L"[-]{0,1}[0-9]{0,}[.]{0,1}[0-9]{0,}[e]{1}[-]{1}[0-9]{1,}";
|
||||
|
||||
const auto& localizer = LocalizationSettings::GetInstance();
|
||||
String^ englishString = localizer.GetEnglishValueFromLocalizedDigits(str);
|
||||
String ^ englishString = localizer.GetEnglishValueFromLocalizedDigits(str);
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
@@ -681,7 +664,7 @@ bool Calculator::IsValidRegularExpression(std::wstring str)
|
||||
return result;
|
||||
}
|
||||
|
||||
void Calculator::DockPanelTapped(_In_ TappedRoutedEventArgs^ e)
|
||||
void Calculator::DockPanelTapped(_In_ TappedRoutedEventArgs ^ e)
|
||||
{
|
||||
int index = DockPivot->SelectedIndex;
|
||||
if (index == 1 && !IsProgrammer)
|
||||
@@ -698,23 +681,22 @@ void Calculator::UnregisterEventHandlers()
|
||||
ExpressionText->UnregisterEventHandlers();
|
||||
}
|
||||
|
||||
void Calculator::OnErrorLayoutCompleted(_In_ Object^ sender, _In_ Object^ e)
|
||||
void Calculator::OnErrorLayoutCompleted(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
SetDefaultFocus();
|
||||
}
|
||||
|
||||
void Calculator::OnHistoryAccessKeyInvoked(_In_ UIElement^ sender, _In_ AccessKeyInvokedEventArgs^ args)
|
||||
void Calculator::OnHistoryAccessKeyInvoked(_In_ UIElement ^ sender, _In_ AccessKeyInvokedEventArgs ^ args)
|
||||
{
|
||||
DockPivot->SelectedItem = HistoryPivotItem;
|
||||
}
|
||||
|
||||
void Calculator::OnMemoryAccessKeyInvoked(_In_ UIElement^ sender, _In_ AccessKeyInvokedEventArgs^ args)
|
||||
void Calculator::OnMemoryAccessKeyInvoked(_In_ UIElement ^ sender, _In_ AccessKeyInvokedEventArgs ^ args)
|
||||
{
|
||||
DockPivot->SelectedItem = MemoryPivotItem;
|
||||
}
|
||||
|
||||
|
||||
void CalculatorApp::Calculator::DockPivot_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e)
|
||||
void CalculatorApp::Calculator::DockPivot_SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e)
|
||||
{
|
||||
if (DockPivot->SelectedIndex == 0)
|
||||
{
|
||||
|
@@ -33,13 +33,13 @@ namespace CalculatorApp
|
||||
double portraitScientificNumPadFont;
|
||||
};
|
||||
|
||||
public delegate void FullscreenFlyoutClosedEventHandler();
|
||||
public
|
||||
delegate void FullscreenFlyoutClosedEventHandler();
|
||||
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class Calculator sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class Calculator sealed
|
||||
{
|
||||
public:
|
||||
event FullscreenFlyoutClosedEventHandler^ FullscreenFlyoutClosed;
|
||||
event FullscreenFlyoutClosedEventHandler ^ FullscreenFlyoutClosed;
|
||||
|
||||
Calculator();
|
||||
property CalculatorApp::ViewModel::StandardCalculatorViewModel^ Model
|
||||
@@ -57,7 +57,7 @@ namespace CalculatorApp
|
||||
COMMAND_FOR_METHOD(HistoryButtonPressed, Calculator::ToggleHistoryFlyout);
|
||||
|
||||
void AnimateCalculator(bool resultAnimate);
|
||||
void InitializeHistoryView(CalculatorApp::ViewModel::HistoryViewModel^ historyVM);
|
||||
void InitializeHistoryView(CalculatorApp::ViewModel::HistoryViewModel ^ historyVM);
|
||||
void UpdatePanelViewState();
|
||||
void UnregisterEventHandlers();
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace CalculatorApp
|
||||
void SetDefaultFocus();
|
||||
|
||||
private:
|
||||
void OnLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
void LoadResourceStrings();
|
||||
|
||||
@@ -75,24 +75,24 @@ namespace CalculatorApp
|
||||
void UpdateMemoryState();
|
||||
void UpdateHistoryState();
|
||||
|
||||
void CalculationResultsOnSelected(_In_ Platform::Object^ sender);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void CalculationResultsOnSelected(_In_ Platform::Object ^ sender);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs ^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnIsScientificPropertyChanged(bool oldValue, bool newValue);
|
||||
void OnIsProgrammerPropertyChanged(bool oldValue, bool newValue);
|
||||
void OnIsStandardPropertyChanged(bool oldValue, bool newValue);
|
||||
void OnIsInErrorPropertyChanged();
|
||||
void OnCalcPropertyChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e);
|
||||
void OnStoryboardCompleted(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnLayoutStateChanged(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnCalcPropertyChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e);
|
||||
void OnStoryboardCompleted(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnLayoutStateChanged(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void EnsureScientific();
|
||||
void EnsureProgrammer();
|
||||
void SetFontSizeResources();
|
||||
std::wstring GetCurrentLayoutState();
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::Controls::ListView^ m_tokenList;
|
||||
Windows::UI::Xaml::Controls::MenuFlyout^ m_displayFlyout;
|
||||
Windows::UI::Xaml::Controls::ListView ^ m_tokenList;
|
||||
Windows::UI::Xaml::Controls::MenuFlyout ^ m_displayFlyout;
|
||||
bool m_doAnimate;
|
||||
bool m_resultAnimate;
|
||||
bool m_isLastAnimatedInScientific;
|
||||
@@ -100,40 +100,42 @@ namespace CalculatorApp
|
||||
bool m_IsLastFlyoutMemory = false;
|
||||
bool m_IsLastFlyoutHistory = false;
|
||||
|
||||
Platform::String^ m_openMemoryFlyoutAutomationName;
|
||||
Platform::String^ m_closeMemoryFlyoutAutomationName;
|
||||
Platform::String^ m_openHistoryFlyoutAutomationName;
|
||||
Platform::String^ m_closeHistoryFlyoutAutomationName;
|
||||
Platform::String ^ m_openMemoryFlyoutAutomationName;
|
||||
Platform::String ^ m_closeMemoryFlyoutAutomationName;
|
||||
Platform::String ^ m_openHistoryFlyoutAutomationName;
|
||||
Platform::String ^ m_closeHistoryFlyoutAutomationName;
|
||||
|
||||
Windows::UI::Xaml::Controls::PivotItem^ m_pivotItem;
|
||||
Windows::UI::Xaml::Controls::PivotItem ^ m_pivotItem;
|
||||
bool m_IsDigit = false;
|
||||
Memory^ m_memory;
|
||||
void HistoryFlyout_Opened(_In_ Platform::Object ^sender, _In_ Platform::Object ^args);
|
||||
void HistoryFlyout_Closing(_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase^ sender, _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs^ args);
|
||||
void HistoryFlyout_Closed(_In_ Platform::Object ^sender, _In_ Platform::Object ^args);
|
||||
Memory ^ m_memory;
|
||||
void HistoryFlyout_Opened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
|
||||
void HistoryFlyout_Closing(_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender,
|
||||
_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args);
|
||||
void HistoryFlyout_Closed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
|
||||
void OnHideHistoryClicked();
|
||||
void OnHideMemoryClicked();
|
||||
void OnHistoryItemClicked(_In_ CalculatorApp::ViewModel::HistoryItemViewModel^ e);
|
||||
void ToggleHistoryFlyout(Platform::Object^ parameter);
|
||||
void OnHistoryItemClicked(_In_ CalculatorApp::ViewModel::HistoryItemViewModel ^ e);
|
||||
void ToggleHistoryFlyout(Platform::Object ^ parameter);
|
||||
void ToggleMemoryFlyout();
|
||||
CalculatorApp::HistoryList^ m_historyList;
|
||||
CalculatorApp::HistoryList ^ m_historyList;
|
||||
bool m_fIsHistoryFlyoutOpen;
|
||||
bool m_fIsMemoryFlyoutOpen;
|
||||
void OnMemoryFlyoutOpened(_In_ Platform::Object ^sender, _In_ Platform::Object ^args);
|
||||
void OnMemoryFlyoutClosing(_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase^ sender, _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs^ args);
|
||||
void OnMemoryFlyoutClosed(_In_ Platform::Object ^sender, _In_ Platform::Object ^args);
|
||||
void OnMemoryFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
|
||||
void OnMemoryFlyoutClosing(_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender,
|
||||
_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args);
|
||||
void OnMemoryFlyoutClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
|
||||
void SetChildAsMemory();
|
||||
void SetChildAsHistory();
|
||||
Memory^ GetMemory();
|
||||
Memory ^ GetMemory();
|
||||
void EnableControls(bool enable);
|
||||
void EnableMemoryControls(bool enable);
|
||||
void OnMemoryFlyOutTapped(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
|
||||
void OnHistoryFlyOutTapped(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
|
||||
void OnMemoryFlyOutTapped(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs ^ e);
|
||||
void OnHistoryFlyOutTapped(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs ^ e);
|
||||
bool IsValidRegularExpression(std::wstring str);
|
||||
void DockPanelTapped(_In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
|
||||
void OnErrorLayoutCompleted(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnHistoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs^ args);
|
||||
void OnMemoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs^ args);
|
||||
void DockPivot_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
|
||||
};
|
||||
void DockPanelTapped(_In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs ^ e);
|
||||
void OnErrorLayoutCompleted(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnHistoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement ^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs ^ args);
|
||||
void OnMemoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement ^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs ^ args);
|
||||
void DockPivot_SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@@ -25,8 +25,7 @@ using namespace Windows::UI::Xaml::Input;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
CalculatorProgrammerBitFlipPanel::CalculatorProgrammerBitFlipPanel() :
|
||||
m_updatingCheckedStates(false)
|
||||
CalculatorProgrammerBitFlipPanel::CalculatorProgrammerBitFlipPanel() : m_updatingCheckedStates(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
auto booleanToVisibilityConverter = ref new Converters::BooleanToVisibilityConverter;
|
||||
@@ -35,13 +34,13 @@ CalculatorProgrammerBitFlipPanel::CalculatorProgrammerBitFlipPanel() :
|
||||
AssignFlipButtons();
|
||||
}
|
||||
|
||||
void CalculatorProgrammerBitFlipPanel::OnLoaded(Object^ sender, RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerBitFlipPanel::OnLoaded(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
UnsubscribePropertyChanged();
|
||||
SubscribePropertyChanged();
|
||||
}
|
||||
|
||||
void CalculatorProgrammerBitFlipPanel::OnUnloaded(Object^ sender, RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerBitFlipPanel::OnUnloaded(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
UnsubscribePropertyChanged();
|
||||
}
|
||||
@@ -50,8 +49,7 @@ void CalculatorProgrammerBitFlipPanel::SubscribePropertyChanged()
|
||||
{
|
||||
if (Model != nullptr)
|
||||
{
|
||||
m_propertyChangedToken =
|
||||
Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &CalculatorProgrammerBitFlipPanel::OnPropertyChanged);
|
||||
m_propertyChangedToken = Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &CalculatorProgrammerBitFlipPanel::OnPropertyChanged);
|
||||
|
||||
UpdateCheckedStates();
|
||||
}
|
||||
@@ -66,7 +64,7 @@ void CalculatorProgrammerBitFlipPanel::UnsubscribePropertyChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerBitFlipPanel::OnPropertyChanged(Object^ sender, PropertyChangedEventArgs^ e)
|
||||
void CalculatorProgrammerBitFlipPanel::OnPropertyChanged(Object ^ sender, PropertyChangedEventArgs ^ e)
|
||||
{
|
||||
if (e->PropertyName == StandardCalculatorViewModel::BinaryDisplayValuePropertyName)
|
||||
{
|
||||
@@ -74,25 +72,25 @@ void CalculatorProgrammerBitFlipPanel::OnPropertyChanged(Object^ sender, Propert
|
||||
}
|
||||
}
|
||||
|
||||
StandardCalculatorViewModel^ CalculatorProgrammerBitFlipPanel::Model::get()
|
||||
StandardCalculatorViewModel ^ CalculatorProgrammerBitFlipPanel::Model::get()
|
||||
{
|
||||
return static_cast<StandardCalculatorViewModel^>(this->DataContext);
|
||||
return static_cast<StandardCalculatorViewModel ^>(this->DataContext);
|
||||
}
|
||||
|
||||
void CalculatorProgrammerBitFlipPanel::AssignFlipButtons()
|
||||
{
|
||||
assert(m_flipButtons.size() == 64);
|
||||
|
||||
m_flipButtons[0] = this->Bit0;
|
||||
m_flipButtons[1] = this->Bit1;
|
||||
m_flipButtons[2] = this->Bit2;
|
||||
m_flipButtons[3] = this->Bit3;
|
||||
m_flipButtons[4] = this->Bit4;
|
||||
m_flipButtons[5] = this->Bit5;
|
||||
m_flipButtons[6] = this->Bit6;
|
||||
m_flipButtons[7] = this->Bit7;
|
||||
m_flipButtons[8] = this->Bit8;
|
||||
m_flipButtons[9] = this->Bit9;
|
||||
m_flipButtons[0] = this->Bit0;
|
||||
m_flipButtons[1] = this->Bit1;
|
||||
m_flipButtons[2] = this->Bit2;
|
||||
m_flipButtons[3] = this->Bit3;
|
||||
m_flipButtons[4] = this->Bit4;
|
||||
m_flipButtons[5] = this->Bit5;
|
||||
m_flipButtons[6] = this->Bit6;
|
||||
m_flipButtons[7] = this->Bit7;
|
||||
m_flipButtons[8] = this->Bit8;
|
||||
m_flipButtons[9] = this->Bit9;
|
||||
m_flipButtons[10] = this->Bit10;
|
||||
m_flipButtons[11] = this->Bit11;
|
||||
m_flipButtons[12] = this->Bit12;
|
||||
@@ -149,29 +147,31 @@ void CalculatorProgrammerBitFlipPanel::AssignFlipButtons()
|
||||
m_flipButtons[63] = this->Bit63;
|
||||
}
|
||||
|
||||
void CalculatorProgrammerBitFlipPanel::SetVisibilityBinding(_In_ FrameworkElement^ element, _In_ String^ path, _In_ IValueConverter^ converter)
|
||||
void CalculatorProgrammerBitFlipPanel::SetVisibilityBinding(_In_ FrameworkElement ^ element, _In_ String ^ path, _In_ IValueConverter ^ converter)
|
||||
{
|
||||
Binding^ commandBinding = ref new Binding();
|
||||
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) { return; }
|
||||
if (m_updatingCheckedStates)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle this the bit toggled event only if it is coming from BitFlip mode.
|
||||
// Any input from the Numpad may also result in toggling the bit as their state is bound to the BinaryDisplayValue.
|
||||
// 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,
|
||||
// which continuously alters the Display Value and the state of the Bit Flip buttons.
|
||||
if ((Model->IsBitFlipChecked)
|
||||
&& Model->IsProgrammer)
|
||||
if ((Model->IsBitFlipChecked) && Model->IsProgrammer)
|
||||
{
|
||||
TraceLogger::GetInstance().LogBitFlipUsed();
|
||||
|
||||
auto flipButton = static_cast<FlipButtons^>(sender);
|
||||
auto flipButton = static_cast<FlipButtons ^>(sender);
|
||||
Model->ButtonPressed->Execute(flipButton->ButtonId);
|
||||
}
|
||||
}
|
||||
@@ -181,17 +181,15 @@ void CalculatorProgrammerBitFlipPanel::UpdateCheckedStates()
|
||||
assert(!m_updatingCheckedStates);
|
||||
assert(m_flipButtons.size() == s_numBits);
|
||||
|
||||
if (Model == nullptr) { return; }
|
||||
if (Model == nullptr)
|
||||
{
|
||||
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
|
||||
};
|
||||
static constexpr array<wchar_t, 4> unwantedChars = { L' ', Utils::LRE, Utils::PDF, Utils::LRO };
|
||||
|
||||
wstringstream stream;
|
||||
wstring displayValue = Model->BinaryDisplayValue->Data();
|
||||
|
@@ -17,36 +17,33 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorProgrammerBitFlipPanel sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorProgrammerBitFlipPanel sealed
|
||||
{
|
||||
public:
|
||||
CalculatorProgrammerBitFlipPanel();
|
||||
|
||||
property CalculatorApp::ViewModel::StandardCalculatorViewModel^ Model
|
||||
{
|
||||
CalculatorApp::ViewModel::StandardCalculatorViewModel^ get();
|
||||
}
|
||||
property CalculatorApp::ViewModel::StandardCalculatorViewModel
|
||||
^ Model { CalculatorApp::ViewModel::StandardCalculatorViewModel ^ get(); }
|
||||
|
||||
private:
|
||||
void OnLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnUnloaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
private : void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnUnloaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
void SubscribePropertyChanged();
|
||||
void UnsubscribePropertyChanged();
|
||||
void OnPropertyChanged(Platform::Object^ sender, Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e);
|
||||
void OnPropertyChanged(Platform::Object ^ sender, Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e);
|
||||
|
||||
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 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 UpdateCheckedStates();
|
||||
|
||||
private:
|
||||
Windows::Foundation::EventRegistrationToken m_propertyChangedToken;
|
||||
|
||||
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;
|
||||
bool m_updatingCheckedStates;
|
||||
};
|
||||
}
|
||||
|
@@ -20,21 +20,20 @@ using namespace Windows::UI::Xaml::Navigation;
|
||||
using namespace Windows::UI::ViewManagement;
|
||||
using namespace Windows::UI::Core;
|
||||
|
||||
CalculatorProgrammerDisplayPanel::CalculatorProgrammerDisplayPanel() :
|
||||
m_isErrorVisualState(false)
|
||||
CalculatorProgrammerDisplayPanel::CalculatorProgrammerDisplayPanel() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
void CalculatorProgrammerDisplayPanel::ShowBitFlip(Object^ sender, RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerDisplayPanel::ShowBitFlip(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogBitFlipPaneClicked();
|
||||
}
|
||||
|
||||
void CalculatorProgrammerDisplayPanel::OnBitLengthButtonPressed(Object^ parameter)
|
||||
void CalculatorProgrammerDisplayPanel::OnBitLengthButtonPressed(Object ^ parameter)
|
||||
{
|
||||
TraceLogger::GetInstance().LogBitLengthButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
String^ buttonId = parameter->ToString();
|
||||
String ^ buttonId = parameter->ToString();
|
||||
|
||||
QwordButton->Visibility = ::Visibility::Collapsed;
|
||||
DwordButton->Visibility = ::Visibility::Collapsed;
|
||||
@@ -90,7 +89,7 @@ void CalculatorProgrammerDisplayPanel::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
}
|
||||
}
|
||||
|
@@ -8,8 +8,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorProgrammerDisplayPanel sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorProgrammerDisplayPanel sealed
|
||||
{
|
||||
public:
|
||||
CalculatorProgrammerDisplayPanel();
|
||||
@@ -23,14 +22,15 @@ namespace CalculatorApp
|
||||
}
|
||||
}
|
||||
|
||||
property bool IsErrorVisualState {
|
||||
property bool IsErrorVisualState
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
|
||||
private:
|
||||
void ShowBitFlip(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnBitLengthButtonPressed(Platform::Object^ parameter);
|
||||
void ShowBitFlip(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnBitLengthButtonPressed(Platform::Object ^ parameter);
|
||||
|
||||
bool m_isErrorVisualState;
|
||||
};
|
||||
|
@@ -36,7 +36,7 @@ CalculatorProgrammerOperators::CalculatorProgrammerOperators()
|
||||
CopyMenuItem->Text = AppResourceProvider::GetInstance().GetResourceString(L"copyMenuItem");
|
||||
}
|
||||
|
||||
void CalculatorProgrammerOperators::HexButtonChecked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerOperators::HexButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogRadixButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
if (Model)
|
||||
@@ -45,7 +45,7 @@ void CalculatorProgrammerOperators::HexButtonChecked(_In_ Object^ sender, _In_ R
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerOperators::DecButtonChecked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerOperators::DecButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogRadixButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
if (Model)
|
||||
@@ -54,7 +54,7 @@ void CalculatorProgrammerOperators::DecButtonChecked(_In_ Object^ sender, _In_ R
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerOperators::OctButtonChecked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerOperators::OctButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogRadixButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
if (Model)
|
||||
@@ -63,7 +63,7 @@ void CalculatorProgrammerOperators::OctButtonChecked(_In_ Object^ sender, _In_ R
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerOperators::BinButtonChecked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerOperators::BinButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogRadixButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
if (Model)
|
||||
@@ -101,9 +101,9 @@ void CalculatorProgrammerOperators::SetRadixButton(RADIX_TYPE radixType)
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerOperators::OnCopyMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerOperators::OnCopyMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
auto source = safe_cast<RadixButton^>(ProgrammerOperatorsContextMenu->Target);
|
||||
auto source = safe_cast<RadixButton ^>(ProgrammerOperatorsContextMenu->Target);
|
||||
|
||||
CopyPasteManager::CopyToClipboard(source->GetRawDisplayValue());
|
||||
}
|
||||
|
@@ -9,8 +9,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorProgrammerOperators sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorProgrammerOperators sealed
|
||||
{
|
||||
public:
|
||||
CalculatorProgrammerOperators();
|
||||
@@ -23,16 +22,15 @@ namespace CalculatorApp
|
||||
|
||||
DEPENDENCY_PROPERTY_OWNER(CalculatorProgrammerOperators);
|
||||
|
||||
DEPENDENCY_PROPERTY(_In_ Windows::UI::Xaml::Style^, SymbolButtonStyle);
|
||||
DEPENDENCY_PROPERTY(_In_ Windows::UI::Xaml::Style ^, SymbolButtonStyle);
|
||||
|
||||
internal:
|
||||
void SetRadixButton(RADIX_TYPE radixType);
|
||||
internal : void SetRadixButton(RADIX_TYPE radixType);
|
||||
|
||||
private:
|
||||
void DecButtonChecked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void HexButtonChecked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void BinButtonChecked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OctButtonChecked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void DecButtonChecked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void HexButtonChecked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void BinButtonChecked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OctButtonChecked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@@ -23,8 +23,7 @@ using namespace Windows::UI::Xaml::Data;
|
||||
using namespace CalculatorApp::Common;
|
||||
using namespace Windows::UI::Xaml::Media;
|
||||
|
||||
CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators() :
|
||||
m_isErrorVisualState(false)
|
||||
CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@@ -32,19 +31,20 @@ CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators() :
|
||||
SetVisibilityBinding(ProgRadixOps, L"IsBinaryBitFlippingEnabled", booleanToVisibilityNegationConverter);
|
||||
}
|
||||
|
||||
void CalculatorProgrammerRadixOperators::OnLoaded(Object^, RoutedEventArgs^)
|
||||
void CalculatorProgrammerRadixOperators::OnLoaded(Object ^, RoutedEventArgs ^)
|
||||
{
|
||||
m_progModeRadixChangeToken = Model->ProgModeRadixChange += ref new ProgModeRadixChangeHandler(this, &CalculatorProgrammerRadixOperators::ProgModeRadixChange);
|
||||
m_progModeRadixChangeToken = Model->ProgModeRadixChange +=
|
||||
ref new ProgModeRadixChangeHandler(this, &CalculatorProgrammerRadixOperators::ProgModeRadixChange);
|
||||
}
|
||||
void CalculatorProgrammerRadixOperators::OnUnloaded(Object^, RoutedEventArgs^)
|
||||
void CalculatorProgrammerRadixOperators::OnUnloaded(Object ^, RoutedEventArgs ^)
|
||||
{
|
||||
Model->ProgModeRadixChange -= m_progModeRadixChangeToken;
|
||||
}
|
||||
|
||||
void CalculatorProgrammerRadixOperators::Shift_Clicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerRadixOperators::Shift_Clicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
bool isShiftChecked = static_cast<ToggleButton^>(sender)->IsChecked->Value;
|
||||
auto scvm = safe_cast<StandardCalculatorViewModel^>(this->DataContext);
|
||||
bool isShiftChecked = static_cast<ToggleButton ^>(sender)->IsChecked->Value;
|
||||
auto scvm = safe_cast<StandardCalculatorViewModel ^>(this->DataContext);
|
||||
scvm->IsShiftProgrammerChecked = isShiftChecked;
|
||||
|
||||
if (RolButton == nullptr)
|
||||
@@ -69,9 +69,9 @@ void CalculatorProgrammerRadixOperators::Shift_Clicked(Platform::Object^ sender,
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerRadixOperators::SetVisibilityBinding(FrameworkElement^ element, String^ path, IValueConverter^ converter)
|
||||
void CalculatorProgrammerRadixOperators::SetVisibilityBinding(FrameworkElement ^ element, String ^ path, IValueConverter ^ converter)
|
||||
{
|
||||
Binding^ commandBinding = ref new Binding();
|
||||
Binding ^ commandBinding = ref new Binding();
|
||||
commandBinding->Path = ref new PropertyPath(path);
|
||||
commandBinding->Converter = converter;
|
||||
element->SetBinding(VisibilityProperty, commandBinding);
|
||||
@@ -92,18 +92,18 @@ void CalculatorProgrammerRadixOperators::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
NumberPad->IsErrorVisualState = m_isErrorVisualState;
|
||||
}
|
||||
}
|
||||
|
||||
String^ CalculatorProgrammerRadixOperators::ParenthesisCountToString(unsigned int count) {
|
||||
String ^ CalculatorProgrammerRadixOperators::ParenthesisCountToString(unsigned int count)
|
||||
{
|
||||
return (count == 0) ? ref new String() : ref new String(to_wstring(count).data());
|
||||
}
|
||||
|
||||
|
||||
void CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators::OpenParenthesisButton_GotFocus(Object^ sender, RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators::OpenParenthesisButton_GotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
Model->SetOpenParenthesisCountNarratorAnnouncement();
|
||||
}
|
||||
|
@@ -9,8 +9,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorProgrammerRadixOperators sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorProgrammerRadixOperators sealed
|
||||
{
|
||||
public:
|
||||
CalculatorProgrammerRadixOperators();
|
||||
@@ -22,23 +21,24 @@ namespace CalculatorApp
|
||||
}
|
||||
}
|
||||
|
||||
property bool IsErrorVisualState {
|
||||
property bool IsErrorVisualState
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
Platform::String^ ParenthesisCountToString(unsigned int count);
|
||||
Platform::String ^ ParenthesisCountToString(unsigned int count);
|
||||
|
||||
DEPENDENCY_PROPERTY_OWNER(CalculatorProgrammerRadixOperators);
|
||||
|
||||
private:
|
||||
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 OnUnloaded(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 OnUnloaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void ProgModeRadixChange();
|
||||
|
||||
bool m_isErrorVisualState;
|
||||
Windows::Foundation::EventRegistrationToken m_progModeRadixChangeToken;
|
||||
void OpenParenthesisButton_GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OpenParenthesisButton_GotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@@ -29,27 +29,26 @@ using namespace Windows::UI::Core;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
CalculatorScientificAngleButtons::CalculatorScientificAngleButtons() :
|
||||
m_isErrorVisualState(false)
|
||||
CalculatorScientificAngleButtons::CalculatorScientificAngleButtons() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
void CalculatorScientificAngleButtons::HypButton_Toggled(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorScientificAngleButtons::HypButton_Toggled(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogHypButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
}
|
||||
|
||||
void CalculatorScientificAngleButtons::FToEButton_Toggled(_In_ Object^ sender,_In_ RoutedEventArgs^ e)
|
||||
void CalculatorScientificAngleButtons::FToEButton_Toggled(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
auto viewModel = safe_cast<StandardCalculatorViewModel^>(this->DataContext);
|
||||
auto viewModel = safe_cast<StandardCalculatorViewModel ^>(this->DataContext);
|
||||
viewModel->FtoEButtonToggled();
|
||||
}
|
||||
|
||||
void CalculatorApp::CalculatorScientificAngleButtons::OnAngleButtonPressed(_In_ Object^ commandParameter)
|
||||
void CalculatorApp::CalculatorScientificAngleButtons::OnAngleButtonPressed(_In_ Object ^ commandParameter)
|
||||
{
|
||||
TraceLogger::GetInstance().LogAngleButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
String^ buttonId = static_cast<String^>(commandParameter);
|
||||
String ^ buttonId = static_cast<String ^>(commandParameter);
|
||||
|
||||
DegreeButton->Visibility = ::Visibility::Collapsed;
|
||||
RadianButton->Visibility = ::Visibility::Collapsed;
|
||||
@@ -85,7 +84,7 @@ void CalculatorScientificAngleButtons::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
}
|
||||
}
|
||||
|
@@ -13,8 +13,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorScientificAngleButtons sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorScientificAngleButtons sealed
|
||||
{
|
||||
public:
|
||||
CalculatorScientificAngleButtons();
|
||||
@@ -27,16 +26,17 @@ namespace CalculatorApp
|
||||
|
||||
COMMAND_FOR_METHOD(ButtonPressed, CalculatorScientificAngleButtons::OnAngleButtonPressed)
|
||||
|
||||
property bool IsErrorVisualState {
|
||||
property bool IsErrorVisualState
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
|
||||
private:
|
||||
void OnAngleButtonPressed(_In_ Platform::Object^ commandParameter);
|
||||
void FToEButton_Toggled(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void HypButton_Toggled(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnAngleButtonPressed(_In_ Platform::Object ^ commandParameter);
|
||||
void FToEButton_Toggled(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void HypButton_Toggled(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
bool m_isErrorVisualState;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@@ -39,14 +39,14 @@ CalculatorScientificOperators::CalculatorScientificOperators()
|
||||
Common::KeyboardShortcutManager::ShiftButtonChecked(false);
|
||||
}
|
||||
|
||||
void CalculatorScientificOperators::ShortLayout_Completed(_In_ Platform::Object^ /*sender*/, _In_ Platform::Object^ /*e*/)
|
||||
void CalculatorScientificOperators::ShortLayout_Completed(_In_ Platform::Object ^ /*sender*/, _In_ Platform::Object ^ /*e*/)
|
||||
{
|
||||
IsWideLayout = false;
|
||||
SetOperatorRowVisibility();
|
||||
Common::KeyboardShortcutManager::ShiftButtonChecked(Model->IsShiftChecked);
|
||||
}
|
||||
|
||||
void CalculatorScientificOperators::WideLayout_Completed(_In_ Platform::Object^ /*sender*/, _In_ Platform::Object^ /*e*/)
|
||||
void CalculatorScientificOperators::WideLayout_Completed(_In_ Platform::Object ^ /*sender*/, _In_ Platform::Object ^ /*e*/)
|
||||
{
|
||||
IsWideLayout = true;
|
||||
SetOperatorRowVisibility();
|
||||
@@ -55,12 +55,12 @@ void CalculatorScientificOperators::WideLayout_Completed(_In_ Platform::Object^
|
||||
|
||||
void CalculatorScientificOperators::OnIsErrorVisualStatePropertyChanged(bool /*oldValue*/, bool newValue)
|
||||
{
|
||||
String^ newState = newValue ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = newValue ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
NumberPad->IsErrorVisualState = newValue;
|
||||
}
|
||||
|
||||
void CalculatorScientificOperators::shiftButton_Check(_In_ Platform::Object^ /*sender*/, _In_ Windows::UI::Xaml::RoutedEventArgs^ /*e*/)
|
||||
void CalculatorScientificOperators::shiftButton_Check(_In_ Platform::Object ^ /*sender*/, _In_ Windows::UI::Xaml::RoutedEventArgs ^ /*e*/)
|
||||
{
|
||||
bool isChecked = ShiftButton->IsChecked->Value;
|
||||
Model->IsShiftChecked = isChecked;
|
||||
@@ -68,7 +68,8 @@ void CalculatorScientificOperators::shiftButton_Check(_In_ Platform::Object^ /*s
|
||||
SetOperatorRowVisibility();
|
||||
}
|
||||
|
||||
void CalculatorScientificOperators::shiftButton_IsEnabledChanged(_In_ Platform::Object^ /*sender*/, _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ /*e*/)
|
||||
void CalculatorScientificOperators::shiftButton_IsEnabledChanged(_In_ Platform::Object ^ /*sender*/,
|
||||
_In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ /*e*/)
|
||||
{
|
||||
SetOperatorRowVisibility();
|
||||
Common::KeyboardShortcutManager::ShiftButtonChecked(ShiftButton->IsEnabled && ShiftButton->IsChecked->Value);
|
||||
@@ -99,11 +100,12 @@ void CalculatorScientificOperators::SetOperatorRowVisibility()
|
||||
InvRow2->Visibility = invRowVis;
|
||||
}
|
||||
|
||||
void CalculatorScientificOperators::OpenParenthesisButton_GotFocus(Object^ sender, RoutedEventArgs^ e)
|
||||
void CalculatorScientificOperators::OpenParenthesisButton_GotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
Model->SetOpenParenthesisCountNarratorAnnouncement();
|
||||
}
|
||||
|
||||
String^ CalculatorScientificOperators::ParenthesisCountToString(unsigned int count) {
|
||||
String ^ CalculatorScientificOperators::ParenthesisCountToString(unsigned int count)
|
||||
{
|
||||
return (count == 0) ? ref new String() : ref new String(to_wstring(count).data());
|
||||
}
|
||||
|
@@ -16,8 +16,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorScientificOperators sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorScientificOperators sealed
|
||||
{
|
||||
public:
|
||||
CalculatorScientificOperators();
|
||||
@@ -32,15 +31,19 @@ namespace CalculatorApp
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(bool, IsErrorVisualState, false);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT(bool, IsWideLayout, false);
|
||||
|
||||
bool IsShiftEnabled(bool isWideLayout, bool isErrorState) { return !(isWideLayout || isErrorState); }
|
||||
void OpenParenthesisButton_GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
Platform::String^ ParenthesisCountToString(unsigned int count);
|
||||
bool IsShiftEnabled(bool isWideLayout, bool isErrorState)
|
||||
{
|
||||
return !(isWideLayout || isErrorState);
|
||||
}
|
||||
void OpenParenthesisButton_GotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
Platform::String ^ ParenthesisCountToString(unsigned int count);
|
||||
|
||||
private:
|
||||
void ShortLayout_Completed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void WideLayout_Completed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void ShortLayout_Completed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void WideLayout_Completed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnIsErrorVisualStatePropertyChanged(bool oldValue, bool newValue);
|
||||
void shiftButton_Check(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void shiftButton_IsEnabledChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ e);
|
||||
void shiftButton_Check(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void shiftButton_IsEnabledChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ e);
|
||||
void SetOperatorRowVisibility();
|
||||
};
|
||||
}
|
||||
|
@@ -24,13 +24,13 @@ using namespace Windows::UI::Xaml::Navigation;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
CalculatorStandardOperators::CalculatorStandardOperators() :
|
||||
m_isErrorVisualState(false)
|
||||
CalculatorStandardOperators::CalculatorStandardOperators() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
bool CalculatorStandardOperators::IsErrorVisualState::get() {
|
||||
bool CalculatorStandardOperators::IsErrorVisualState::get()
|
||||
{
|
||||
return m_isErrorVisualState;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ void CalculatorStandardOperators::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
NumberPad->IsErrorVisualState = m_isErrorVisualState;
|
||||
}
|
||||
|
@@ -13,8 +13,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorStandardOperators sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorStandardOperators sealed
|
||||
{
|
||||
public:
|
||||
CalculatorStandardOperators();
|
||||
|
@@ -51,7 +51,7 @@ DateCalculator::DateCalculator()
|
||||
// Setting the FirstDayofWeek
|
||||
DateDiff_FromDate->FirstDayOfWeek = localizationSettings.GetFirstDayOfWeek();
|
||||
DateDiff_ToDate->FirstDayOfWeek = localizationSettings.GetFirstDayOfWeek();
|
||||
|
||||
|
||||
// Setting the Language explicitly is not required,
|
||||
// this is a workaround for the bug in the control due to which
|
||||
// the displayed date is incorrect for non Gregorian Calendar Systems
|
||||
@@ -79,10 +79,9 @@ DateCalculator::DateCalculator()
|
||||
DateDiff_ToDate->MaxDate = maxYear;
|
||||
|
||||
// Set the PlaceHolderText for CalendarDatePicker
|
||||
DateTimeFormatter^ dateTimeFormatter = LocalizationService::GetRegionalSettingsAwareDateTimeFormatter(
|
||||
L"day month year",
|
||||
localizationSettings.GetCalendarIdentifier(),
|
||||
ClockIdentifiers::TwentyFourHour); // Clock Identifier is not used
|
||||
DateTimeFormatter ^ dateTimeFormatter =
|
||||
LocalizationService::GetRegionalSettingsAwareDateTimeFormatter(L"day month year", localizationSettings.GetCalendarIdentifier(),
|
||||
ClockIdentifiers::TwentyFourHour); // Clock Identifier is not used
|
||||
|
||||
DateDiff_FromDate->DateFormat = L"day month year";
|
||||
DateDiff_ToDate->DateFormat = L"day month year";
|
||||
@@ -93,14 +92,15 @@ DateCalculator::DateCalculator()
|
||||
DateDiff_ToDate->PlaceholderText = placeholderText;
|
||||
|
||||
CopyMenuItem->Text = AppResourceProvider::GetInstance().GetResourceString(L"copyMenuItem");
|
||||
m_dateCalcOptionChangedEventToken = DateCalculationOption->SelectionChanged += ref new SelectionChangedEventHandler(this, &DateCalculator::DateCalcOption_Changed);
|
||||
m_dateCalcOptionChangedEventToken = DateCalculationOption->SelectionChanged +=
|
||||
ref new SelectionChangedEventHandler(this, &DateCalculator::DateCalcOption_Changed);
|
||||
}
|
||||
|
||||
void DateCalculator::FromDate_DateChanged(_In_ CalendarDatePicker^ sender, _In_ CalendarDatePickerDateChangedEventArgs^ e)
|
||||
void DateCalculator::FromDate_DateChanged(_In_ CalendarDatePicker ^ sender, _In_ CalendarDatePickerDateChangedEventArgs ^ e)
|
||||
{
|
||||
if (e->NewDate != nullptr)
|
||||
{
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel^>(this->DataContext);
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
|
||||
dateCalcViewModel->FromDate = e->NewDate->Value;
|
||||
TraceLogger::GetInstance().LogDateDifferenceModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
}
|
||||
@@ -110,11 +110,11 @@ void DateCalculator::FromDate_DateChanged(_In_ CalendarDatePicker^ sender, _In_
|
||||
}
|
||||
}
|
||||
|
||||
void DateCalculator::ToDate_DateChanged(_In_ CalendarDatePicker^ sender, _In_ CalendarDatePickerDateChangedEventArgs^ e)
|
||||
void DateCalculator::ToDate_DateChanged(_In_ CalendarDatePicker ^ sender, _In_ CalendarDatePickerDateChangedEventArgs ^ e)
|
||||
{
|
||||
if (e->NewDate != nullptr)
|
||||
{
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel^>(this->DataContext);
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
|
||||
dateCalcViewModel->ToDate = e->NewDate->Value;
|
||||
TraceLogger::GetInstance().LogDateDifferenceModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
}
|
||||
@@ -124,13 +124,14 @@ void DateCalculator::ToDate_DateChanged(_In_ CalendarDatePicker^ sender, _In_ Ca
|
||||
}
|
||||
}
|
||||
|
||||
void DateCalculator::AddSubtract_DateChanged(_In_ CalendarDatePicker^ sender, _In_ CalendarDatePickerDateChangedEventArgs^ e)
|
||||
void DateCalculator::AddSubtract_DateChanged(_In_ CalendarDatePicker ^ sender, _In_ CalendarDatePickerDateChangedEventArgs ^ e)
|
||||
{
|
||||
if (e->NewDate != nullptr)
|
||||
{
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel^>(this->DataContext);
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
|
||||
dateCalcViewModel->StartDate = e->NewDate->Value;
|
||||
TraceLogger::GetInstance().LogDateAddSubtractModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()), dateCalcViewModel->IsAddMode);
|
||||
TraceLogger::GetInstance().LogDateAddSubtractModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()),
|
||||
dateCalcViewModel->IsAddMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -138,15 +139,16 @@ void DateCalculator::AddSubtract_DateChanged(_In_ CalendarDatePicker^ sender, _I
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorApp::DateCalculator::OffsetValue_Changed(_In_ Platform::Object^ sender, _In_ SelectionChangedEventArgs^ e)
|
||||
void CalculatorApp::DateCalculator::OffsetValue_Changed(_In_ Platform::Object ^ sender, _In_ SelectionChangedEventArgs ^ e)
|
||||
{
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel^>(this->DataContext);
|
||||
TraceLogger::GetInstance().LogDateAddSubtractModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()), dateCalcViewModel->IsAddMode);
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
|
||||
TraceLogger::GetInstance().LogDateAddSubtractModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()),
|
||||
dateCalcViewModel->IsAddMode);
|
||||
}
|
||||
|
||||
void DateCalculator::OnCopyMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void DateCalculator::OnCopyMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
auto calcResult = safe_cast<TextBlock^>(ResultsContextMenu->Target);
|
||||
auto calcResult = safe_cast<TextBlock ^>(ResultsContextMenu->Target);
|
||||
|
||||
CopyPasteManager::CopyToClipboard(calcResult->Text);
|
||||
}
|
||||
@@ -178,13 +180,13 @@ void DateCalculator::SetDefaultFocus()
|
||||
DateCalculationOption->Focus(::FocusState::Programmatic);
|
||||
}
|
||||
|
||||
void DateCalculator::DateCalcOption_Changed(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e)
|
||||
void DateCalculator::DateCalcOption_Changed(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e)
|
||||
{
|
||||
FindName("AddSubtractDateGrid");
|
||||
DateCalculationOption->SelectionChanged -= m_dateCalcOptionChangedEventToken;
|
||||
}
|
||||
|
||||
void CalculatorApp::DateCalculator::AddSubtractDateGrid_Loaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
void CalculatorApp::DateCalculator::AddSubtractDateGrid_Loaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
const auto& localizationSettings = LocalizationSettings::GetInstance();
|
||||
|
||||
@@ -198,7 +200,7 @@ void CalculatorApp::DateCalculator::AddSubtractDateGrid_Loaded(_In_ Platform::Ob
|
||||
AddSubtract_FromDate->DateFormat = L"day month year";
|
||||
}
|
||||
|
||||
void DateCalculator::ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker^ calendarDatePicker, Windows::Foundation::DateTime dateTime)
|
||||
void DateCalculator::ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ calendarDatePicker, Windows::Foundation::DateTime dateTime)
|
||||
{
|
||||
// Reselect the unselected Date
|
||||
calendarDatePicker->Date = ref new Box<DateTime>(dateTime);
|
||||
@@ -207,25 +209,25 @@ void DateCalculator::ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::Cale
|
||||
calendarDatePicker->IsCalendarOpen = false;
|
||||
}
|
||||
|
||||
void DateCalculator::OffsetDropDownClosed(_In_ Object^ sender, _In_ Object^ e)
|
||||
void DateCalculator::OffsetDropDownClosed(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
RaiseLiveRegionChangedAutomationEvent(/* DateDiff mode */ false);
|
||||
}
|
||||
|
||||
void DateCalculator::CalendarFlyoutClosed(_In_ Object^ sender, _In_ Object^ e)
|
||||
void DateCalculator::CalendarFlyoutClosed(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel^>(this->DataContext);
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
|
||||
RaiseLiveRegionChangedAutomationEvent(dateCalcViewModel->IsDateDiffMode);
|
||||
}
|
||||
|
||||
void DateCalculator::RaiseLiveRegionChangedAutomationEvent(_In_ bool isDateDiffMode)
|
||||
{
|
||||
TextBlock^ resultTextBlock = (isDateDiffMode ? DateDiffAllUnitsResultLabel : DateResultLabel);
|
||||
String^ automationName = AutomationProperties::GetName(resultTextBlock);
|
||||
TextBlock ^ resultTextBlock = (isDateDiffMode ? DateDiffAllUnitsResultLabel : DateResultLabel);
|
||||
String ^ automationName = AutomationProperties::GetName(resultTextBlock);
|
||||
TextBlockAutomationPeer::FromElement(resultTextBlock)->RaiseAutomationEvent(AutomationEvents::LiveRegionChanged);
|
||||
}
|
||||
|
||||
void DateCalculator::AddSubtractOption_Checked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void DateCalculator::AddSubtractOption_Checked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
RaiseLiveRegionChangedAutomationEvent(/* DateDiff mode */ false);
|
||||
}
|
||||
|
@@ -21,8 +21,7 @@ const int c_minYear = 1601;
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class DateCalculator sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class DateCalculator sealed
|
||||
{
|
||||
public:
|
||||
DateCalculator();
|
||||
@@ -30,18 +29,21 @@ namespace CalculatorApp
|
||||
void SetDefaultFocus();
|
||||
|
||||
private:
|
||||
void FromDate_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker^ sender, _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs^ e);
|
||||
void ToDate_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker^ sender, _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs^ e);
|
||||
void AddSubtract_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker^ sender, _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs^ e);
|
||||
void OffsetValue_Changed(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnLoaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void DateCalcOption_Changed(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
|
||||
void AddSubtractDateGrid_Loaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void AddSubtractOption_Checked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker^ calendarDatePicker, Windows::Foundation::DateTime dateTime);
|
||||
void OffsetDropDownClosed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void CalendarFlyoutClosed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void FromDate_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender,
|
||||
_In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e);
|
||||
void ToDate_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender,
|
||||
_In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e);
|
||||
void AddSubtract_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender,
|
||||
_In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e);
|
||||
void OffsetValue_Changed(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnLoaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void DateCalcOption_Changed(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
|
||||
void AddSubtractDateGrid_Loaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void AddSubtractOption_Checked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ calendarDatePicker, Windows::Foundation::DateTime dateTime);
|
||||
void OffsetDropDownClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void CalendarFlyoutClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void RaiseLiveRegionChangedAutomationEvent(_In_ bool isDateDiffMode);
|
||||
|
||||
Windows::Foundation::EventRegistrationToken m_dateCalcOptionChangedEventToken;
|
||||
|
@@ -40,10 +40,10 @@ HistoryList::HistoryList()
|
||||
HistoryEmpty->FlowDirection = LocalizationService::GetInstance()->GetFlowDirection();
|
||||
}
|
||||
|
||||
void HistoryList::ListView_ItemClick(_In_ Object^ sender, _In_ ItemClickEventArgs^ e)
|
||||
void HistoryList::ListView_ItemClick(_In_ Object ^ sender, _In_ ItemClickEventArgs ^ e)
|
||||
{
|
||||
HistoryViewModel^ historyVM = static_cast<HistoryViewModel^>(this->DataContext);
|
||||
HistoryItemViewModel^ clickedItem = safe_cast<HistoryItemViewModel^>(e->ClickedItem);
|
||||
HistoryViewModel ^ historyVM = static_cast<HistoryViewModel ^>(this->DataContext);
|
||||
HistoryItemViewModel ^ clickedItem = safe_cast<HistoryItemViewModel ^>(e->ClickedItem);
|
||||
|
||||
// When the user clears the history list in the overlay view and presses enter, the clickedItem is nullptr
|
||||
if (clickedItem != nullptr)
|
||||
@@ -52,16 +52,16 @@ void HistoryList::ListView_ItemClick(_In_ Object^ sender, _In_ ItemClickEventArg
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryList::OnDeleteMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void HistoryList::OnDeleteMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
auto clickedItem = safe_cast<HistoryItemViewModel^>(safe_cast<FrameworkElement^>(sender)->DataContext);
|
||||
auto clickedItem = safe_cast<HistoryItemViewModel ^>(safe_cast<FrameworkElement ^>(sender)->DataContext);
|
||||
|
||||
Model->DeleteItem(clickedItem);
|
||||
}
|
||||
|
||||
void HistoryList::OnDeleteSwipeInvoked(_In_ MUXC::SwipeItem^ sender, _In_ MUXC::SwipeItemInvokedEventArgs^ e)
|
||||
void HistoryList::OnDeleteSwipeInvoked(_In_ MUXC::SwipeItem ^ sender, _In_ MUXC::SwipeItemInvokedEventArgs ^ e)
|
||||
{
|
||||
auto swipedItem = safe_cast<HistoryItemViewModel^>(e->SwipeControl->DataContext);
|
||||
auto swipedItem = safe_cast<HistoryItemViewModel ^>(e->SwipeControl->DataContext);
|
||||
|
||||
Model->DeleteItem(swipedItem);
|
||||
}
|
||||
|
@@ -15,8 +15,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class HistoryList sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class HistoryList sealed
|
||||
{
|
||||
public:
|
||||
HistoryList();
|
||||
@@ -34,8 +33,8 @@ namespace CalculatorApp
|
||||
private:
|
||||
Windows::Foundation::Rect m_visibleBounds;
|
||||
Windows::Foundation::Rect m_coreBounds;
|
||||
void ListView_ItemClick(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs^ e);
|
||||
void OnDeleteMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnDeleteSwipeInvoked(_In_ Microsoft::UI::Xaml::Controls::SwipeItem^ sender, _In_ Microsoft::UI::Xaml::Controls::SwipeItemInvokedEventArgs^ e);
|
||||
void ListView_ItemClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ e);
|
||||
void OnDeleteMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnDeleteSwipeInvoked(_In_ Microsoft::UI::Xaml::Controls::SwipeItem ^ sender, _In_ Microsoft::UI::Xaml::Controls::SwipeItemInvokedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@@ -63,8 +63,7 @@ namespace CalculatorApp::VisualStates
|
||||
}
|
||||
}
|
||||
|
||||
MainPage::MainPage() :
|
||||
m_model(ref new ApplicationViewModel())
|
||||
MainPage::MainPage() : m_model(ref new ApplicationViewModel())
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@@ -83,7 +82,7 @@ MainPage::MainPage() :
|
||||
}
|
||||
}
|
||||
|
||||
void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
|
||||
void MainPage::OnNavigatedTo(NavigationEventArgs ^ e)
|
||||
{
|
||||
if (m_model->CalculatorViewModel)
|
||||
{
|
||||
@@ -93,7 +92,7 @@ void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
|
||||
ViewMode initialMode = ViewMode::Standard;
|
||||
if (e->Parameter != nullptr)
|
||||
{
|
||||
String^ stringParameter = dynamic_cast<String^>(e->Parameter);
|
||||
String ^ stringParameter = dynamic_cast<String ^>(e->Parameter);
|
||||
if (stringParameter != nullptr)
|
||||
{
|
||||
initialMode = (ViewMode)stoi(stringParameter->Data());
|
||||
@@ -101,7 +100,7 @@ void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings;
|
||||
ApplicationDataContainer ^ localSettings = ApplicationData::Current->LocalSettings;
|
||||
if (localSettings->Values->HasKey(ApplicationViewModel::ModePropertyName))
|
||||
{
|
||||
initialMode = NavCategory::Deserialize(localSettings->Values->Lookup(ApplicationViewModel::ModePropertyName));
|
||||
@@ -111,15 +110,15 @@ void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
|
||||
m_model->Initialize(initialMode);
|
||||
}
|
||||
|
||||
void MainPage::WindowSizeChanged(_In_ Platform::Object^ /*sender*/, _In_ Windows::UI::Core::WindowSizeChangedEventArgs^ e)
|
||||
void MainPage::WindowSizeChanged(_In_ Platform::Object ^ /*sender*/, _In_ Windows::UI::Core::WindowSizeChangedEventArgs ^ e)
|
||||
{
|
||||
// We don't use layout aware page's view states, we have our own
|
||||
UpdateViewState();
|
||||
}
|
||||
|
||||
void MainPage::OnAppPropertyChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e)
|
||||
void MainPage::OnAppPropertyChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e)
|
||||
{
|
||||
String^ propertyName = e->PropertyName;
|
||||
String ^ propertyName = e->PropertyName;
|
||||
if (propertyName == ApplicationViewModel::ModePropertyName)
|
||||
{
|
||||
ViewMode newValue = m_model->Mode;
|
||||
@@ -233,7 +232,7 @@ void MainPage::UpdatePanelViewState()
|
||||
}
|
||||
}
|
||||
|
||||
void MainPage::OnPageLoaded(_In_ Object^, _In_ RoutedEventArgs^ args)
|
||||
void MainPage::OnPageLoaded(_In_ Object ^, _In_ RoutedEventArgs ^ args)
|
||||
{
|
||||
if (!m_converter && !m_calculator && !m_dateCalculator)
|
||||
{
|
||||
@@ -249,15 +248,15 @@ void MainPage::OnPageLoaded(_In_ Object^, _In_ RoutedEventArgs^ args)
|
||||
SetDefaultFocus();
|
||||
|
||||
// Delay load things later when we get a chance.
|
||||
this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([]()
|
||||
{
|
||||
if (TraceLogger::GetInstance().UpdateWindowIdLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())))
|
||||
{
|
||||
TraceLogger::GetInstance().LogAppLaunchComplete();
|
||||
AppLifecycleLogger::GetInstance().LaunchUIResponsive();
|
||||
AppLifecycleLogger::GetInstance().LaunchVisibleComplete();
|
||||
}
|
||||
}));
|
||||
this->Dispatcher->RunAsync(
|
||||
CoreDispatcherPriority::Normal, ref new DispatchedHandler([]() {
|
||||
if (TraceLogger::GetInstance().UpdateWindowIdLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())))
|
||||
{
|
||||
TraceLogger::GetInstance().LogAppLaunchComplete();
|
||||
AppLifecycleLogger::GetInstance().LaunchUIResponsive();
|
||||
AppLifecycleLogger::GetInstance().LaunchVisibleComplete();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void MainPage::SetDefaultFocus()
|
||||
@@ -284,13 +283,13 @@ void MainPage::EnsureCalculator()
|
||||
m_calculator = ref new Calculator();
|
||||
m_calculator->Name = L"Calculator";
|
||||
m_calculator->DataContext = m_model->CalculatorViewModel;
|
||||
Binding^ isStandardBinding = ref new Binding();
|
||||
Binding ^ isStandardBinding = ref new Binding();
|
||||
isStandardBinding->Path = ref new PropertyPath(L"IsStandard");
|
||||
m_calculator->SetBinding(m_calculator->IsStandardProperty, isStandardBinding);
|
||||
Binding^ isScientificBinding = ref new Binding();
|
||||
Binding ^ isScientificBinding = ref new Binding();
|
||||
isScientificBinding->Path = ref new PropertyPath(L"IsScientific");
|
||||
m_calculator->SetBinding(m_calculator->IsScientificProperty, isScientificBinding);
|
||||
Binding^ isProgramerBinding = ref new Binding();
|
||||
Binding ^ isProgramerBinding = ref new Binding();
|
||||
isProgramerBinding->Path = ref new PropertyPath(L"IsProgrammer");
|
||||
m_calculator->SetBinding(m_calculator->IsProgrammerProperty, isProgramerBinding);
|
||||
m_calculator->Style = CalculatorBaseStyle;
|
||||
@@ -307,7 +306,6 @@ void MainPage::EnsureCalculator()
|
||||
{
|
||||
m_dateCalculator->CloseCalendarFlyout();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainPage::EnsureDateCalculator()
|
||||
@@ -342,11 +340,11 @@ void MainPage::EnsureConverter()
|
||||
}
|
||||
}
|
||||
|
||||
void MainPage::OnNavLoaded(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void MainPage::OnNavLoaded(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
if (NavView->SelectedItem == nullptr)
|
||||
{
|
||||
auto menuItems = static_cast<IObservableVector<Object^>^>(NavView->MenuItemsSource);
|
||||
auto menuItems = static_cast<IObservableVector<Object ^> ^>(NavView->MenuItemsSource);
|
||||
auto itemCount = static_cast<int>(menuItems->Size);
|
||||
auto flatIndex = NavCategory::GetFlatIndex(Model->Mode);
|
||||
|
||||
@@ -365,7 +363,7 @@ void MainPage::OnNavLoaded(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
NavView->SetValue(Common::KeyboardShortcutManager::VirtualKeyControlChordProperty, Common::MyVirtualKey::E);
|
||||
}
|
||||
|
||||
void MainPage::OnNavPaneOpening(_In_ MUXC::NavigationView^ sender, _In_ Object^ args)
|
||||
void MainPage::OnNavPaneOpening(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
if (!NavFooter)
|
||||
{
|
||||
@@ -373,24 +371,24 @@ void MainPage::OnNavPaneOpening(_In_ MUXC::NavigationView^ sender, _In_ Object^
|
||||
}
|
||||
}
|
||||
|
||||
void MainPage::OnNavPaneOpened(_In_ MUXC::NavigationView^ sender, _In_ Object^ args)
|
||||
void MainPage::OnNavPaneOpened(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
KeyboardShortcutManager::HonorShortcuts(false);
|
||||
TraceLogger::GetInstance().LogNavBarOpened();
|
||||
}
|
||||
|
||||
void MainPage::OnNavPaneClosed(_In_ MUXC::NavigationView^ sender, _In_ Object^ args)
|
||||
void MainPage::OnNavPaneClosed(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
KeyboardShortcutManager::HonorShortcuts(true);
|
||||
this->SetDefaultFocus();
|
||||
}
|
||||
|
||||
void MainPage::OnAboutButtonClick(Object^ sender, ItemClickEventArgs^ e)
|
||||
void MainPage::OnAboutButtonClick(Object ^ sender, ItemClickEventArgs ^ e)
|
||||
{
|
||||
ShowAboutPage();
|
||||
}
|
||||
|
||||
void MainPage::OnAboutFlyoutOpened(_In_ Object^ sender, _In_ Object^ e)
|
||||
void MainPage::OnAboutFlyoutOpened(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
// Keep Ignoring Escape till the About page flyout is opened
|
||||
KeyboardShortcutManager::IgnoreEscape(false);
|
||||
@@ -398,7 +396,7 @@ void MainPage::OnAboutFlyoutOpened(_In_ Object^ sender, _In_ Object^ e)
|
||||
KeyboardShortcutManager::UpdateDropDownState(this->AboutPageFlyout);
|
||||
}
|
||||
|
||||
void MainPage::OnAboutFlyoutClosed(_In_ Object^ sender, _In_ Object^ e)
|
||||
void MainPage::OnAboutFlyoutClosed(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
// Start Honoring Escape once the About page flyout is closed
|
||||
KeyboardShortcutManager::HonorEscape();
|
||||
@@ -406,19 +404,19 @@ void MainPage::OnAboutFlyoutClosed(_In_ Object^ sender, _In_ Object^ e)
|
||||
KeyboardShortcutManager::UpdateDropDownState(nullptr);
|
||||
}
|
||||
|
||||
void MainPage::OnNavSelectionChanged(_In_ Object^ sender, _In_ MUXC::NavigationViewSelectionChangedEventArgs^ e)
|
||||
void MainPage::OnNavSelectionChanged(_In_ Object ^ sender, _In_ MUXC::NavigationViewSelectionChangedEventArgs ^ e)
|
||||
{
|
||||
auto item = dynamic_cast<MUXC::NavigationViewItem^>(e->SelectedItemContainer);
|
||||
auto item = dynamic_cast<MUXC::NavigationViewItem ^>(e->SelectedItemContainer);
|
||||
if (item != nullptr)
|
||||
{
|
||||
auto selectedItem = static_cast<NavCategory^>(item->DataContext);
|
||||
auto selectedItem = static_cast<NavCategory ^>(item->DataContext);
|
||||
Model->Mode = selectedItem->Mode;
|
||||
}
|
||||
}
|
||||
|
||||
IObservableVector<Object^>^ MainPage::CreateUIElementsForCategories(_In_ IObservableVector<NavCategoryGroup^>^ categories)
|
||||
IObservableVector<Object ^> ^ MainPage::CreateUIElementsForCategories(_In_ IObservableVector<NavCategoryGroup ^> ^ categories)
|
||||
{
|
||||
auto menuCategories = ref new Vector<Object^>();
|
||||
auto menuCategories = ref new Vector<Object ^>();
|
||||
|
||||
for (auto group : categories)
|
||||
{
|
||||
@@ -433,7 +431,7 @@ IObservableVector<Object^>^ MainPage::CreateUIElementsForCategories(_In_ IObserv
|
||||
return menuCategories;
|
||||
}
|
||||
|
||||
MUXC::NavigationViewItemHeader^ MainPage::CreateNavViewHeaderFromGroup(NavCategoryGroup^ group)
|
||||
MUXC::NavigationViewItemHeader ^ MainPage::CreateNavViewHeaderFromGroup(NavCategoryGroup ^ group)
|
||||
{
|
||||
auto header = ref new MUXC::NavigationViewItemHeader();
|
||||
header->DataContext = group;
|
||||
@@ -445,19 +443,19 @@ MUXC::NavigationViewItemHeader^ MainPage::CreateNavViewHeaderFromGroup(NavCatego
|
||||
return header;
|
||||
}
|
||||
|
||||
MUXC::NavigationViewItem^ MainPage::CreateNavViewItemFromCategory(NavCategory^ category)
|
||||
MUXC::NavigationViewItem ^ MainPage::CreateNavViewItemFromCategory(NavCategory ^ category)
|
||||
{
|
||||
auto item = ref new MUXC::NavigationViewItem();
|
||||
item->DataContext = category;
|
||||
|
||||
auto icon = ref new FontIcon();
|
||||
icon->FontFamily = static_cast<Windows::UI::Xaml::Media::FontFamily^>(App::Current->Resources->Lookup(L"CalculatorFontFamily"));
|
||||
icon->FontFamily = static_cast<Windows::UI::Xaml::Media::FontFamily ^>(App::Current->Resources->Lookup(L"CalculatorFontFamily"));
|
||||
icon->Glyph = category->Glyph;
|
||||
item->Icon = icon;
|
||||
|
||||
item->Content = category->Name;
|
||||
item->AccessKey = category->AccessKey;
|
||||
item->Style = static_cast<Windows::UI::Xaml::Style^>(Resources->Lookup(L"NavViewItemStyle"));
|
||||
item->Style = static_cast<Windows::UI::Xaml::Style ^>(Resources->Lookup(L"NavViewItemStyle"));
|
||||
|
||||
AutomationProperties::SetName(item, category->AutomationName);
|
||||
AutomationProperties::SetAutomationId(item, category->AutomationId);
|
||||
@@ -491,7 +489,7 @@ void MainPage::SetHeaderAutomationName()
|
||||
ViewMode mode = m_model->Mode;
|
||||
auto resProvider = AppResourceProvider::GetInstance();
|
||||
|
||||
String^ name;
|
||||
String ^ name;
|
||||
if (NavCategory::IsDateCalculatorViewMode(mode))
|
||||
{
|
||||
name = resProvider.GetResourceString(L"HeaderAutomationName_Date");
|
||||
@@ -520,12 +518,12 @@ void MainPage::SetHeaderAutomationName()
|
||||
|
||||
void MainPage::AnnounceCategoryName()
|
||||
{
|
||||
String^ categoryName = AutomationProperties::GetName(Header);
|
||||
NarratorAnnouncement^ announcement = CalculatorAnnouncement::GetCategoryNameChangedAnnouncement(categoryName);
|
||||
String ^ categoryName = AutomationProperties::GetName(Header);
|
||||
NarratorAnnouncement ^ announcement = CalculatorAnnouncement::GetCategoryNameChangedAnnouncement(categoryName);
|
||||
NarratorNotifier->Announce(announcement);
|
||||
}
|
||||
|
||||
void MainPage::OnNavItemInvoked(MUXC::NavigationView^ /*sender*/, _In_ MUXC::NavigationViewItemInvokedEventArgs^ e)
|
||||
void MainPage::OnNavItemInvoked(MUXC::NavigationView ^ /*sender*/, _In_ MUXC::NavigationViewItemInvokedEventArgs ^ e)
|
||||
{
|
||||
NavView->IsPaneOpen = false;
|
||||
}
|
||||
|
@@ -19,50 +19,51 @@ namespace CalculatorApp
|
||||
/// <summary>
|
||||
/// A basic page that provides characteristics common to most applications.
|
||||
/// </summary>
|
||||
public ref class MainPage sealed
|
||||
public
|
||||
ref class MainPage sealed
|
||||
{
|
||||
public:
|
||||
MainPage();
|
||||
property CalculatorApp::ViewModel::ApplicationViewModel^ Model
|
||||
{
|
||||
CalculatorApp::ViewModel::ApplicationViewModel^ get(){
|
||||
return m_model;
|
||||
}
|
||||
}
|
||||
property CalculatorApp::ViewModel::ApplicationViewModel
|
||||
^ Model { CalculatorApp::ViewModel::ApplicationViewModel ^ get() { return m_model; } }
|
||||
|
||||
void UnregisterEventHandlers();
|
||||
void
|
||||
UnregisterEventHandlers();
|
||||
|
||||
void SetDefaultFocus();
|
||||
void SetHeaderAutomationName();
|
||||
|
||||
Windows::Foundation::Collections::IObservableVector<Platform::Object^>^ CreateUIElementsForCategories(_In_ Windows::Foundation::Collections::IObservableVector<CalculatorApp::Common::NavCategoryGroup^>^ categories);
|
||||
Windows::Foundation::Collections::IObservableVector<
|
||||
Platform::Object
|
||||
^> ^ CreateUIElementsForCategories(_In_ Windows::Foundation::Collections::IObservableVector<CalculatorApp::Common::NavCategoryGroup ^> ^ categories);
|
||||
|
||||
protected:
|
||||
void OnNavigatedTo(_In_ Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
|
||||
void OnNavigatedTo(_In_ Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e) override;
|
||||
|
||||
private:
|
||||
void WindowSizeChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Core::WindowSizeChangedEventArgs^ e);
|
||||
void OnAppPropertyChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e);
|
||||
void WindowSizeChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Core::WindowSizeChangedEventArgs ^ e);
|
||||
void OnAppPropertyChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e);
|
||||
|
||||
void OnNavLoaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnNavPaneOpening(_In_ Microsoft::UI::Xaml::Controls::NavigationView^ sender, _In_ Platform::Object^ args);
|
||||
void OnNavPaneOpened(_In_ Microsoft::UI::Xaml::Controls::NavigationView^ sender, _In_ Platform::Object^ args);
|
||||
void OnNavPaneClosed(_In_ Microsoft::UI::Xaml::Controls::NavigationView^ sender, _In_ Platform::Object^ args);
|
||||
void OnNavSelectionChanged(_In_ Platform::Object^ sender, _In_ Microsoft::UI::Xaml::Controls::NavigationViewSelectionChangedEventArgs^ e);
|
||||
void OnNavItemInvoked(Microsoft::UI::Xaml::Controls::NavigationView^ /*sender*/, _In_ Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs^ e);
|
||||
void OnNavLoaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnNavPaneOpening(_In_ Microsoft::UI::Xaml::Controls::NavigationView ^ sender, _In_ Platform::Object ^ args);
|
||||
void OnNavPaneOpened(_In_ Microsoft::UI::Xaml::Controls::NavigationView ^ sender, _In_ Platform::Object ^ args);
|
||||
void OnNavPaneClosed(_In_ Microsoft::UI::Xaml::Controls::NavigationView ^ sender, _In_ Platform::Object ^ args);
|
||||
void OnNavSelectionChanged(_In_ Platform::Object ^ sender, _In_ Microsoft::UI::Xaml::Controls::NavigationViewSelectionChangedEventArgs ^ e);
|
||||
void OnNavItemInvoked(Microsoft::UI::Xaml::Controls::NavigationView ^ /*sender*/,
|
||||
_In_ Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs ^ e);
|
||||
|
||||
void OnAboutButtonClick(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs^ e);
|
||||
void OnAboutFlyoutOpened(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnAboutFlyoutClosed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnAboutButtonClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ e);
|
||||
void OnAboutFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnAboutFlyoutClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
|
||||
Microsoft::UI::Xaml::Controls::NavigationViewItemHeader ^ CreateNavViewHeaderFromGroup(CalculatorApp::Common::NavCategoryGroup ^ group);
|
||||
Microsoft::UI::Xaml::Controls::NavigationViewItem ^ CreateNavViewItemFromCategory(CalculatorApp::Common::NavCategory ^ category);
|
||||
|
||||
Microsoft::UI::Xaml::Controls::NavigationViewItemHeader^ CreateNavViewHeaderFromGroup(CalculatorApp::Common::NavCategoryGroup^ group);
|
||||
Microsoft::UI::Xaml::Controls::NavigationViewItem^ CreateNavViewItemFromCategory(CalculatorApp::Common::NavCategory^ category);
|
||||
|
||||
void ShowHideControls(CalculatorApp::Common::ViewMode mode);
|
||||
void UpdateViewState();
|
||||
void UpdatePanelViewState();
|
||||
|
||||
void OnPageLoaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnPageLoaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
void EnsureCalculator();
|
||||
void EnsureConverter();
|
||||
@@ -71,10 +72,10 @@ namespace CalculatorApp
|
||||
|
||||
void AnnounceCategoryName();
|
||||
|
||||
CalculatorApp::Calculator^ m_calculator;
|
||||
CalculatorApp::UnitConverter^ m_converter;
|
||||
CalculatorApp::DateCalculator^ m_dateCalculator;
|
||||
CalculatorApp::Calculator ^ m_calculator;
|
||||
CalculatorApp::UnitConverter ^ m_converter;
|
||||
CalculatorApp::DateCalculator ^ m_dateCalculator;
|
||||
Windows::Foundation::EventRegistrationToken m_windowSizeEventToken;
|
||||
CalculatorApp::ViewModel::ApplicationViewModel^ m_model;
|
||||
CalculatorApp::ViewModel::ApplicationViewModel ^ m_model;
|
||||
};
|
||||
}
|
||||
|
@@ -35,18 +35,17 @@ using namespace Windows::UI::ViewManagement;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Memory, RowHeight);
|
||||
|
||||
Memory::Memory() :
|
||||
m_isErrorVisualState(false)
|
||||
Memory::Memory() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
m_memoryItemFlyout = safe_cast<MenuFlyout^>(Resources->Lookup("MemoryContextMenu"));
|
||||
m_memoryItemFlyout = safe_cast<MenuFlyout ^>(Resources->Lookup("MemoryContextMenu"));
|
||||
|
||||
MemoryPaneEmpty->FlowDirection = LocalizationService::GetInstance()->GetFlowDirection();
|
||||
}
|
||||
|
||||
void Memory::MemoryListItemClick(_In_ Object^ sender, _In_ ItemClickEventArgs^ e)
|
||||
void Memory::MemoryListItemClick(_In_ Object ^ sender, _In_ ItemClickEventArgs ^ e)
|
||||
{
|
||||
MemoryItemViewModel^ memorySlot = safe_cast<MemoryItemViewModel^>(e->ClickedItem);
|
||||
MemoryItemViewModel ^ memorySlot = safe_cast<MemoryItemViewModel ^>(e->ClickedItem);
|
||||
|
||||
// In case the memory list is clicked and enter is pressed,
|
||||
// On Item clicked event gets fired and e->ClickedItem is Null.
|
||||
@@ -56,20 +55,20 @@ void Memory::MemoryListItemClick(_In_ Object^ sender, _In_ ItemClickEventArgs^ e
|
||||
}
|
||||
}
|
||||
|
||||
void Memory::OnContextRequested(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs^ e)
|
||||
void Memory::OnContextRequested(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs ^ e)
|
||||
{
|
||||
// Walk up the tree to find the ListViewItem.
|
||||
// There may not be one if the click wasn't on an item.
|
||||
auto requestedElement = safe_cast<FrameworkElement^>(e->OriginalSource);
|
||||
while ((requestedElement != sender) && !dynamic_cast<ListViewItem^>(requestedElement))
|
||||
auto requestedElement = safe_cast<FrameworkElement ^>(e->OriginalSource);
|
||||
while ((requestedElement != sender) && !dynamic_cast<ListViewItem ^>(requestedElement))
|
||||
{
|
||||
requestedElement = safe_cast<FrameworkElement^>(VisualTreeHelper::GetParent(requestedElement));
|
||||
requestedElement = safe_cast<FrameworkElement ^>(VisualTreeHelper::GetParent(requestedElement));
|
||||
}
|
||||
|
||||
if (requestedElement != sender)
|
||||
{
|
||||
// The context menu request was for a ListViewItem.
|
||||
auto memorySlot = safe_cast<MemoryItemViewModel^>(MemoryListView->ItemFromContainer(requestedElement));
|
||||
auto memorySlot = safe_cast<MemoryItemViewModel ^>(MemoryListView->ItemFromContainer(requestedElement));
|
||||
Point point;
|
||||
if (e->TryGetPosition(requestedElement, &point))
|
||||
{
|
||||
@@ -85,22 +84,22 @@ void Memory::OnContextRequested(Windows::UI::Xaml::UIElement^ sender, Windows::U
|
||||
}
|
||||
}
|
||||
|
||||
void Memory::OnContextCanceled(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
void Memory::OnContextCanceled(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
m_memoryItemFlyout->Hide();
|
||||
}
|
||||
|
||||
void Memory::OnClearMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void Memory::OnClearMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
GetMemoryItemForCurrentFlyout()->Clear();
|
||||
}
|
||||
|
||||
void Memory::OnMemoryAddMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void Memory::OnMemoryAddMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
GetMemoryItemForCurrentFlyout()->MemoryAdd();
|
||||
}
|
||||
|
||||
void Memory::OnMemorySubtractMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void Memory::OnMemorySubtractMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
GetMemoryItemForCurrentFlyout()->MemorySubtract();
|
||||
}
|
||||
@@ -115,14 +114,14 @@ void Memory::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
}
|
||||
}
|
||||
|
||||
MemoryItemViewModel^ Memory::GetMemoryItemForCurrentFlyout()
|
||||
MemoryItemViewModel ^ Memory::GetMemoryItemForCurrentFlyout()
|
||||
{
|
||||
auto listViewItem = m_memoryItemFlyout->Target;
|
||||
|
||||
return safe_cast<MemoryItemViewModel^>(MemoryListView->ItemFromContainer(listViewItem));
|
||||
return safe_cast<MemoryItemViewModel ^>(MemoryListView->ItemFromContainer(listViewItem));
|
||||
}
|
||||
|
@@ -15,8 +15,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class Memory sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class Memory sealed
|
||||
{
|
||||
public:
|
||||
Memory();
|
||||
@@ -30,25 +29,25 @@ namespace CalculatorApp
|
||||
DEPENDENCY_PROPERTY_OWNER(Memory);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::GridLength, RowHeight);
|
||||
|
||||
property bool IsErrorVisualState {
|
||||
property bool IsErrorVisualState
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::Controls::MenuFlyout^ m_memoryItemFlyout;
|
||||
Windows::UI::Xaml::Controls::MenuFlyout ^ m_memoryItemFlyout;
|
||||
Windows::Foundation::Rect m_visibleBounds;
|
||||
Windows::Foundation::Rect m_coreBounds;
|
||||
bool m_isErrorVisualState;
|
||||
|
||||
void MemoryListItemClick(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs^ e);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnClearMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnMemoryAddMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnMemorySubtractMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
|
||||
CalculatorApp::ViewModel::MemoryItemViewModel^ GetMemoryItemForCurrentFlyout();
|
||||
void MemoryListItemClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ e);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs ^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnClearMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnMemoryAddMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnMemorySubtractMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
CalculatorApp::ViewModel::MemoryItemViewModel ^ GetMemoryItemForCurrentFlyout();
|
||||
};
|
||||
}
|
||||
|
@@ -31,51 +31,51 @@ MemoryListItem::MemoryListItem()
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnPointerEntered(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
|
||||
void MemoryListItem::OnPointerEntered(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
Control::OnPointerEntered(e);
|
||||
|
||||
// Only show hover buttons when the user is using mouse or pen.
|
||||
if (e->Pointer->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse || e->Pointer->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Pen)
|
||||
if (e->Pointer->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse
|
||||
|| e->Pointer->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Pen)
|
||||
{
|
||||
VisualStateManager::GoToState(this, "MemoryButtonsVisible", true);
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryListItem::OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
|
||||
void MemoryListItem::OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
Control::OnPointerExited(e);
|
||||
|
||||
VisualStateManager::GoToState(this, "MemoryButtonsHidden", true);
|
||||
}
|
||||
|
||||
void MemoryListItem::OnClearButtonClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void MemoryListItem::OnClearButtonClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
Model->Clear();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnMemoryAddButtonClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void MemoryListItem::OnMemoryAddButtonClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
Model->MemoryAdd();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnMemorySubtractButtonClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void MemoryListItem::OnMemorySubtractButtonClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
Model->MemorySubtract();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnClearSwipeInvoked(_In_ SwipeItem^ sender, SwipeItemInvokedEventArgs^ e)
|
||||
void MemoryListItem::OnClearSwipeInvoked(_In_ SwipeItem ^ sender, SwipeItemInvokedEventArgs ^ e)
|
||||
{
|
||||
Model->Clear();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnMemoryAddSwipeInvoked(_In_ SwipeItem^ sender, SwipeItemInvokedEventArgs^ e)
|
||||
void MemoryListItem::OnMemoryAddSwipeInvoked(_In_ SwipeItem ^ sender, SwipeItemInvokedEventArgs ^ e)
|
||||
{
|
||||
Model->MemoryAdd();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnMemorySubtractSwipeInvoked(_In_ SwipeItem^ sender, SwipeItemInvokedEventArgs^ e)
|
||||
void MemoryListItem::OnMemorySubtractSwipeInvoked(_In_ SwipeItem ^ sender, SwipeItemInvokedEventArgs ^ e)
|
||||
{
|
||||
Model->MemorySubtract();
|
||||
}
|
||||
|
||||
|
@@ -11,26 +11,24 @@ namespace CalculatorApp
|
||||
/// <summary>
|
||||
/// Represents a single item in the Memory list.
|
||||
/// </summary>
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class MemoryListItem sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class MemoryListItem sealed
|
||||
{
|
||||
public:
|
||||
MemoryListItem();
|
||||
|
||||
DEPENDENCY_PROPERTY_OWNER(MemoryListItem);
|
||||
DEPENDENCY_PROPERTY(CalculatorApp::ViewModel::MemoryItemViewModel^, Model);
|
||||
DEPENDENCY_PROPERTY(CalculatorApp::ViewModel::MemoryItemViewModel ^, Model);
|
||||
|
||||
protected:
|
||||
void OnPointerEntered(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
|
||||
void OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
|
||||
void OnPointerEntered(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||
void OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||
|
||||
private:
|
||||
void OnClearButtonClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnMemoryAddButtonClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnMemorySubtractButtonClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnClearSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs^ e);
|
||||
void OnMemoryAddSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs^ e);
|
||||
void OnMemorySubtractSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs^ e);
|
||||
|
||||
void OnClearButtonClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnMemoryAddButtonClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnMemorySubtractButtonClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnClearSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem ^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs ^ e);
|
||||
void OnMemoryAddSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem ^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs ^ e);
|
||||
void OnMemorySubtractSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem ^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@@ -31,13 +31,12 @@ using namespace CalculatorApp::Common;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(NumberPad, ButtonStyle);
|
||||
|
||||
NumberPad::NumberPad() :
|
||||
m_isErrorVisualState(false)
|
||||
NumberPad::NumberPad() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
const auto& localizationSettings = LocalizationSettings::GetInstance();
|
||||
|
||||
|
||||
this->DecimalSeparatorButton->Content = localizationSettings.GetDecimalSeparator();
|
||||
this->Num0Button->Content = localizationSettings.GetDigitSymbolFromEnUsDigit('0');
|
||||
this->Num1Button->Content = localizationSettings.GetDigitSymbolFromEnUsDigit('1');
|
||||
@@ -64,7 +63,7 @@ void NumberPad::ProgModeRadixChange()
|
||||
Num8Button->IsEnabled = true;
|
||||
Num9Button->IsEnabled = true;
|
||||
|
||||
auto vm = safe_cast<StandardCalculatorViewModel^>(this->DataContext);
|
||||
auto vm = safe_cast<StandardCalculatorViewModel ^>(this->DataContext);
|
||||
RADIX_TYPE radixType = vm->GetCurrentRadixType();
|
||||
|
||||
if (radixType == RADIX_TYPE::BIN_RADIX)
|
||||
@@ -95,7 +94,7 @@ void NumberPad::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
}
|
||||
}
|
||||
|
@@ -13,14 +13,13 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class NumberPad sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class NumberPad sealed
|
||||
{
|
||||
public:
|
||||
NumberPad();
|
||||
DEPENDENCY_PROPERTY_OWNER(NumberPad);
|
||||
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Style^, ButtonStyle);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Style ^, ButtonStyle);
|
||||
|
||||
property bool IsErrorVisualState
|
||||
{
|
||||
|
@@ -28,8 +28,9 @@ OperatorsPanel::OperatorsPanel()
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
StandardCalculatorViewModel^ OperatorsPanel::Model::get() {
|
||||
return static_cast<CalculatorApp::ViewModel::StandardCalculatorViewModel^>(this->DataContext);
|
||||
StandardCalculatorViewModel ^ OperatorsPanel::Model::get()
|
||||
{
|
||||
return static_cast<CalculatorApp::ViewModel::StandardCalculatorViewModel ^>(this->DataContext);
|
||||
}
|
||||
|
||||
void OperatorsPanel::OnIsBitFlipCheckedPropertyChanged(bool /*oldValue*/, bool newValue)
|
||||
|
@@ -11,17 +11,14 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class OperatorsPanel sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class OperatorsPanel sealed
|
||||
{
|
||||
public:
|
||||
OperatorsPanel();
|
||||
property CalculatorApp::ViewModel::StandardCalculatorViewModel^ Model
|
||||
{
|
||||
CalculatorApp::ViewModel::StandardCalculatorViewModel^ get();
|
||||
}
|
||||
property CalculatorApp::ViewModel::StandardCalculatorViewModel
|
||||
^ Model { CalculatorApp::ViewModel::StandardCalculatorViewModel ^ get(); }
|
||||
|
||||
DEPENDENCY_PROPERTY_OWNER(OperatorsPanel);
|
||||
DEPENDENCY_PROPERTY_OWNER(OperatorsPanel);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsBitFlipChecked);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsErrorVisualState);
|
||||
|
||||
|
@@ -24,26 +24,28 @@ AspectRatioTrigger::~AspectRatioTrigger()
|
||||
UnregisterSizeChanged(Source);
|
||||
}
|
||||
|
||||
void AspectRatioTrigger::OnSourcePropertyChanged(FrameworkElement^ oldValue, FrameworkElement^ newValue)
|
||||
void AspectRatioTrigger::OnSourcePropertyChanged(FrameworkElement ^ oldValue, FrameworkElement ^ newValue)
|
||||
{
|
||||
UnregisterSizeChanged(oldValue);
|
||||
RegisterSizeChanged(newValue);
|
||||
}
|
||||
|
||||
void AspectRatioTrigger::RegisterSizeChanged(FrameworkElement^ element)
|
||||
void AspectRatioTrigger::RegisterSizeChanged(FrameworkElement ^ element)
|
||||
{
|
||||
if (element == nullptr) { return; }
|
||||
if (element == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (element != Source)
|
||||
{
|
||||
UnregisterSizeChanged(Source);
|
||||
}
|
||||
|
||||
m_sizeChangedToken =
|
||||
element->SizeChanged += ref new SizeChangedEventHandler(this, &AspectRatioTrigger::OnSizeChanged);
|
||||
m_sizeChangedToken = element->SizeChanged += ref new SizeChangedEventHandler(this, &AspectRatioTrigger::OnSizeChanged);
|
||||
}
|
||||
|
||||
void AspectRatioTrigger::UnregisterSizeChanged(FrameworkElement^ element)
|
||||
void AspectRatioTrigger::UnregisterSizeChanged(FrameworkElement ^ element)
|
||||
{
|
||||
if ((element != nullptr) && (m_sizeChangedToken.Value != 0))
|
||||
{
|
||||
@@ -52,7 +54,7 @@ void AspectRatioTrigger::UnregisterSizeChanged(FrameworkElement^ element)
|
||||
}
|
||||
}
|
||||
|
||||
void AspectRatioTrigger::OnSizeChanged(Object^ sender, SizeChangedEventArgs^ e)
|
||||
void AspectRatioTrigger::OnSizeChanged(Object ^ sender, SizeChangedEventArgs ^ e)
|
||||
{
|
||||
UpdateIsActive(e->NewSize);
|
||||
}
|
||||
|
@@ -13,13 +13,15 @@
|
||||
|
||||
namespace CalculatorApp::Views::StateTriggers
|
||||
{
|
||||
public enum class Aspect
|
||||
public
|
||||
enum class Aspect
|
||||
{
|
||||
Height,
|
||||
Width
|
||||
};
|
||||
|
||||
public ref class AspectRatioTrigger sealed : public Windows::UI::Xaml::StateTriggerBase
|
||||
public
|
||||
ref class AspectRatioTrigger sealed : public Windows::UI::Xaml::StateTriggerBase
|
||||
{
|
||||
public:
|
||||
AspectRatioTrigger();
|
||||
@@ -27,7 +29,7 @@ namespace CalculatorApp::Views::StateTriggers
|
||||
DEPENDENCY_PROPERTY_OWNER(AspectRatioTrigger);
|
||||
|
||||
/* The source for which this class will respond to size changed events. */
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(Windows::UI::Xaml::FrameworkElement^, Source);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(Windows::UI::Xaml::FrameworkElement ^, Source);
|
||||
|
||||
/* Either Height or Width. The property will determine which aspect is used as the numerator when calculating
|
||||
the aspect ratio. */
|
||||
@@ -42,11 +44,11 @@ namespace CalculatorApp::Views::StateTriggers
|
||||
private:
|
||||
~AspectRatioTrigger();
|
||||
|
||||
void OnSourcePropertyChanged(Windows::UI::Xaml::FrameworkElement^ oldValue, Windows::UI::Xaml::FrameworkElement^ newValue);
|
||||
void OnSourcePropertyChanged(Windows::UI::Xaml::FrameworkElement ^ oldValue, Windows::UI::Xaml::FrameworkElement ^ newValue);
|
||||
|
||||
void RegisterSizeChanged(Windows::UI::Xaml::FrameworkElement^ element);
|
||||
void UnregisterSizeChanged(Windows::UI::Xaml::FrameworkElement^ element);
|
||||
void OnSizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);
|
||||
void RegisterSizeChanged(Windows::UI::Xaml::FrameworkElement ^ element);
|
||||
void UnregisterSizeChanged(Windows::UI::Xaml::FrameworkElement ^ element);
|
||||
void OnSizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
|
||||
|
||||
void UpdateIsActive(Windows::Foundation::Size sourceSize);
|
||||
|
||||
|
@@ -29,9 +29,9 @@ using namespace Windows::UI::Xaml::Navigation;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(SupplementaryResults, Results);
|
||||
|
||||
Object^ DelighterUnitToStyleConverter::Convert(Object^ value, TypeName /*targetType*/, Object^ /*parameter*/, String^ /*language*/)
|
||||
Object ^ DelighterUnitToStyleConverter::Convert(Object ^ value, TypeName /*targetType*/, Object ^ /*parameter*/, String ^ /*language*/)
|
||||
{
|
||||
Unit^ unit = safe_cast<Unit^>(value);
|
||||
Unit ^ unit = safe_cast<Unit ^>(value);
|
||||
|
||||
assert(unit->GetModelUnit().isWhimsical);
|
||||
if (!unit->GetModelUnit().isWhimsical)
|
||||
@@ -41,19 +41,19 @@ Object^ DelighterUnitToStyleConverter::Convert(Object^ value, TypeName /*targetT
|
||||
|
||||
std::wstring key = L"Unit_";
|
||||
key.append(std::to_wstring(unit->GetModelUnit().id));
|
||||
return safe_cast<IStyle^>(m_delighters->Lookup(ref new String(key.c_str())));
|
||||
return safe_cast<IStyle ^>(m_delighters->Lookup(ref new String(key.c_str())));
|
||||
}
|
||||
|
||||
Object^ DelighterUnitToStyleConverter::ConvertBack(Object^ /*value*/, TypeName /*targetType*/, Object^ /*parameter*/, String^ /*language*/)
|
||||
Object ^ DelighterUnitToStyleConverter::ConvertBack(Object ^ /*value*/, TypeName /*targetType*/, Object ^ /*parameter*/, String ^ /*language*/)
|
||||
{
|
||||
// We never use convert back, only one way binding supported
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::DataTemplate^ SupplementaryResultDataTemplateSelector::SelectTemplateCore(Object^ item, DependencyObject^ /*container*/)
|
||||
Windows::UI::Xaml::DataTemplate ^ SupplementaryResultDataTemplateSelector::SelectTemplateCore(Object ^ item, DependencyObject ^ /*container*/)
|
||||
{
|
||||
SupplementaryResult^ result = safe_cast<SupplementaryResult^>(item);
|
||||
SupplementaryResult ^ result = safe_cast<SupplementaryResult ^>(item);
|
||||
if (result->IsWhimsical())
|
||||
{
|
||||
return DelighterTemplate;
|
||||
@@ -75,11 +75,11 @@ bool SupplementaryResultNoOverflowStackPanel::ShouldPrioritizeLastItem()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto lastChild = dynamic_cast<FrameworkElement^>(Children->GetAt(Children->Size - 1));
|
||||
auto lastChild = dynamic_cast<FrameworkElement ^>(Children->GetAt(Children->Size - 1));
|
||||
if (lastChild == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto suppResult = dynamic_cast<SupplementaryResult^>(lastChild->DataContext);
|
||||
return suppResult == nullptr? false: suppResult->IsWhimsical();
|
||||
auto suppResult = dynamic_cast<SupplementaryResult ^>(lastChild->DataContext);
|
||||
return suppResult == nullptr ? false : suppResult->IsWhimsical();
|
||||
}
|
||||
|
@@ -15,7 +15,8 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
public ref class DelighterUnitToStyleConverter sealed : public Windows::UI::Xaml::Data::IValueConverter
|
||||
public
|
||||
ref class DelighterUnitToStyleConverter sealed : public Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
public:
|
||||
DelighterUnitToStyleConverter()
|
||||
@@ -24,18 +25,24 @@ namespace CalculatorApp
|
||||
m_delighters->Source = ref new Windows::Foundation::Uri(L"ms-appx:///Views/DelighterUnitStyles.xaml");
|
||||
}
|
||||
|
||||
internal:
|
||||
virtual Platform::Object^ Convert(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language) = Windows::UI::Xaml::Data::IValueConverter::Convert;
|
||||
virtual Platform::Object^ ConvertBack(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack;
|
||||
internal : virtual Platform::Object
|
||||
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter,
|
||||
Platform::String ^ language) = Windows::UI::Xaml::Data::IValueConverter::Convert;
|
||||
virtual Platform::Object
|
||||
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter,
|
||||
Platform::String ^ language) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack;
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::ResourceDictionary^ m_delighters;
|
||||
Windows::UI::Xaml::ResourceDictionary ^ m_delighters;
|
||||
};
|
||||
|
||||
public ref class SupplementaryResultDataTemplateSelector sealed : public Windows::UI::Xaml::Controls::DataTemplateSelector
|
||||
public
|
||||
ref class SupplementaryResultDataTemplateSelector sealed : public Windows::UI::Xaml::Controls::DataTemplateSelector
|
||||
{
|
||||
public:
|
||||
SupplementaryResultDataTemplateSelector() {}
|
||||
SupplementaryResultDataTemplateSelector()
|
||||
{
|
||||
}
|
||||
|
||||
property Windows::UI::Xaml::DataTemplate^ RegularTemplate
|
||||
{
|
||||
@@ -53,22 +60,22 @@ namespace CalculatorApp
|
||||
virtual Windows::UI::Xaml::DataTemplate^ SelectTemplateCore(Platform::Object^ item, Windows::UI::Xaml::DependencyObject^ container) override;
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::DataTemplate^ m_regularTemplate;
|
||||
Windows::UI::Xaml::DataTemplate^ m_delighterTemplate;
|
||||
Windows::UI::Xaml::DataTemplate ^ m_regularTemplate;
|
||||
Windows::UI::Xaml::DataTemplate ^ m_delighterTemplate;
|
||||
};
|
||||
|
||||
public ref class SupplementaryResultNoOverflowStackPanel sealed: public CalculatorApp::Controls::HorizontalNoOverflowStackPanel
|
||||
public
|
||||
ref class SupplementaryResultNoOverflowStackPanel sealed : public CalculatorApp::Controls::HorizontalNoOverflowStackPanel
|
||||
{
|
||||
protected:
|
||||
virtual bool ShouldPrioritizeLastItem() override;
|
||||
};
|
||||
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class SupplementaryResults sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class SupplementaryResults sealed
|
||||
{
|
||||
public:
|
||||
SupplementaryResults();
|
||||
DEPENDENCY_PROPERTY_OWNER(SupplementaryResults);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT(Windows::Foundation::Collections::IIterable<ViewModel::SupplementaryResult^>^, Results, nullptr);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT(Windows::Foundation::Collections::IIterable<ViewModel::SupplementaryResult ^> ^, Results, nullptr);
|
||||
};
|
||||
}
|
||||
|
@@ -20,8 +20,7 @@ using namespace Windows::Foundation::Collections;
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
TitleBar::TitleBar() :
|
||||
m_coreTitleBar(CoreApplication::GetCurrentView()->TitleBar)
|
||||
TitleBar::TitleBar() : m_coreTitleBar(CoreApplication::GetCurrentView()->TitleBar)
|
||||
{
|
||||
m_uiSettings = ref new UISettings();
|
||||
m_accessibilitySettings = ref new AccessibilitySettings();
|
||||
@@ -33,24 +32,23 @@ namespace CalculatorApp
|
||||
AppName->Text = AppResourceProvider::GetInstance().GetResourceString(L"AppName");
|
||||
}
|
||||
|
||||
void TitleBar::OnLoaded(_In_ Object^ /*sender*/, _In_ RoutedEventArgs^ /*e*/)
|
||||
void TitleBar::OnLoaded(_In_ Object ^ /*sender*/, _In_ RoutedEventArgs ^ /*e*/)
|
||||
{
|
||||
//Register events
|
||||
m_visibilityChangedToken = m_coreTitleBar->IsVisibleChanged += ref new TypedEventHandler<CoreApplicationViewTitleBar^, Object^>([this](CoreApplicationViewTitleBar^ cTitleBar, Object^)
|
||||
{
|
||||
this->SetTitleBarVisibility();
|
||||
});
|
||||
m_layoutChangedToken = m_coreTitleBar->LayoutMetricsChanged += ref new TypedEventHandler<CoreApplicationViewTitleBar^, Object^>(
|
||||
[this](CoreApplicationViewTitleBar^ cTitleBar, Object^)
|
||||
{
|
||||
this->LayoutRoot->Height = cTitleBar->Height;
|
||||
this->SetTitleBarPadding();
|
||||
});
|
||||
// Register events
|
||||
m_visibilityChangedToken = m_coreTitleBar->IsVisibleChanged += ref new TypedEventHandler<CoreApplicationViewTitleBar ^, Object ^>(
|
||||
[this](CoreApplicationViewTitleBar ^ cTitleBar, Object ^) { this->SetTitleBarVisibility(); });
|
||||
m_layoutChangedToken = m_coreTitleBar->LayoutMetricsChanged +=
|
||||
ref new TypedEventHandler<CoreApplicationViewTitleBar ^, Object ^>([this](CoreApplicationViewTitleBar ^ cTitleBar, Object ^) {
|
||||
this->LayoutRoot->Height = cTitleBar->Height;
|
||||
this->SetTitleBarPadding();
|
||||
});
|
||||
|
||||
m_colorValuesChangedToken = m_uiSettings->ColorValuesChanged += ref new TypedEventHandler<UISettings^, Object^>(this, &TitleBar::ColorValuesChanged);
|
||||
m_accessibilitySettingsToken = m_accessibilitySettings->HighContrastChanged += ref new Windows::Foundation::TypedEventHandler<AccessibilitySettings ^, Object ^>(this, &CalculatorApp::TitleBar::OnHighContrastChanged);
|
||||
m_windowActivatedToken = Window::Current->Activated += ref new Windows::UI::Xaml::WindowActivatedEventHandler(this, &CalculatorApp::TitleBar::OnWindowActivated);
|
||||
//Set properties
|
||||
m_colorValuesChangedToken = m_uiSettings->ColorValuesChanged += ref new TypedEventHandler<UISettings ^, Object ^>(this, &TitleBar::ColorValuesChanged);
|
||||
m_accessibilitySettingsToken = m_accessibilitySettings->HighContrastChanged +=
|
||||
ref new Windows::Foundation::TypedEventHandler<AccessibilitySettings ^, Object ^>(this, &CalculatorApp::TitleBar::OnHighContrastChanged);
|
||||
m_windowActivatedToken = Window::Current->Activated +=
|
||||
ref new Windows::UI::Xaml::WindowActivatedEventHandler(this, &CalculatorApp::TitleBar::OnWindowActivated);
|
||||
// Set properties
|
||||
LayoutRoot->Height = m_coreTitleBar->Height;
|
||||
SetTitleBarControlColors();
|
||||
SetTitleBarExtendView();
|
||||
@@ -58,9 +56,9 @@ namespace CalculatorApp
|
||||
SetTitleBarPadding();
|
||||
}
|
||||
|
||||
void TitleBar::OnUnloaded(_In_ Object^ /*sender*/, _In_ RoutedEventArgs^ /*e*/)
|
||||
void TitleBar::OnUnloaded(_In_ Object ^ /*sender*/, _In_ RoutedEventArgs ^ /*e*/)
|
||||
{
|
||||
//Unregister events
|
||||
// Unregister events
|
||||
m_coreTitleBar->LayoutMetricsChanged -= m_layoutChangedToken;
|
||||
m_layoutChangedToken.Value = 0;
|
||||
m_coreTitleBar->IsVisibleChanged -= m_visibilityChangedToken;
|
||||
@@ -102,24 +100,28 @@ namespace CalculatorApp
|
||||
this->LayoutRoot->Padding = Thickness(leftAddition, 0, rightAddition, 0);
|
||||
}
|
||||
|
||||
void TitleBar::ColorValuesChanged(_In_ UISettings^ /*sender*/, _In_ Object^ /*e*/)
|
||||
void TitleBar::ColorValuesChanged(_In_ UISettings ^ /*sender*/, _In_ Object ^ /*e*/)
|
||||
{
|
||||
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() {
|
||||
SetTitleBarControlColors();
|
||||
}));
|
||||
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() { SetTitleBarControlColors(); }));
|
||||
}
|
||||
|
||||
void TitleBar::SetTitleBarControlColors()
|
||||
{
|
||||
auto applicationView = ApplicationView::GetForCurrentView();
|
||||
if (applicationView == nullptr) { return; }
|
||||
if (applicationView == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto applicationTitleBar = applicationView->TitleBar;
|
||||
if (applicationTitleBar == nullptr) { return; }
|
||||
if (applicationTitleBar == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_accessibilitySettings->HighContrast)
|
||||
{
|
||||
//Reset to use default colors.
|
||||
// Reset to use default colors.
|
||||
applicationTitleBar->ButtonBackgroundColor = nullptr;
|
||||
applicationTitleBar->ButtonForegroundColor = nullptr;
|
||||
applicationTitleBar->ButtonInactiveBackgroundColor = nullptr;
|
||||
@@ -132,12 +134,13 @@ namespace CalculatorApp
|
||||
else
|
||||
{
|
||||
Color bgColor = Colors::Transparent;
|
||||
Color fgColor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlPageTextBaseHighBrush"))->Color;
|
||||
Color inactivefgColor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlForegroundChromeDisabledLowBrush"))->Color;
|
||||
Color hoverbgColor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlBackgroundListLowBrush"))->Color;
|
||||
Color hoverfgColor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlForegroundBaseHighBrush"))->Color;
|
||||
Color pressedbgColor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlBackgroundListMediumBrush"))->Color;
|
||||
Color pressedfgCoolor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlForegroundBaseHighBrush"))->Color;
|
||||
Color fgColor = safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlPageTextBaseHighBrush"))->Color;
|
||||
Color inactivefgColor =
|
||||
safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlForegroundChromeDisabledLowBrush"))->Color;
|
||||
Color hoverbgColor = safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlBackgroundListLowBrush"))->Color;
|
||||
Color hoverfgColor = safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlForegroundBaseHighBrush"))->Color;
|
||||
Color pressedbgColor = safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlBackgroundListMediumBrush"))->Color;
|
||||
Color pressedfgCoolor = safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlForegroundBaseHighBrush"))->Color;
|
||||
applicationTitleBar->ButtonBackgroundColor = bgColor;
|
||||
applicationTitleBar->ButtonForegroundColor = fgColor;
|
||||
applicationTitleBar->ButtonInactiveBackgroundColor = bgColor;
|
||||
@@ -152,14 +155,15 @@ namespace CalculatorApp
|
||||
void TitleBar::OnHighContrastChanged(_In_ AccessibilitySettings ^ /*sender*/, _In_ Object ^ /*args*/)
|
||||
{
|
||||
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() {
|
||||
SetTitleBarControlColors();
|
||||
SetTitleBarExtendView();
|
||||
SetTitleBarVisibility();
|
||||
}));
|
||||
SetTitleBarControlColors();
|
||||
SetTitleBarExtendView();
|
||||
SetTitleBarVisibility();
|
||||
}));
|
||||
}
|
||||
|
||||
void TitleBar::OnWindowActivated(_In_ Object ^ /*sender*/, _In_ WindowActivatedEventArgs ^e)
|
||||
void TitleBar::OnWindowActivated(_In_ Object ^ /*sender*/, _In_ WindowActivatedEventArgs ^ e)
|
||||
{
|
||||
VisualStateManager::GoToState(this, e->WindowActivationState == CoreWindowActivationState::Deactivated ? WindowNotFocused->Name : WindowFocused->Name, false);
|
||||
VisualStateManager::GoToState(this, e->WindowActivationState == CoreWindowActivationState::Deactivated ? WindowNotFocused->Name : WindowFocused->Name,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
@@ -7,36 +7,37 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Standalone control managing the title bar of the application.
|
||||
/// Display a transparent custom title bar when high-contrast is off and the native title bar when on.
|
||||
/// Automatically react to color changes, tablet mode, etc...
|
||||
/// </summary>
|
||||
public ref class TitleBar sealed
|
||||
public
|
||||
ref class TitleBar sealed
|
||||
{
|
||||
public:
|
||||
TitleBar();
|
||||
private:
|
||||
void OnLoaded(_In_ Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnUnloaded(_In_ Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
|
||||
void SetTitleBarText(Platform::String^ text);
|
||||
private:
|
||||
void OnLoaded(_In_ Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnUnloaded(_In_ Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
void SetTitleBarText(Platform::String ^ text);
|
||||
void SetTitleBarVisibility();
|
||||
void SetTitleBarPadding();
|
||||
void SetTitleBarControlColors();
|
||||
void SetTitleBarExtendView();
|
||||
void ColorValuesChanged(_In_ Windows::UI::ViewManagement::UISettings^ sender, _In_ Platform::Object^ e);
|
||||
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^sender, Platform::Object ^args);
|
||||
void OnWindowActivated(Platform::Object ^sender, Windows::UI::Core::WindowActivatedEventArgs ^e);
|
||||
void ColorValuesChanged(_In_ Windows::UI::ViewManagement::UISettings ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^ sender, Platform::Object ^ args);
|
||||
void OnWindowActivated(Platform::Object ^ sender, Windows::UI::Core::WindowActivatedEventArgs ^ e);
|
||||
|
||||
Platform::Agile<Windows::ApplicationModel::Core::CoreApplicationViewTitleBar^> m_coreTitleBar;
|
||||
Platform::Agile<Windows::ApplicationModel::Core::CoreApplicationViewTitleBar ^> m_coreTitleBar;
|
||||
Windows::Foundation::EventRegistrationToken m_layoutChangedToken;
|
||||
Windows::Foundation::EventRegistrationToken m_visibilityChangedToken;
|
||||
Windows::Foundation::EventRegistrationToken m_colorValuesChangedToken;
|
||||
Windows::Foundation::EventRegistrationToken m_windowActivatedToken;
|
||||
Windows::Foundation::EventRegistrationToken m_accessibilitySettingsToken;
|
||||
Windows::UI::ViewManagement::UISettings^ m_uiSettings;
|
||||
Windows::UI::ViewManagement::AccessibilitySettings^ m_accessibilitySettings;
|
||||
Windows::UI::ViewManagement::UISettings ^ m_uiSettings;
|
||||
Windows::UI::ViewManagement::AccessibilitySettings ^ m_accessibilitySettings;
|
||||
};
|
||||
}
|
||||
|
@@ -45,9 +45,7 @@ using namespace Windows::UI::ViewManagement;
|
||||
// There are 10,000 intervals in 1 ms.
|
||||
static const long long DURATION_500_MS = 10000 * 500;
|
||||
|
||||
UnitConverter::UnitConverter() :
|
||||
m_meteredConnectionOverride(false),
|
||||
m_isAnimationEnabled(false)
|
||||
UnitConverter::UnitConverter() : m_meteredConnectionOverride(false), m_isAnimationEnabled(false)
|
||||
{
|
||||
m_layoutDirection = LocalizationService::GetInstance()->GetFlowDirection();
|
||||
m_FlowDirectionHorizontalAlignment = m_layoutDirection == ::FlowDirection::RightToLeft ? ::HorizontalAlignment::Right : ::HorizontalAlignment::Left;
|
||||
@@ -70,16 +68,15 @@ UnitConverter::UnitConverter() :
|
||||
|
||||
InitializeOfflineStatusTextBlock();
|
||||
|
||||
m_resultsFlyout = static_cast<MenuFlyout^>(Resources->Lookup(L"CalculationResultContextMenu"));
|
||||
m_resultsFlyout = static_cast<MenuFlyout ^>(Resources->Lookup(L"CalculationResultContextMenu"));
|
||||
CopyMenuItem->Text = resLoader.GetResourceString(L"copyMenuItem");
|
||||
PasteMenuItem->Text = resLoader.GetResourceString(L"pasteMenuItem");
|
||||
}
|
||||
|
||||
void UnitConverter::OnPropertyChanged(_In_ Object^ sender, _In_ PropertyChangedEventArgs^ e)
|
||||
void UnitConverter::OnPropertyChanged(_In_ Object ^ sender, _In_ PropertyChangedEventArgs ^ e)
|
||||
{
|
||||
String^ propertyName = e->PropertyName;
|
||||
if (propertyName == UnitConverterViewModel::NetworkBehaviorPropertyName ||
|
||||
propertyName == UnitConverterViewModel::CurrencyDataLoadFailedPropertyName)
|
||||
String ^ propertyName = e->PropertyName;
|
||||
if (propertyName == UnitConverterViewModel::NetworkBehaviorPropertyName || propertyName == UnitConverterViewModel::CurrencyDataLoadFailedPropertyName)
|
||||
{
|
||||
OnNetworkBehaviorChanged();
|
||||
}
|
||||
@@ -165,7 +162,7 @@ void UnitConverter::SetFailedToRefreshStatus()
|
||||
void UnitConverter::InitializeOfflineStatusTextBlock()
|
||||
{
|
||||
auto resProvider = AppResourceProvider::GetInstance();
|
||||
std::wstring offlineStatusHyperlinkText = static_cast<String^>(resProvider.GetResourceString(L"OfflineStatusHyperlinkText"))->Data();
|
||||
std::wstring offlineStatusHyperlinkText = static_cast<String ^>(resProvider.GetResourceString(L"OfflineStatusHyperlinkText"))->Data();
|
||||
|
||||
// The resource string has the 'NetworkSettings' hyperlink wrapped with '%HL%'.
|
||||
// Break the string and assign pieces appropriately.
|
||||
@@ -188,10 +185,7 @@ void UnitConverter::InitializeOfflineStatusTextBlock()
|
||||
OfflineRunLink->Text = offlineStatusTextLink;
|
||||
OfflineRunAfterLink->Text = offlineStatusTextAfterHyperlink;
|
||||
|
||||
AutomationProperties::SetName(OfflineBlock,
|
||||
offlineStatusTextBeforeHyperlink + L" " +
|
||||
offlineStatusTextLink + L" " +
|
||||
offlineStatusTextAfterHyperlink);
|
||||
AutomationProperties::SetName(OfflineBlock, offlineStatusTextBeforeHyperlink + L" " + offlineStatusTextLink + L" " + offlineStatusTextAfterHyperlink);
|
||||
}
|
||||
|
||||
void UnitConverter::SetCurrencyTimestampFontWeight()
|
||||
@@ -206,7 +200,7 @@ void UnitConverter::SetCurrencyTimestampFontWeight()
|
||||
}
|
||||
}
|
||||
|
||||
void UnitConverter::OnValueKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
|
||||
void UnitConverter::OnValueKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e)
|
||||
{
|
||||
if (e->Key == VirtualKey::Space)
|
||||
{
|
||||
@@ -214,10 +208,10 @@ void UnitConverter::OnValueKeyDown(Platform::Object^ sender, Windows::UI::Xaml::
|
||||
}
|
||||
}
|
||||
|
||||
void UnitConverter::OnContextRequested(UIElement^ sender, ContextRequestedEventArgs^ e)
|
||||
void UnitConverter::OnContextRequested(UIElement ^ sender, ContextRequestedEventArgs ^ e)
|
||||
{
|
||||
OnValueSelected(sender);
|
||||
auto requestedElement = safe_cast<FrameworkElement^>(sender);
|
||||
auto requestedElement = safe_cast<FrameworkElement ^>(sender);
|
||||
|
||||
PasteMenuItem->IsEnabled = CopyPasteManager::HasStringToPaste();
|
||||
|
||||
@@ -235,21 +229,20 @@ void UnitConverter::OnContextRequested(UIElement^ sender, ContextRequestedEventA
|
||||
e->Handled = true;
|
||||
}
|
||||
|
||||
void UnitConverter::OnContextCanceled(UIElement^ sender, RoutedEventArgs^ e)
|
||||
void UnitConverter::OnContextCanceled(UIElement ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
m_resultsFlyout->Hide();
|
||||
}
|
||||
|
||||
void UnitConverter::OnCopyMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void UnitConverter::OnCopyMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
auto calcResult = safe_cast<CalculationResult^>(m_resultsFlyout->Target);
|
||||
auto calcResult = safe_cast<CalculationResult ^>(m_resultsFlyout->Target);
|
||||
CopyPasteManager::CopyToClipboard(calcResult->GetRawDisplayValue());
|
||||
}
|
||||
|
||||
void UnitConverter::OnPasteMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void UnitConverter::OnPasteMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
CopyPasteManager::GetStringToPaste(Model->Mode, CategoryGroupType::Converter).then([this](String^ pastedString)
|
||||
{
|
||||
CopyPasteManager::GetStringToPaste(Model->Mode, CategoryGroupType::Converter).then([this](String ^ pastedString) {
|
||||
Model->OnPaste(pastedString, Model->Mode);
|
||||
});
|
||||
}
|
||||
@@ -262,34 +255,29 @@ void UnitConverter::AnimateConverter()
|
||||
}
|
||||
}
|
||||
|
||||
void UnitConverter::OnValueSelected(_In_ Platform::Object^ sender)
|
||||
void UnitConverter::OnValueSelected(_In_ Platform::Object ^ sender)
|
||||
{
|
||||
auto value = safe_cast<CalculationResult^>(sender);
|
||||
auto value = safe_cast<CalculationResult ^>(sender);
|
||||
// update the font size since the font is changed to bold
|
||||
value->UpdateTextState();
|
||||
safe_cast<UnitConverterViewModel^>(this->DataContext)->OnValueActivated(AsActivatable(value));
|
||||
safe_cast<UnitConverterViewModel ^>(this->DataContext)->OnValueActivated(AsActivatable(value));
|
||||
}
|
||||
|
||||
void UnitConverter::UpdateDropDownState(_In_ Platform::Object^ sender, _In_ Platform::Object^ e)
|
||||
void UnitConverter::UpdateDropDownState(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e)
|
||||
{
|
||||
safe_cast<UnitConverterViewModel^>(this->DataContext)->IsDropDownOpen = (Units1->IsDropDownOpen) || (Units2->IsDropDownOpen);
|
||||
safe_cast<UnitConverterViewModel ^>(this->DataContext)->IsDropDownOpen = (Units1->IsDropDownOpen) || (Units2->IsDropDownOpen);
|
||||
KeyboardShortcutManager::UpdateDropDownState((Units1->IsDropDownOpen) || (Units2->IsDropDownOpen));
|
||||
}
|
||||
|
||||
void UnitConverter::OnLoaded(_In_ Object^, _In_ RoutedEventArgs^)
|
||||
void UnitConverter::OnLoaded(_In_ Object ^, _In_ RoutedEventArgs ^)
|
||||
{
|
||||
}
|
||||
|
||||
void UnitConverter::SetDefaultFocus()
|
||||
{
|
||||
const std::vector<Control^> focusPrecedence = {
|
||||
Value1,
|
||||
CurrencyRefreshBlockControl,
|
||||
OfflineBlock,
|
||||
ClearEntryButtonPos0
|
||||
};
|
||||
const std::vector<Control ^> focusPrecedence = { Value1, CurrencyRefreshBlockControl, OfflineBlock, ClearEntryButtonPos0 };
|
||||
|
||||
for (Control^ control : focusPrecedence)
|
||||
for (Control ^ control : focusPrecedence)
|
||||
{
|
||||
if (control->Focus(::FocusState::Programmatic))
|
||||
{
|
||||
@@ -298,7 +286,7 @@ void UnitConverter::SetDefaultFocus()
|
||||
}
|
||||
}
|
||||
|
||||
void UnitConverter::CurrencyRefreshButton_Click(_In_ Object^ /*sender*/, _In_ RoutedEventArgs^ /*e*/)
|
||||
void UnitConverter::CurrencyRefreshButton_Click(_In_ Object ^ /*sender*/, _In_ RoutedEventArgs ^ /*e*/)
|
||||
{
|
||||
if (Model->NetworkBehavior == NetworkAccessBehavior::OptIn)
|
||||
{
|
||||
@@ -308,17 +296,16 @@ void UnitConverter::CurrencyRefreshButton_Click(_In_ Object^ /*sender*/, _In_ Ro
|
||||
Model->RefreshCurrencyRatios();
|
||||
}
|
||||
|
||||
void UnitConverter::OnDataContextChanged(_In_ FrameworkElement^ sender, _In_ DataContextChangedEventArgs^ args)
|
||||
void UnitConverter::OnDataContextChanged(_In_ FrameworkElement ^ sender, _In_ DataContextChangedEventArgs ^ args)
|
||||
{
|
||||
Model->PropertyChanged -= m_propertyChangedToken;
|
||||
|
||||
m_propertyChangedToken =
|
||||
Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &UnitConverter::OnPropertyChanged);
|
||||
m_propertyChangedToken = Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &UnitConverter::OnPropertyChanged);
|
||||
|
||||
OnNetworkBehaviorChanged();
|
||||
}
|
||||
|
||||
void UnitConverter::Units1_IsEnabledChanged(Object^ sender, DependencyPropertyChangedEventArgs^ e)
|
||||
void UnitConverter::Units1_IsEnabledChanged(Object ^ sender, DependencyPropertyChangedEventArgs ^ e)
|
||||
{
|
||||
if ((Units1->Visibility == ::Visibility::Visible) && Units1->IsEnabled)
|
||||
{
|
||||
@@ -352,12 +339,12 @@ void UnitConverter::StartProgressRingWithDelay()
|
||||
|
||||
m_delayTimer = ref new DispatcherTimer();
|
||||
m_delayTimer->Interval = delay;
|
||||
m_delayTimer->Tick += ref new EventHandler<Object^>(this, &UnitConverter::OnDelayTimerTick);
|
||||
m_delayTimer->Tick += ref new EventHandler<Object ^>(this, &UnitConverter::OnDelayTimerTick);
|
||||
|
||||
m_delayTimer->Start();
|
||||
}
|
||||
|
||||
void UnitConverter::OnDelayTimerTick(Object^ /*sender*/, Object^ /*e*/)
|
||||
void UnitConverter::OnDelayTimerTick(Object ^ /*sender*/, Object ^ /*e*/)
|
||||
{
|
||||
CurrencyLoadingProgressRing->IsActive = true;
|
||||
m_delayTimer->Stop();
|
||||
@@ -374,8 +361,8 @@ void UnitConverter::HideProgressRing()
|
||||
}
|
||||
|
||||
// The function will make sure the UI will have enough space to display supplementary results and currency information
|
||||
void CalculatorApp::UnitConverter::SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e)
|
||||
void CalculatorApp::UnitConverter::SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e)
|
||||
{
|
||||
//We add 0.01 to be sure to not create an infinite loop with SizeChanged events cascading due to float approximation
|
||||
// We add 0.01 to be sure to not create an infinite loop with SizeChanged events cascading due to float approximation
|
||||
RowDltrUnits->MinHeight = max(48.0, e->NewSize.Height + 0.01);
|
||||
}
|
||||
|
@@ -16,8 +16,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class UnitConverter sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class UnitConverter sealed
|
||||
{
|
||||
public:
|
||||
UnitConverter();
|
||||
@@ -44,20 +43,20 @@ namespace CalculatorApp
|
||||
void SetDefaultFocus();
|
||||
|
||||
private:
|
||||
void OnValueKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnPasteMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnValueSelected(_In_ Platform::Object^ sender);
|
||||
void UpdateDropDownState(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnLoaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void CurrencyRefreshButton_Click(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnValueKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs ^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnPasteMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnValueSelected(_In_ Platform::Object ^ sender);
|
||||
void UpdateDropDownState(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnLoaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void CurrencyRefreshButton_Click(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
void OnPropertyChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e);
|
||||
void OnDataContextChanged(_In_ Windows::UI::Xaml::FrameworkElement^ sender, _In_ Windows::UI::Xaml::DataContextChangedEventArgs^ args);
|
||||
void OnPropertyChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e);
|
||||
void OnDataContextChanged(_In_ Windows::UI::Xaml::FrameworkElement ^ sender, _In_ Windows::UI::Xaml::DataContextChangedEventArgs ^ args);
|
||||
void OnIsDisplayVisibleChanged();
|
||||
void Units1_IsEnabledChanged(Platform::Object^ sender, Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ e);
|
||||
void Units1_IsEnabledChanged(Platform::Object ^ sender, Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ e);
|
||||
|
||||
void OnNetworkBehaviorChanged();
|
||||
void OnNormalNetworkAccess();
|
||||
@@ -73,22 +72,22 @@ namespace CalculatorApp
|
||||
void SetCurrencyTimestampFontWeight();
|
||||
|
||||
void StartProgressRingWithDelay();
|
||||
void OnDelayTimerTick(Platform::Object^ sender, Platform::Object^ e);
|
||||
void OnDelayTimerTick(Platform::Object ^ sender, Platform::Object ^ e);
|
||||
void HideProgressRing();
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::FlowDirection m_layoutDirection;
|
||||
Windows::Foundation::EventRegistrationToken m_propertyChangedToken;
|
||||
Windows::UI::Xaml::Controls::MenuFlyout^ m_resultsFlyout;
|
||||
|
||||
Platform::String^ m_chargesMayApplyText;
|
||||
Platform::String^ m_failedToRefreshText;
|
||||
Windows::UI::Xaml::Controls::MenuFlyout ^ m_resultsFlyout;
|
||||
|
||||
Platform::String ^ m_chargesMayApplyText;
|
||||
Platform::String ^ m_failedToRefreshText;
|
||||
|
||||
bool m_meteredConnectionOverride;
|
||||
|
||||
Windows::UI::Xaml::DispatcherTimer^ m_delayTimer;
|
||||
Windows::UI::Xaml::DispatcherTimer ^ m_delayTimer;
|
||||
|
||||
bool m_isAnimationEnabled;
|
||||
void SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);
|
||||
void SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user