Modify how Calculator manages the visibility of the History button (#712)
* Modify how Calculator manages the History button + code cleaning * remove extra include
This commit is contained in:
parent
136ade6aa8
commit
e38e911bfa
@ -354,7 +354,6 @@
|
||||
<ClInclude Include="StandardCalculatorViewModel.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="UnitConverterViewModel.h" />
|
||||
<ClInclude Include="ViewState.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ApplicationViewModel.cpp" />
|
||||
@ -395,7 +394,6 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="StandardCalculatorViewModel.cpp" />
|
||||
<ClCompile Include="UnitConverterViewModel.cpp" />
|
||||
<ClCompile Include="ViewState.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CalcManager\CalcManager.vcxproj">
|
||||
|
@ -20,7 +20,6 @@
|
||||
<ClCompile Include="MemoryItemViewModel.cpp" />
|
||||
<ClCompile Include="StandardCalculatorViewModel.cpp" />
|
||||
<ClCompile Include="UnitConverterViewModel.cpp" />
|
||||
<ClCompile Include="ViewState.cpp" />
|
||||
<ClCompile Include="Common\AppResourceProvider.cpp">
|
||||
<Filter>Common</Filter>
|
||||
</ClCompile>
|
||||
@ -95,7 +94,6 @@
|
||||
<ClInclude Include="MemoryItemViewModel.h" />
|
||||
<ClInclude Include="StandardCalculatorViewModel.h" />
|
||||
<ClInclude Include="UnitConverterViewModel.h" />
|
||||
<ClInclude Include="ViewState.h" />
|
||||
<ClInclude Include="Common\AlwaysSelectedCollectionView.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
@ -205,4 +203,7 @@
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="$(MSBuildThisFileDirectory)DensityStyles\Compact.xaml" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -10,7 +10,6 @@
|
||||
#include "Common/AppResourceProvider.h"
|
||||
#include "Common/ExpressionCommandSerializer.h"
|
||||
#include "Common/ExpressionCommandDeserializer.h"
|
||||
#include "ViewState.h"
|
||||
|
||||
using namespace CalculatorApp;
|
||||
using namespace CalculatorApp::Common;
|
||||
|
@ -1,19 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "ViewState.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
namespace ViewState
|
||||
{
|
||||
Platform::StringReference Snap(L"Snap");
|
||||
Platform::StringReference DockedView(L"DockedView");
|
||||
|
||||
bool IsValidViewState(Platform::String ^ viewState)
|
||||
{
|
||||
return viewState->Equals(ViewState::Snap) || viewState->Equals(ViewState::DockedView);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
namespace ViewState
|
||||
{
|
||||
extern Platform::StringReference Snap;
|
||||
extern Platform::StringReference DockedView;
|
||||
|
||||
bool IsValidViewState(Platform::String ^ viewState);
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@
|
||||
#include "CalcViewModel/Common/Automation/NarratorNotifier.h"
|
||||
#include "CalcViewModel/Common/AppResourceProvider.h"
|
||||
#include "CalcViewModel/Common/LocalizationSettings.h"
|
||||
#include "CalcViewModel/ViewState.h"
|
||||
#include "Views/MainPage.xaml.h"
|
||||
|
||||
using namespace CalculatorApp;
|
||||
@ -94,26 +93,6 @@ bool App::IsAnimationEnabled()
|
||||
return App::m_isAnimationEnabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the current application view state. The value
|
||||
/// will match one of the constants in the ViewState namespace.
|
||||
/// </summary>
|
||||
String ^ App::GetAppViewState()
|
||||
{
|
||||
String ^ newViewState;
|
||||
CoreWindow ^ window = CoreWindow::GetForCurrentThread();
|
||||
if ((window->Bounds.Width >= 560) && (window->Bounds.Height >= 356))
|
||||
{
|
||||
newViewState = ViewState::DockedView;
|
||||
}
|
||||
else
|
||||
{
|
||||
newViewState = ViewState::Snap;
|
||||
}
|
||||
|
||||
return newViewState;
|
||||
}
|
||||
|
||||
void App::AddWindowToMap(_In_ WindowFrameService ^ frameService)
|
||||
{
|
||||
reader_writer_lock::scoped_lock lock(m_windowsMapLock);
|
||||
@ -468,10 +447,5 @@ void App::DismissedEventHandler(SplashScreen ^ sender, Object ^ e)
|
||||
SetupJumpList();
|
||||
}
|
||||
|
||||
float App::GetAppWindowHeight()
|
||||
{
|
||||
CoreWindow ^ window = CoreWindow::GetForCurrentThread();
|
||||
return window->Bounds.Height;
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,9 +29,8 @@ namespace CalculatorApp
|
||||
virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs ^ args) override;
|
||||
virtual void OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs ^ args) override;
|
||||
|
||||
internal : static bool IsAnimationEnabled();
|
||||
static Platform::String ^ GetAppViewState();
|
||||
static float GetAppWindowHeight();
|
||||
internal :
|
||||
static bool IsAnimationEnabled();
|
||||
void RemoveWindow(_In_ WindowFrameService ^ frameService);
|
||||
void RemoveSecondaryWindow(_In_ WindowFrameService ^ frameService);
|
||||
|
||||
|
@ -491,6 +491,7 @@
|
||||
<Setter Target="ColumnMain.Width" Value="320*"/>
|
||||
<Setter Target="ColumnHistory.Width" Value="240*"/>
|
||||
<Setter Target="DockPanel.Visibility" Value="Visible"/>
|
||||
<Setter Target="HistoryButton.Visibility" Value="Collapsed"/>
|
||||
<Setter Target="M6.Width" Value="0"/>
|
||||
</VisualState.Setters>
|
||||
<Storyboard Completed="OnLayoutVisualStateCompleted"/>
|
||||
@ -644,17 +645,17 @@
|
||||
<!-- Programmer display panel controls -->
|
||||
<local:CalculatorProgrammerOperators x:Name="ProgrammerOperators"
|
||||
Grid.Row="3"
|
||||
x:Load="False"
|
||||
IsEnabled="{x:Bind Model.IsProgrammer, Mode=OneWay}"
|
||||
TabIndex="6"
|
||||
Visibility="{x:Bind Model.IsProgrammer, Mode=OneWay}"/>
|
||||
Visibility="{x:Bind Model.IsProgrammer, Mode=OneWay}"
|
||||
IsEnabled="{x:Bind Model.IsProgrammer, Mode=OneWay}"
|
||||
x:Load="False"/>
|
||||
|
||||
<local:CalculatorProgrammerDisplayPanel x:Name="ProgrammerDisplayPanel"
|
||||
Grid.Row="4"
|
||||
x:Load="False"
|
||||
IsEnabled="{x:Bind Model.IsProgrammer, Mode=OneWay}"
|
||||
TabIndex="7"
|
||||
Visibility="{x:Bind Model.IsProgrammer, Mode=OneWay}"/>
|
||||
Visibility="{x:Bind Model.IsProgrammer, Mode=OneWay}"
|
||||
IsEnabled="{x:Bind Model.IsProgrammer, Mode=OneWay}"
|
||||
x:Load="False"/>
|
||||
|
||||
<Grid x:Name="HistoryButtonParent" Visibility="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanToVisibilityNegationConverter}, Mode=OneWay}">
|
||||
<Button x:Name="HistoryButton"
|
||||
@ -665,8 +666,8 @@
|
||||
Command="{x:Bind HistoryButtonPressed, Mode=OneTime}"
|
||||
Content=""
|
||||
ExitDisplayModeOnAccessKeyInvoked="False"
|
||||
IsEnabled="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}"
|
||||
TabIndex="2">
|
||||
TabIndex="2"
|
||||
IsEnabled="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}">
|
||||
<FlyoutBase.AttachedFlyout>
|
||||
<Flyout x:Name="HistoryFlyout"
|
||||
AutomationProperties.AutomationId="HistoryFlyout"
|
||||
@ -681,10 +682,10 @@
|
||||
<!-- Scientific angle buttons -->
|
||||
<local:CalculatorScientificAngleButtons x:Name="ScientificAngleButtons"
|
||||
Grid.Row="3"
|
||||
x:Load="False"
|
||||
IsEnabled="{x:Bind Model.IsScientific, Mode=OneWay}"
|
||||
TabIndex="6"
|
||||
Visibility="{x:Bind Model.IsScientific, Mode=OneWay}"/>
|
||||
Visibility="{x:Bind Model.IsScientific, Mode=OneWay}"
|
||||
IsEnabled="{x:Bind Model.IsScientific, Mode=OneWay}"
|
||||
x:Load="False"/>
|
||||
|
||||
<!-- Memory panel controls -->
|
||||
<Grid x:Name="MemoryPanel"
|
||||
@ -763,8 +764,8 @@
|
||||
Click="ToggleMemoryFlyout"
|
||||
Content="M0,9.46968e-006L1.96199,9.46968e-006L4.17099,5.59502C4.33899,6.02501 4.44899,6.34502 4.5,6.55602L4.52899,6.55602C4.67299,6.11501 4.791,5.78701 4.87999,5.57201L7.12999,9.46968e-006L9.023,9.46968e-006L9.023,8.402L7.64,8.402L7.64,2.96501C7.64,2.519 7.668,1.97401 7.722,1.33L7.69899,1.33C7.613,1.697 7.53699,1.96101 7.46999,2.12102L4.96199,8.402L4.002,8.402L1.48799,2.16801C1.418,1.98399 1.34299,1.705 1.265,1.33L1.24199,1.33C1.273,1.666 1.28899,2.21501 1.28899,2.976L1.28899,8.402L0,8.402zM10.5,0L15.5,0L12.99,2.5z"
|
||||
ExitDisplayModeOnAccessKeyInvoked="False"
|
||||
IsEnabled="{x:Bind Model.IsMemoryEmpty, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}"
|
||||
TabIndex="15">
|
||||
TabIndex="15"
|
||||
IsEnabled="{x:Bind Model.IsMemoryEmpty, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}">
|
||||
<FlyoutBase.AttachedFlyout>
|
||||
<Flyout x:Name="MemoryFlyout"
|
||||
x:Uid="MemoryFlyout"
|
||||
@ -1089,10 +1090,10 @@
|
||||
VerticalAlignment="Top"
|
||||
Background="Transparent"
|
||||
Opacity="0"
|
||||
IsEnabled="False"
|
||||
IsTabStop="False"
|
||||
Template="{StaticResource PreviousTemplate}"
|
||||
UseSystemFocusVisuals="False"/>
|
||||
UseSystemFocusVisuals="False"
|
||||
IsEnabled="False"/>
|
||||
<Button x:Name="NextButton"
|
||||
Grid.Column="1"
|
||||
Width="20"
|
||||
@ -1102,10 +1103,10 @@
|
||||
VerticalAlignment="Top"
|
||||
Background="Transparent"
|
||||
Opacity="0"
|
||||
IsEnabled="False"
|
||||
IsTabStop="False"
|
||||
Template="{StaticResource NextTemplate}"
|
||||
UseSystemFocusVisuals="False"/>
|
||||
UseSystemFocusVisuals="False"
|
||||
IsEnabled="False"/>
|
||||
<ContentPresenter x:Name="RightHeaderPresenter"
|
||||
Grid.Column="2"
|
||||
HorizontalAlignment="Stretch"
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "CalcViewModel/Common/TraceLogger.h"
|
||||
#include "CalcViewModel/Common/CopyPasteManager.h"
|
||||
#include "CalcViewModel/StandardCalculatorViewModel.h"
|
||||
#include "CalcViewModel/ViewState.h"
|
||||
#include "CalcViewModel/Common/LocalizationSettings.h"
|
||||
#include "Memory.xaml.h"
|
||||
#include "HistoryList.xaml.h"
|
||||
@ -393,13 +392,11 @@ void Calculator::UpdatePanelViewState()
|
||||
|
||||
void Calculator::UpdateHistoryState()
|
||||
{
|
||||
String ^ viewState = App::GetAppViewState();
|
||||
if (viewState == ViewState::DockedView)
|
||||
if (DockPanel->Visibility == ::Visibility::Visible)
|
||||
{
|
||||
// docked view
|
||||
CloseHistoryFlyout();
|
||||
SetChildAsHistory();
|
||||
HistoryButton->Visibility = ::Visibility::Collapsed;
|
||||
|
||||
if (!IsProgrammer && m_IsLastFlyoutHistory)
|
||||
{
|
||||
@ -407,7 +404,8 @@ void Calculator::UpdateHistoryState()
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // flyout view
|
||||
{
|
||||
// flyout view
|
||||
DockHistoryHolder->Child = nullptr;
|
||||
if (!IsProgrammer)
|
||||
{
|
||||
@ -431,8 +429,7 @@ void Calculator::UpdateMemoryState()
|
||||
ClearMemoryButton->IsEnabled = false;
|
||||
}
|
||||
|
||||
String ^ viewState = App::GetAppViewState();
|
||||
if (viewState == ViewState::DockedView)
|
||||
if (DockPanel->Visibility == ::Visibility::Visible)
|
||||
{
|
||||
CloseMemoryFlyout();
|
||||
SetChildAsMemory();
|
||||
@ -543,7 +540,7 @@ void Calculator::SetDefaultFocus()
|
||||
|
||||
void Calculator::ToggleHistoryFlyout(Object ^ /*parameter*/)
|
||||
{
|
||||
if (Model->IsProgrammer || App::GetAppViewState() == ViewState::DockedView)
|
||||
if (Model->IsProgrammer || DockPanel->Visibility == ::Visibility::Visible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -562,19 +559,20 @@ void Calculator::ToggleHistoryFlyout(Object ^ /*parameter*/)
|
||||
|
||||
void Calculator::ToggleMemoryFlyout()
|
||||
{
|
||||
String ^ viewState = App::GetAppViewState();
|
||||
if (viewState != ViewState::DockedView)
|
||||
if (DockPanel->Visibility == ::Visibility::Visible)
|
||||
{
|
||||
if (m_fIsMemoryFlyoutOpen)
|
||||
{
|
||||
MemoryFlyout->Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
MemoryFlyout->Content = GetMemory();
|
||||
m_memory->RowHeight = NumpadPanel->ActualHeight;
|
||||
FlyoutBase::ShowAttachedFlyout(MemoryButton);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_fIsMemoryFlyoutOpen)
|
||||
{
|
||||
MemoryFlyout->Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
MemoryFlyout->Content = GetMemory();
|
||||
m_memory->RowHeight = NumpadPanel->ActualHeight;
|
||||
FlyoutBase::ShowAttachedFlyout(MemoryButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user