mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-30 11:38:26 -07:00
Add dual-screen support to Calculator (#1027)
This commit is contained in:
parent
980b60f271
commit
15944fcd10
27 changed files with 2411 additions and 1279 deletions
|
@ -334,6 +334,7 @@
|
|||
<ClInclude Include="StandardCalculatorViewModel.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="UnitConverterViewModel.h" />
|
||||
<ClInclude Include="Utils\DeviceFamilyHelper.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ApplicationViewModel.cpp" />
|
||||
|
@ -374,6 +375,7 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="StandardCalculatorViewModel.cpp" />
|
||||
<ClCompile Include="UnitConverterViewModel.cpp" />
|
||||
<ClCompile Include="Utils\DeviceFamilyHelper.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CalcManager\CalcManager.vcxproj">
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
<Filter Include="GraphingCalculator">
|
||||
<UniqueIdentifier>{cf7dca32-9727-4f98-83c3-1c0ca7dd1e0c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Utils">
|
||||
<UniqueIdentifier>{68bb415f-fcb1-4759-b0a7-c5caf9d72396}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp" />
|
||||
|
@ -86,6 +89,9 @@
|
|||
<ClCompile Include="GraphingCalculator\GraphingSettingsViewModel.cpp">
|
||||
<Filter>GraphingCalculator</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Utils\DeviceFamilyHelper.cpp">
|
||||
<Filter>Utils</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
|
@ -199,6 +205,9 @@
|
|||
<ClInclude Include="Common\DelegateCommand.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Utils\DeviceFamilyHelper.h">
|
||||
<Filter>Utils</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="DataLoaders\DefaultFromToCurrency.json">
|
||||
|
|
54
src/CalcViewModel/Utils/DeviceFamilyHelper.cpp
Normal file
54
src/CalcViewModel/Utils/DeviceFamilyHelper.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "DeviceFamilyHelper.h"
|
||||
|
||||
using namespace CalculatorApp::ViewModel::Utils;
|
||||
using namespace Windows::System::Profile;
|
||||
|
||||
bool DeviceFamilyHelper::m_isInit{ false };
|
||||
DeviceFamily DeviceFamilyHelper::m_deviceFamily{ DeviceFamily::Unknown };
|
||||
|
||||
DeviceFamily DeviceFamilyHelper::GetDeviceFamily()
|
||||
{
|
||||
if (!m_isInit)
|
||||
{
|
||||
InitDeviceFamily();
|
||||
m_isInit = true;
|
||||
}
|
||||
return m_deviceFamily;
|
||||
}
|
||||
|
||||
void DeviceFamilyHelper::InitDeviceFamily()
|
||||
{
|
||||
auto deviceFamily = AnalyticsInfo::VersionInfo->DeviceFamily;
|
||||
if (deviceFamily == L"Windows.Desktop")
|
||||
{
|
||||
m_deviceFamily = DeviceFamily::Desktop;
|
||||
}
|
||||
else if (deviceFamily == L"Windows.Core")
|
||||
{
|
||||
m_deviceFamily = DeviceFamily::WindowsCore;
|
||||
}
|
||||
else if (deviceFamily == L"Windows.Xbox")
|
||||
{
|
||||
m_deviceFamily = DeviceFamily::Xbox;
|
||||
}
|
||||
else if (deviceFamily == L"Windows.Team")
|
||||
{
|
||||
m_deviceFamily = DeviceFamily::SurfaceHub;
|
||||
}
|
||||
else if (deviceFamily == L"Windows.Holographic")
|
||||
{
|
||||
m_deviceFamily = DeviceFamily::HoloLens;
|
||||
}
|
||||
else if (deviceFamily == L"Windows.Mobile")
|
||||
{
|
||||
m_deviceFamily = DeviceFamily::Mobile;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_deviceFamily = DeviceFamily::Unknown;
|
||||
}
|
||||
}
|
31
src/CalcViewModel/Utils/DeviceFamilyHelper.h
Normal file
31
src/CalcViewModel/Utils/DeviceFamilyHelper.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace CalculatorApp::ViewModel::Utils
|
||||
{
|
||||
public enum class DeviceFamily
|
||||
{
|
||||
Unknown,
|
||||
Desktop,
|
||||
Mobile,
|
||||
Xbox,
|
||||
SurfaceHub,
|
||||
HoloLens,
|
||||
WindowsCore,
|
||||
};
|
||||
|
||||
public ref class DeviceFamilyHelper sealed
|
||||
{
|
||||
private:
|
||||
DeviceFamilyHelper() {}
|
||||
public:
|
||||
static DeviceFamily GetDeviceFamily();
|
||||
private:
|
||||
static void InitDeviceFamily();
|
||||
private:
|
||||
static bool m_isInit;
|
||||
static DeviceFamily m_deviceFamily;
|
||||
};
|
||||
}
|
|
@ -3,6 +3,8 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Controls="using:CalculatorApp.Controls"
|
||||
xmlns:common="using:CalculatorApp.Common"
|
||||
xmlns:contract7NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,7)"
|
||||
xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)"
|
||||
xmlns:local="using:CalculatorApp">
|
||||
|
||||
<Application.Resources>
|
||||
|
@ -84,7 +86,7 @@
|
|||
<SolidColorBrush x:Key="EquationBrush12" Color="#FFF7630C"/>
|
||||
<SolidColorBrush x:Key="EquationBrush13" Color="#FF8E562E"/>
|
||||
<SolidColorBrush x:Key="EquationBrush14" Color="#FF000000"/>
|
||||
|
||||
<SolidColorBrush x:Key="DividerBrush" Color="#60FFFFFF"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<Thickness x:Key="HighContrastThicknessTop">0,0,0,0</Thickness>
|
||||
|
@ -163,6 +165,7 @@
|
|||
<SolidColorBrush x:Key="EquationBrush12" Color="#FFF7630C"/>
|
||||
<SolidColorBrush x:Key="EquationBrush13" Color="#FF8E562E"/>
|
||||
<SolidColorBrush x:Key="EquationBrush14" Color="#FF000000"/>
|
||||
<SolidColorBrush x:Key="DividerBrush" Color="#33000000"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="HighContrast">
|
||||
<Thickness x:Key="HighContrastThicknessTop">0,1,0,0</Thickness>
|
||||
|
@ -197,6 +200,7 @@
|
|||
<SolidColorBrush x:Key="EquationBrush2" Color="{ThemeResource SystemColorHighlightColor}"/>
|
||||
<SolidColorBrush x:Key="EquationBrush3" Color="{ThemeResource SystemColorHotlightColor}"/>
|
||||
<SolidColorBrush x:Key="EquationBrush4" Color="{ThemeResource SystemColorWindowTextColor}"/>
|
||||
<SolidColorBrush x:Key="DividerBrush" Color="Transparent"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
|
||||
|
@ -1764,6 +1768,125 @@
|
|||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Controls:TwoPaneViewCX">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="MinWideModeWidth" Value="641"/>
|
||||
<Setter Property="MinTallModeHeight" Value="641"/>
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Controls:TwoPaneViewCX">
|
||||
<Grid x:Name="RootGrid"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="{TemplateBinding Background}">
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="PART_ColumnLeft" Width="Auto"/>
|
||||
<ColumnDefinition x:Name="PART_ColumnMiddle" Width="0"/>
|
||||
<ColumnDefinition x:Name="PART_ColumnRight" Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition x:Name="PART_RowTop" Height="*"/>
|
||||
<RowDefinition x:Name="PART_RowMiddle" Height="0"/>
|
||||
<RowDefinition x:Name="PART_RowBottom" Height="0"/>
|
||||
</Grid.RowDefinitions>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="ModeStates">
|
||||
<VisualState x:Name="ViewMode_LeftRight"/>
|
||||
|
||||
<VisualState x:Name="ViewMode_RightLeft">
|
||||
<VisualState.Setters>
|
||||
<contract7NotPresent:Setter Target="PART_Pane1.(Grid.Column)" Value="2"/>
|
||||
<contract7NotPresent:Setter Target="PART_Pane2.(Grid.Column)" Value="0"/>
|
||||
|
||||
<contract7Present:Setter Target="PART_Pane1ScrollViewer.(Grid.Column)" Value="2"/>
|
||||
<contract7Present:Setter Target="PART_Pane2ScrollViewer.(Grid.Column)" Value="0"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
<VisualState x:Name="ViewMode_TopBottom">
|
||||
<VisualState.Setters>
|
||||
<contract7NotPresent:Setter Target="PART_Pane1.(Grid.Column)" Value="0"/>
|
||||
<contract7NotPresent:Setter Target="PART_Pane1.(Grid.Row)" Value="0"/>
|
||||
|
||||
<contract7NotPresent:Setter Target="PART_Pane2.(Grid.Column)" Value="0"/>
|
||||
<contract7NotPresent:Setter Target="PART_Pane2.(Grid.Row)" Value="2"/>
|
||||
|
||||
<contract7Present:Setter Target="PART_Pane1ScrollViewer.(Grid.Column)" Value="0"/>
|
||||
<contract7Present:Setter Target="PART_Pane1ScrollViewer.(Grid.Row)" Value="0"/>
|
||||
|
||||
<contract7Present:Setter Target="PART_Pane2ScrollViewer.(Grid.Column)" Value="0"/>
|
||||
<contract7Present:Setter Target="PART_Pane2ScrollViewer.(Grid.Row)" Value="2"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
<VisualState x:Name="ViewMode_BottomTop">
|
||||
<VisualState.Setters>
|
||||
<contract7NotPresent:Setter Target="PART_Pane1.(Grid.Column)" Value="0"/>
|
||||
<contract7NotPresent:Setter Target="PART_Pane1.(Grid.Row)" Value="2"/>
|
||||
|
||||
<contract7NotPresent:Setter Target="PART_Pane2.(Grid.Column)" Value="0"/>
|
||||
<contract7NotPresent:Setter Target="PART_Pane2.(Grid.Row)" Value="0"/>
|
||||
|
||||
<contract7Present:Setter Target="PART_Pane1ScrollViewer.(Grid.Column)" Value="0"/>
|
||||
<contract7Present:Setter Target="PART_Pane1ScrollViewer.(Grid.Row)" Value="2"/>
|
||||
|
||||
<contract7Present:Setter Target="PART_Pane2ScrollViewer.(Grid.Column)" Value="0"/>
|
||||
<contract7Present:Setter Target="PART_Pane2ScrollViewer.(Grid.Row)" Value="0"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
<VisualState x:Name="ViewMode_OneOnly">
|
||||
<VisualState.Setters>
|
||||
<contract7NotPresent:Setter Target="PART_Pane2.Visibility" Value="Collapsed"/>
|
||||
|
||||
<contract7Present:Setter Target="PART_Pane2ScrollViewer.Visibility" Value="Collapsed"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
<VisualState x:Name="ViewMode_TwoOnly">
|
||||
<VisualState.Setters>
|
||||
<contract7NotPresent:Setter Target="PART_Pane1.Visibility" Value="Collapsed"/>
|
||||
<contract7NotPresent:Setter Target="PART_Pane2.(Grid.Column)" Value="0"/>
|
||||
|
||||
<contract7Present:Setter Target="PART_Pane1ScrollViewer.Visibility" Value="Collapsed"/>
|
||||
<contract7Present:Setter Target="PART_Pane2ScrollViewer.(Grid.Column)" Value="0"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
|
||||
<contract7Present:ScrollViewer x:Name="PART_Pane1ScrollViewer"
|
||||
Grid.Column="0"
|
||||
IsTabStop="False"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<Border Child="{TemplateBinding Pane1}"/>
|
||||
</contract7Present:ScrollViewer>
|
||||
|
||||
<contract7Present:ScrollViewer x:Name="PART_Pane2ScrollViewer"
|
||||
Grid.Column="2"
|
||||
IsTabStop="False"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<Border Child="{TemplateBinding Pane2}"/>
|
||||
</contract7Present:ScrollViewer>
|
||||
|
||||
<contract7NotPresent:Border x:Name="PART_Pane1"
|
||||
Grid.Column="0"
|
||||
Child="{TemplateBinding Pane1}"/>
|
||||
|
||||
<contract7NotPresent:Border x:Name="PART_Pane2"
|
||||
Grid.Column="2"
|
||||
Child="{TemplateBinding Pane2}"/>
|
||||
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
|
|
|
@ -252,6 +252,7 @@
|
|||
</ClInclude>
|
||||
<ClInclude Include="Controls\RadixButton.h" />
|
||||
<ClInclude Include="Controls\SupplementaryItemsControl.h" />
|
||||
<ClInclude Include="Controls\TwoPaneViewCX.h" />
|
||||
<ClInclude Include="Converters\BooleanNegationConverter.h" />
|
||||
<ClInclude Include="Converters\BooleanToVisibilityConverter.h" />
|
||||
<ClInclude Include="Converters\ExpressionItemTemplateSelector.h" />
|
||||
|
@ -329,6 +330,7 @@
|
|||
<ClInclude Include="Views\OperatorsPanel.xaml.h">
|
||||
<DependentUpon>Views\OperatorsPanel.xaml</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Views\StateTriggers\ApplicationViewModeTrigger.h" />
|
||||
<ClInclude Include="Views\StateTriggers\AspectRatioTrigger.h" />
|
||||
<ClInclude Include="Views\StateTriggers\ControlSizeTrigger.h" />
|
||||
<ClInclude Include="Views\SupplementaryResults.xaml.h">
|
||||
|
@ -422,6 +424,7 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="Controls\RadixButton.cpp" />
|
||||
<ClCompile Include="Controls\SupplementaryItemsControl.cpp" />
|
||||
<ClCompile Include="Controls\TwoPaneViewCX.cpp" />
|
||||
<ClCompile Include="Converters\BooleanNegationConverter.cpp" />
|
||||
<ClCompile Include="Converters\BooleanToVisibilityConverter.cpp" />
|
||||
<ClCompile Include="Converters\ExpressionItemTemplateSelector.cpp" />
|
||||
|
@ -505,6 +508,7 @@
|
|||
<ClCompile Include="Views\OperatorsPanel.xaml.cpp">
|
||||
<DependentUpon>Views\OperatorsPanel.xaml</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Views\StateTriggers\ApplicationViewModeTrigger.cpp" />
|
||||
<ClCompile Include="Views\StateTriggers\AspectRatioTrigger.cpp" />
|
||||
<ClCompile Include="Views\StateTriggers\ControlSizeTrigger.cpp" />
|
||||
<ClCompile Include="Views\SupplementaryResults.xaml.cpp">
|
||||
|
@ -976,7 +980,7 @@
|
|||
</Target>
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets" Condition="Exists('..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets')" />
|
||||
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.2.190830001\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.2.190830001\build\native\Microsoft.UI.Xaml.targets')" />
|
||||
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.3.200213001\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.3.200213001\build\native\Microsoft.UI.Xaml.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
|
@ -984,6 +988,6 @@
|
|||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.props'))" />
|
||||
<Error Condition="!Exists('..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets'))" />
|
||||
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.2.190830001\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.2.190830001\build\native\Microsoft.UI.Xaml.targets'))" />
|
||||
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.3.200213001\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.3.200213001\build\native\Microsoft.UI.Xaml.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
@ -329,6 +329,12 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="Common\ViewState.cpp" />
|
||||
<ClCompile Include="Utils\DispatcherTimerDelayer.cpp" />
|
||||
<ClCompile Include="Controls\TwoPaneViewCX.cpp">
|
||||
<Filter>Controls</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Views\StateTriggers\ApplicationViewModeTrigger.cpp">
|
||||
<Filter>Views\StateTriggers</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
|
@ -437,6 +443,12 @@
|
|||
</ClInclude>
|
||||
<ClInclude Include="Common\ViewState.h" />
|
||||
<ClInclude Include="Utils\DispatcherTimerDelayer.h" />
|
||||
<ClInclude Include="Controls\TwoPaneViewCX.h">
|
||||
<Filter>Controls</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Views\StateTriggers\ApplicationViewModeTrigger.h">
|
||||
<Filter>Views\StateTriggers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest" />
|
||||
|
@ -522,7 +534,6 @@
|
|||
<Page Include="Views\GraphingCalculator\GraphingNumPad.xaml">
|
||||
<Filter>Views\GraphingCalculator</Filter>
|
||||
</Page>
|
||||
<Page Include="$(MSBuildThisFileDirectory)DensityStyles\Compact.xaml" />
|
||||
<Page Include="Controls\PreviewTagControl.xaml" />
|
||||
<Page Include="EquationStylePanelControl.xaml" />
|
||||
</ItemGroup>
|
||||
|
|
487
src/Calculator/Controls/TwoPaneViewCX.cpp
Normal file
487
src/Calculator/Controls/TwoPaneViewCX.cpp
Normal file
|
@ -0,0 +1,487 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See LICENSE in the project root for license information.
|
||||
|
||||
#include "pch.h"
|
||||
#include "TwoPaneViewCX.h"
|
||||
#include "Utils/VisualTree.h"
|
||||
#include <math.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Platform;
|
||||
using namespace CalculatorApp::Controls;
|
||||
using namespace Calculator::Utils;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::UI::ViewManagement;
|
||||
using namespace Windows::UI::Xaml;
|
||||
using namespace Windows::UI::Xaml::Controls;
|
||||
using Windows::Foundation::Metadata::ApiInformation;
|
||||
namespace MUXC = Microsoft::UI::Xaml::Controls;
|
||||
|
||||
StringReference c_pane1ScrollViewerName(L"PART_Pane1ScrollViewer");
|
||||
StringReference c_pane2ScrollViewerName(L"PART_Pane2ScrollViewer");
|
||||
StringReference c_columnLeftName(L"PART_ColumnLeft");
|
||||
StringReference c_columnMiddleName(L"PART_ColumnMiddle");
|
||||
StringReference c_columnRightName(L"PART_ColumnRight");
|
||||
StringReference c_rowTopName(L"PART_RowTop");
|
||||
StringReference c_rowMiddleName(L"PART_RowMiddle");
|
||||
StringReference c_rowBottomName(L"PART_RowBottom");
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, Pane1);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, Pane2);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, Pane1Length);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, Pane2Length);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, Pane1MinLength);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, Pane2MinLength);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, Pane1MaxLength);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, Pane2MaxLength);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, PanePriority);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, Mode);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, WideModeConfiguration);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, TallModeConfiguration);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, MinWideModeWidth);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(TwoPaneViewCX, MinTallModeHeight);
|
||||
|
||||
TwoPaneViewCX::TwoPaneViewCX()
|
||||
{
|
||||
this->DefaultStyleKey = L"CalculatorApp.Controls.TwoPaneViewCX";
|
||||
this->SizeChanged += ref new Windows::UI::Xaml::SizeChangedEventHandler(this, &TwoPaneViewCX::OnSizeChanged);
|
||||
m_windowSizeChangedToken = Window::Current->SizeChanged +=
|
||||
ref new Windows::UI::Xaml::WindowSizeChangedEventHandler(this, &TwoPaneViewCX::OnWindowSizeChanged);
|
||||
}
|
||||
|
||||
TwoPaneViewCX::~TwoPaneViewCX()
|
||||
{
|
||||
Window::Current->SizeChanged -= m_windowSizeChangedToken;
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnApplyTemplate()
|
||||
{
|
||||
m_loaded = true;
|
||||
this->SetScrollViewerProperties(c_pane1ScrollViewerName);
|
||||
this->SetScrollViewerProperties(c_pane2ScrollViewerName);
|
||||
|
||||
if (auto column = dynamic_cast<ColumnDefinition ^>(this->GetTemplateChild(c_columnLeftName)))
|
||||
{
|
||||
m_columnLeft = column;
|
||||
}
|
||||
if (auto column = dynamic_cast<ColumnDefinition ^>(this->GetTemplateChild(c_columnMiddleName)))
|
||||
{
|
||||
m_columnMiddle = column;
|
||||
}
|
||||
if (auto column = dynamic_cast<ColumnDefinition ^>(this->GetTemplateChild(c_columnRightName)))
|
||||
{
|
||||
m_columnRight = column;
|
||||
}
|
||||
if (auto row = dynamic_cast<RowDefinition ^>(this->GetTemplateChild(c_rowTopName)))
|
||||
{
|
||||
m_rowTop = row;
|
||||
}
|
||||
if (auto row = dynamic_cast<RowDefinition ^>(this->GetTemplateChild(c_rowMiddleName)))
|
||||
{
|
||||
m_rowMiddle = row;
|
||||
}
|
||||
if (auto row = dynamic_cast<RowDefinition ^>(this->GetTemplateChild(c_rowBottomName)))
|
||||
{
|
||||
m_rowBottom = row;
|
||||
}
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::UpdateMode()
|
||||
{
|
||||
// Don't bother running this logic until after we hit OnApplyTemplate.
|
||||
if (!m_loaded)
|
||||
return;
|
||||
|
||||
double controlWidth = this->ActualWidth;
|
||||
double controlHeight = this->ActualHeight;
|
||||
|
||||
ViewMode newMode = (this->PanePriority == MUXC::TwoPaneViewPriority::Pane1) ? ViewMode::Pane1Only : ViewMode::Pane2Only;
|
||||
|
||||
// Calculate new mode
|
||||
Rect rcControl = GetControlRect();
|
||||
auto info = this->GetDisplayRegionHelperInfo();
|
||||
bool isInMultipleRegions = IsInMultipleRegions(info, rcControl);
|
||||
|
||||
if (isInMultipleRegions)
|
||||
{
|
||||
if (info.Mode == MUXC::TwoPaneViewMode::Wide)
|
||||
{
|
||||
// Regions are laid out horizontally
|
||||
if (this->WideModeConfiguration != MUXC::TwoPaneViewWideModeConfiguration::SinglePane)
|
||||
{
|
||||
newMode = (this->WideModeConfiguration == MUXC::TwoPaneViewWideModeConfiguration::LeftRight) ? ViewMode::LeftRight : ViewMode::RightLeft;
|
||||
}
|
||||
}
|
||||
else if (info.Mode == MUXC::TwoPaneViewMode::Tall)
|
||||
{
|
||||
// Regions are laid out vertically
|
||||
if (this->TallModeConfiguration != MUXC::TwoPaneViewTallModeConfiguration::SinglePane)
|
||||
{
|
||||
newMode = (this->TallModeConfiguration == MUXC::TwoPaneViewTallModeConfiguration::TopBottom) ? ViewMode::TopBottom : ViewMode::BottomTop;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// One region
|
||||
if (controlWidth > this->MinWideModeWidth && this->WideModeConfiguration != MUXC::TwoPaneViewWideModeConfiguration::SinglePane)
|
||||
{
|
||||
// Split horizontally
|
||||
newMode = (this->WideModeConfiguration == MUXC::TwoPaneViewWideModeConfiguration::LeftRight) ? ViewMode::LeftRight : ViewMode::RightLeft;
|
||||
}
|
||||
else if (controlHeight > this->MinTallModeHeight && this->TallModeConfiguration != MUXC::TwoPaneViewTallModeConfiguration::SinglePane)
|
||||
{
|
||||
// Split vertically
|
||||
newMode = (this->TallModeConfiguration == MUXC::TwoPaneViewTallModeConfiguration::TopBottom) ? ViewMode::TopBottom : ViewMode::BottomTop;
|
||||
}
|
||||
}
|
||||
|
||||
// Update row/column sizes (this may need to happen even if the mode doesn't change)
|
||||
UpdateRowsColumns(newMode, info, rcControl);
|
||||
|
||||
// Update mode if necessary
|
||||
if (newMode != m_currentMode)
|
||||
{
|
||||
m_currentMode = newMode;
|
||||
|
||||
auto newViewMode = MUXC::TwoPaneViewMode::SinglePane;
|
||||
|
||||
switch (m_currentMode)
|
||||
{
|
||||
case ViewMode::Pane1Only:
|
||||
VisualStateManager::GoToState(this, L"ViewMode_OneOnly", true);
|
||||
break;
|
||||
case ViewMode::Pane2Only:
|
||||
VisualStateManager::GoToState(this, L"ViewMode_TwoOnly", true);
|
||||
break;
|
||||
case ViewMode::LeftRight:
|
||||
VisualStateManager::GoToState(this, L"ViewMode_LeftRight", true);
|
||||
newViewMode = MUXC::TwoPaneViewMode::Wide;
|
||||
break;
|
||||
case ViewMode::RightLeft:
|
||||
VisualStateManager::GoToState(this, L"ViewMode_RightLeft", true);
|
||||
newViewMode = MUXC::TwoPaneViewMode::Wide;
|
||||
break;
|
||||
case ViewMode::TopBottom:
|
||||
VisualStateManager::GoToState(this, L"ViewMode_TopBottom", true);
|
||||
newViewMode = MUXC::TwoPaneViewMode::Tall;
|
||||
break;
|
||||
case ViewMode::BottomTop:
|
||||
VisualStateManager::GoToState(this, L"ViewMode_BottomTop", true);
|
||||
newViewMode = MUXC::TwoPaneViewMode::Tall;
|
||||
break;
|
||||
}
|
||||
|
||||
if (newViewMode != this->Mode)
|
||||
{
|
||||
SetValue(s_ModeProperty, newViewMode);
|
||||
this->ModeChanged(this, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::UpdateRowsColumns(ViewMode newMode, DisplayRegionHelperInfo info, Rect rcControl)
|
||||
{
|
||||
if (m_columnLeft && m_columnMiddle && m_columnRight && m_rowTop && m_rowMiddle && m_rowBottom)
|
||||
{
|
||||
// Reset split lengths
|
||||
this->m_columnMiddle->Width = GridLengthHelper::FromPixels(0);
|
||||
this->m_rowMiddle->Height = GridLengthHelper::FromPixels(0);
|
||||
|
||||
// Set columns lengths
|
||||
if (newMode == ViewMode::LeftRight || newMode == ViewMode::RightLeft)
|
||||
{
|
||||
if (newMode == ViewMode::LeftRight)
|
||||
{
|
||||
this->m_columnLeft->MinWidth = this->Pane1MinLength;
|
||||
this->m_columnLeft->MaxWidth = this->Pane1MaxLength;
|
||||
this->m_columnLeft->Width = this->Pane1Length;
|
||||
this->m_columnRight->MinWidth = this->Pane2MinLength;
|
||||
this->m_columnRight->MaxWidth = this->Pane2MaxLength;
|
||||
this->m_columnRight->Width = this->Pane2Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_columnLeft->MinWidth = this->Pane2MinLength;
|
||||
this->m_columnLeft->MaxWidth = this->Pane2MaxLength;
|
||||
this->m_columnLeft->Width = this->Pane2Length;
|
||||
this->m_columnRight->MinWidth = this->Pane1MinLength;
|
||||
this->m_columnRight->MaxWidth = this->Pane1MaxLength;
|
||||
this->m_columnRight->Width = this->Pane1Length;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_columnLeft->MinWidth = 0.0;
|
||||
this->m_columnRight->MinWidth = 0.0;
|
||||
this->m_columnLeft->MaxWidth = std::numeric_limits<double>::max();
|
||||
this->m_columnRight->MaxWidth = std::numeric_limits<double>::max();
|
||||
this->m_columnLeft->Width = GridLengthHelper::FromValueAndType(1, GridUnitType::Star);
|
||||
this->m_columnRight->Width = GridLengthHelper::FromPixels(0);
|
||||
}
|
||||
|
||||
// Set row lengths
|
||||
if (newMode == ViewMode::TopBottom || newMode == ViewMode::BottomTop)
|
||||
{
|
||||
if (newMode == ViewMode::TopBottom)
|
||||
{
|
||||
this->m_rowTop->MinHeight = this->Pane1MinLength;
|
||||
this->m_rowTop->MaxHeight = this->Pane1MaxLength;
|
||||
this->m_rowTop->Height = this->Pane1Length;
|
||||
this->m_rowBottom->MinHeight = this->Pane2MinLength;
|
||||
this->m_rowBottom->MaxHeight = this->Pane2MaxLength;
|
||||
this->m_rowBottom->Height = this->Pane2Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_rowTop->MinHeight = this->Pane2MinLength;
|
||||
this->m_rowTop->MaxHeight = this->Pane2MaxLength;
|
||||
this->m_rowTop->Height = this->Pane2Length;
|
||||
this->m_rowBottom->MinHeight = this->Pane1MinLength;
|
||||
this->m_rowBottom->MaxHeight = this->Pane1MaxLength;
|
||||
this->m_rowBottom->Height = this->Pane1Length;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_rowTop->MinHeight = 0.0;
|
||||
this->m_rowBottom->MinHeight = 0.0;
|
||||
this->m_rowTop->MaxHeight = std::numeric_limits<double>::max();
|
||||
this->m_rowBottom->MaxHeight = std::numeric_limits<double>::max();
|
||||
this->m_rowTop->Height = GridLengthHelper::FromValueAndType(1, GridUnitType::Star);
|
||||
this->m_rowBottom->Height = GridLengthHelper::FromPixels(0);
|
||||
}
|
||||
|
||||
// Handle regions
|
||||
if (IsInMultipleRegions(info, rcControl) && newMode != ViewMode::Pane1Only && newMode != ViewMode::Pane2Only)
|
||||
{
|
||||
Rect rc1 = info.Regions[0];
|
||||
Rect rc2 = info.Regions[1];
|
||||
Rect rcWindow = Window::Current->Bounds;
|
||||
|
||||
if (info.Mode == MUXC::TwoPaneViewMode::Wide)
|
||||
{
|
||||
this->m_columnMiddle->Width = GridLengthHelper::FromPixels(rc2.X - rc1.Width);
|
||||
|
||||
this->m_columnLeft->MinWidth = 0.0;
|
||||
this->m_columnRight->MinWidth = 0.0;
|
||||
this->m_columnLeft->MaxWidth = std::numeric_limits<double>::max();
|
||||
this->m_columnRight->MaxWidth = std::numeric_limits<double>::max();
|
||||
this->m_columnLeft->Width = GridLengthHelper::FromPixels(rc1.Width - rcControl.X);
|
||||
this->m_columnRight->Width = GridLengthHelper::FromPixels(rc2.Width - ((rcWindow.Width - rcControl.Width) - rcControl.X));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_rowMiddle->Height = GridLengthHelper::FromPixels(rc2.Y - rc1.Height);
|
||||
|
||||
this->m_rowTop->MinHeight = 0.0;
|
||||
this->m_rowBottom->MinHeight = 0.0;
|
||||
this->m_rowTop->MaxHeight = std::numeric_limits<double>::max();
|
||||
this->m_rowBottom->MaxHeight = std::numeric_limits<double>::max();
|
||||
this->m_rowTop->Height = GridLengthHelper::FromPixels(rc1.Height - rcControl.Y);
|
||||
this->m_rowBottom->Height = GridLengthHelper::FromPixels(rc2.Height - ((rcWindow.Height - rcControl.Height) - rcControl.Y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rect TwoPaneViewCX::GetControlRect()
|
||||
{
|
||||
// Find out where this control is in the window
|
||||
auto transform = TransformToVisual(Window::Current->Content);
|
||||
return transform->TransformBounds(RectHelper::FromCoordinatesAndDimensions(0, 0, (float)this->ActualWidth, (float)this->ActualHeight));
|
||||
}
|
||||
|
||||
bool TwoPaneViewCX::IsInMultipleRegions(DisplayRegionHelperInfo info, Rect rcControl)
|
||||
{
|
||||
bool isInMultipleRegions = false;
|
||||
|
||||
if (info.Mode != MUXC::TwoPaneViewMode::SinglePane)
|
||||
{
|
||||
Rect rc1 = info.Regions[0];
|
||||
Rect rc2 = info.Regions[1];
|
||||
|
||||
if (info.Mode == MUXC::TwoPaneViewMode::Wide)
|
||||
{
|
||||
// Check that the control is over the split
|
||||
if (rcControl.X < rc1.Width && rcControl.X + rcControl.Width > rc2.X)
|
||||
{
|
||||
isInMultipleRegions = true;
|
||||
}
|
||||
}
|
||||
else if (info.Mode == MUXC::TwoPaneViewMode::Tall)
|
||||
{
|
||||
// Check that the control is over the split
|
||||
if (rcControl.Y < rc1.Height && rcControl.Y + rcControl.Height > rc2.Y)
|
||||
{
|
||||
isInMultipleRegions = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isInMultipleRegions;
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnSizeChanged(Platform::Object ^ /*sender*/, Windows::UI::Xaml::SizeChangedEventArgs ^ /*e*/)
|
||||
{
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnWindowSizeChanged(Platform::Object ^ /*sender*/, Windows::UI::Core::WindowSizeChangedEventArgs ^ /*e*/)
|
||||
{
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnPane1LengthPropertyChanged(GridLength /*oldValue*/, GridLength /*newValue*/)
|
||||
{
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnPane2LengthPropertyChanged(GridLength /*oldValue*/, GridLength /*newValue*/)
|
||||
{
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnPane1MinLengthPropertyChanged(double /*oldValue*/, double /*newValue*/)
|
||||
{
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnPane2MinLengthPropertyChanged(double /*oldValue*/, double /*newValue*/)
|
||||
{
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnPane1MaxLengthPropertyChanged(double /*oldValue*/, double /*newValue*/)
|
||||
{
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnPane2MaxLengthPropertyChanged(double /*oldValue*/, double /*newValue*/)
|
||||
{
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnMinTallModeHeightPropertyChanged(double /*oldValue*/, double newValue)
|
||||
{
|
||||
auto clampedValue = max(0.0, newValue);
|
||||
if (clampedValue != newValue)
|
||||
{
|
||||
this->MinTallModeHeight = clampedValue;
|
||||
return;
|
||||
}
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnMinWideModeWidthPropertyChanged(double /*oldValue*/, double newValue)
|
||||
{
|
||||
auto clampedValue = max(0.0, newValue);
|
||||
if (clampedValue != newValue)
|
||||
{
|
||||
this->MinWideModeWidth = clampedValue;
|
||||
return;
|
||||
}
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnWideModeConfigurationPropertyChanged(
|
||||
MUXC::TwoPaneViewWideModeConfiguration /*oldValue*/,
|
||||
MUXC::TwoPaneViewWideModeConfiguration /*newValue*/)
|
||||
{
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnTallModeConfigurationPropertyChanged(
|
||||
MUXC::TwoPaneViewTallModeConfiguration /*oldValue*/,
|
||||
MUXC::TwoPaneViewTallModeConfiguration /*newValue*/)
|
||||
{
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnPanePriorityPropertyChanged(MUXC::TwoPaneViewPriority /*oldValue*/, MUXC::TwoPaneViewPriority /*newValue*/)
|
||||
{
|
||||
this->UpdateMode();
|
||||
}
|
||||
|
||||
TwoPaneViewCX::DisplayRegionHelperInfo TwoPaneViewCX::GetDisplayRegionHelperInfo()
|
||||
{
|
||||
DisplayRegionHelperInfo info;
|
||||
info.Mode = MUXC::TwoPaneViewMode::SinglePane;
|
||||
|
||||
if (!Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.ViewManagement.ApplicationView", L"GetDisplayRegions"))
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
// ApplicationView::GetForCurrentView throws on failure; in that case we just won't do anything.
|
||||
ApplicationView ^ view;
|
||||
try
|
||||
{
|
||||
view = ApplicationView::GetForCurrentView();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
if (view && (int)view->ViewMode == 2 /*ApplicationViewMode::Spanning*/)
|
||||
{
|
||||
auto regions = view->GetDisplayRegions();
|
||||
if (regions->Size == 2)
|
||||
{
|
||||
auto region1 = regions->GetAt(0);
|
||||
auto region2 = regions->GetAt(1);
|
||||
info.Regions = ref new Array<Rect>(2);
|
||||
info.Regions[0] = RectHelper::FromCoordinatesAndDimensions(
|
||||
region1->WorkAreaOffset.X, region1->WorkAreaOffset.Y, region1->WorkAreaSize.Width, region1->WorkAreaSize.Height);
|
||||
info.Regions[1] = RectHelper::FromCoordinatesAndDimensions(
|
||||
region2->WorkAreaOffset.X, region2->WorkAreaOffset.Y, region2->WorkAreaSize.Width, region2->WorkAreaSize.Height);
|
||||
|
||||
// Determine orientation. If neither of these are true, default to doing nothing.
|
||||
if (info.Regions[0].X < info.Regions[1].X && info.Regions[0].Y == info.Regions[1].Y)
|
||||
{
|
||||
// Double portrait
|
||||
info.Mode = MUXC::TwoPaneViewMode::Wide;
|
||||
}
|
||||
else if (info.Regions[0].X == info.Regions[1].X && info.Regions[0].Y < info.Regions[1].Y)
|
||||
{
|
||||
// Double landscape
|
||||
info.Mode = MUXC::TwoPaneViewMode::Tall;
|
||||
}
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::SetScrollViewerProperties(String ^ scrollViewerName)
|
||||
{
|
||||
if (ApiInformation::IsApiContractPresent(L"Windows.Foundation.UniversalApiContract", 7))
|
||||
{
|
||||
if (auto scrollViewer = dynamic_cast<ScrollViewer ^>(this->GetTemplateChild(scrollViewerName)))
|
||||
{
|
||||
if (ApiInformation::IsPropertyPresent(L"Windows.UI.Xaml.Controls.ScrollContentPresenter", L"SizesContentToTemplatedParent"))
|
||||
{
|
||||
scrollViewer->Loaded += ref new RoutedEventHandler(this, &TwoPaneViewCX::OnScrollViewerLoaded);
|
||||
}
|
||||
|
||||
if (ApiInformation::IsPropertyPresent(L"Windows.UI.Xaml.Controls.ScrollViewer", L"ReduceViewportForCoreInputViewOcclusions"))
|
||||
{
|
||||
scrollViewer->ReduceViewportForCoreInputViewOcclusions = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TwoPaneViewCX::OnScrollViewerLoaded(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
if (auto scrollViewer = dynamic_cast<FrameworkElement ^>(sender))
|
||||
{
|
||||
auto scrollContentPresenterFE = VisualTree::FindDescendantByName(scrollViewer, L"ScrollContentPresenter");
|
||||
if (scrollContentPresenterFE)
|
||||
{
|
||||
if (auto scrollContentPresenter = dynamic_cast<ScrollContentPresenter ^>(scrollContentPresenterFE))
|
||||
{
|
||||
scrollContentPresenter->SizesContentToTemplatedParent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
116
src/Calculator/Controls/TwoPaneViewCX.h
Normal file
116
src/Calculator/Controls/TwoPaneViewCX.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See LICENSE in the project root for license information.
|
||||
|
||||
#pragma once
|
||||
#include "CalcViewModel/Common/Utils.h"
|
||||
|
||||
namespace CalculatorApp::Controls
|
||||
{
|
||||
ref class TwoPaneViewCX;
|
||||
public
|
||||
interface class ITwoPaneViewCX
|
||||
{
|
||||
event Windows::Foundation::TypedEventHandler<TwoPaneViewCX ^, Object ^> ^ ModeChanged;
|
||||
};
|
||||
|
||||
// We can't use the TwoPaneView control from the SDK or from Microsoft.UI.Xaml because of a bug with C++ apps.
|
||||
// (see this issue: https://github.com/microsoft/microsoft-ui-xaml/pull/2045)
|
||||
// This class is a C++/CX port of the C++/WinRT version of Microsoft.UI.Xaml (commit b3a2e45) which include the patch to fix the crash.
|
||||
// This fork adds also 4 new properties Pane1MinLength, Pane2MinLength, Pane1MaxLength, Pane2MaxLength
|
||||
public
|
||||
ref class TwoPaneViewCX sealed : public Windows::UI::Xaml::Controls::Control, [Windows::Foundation::Metadata::Default] ITwoPaneViewCX
|
||||
{
|
||||
enum class ViewMode
|
||||
{
|
||||
Pane1Only,
|
||||
Pane2Only,
|
||||
LeftRight,
|
||||
RightLeft,
|
||||
TopBottom,
|
||||
BottomTop,
|
||||
None
|
||||
};
|
||||
|
||||
struct DisplayRegionHelperInfo
|
||||
{
|
||||
Microsoft::UI::Xaml::Controls::TwoPaneViewMode Mode = Microsoft::UI::Xaml::Controls::TwoPaneViewMode::SinglePane;
|
||||
Platform::Array<Windows::Foundation::Rect> ^ Regions;
|
||||
};
|
||||
|
||||
public:
|
||||
DEPENDENCY_PROPERTY_OWNER(TwoPaneViewCX);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::UIElement ^, Pane1);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::UIElement ^, Pane2);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(
|
||||
Windows::UI::Xaml::GridLength,
|
||||
Pane1Length,
|
||||
Windows::UI::Xaml::GridLengthHelper::FromValueAndType(1, Windows::UI::Xaml::GridUnitType::Auto));
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(
|
||||
Windows::UI::Xaml::GridLength,
|
||||
Pane2Length,
|
||||
Windows::UI::Xaml::GridLengthHelper::FromValueAndType(1, Windows::UI::Xaml::GridUnitType::Star));
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, Pane1MinLength, 0.0);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, Pane2MinLength, 0.0);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, Pane1MaxLength, std::numeric_limits<double>::max());
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, Pane2MaxLength, std::numeric_limits<double>::max());
|
||||
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Microsoft::UI::Xaml::Controls::TwoPaneViewPriority,
|
||||
PanePriority,
|
||||
Microsoft::UI::Xaml::Controls::TwoPaneViewPriority::Pane1);
|
||||
DEPENDENCY_PROPERTY(Microsoft::UI::Xaml::Controls::TwoPaneViewMode, Mode);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(
|
||||
Microsoft::UI::Xaml::Controls::TwoPaneViewWideModeConfiguration,
|
||||
WideModeConfiguration,
|
||||
Microsoft::UI::Xaml::Controls::TwoPaneViewWideModeConfiguration::LeftRight);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(
|
||||
Microsoft::UI::Xaml::Controls::TwoPaneViewTallModeConfiguration,
|
||||
TallModeConfiguration,
|
||||
Microsoft::UI::Xaml::Controls::TwoPaneViewTallModeConfiguration::TopBottom);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, MinWideModeWidth, 641);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, MinTallModeHeight, 641);
|
||||
|
||||
TwoPaneViewCX();
|
||||
virtual ~TwoPaneViewCX();
|
||||
void OnApplyTemplate() override;
|
||||
virtual event Windows::Foundation::TypedEventHandler<TwoPaneViewCX ^, Object ^> ^ ModeChanged;
|
||||
|
||||
private:
|
||||
void UpdateRowsColumns(ViewMode newMode, DisplayRegionHelperInfo info, Windows::Foundation::Rect rcControl);
|
||||
void UpdateMode();
|
||||
bool IsInMultipleRegions(DisplayRegionHelperInfo info, Windows::Foundation::Rect rcControl);
|
||||
void SetScrollViewerProperties(Platform::String ^ scrollViewerName);
|
||||
Windows::Foundation::Rect GetControlRect();
|
||||
DisplayRegionHelperInfo GetDisplayRegionHelperInfo();
|
||||
|
||||
void OnSizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
|
||||
void OnWindowSizeChanged(Platform::Object ^ sender, Windows::UI::Core::WindowSizeChangedEventArgs ^ e);
|
||||
void OnPane1LengthPropertyChanged(Windows::UI::Xaml::GridLength oldValue, Windows::UI::Xaml::GridLength newValue);
|
||||
void OnPane2LengthPropertyChanged(Windows::UI::Xaml::GridLength oldValue, Windows::UI::Xaml::GridLength newValue);
|
||||
void OnPane1MinLengthPropertyChanged(double oldValue, double newValue);
|
||||
void OnPane2MinLengthPropertyChanged(double oldValue, double newValue);
|
||||
void OnPane1MaxLengthPropertyChanged(double oldValue, double newValue);
|
||||
void OnPane2MaxLengthPropertyChanged(double oldValue, double newValue);
|
||||
void
|
||||
OnPanePriorityPropertyChanged(Microsoft::UI::Xaml::Controls::TwoPaneViewPriority oldValue, Microsoft::UI::Xaml::Controls::TwoPaneViewPriority newValue);
|
||||
void OnMinTallModeHeightPropertyChanged(double oldValue, double newValue);
|
||||
void OnMinWideModeWidthPropertyChanged(double oldValue, double newValue);
|
||||
void OnWideModeConfigurationPropertyChanged(
|
||||
Microsoft::UI::Xaml::Controls::TwoPaneViewWideModeConfiguration oldValue,
|
||||
Microsoft::UI::Xaml::Controls::TwoPaneViewWideModeConfiguration newValue);
|
||||
void OnTallModeConfigurationPropertyChanged(
|
||||
Microsoft::UI::Xaml::Controls::TwoPaneViewTallModeConfiguration oldValue,
|
||||
Microsoft::UI::Xaml::Controls::TwoPaneViewTallModeConfiguration newValue);
|
||||
void OnScrollViewerLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::Controls::ColumnDefinition ^ m_columnLeft;
|
||||
Windows::UI::Xaml::Controls::ColumnDefinition ^ m_columnMiddle;
|
||||
Windows::UI::Xaml::Controls::ColumnDefinition ^ m_columnRight;
|
||||
Windows::UI::Xaml::Controls::RowDefinition ^ m_rowTop;
|
||||
Windows::UI::Xaml::Controls::RowDefinition ^ m_rowMiddle;
|
||||
Windows::UI::Xaml::Controls::RowDefinition ^ m_rowBottom;
|
||||
Windows::Foundation::EventRegistrationToken m_windowSizeChangedToken;
|
||||
ViewMode m_currentMode{ ViewMode::None };
|
||||
bool m_loaded{ false };
|
||||
};
|
||||
}
|
0
src/Calculator/MultiTrigger.cpp
Normal file
0
src/Calculator/MultiTrigger.cpp
Normal file
0
src/Calculator/MultiTrigger.h
Normal file
0
src/Calculator/MultiTrigger.h
Normal file
|
@ -8,7 +8,7 @@
|
|||
<Logo>Assets\CalculatorStoreLogo.png</Logo>
|
||||
</Properties>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17133.0" MaxVersionTested="10.0.18362.0" />
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17133.0" MaxVersionTested="10.0.19400.0" />
|
||||
</Dependencies>
|
||||
<Resources>
|
||||
<Resource Language="x-generate" />
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:CalculatorApp"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:triggers="using:CalculatorApp.Views.StateTriggers"
|
||||
Loaded="OnLoaded"
|
||||
mc:Ignorable="d">
|
||||
|
||||
|
@ -382,15 +383,7 @@
|
|||
Icon="Paste"/>
|
||||
</MenuFlyout>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid AutomationProperties.LandmarkType="Main">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="ColumnMain"/>
|
||||
<ColumnDefinition x:Name="ColumnHistory"
|
||||
Width="0"
|
||||
MaxWidth="320"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<!-- Error Layout specific -->
|
||||
<VisualStateGroup x:Name="ErrorVisualStates">
|
||||
|
@ -415,18 +408,13 @@
|
|||
<Setter Target="MemPlus.IsEnabled" Value="False"/>
|
||||
<Setter Target="MemMinus.IsEnabled" Value="False"/>
|
||||
<Setter Target="MemButton.IsEnabled" Value="False"/>
|
||||
<Setter Target="RowExpression.Height" Value="0*"/>
|
||||
<Setter Target="RowExpression.Height" Value="0"/>
|
||||
<Setter Target="RowHamburger.Height" Value="0"/>
|
||||
<Setter Target="RowMemoryControls.Height" Value="0*"/>
|
||||
<Setter Target="RowMemoryControls.Height" Value="0"/>
|
||||
</VisualState.Setters>
|
||||
<Storyboard Completed="OnDisplayVisualStateCompleted"/>
|
||||
</VisualState>
|
||||
<VisualState x:Name="DisplayModeNormal">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="RowExpression.Height" Value="20*"/>
|
||||
<Setter Target="RowHamburger.Height" Value="{StaticResource HamburgerHeightGridLength}"/>
|
||||
<Setter Target="RowMemoryControls.Height" Value="32*"/>
|
||||
</VisualState.Setters>
|
||||
<Storyboard Completed="OnDisplayVisualStateCompleted"/>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
@ -460,12 +448,44 @@
|
|||
</VisualStateGroup>
|
||||
<!-- Layout specific -->
|
||||
<VisualStateGroup x:Name="LayoutVisualStates" CurrentStateChanged="OnVisualStateChanged">
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<triggers:ApplicationViewModeTrigger ViewMode="DoubleLandscape"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="DockPanel.Visibility" Value="Visible"/>
|
||||
<Setter Target="M6.Width" Value="0"/>
|
||||
<Setter Target="ExpressionText.Visibility" Value="Collapsed"/>
|
||||
<Setter Target="Results.Visibility" Value="Collapsed"/>
|
||||
<Setter Target="RowExpression.Height" Value="0"/>
|
||||
<Setter Target="RowMemoryControls.Height" Value="64"/>
|
||||
<Setter Target="RowHamburger.Height" Value="0"/>
|
||||
<Setter Target="RowDisplayControls.Height" Value="0"/>
|
||||
<Setter Target="DualScreenResultPanel.Visibility" Value="Visible"/>
|
||||
<Setter Target="DockPanel.BorderThickness" Value="1,0,0,0"/>
|
||||
<Setter Target="DockPanel.(Grid.ColumnSpan)" Value="1"/>
|
||||
<Setter Target="DockPanel.(Grid.Column)" Value="1"/>
|
||||
<Setter Target="Pane1Panel.Margin" Value="12,0,12,12"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<triggers:ApplicationViewModeTrigger ViewMode="DoublePortrait"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="Pane1Panel.Margin" Value="12"/>
|
||||
<Setter Target="Pane2Panel.Margin" Value="12"/>
|
||||
<Setter Target="DockPanel.Visibility" Value="Visible"/>
|
||||
<Setter Target="M6.Width" Value="0"/>
|
||||
</VisualState.Setters>
|
||||
<Storyboard Completed="OnLayoutVisualStateCompleted"/>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Portrait768x1366">
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowHeight="1366" MinWindowWidth="768"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ColumnHistory.Width" Value="320"/>
|
||||
<Setter Target="PaneView.Pane2Length" Value="320"/>
|
||||
<Setter Target="DockPanel.Visibility" Value="Visible"/>
|
||||
<Setter Target="M6.Width" Value="0"/>
|
||||
</VisualState.Setters>
|
||||
|
@ -476,7 +496,7 @@
|
|||
<AdaptiveTrigger MinWindowHeight="768" MinWindowWidth="1024"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ColumnHistory.Width" Value="320"/>
|
||||
<Setter Target="PaneView.Pane2Length" Value="320"/>
|
||||
<Setter Target="DockPanel.Visibility" Value="Visible"/>
|
||||
<Setter Target="M6.Width" Value="0"/>
|
||||
</VisualState.Setters>
|
||||
|
@ -487,8 +507,8 @@
|
|||
<AdaptiveTrigger MinWindowHeight="0" MinWindowWidth="560"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ColumnMain.Width" Value="320*"/>
|
||||
<Setter Target="ColumnHistory.Width" Value="240*"/>
|
||||
<Setter Target="PaneView.Pane1Length" Value="320*"/>
|
||||
<Setter Target="PaneView.Pane2Length" Value="240*"/>
|
||||
<Setter Target="DockPanel.Visibility" Value="Visible"/>
|
||||
<Setter Target="M6.Width" Value="0"/>
|
||||
</VisualState.Setters>
|
||||
|
@ -516,11 +536,18 @@
|
|||
<Storyboard Completed="OnLayoutVisualStateCompleted"/>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<!-- Results display specific -->
|
||||
<VisualStateGroup>
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<triggers:ApplicationViewModeTrigger ViewMode="DoubleLandscape"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="RowResult.Height" Value="0"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="RegularAlwaysOnTop">
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowHeight="260"/>
|
||||
<triggers:ApplicationViewModeTrigger MinWindowHeight="260" ViewMode="CompactOverlay"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="RowResult.MinHeight" Value="54"/>
|
||||
|
@ -529,7 +556,7 @@
|
|||
</VisualState>
|
||||
<VisualState x:Name="MinAlwaysOnTop">
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowHeight="0"/>
|
||||
<triggers:ApplicationViewModeTrigger MinWindowHeight="0" ViewMode="CompactOverlay"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="RowResult.MinHeight" Value="20"/>
|
||||
|
@ -539,8 +566,6 @@
|
|||
<Setter Target="AlwaysOnTopResults.ScrollButtonsFontSize" Value="12"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup>
|
||||
<VisualState x:Name="ResultsL">
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowHeight="800"/>
|
||||
|
@ -574,7 +599,16 @@
|
|||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
|
||||
<Grid FlowDirection="LeftToRight">
|
||||
<controls:TwoPaneViewCX x:Name="PaneView"
|
||||
Grid.RowSpan="2"
|
||||
MinTallModeHeight="Infinity"
|
||||
MinWideModeWidth="0"
|
||||
Pane1Length="*"
|
||||
Pane2Length="0"
|
||||
Pane2MaxLength="320"
|
||||
TallModeConfiguration="BottomTop">
|
||||
<controls:TwoPaneViewCX.Pane1>
|
||||
<Grid x:Name="Pane1Panel" FlowDirection="LeftToRight">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition x:Name="RowHamburger" Height="{StaticResource HamburgerHeightGridLength}"/>
|
||||
<RowDefinition x:Name="RowExpression"
|
||||
|
@ -781,12 +815,47 @@
|
|||
<local:OperatorsPanel x:Name="OpsPanel" IsBitFlipChecked="{x:Bind Model.IsBitFlipChecked, Mode=OneWay}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</controls:TwoPaneViewCX.Pane1>
|
||||
|
||||
<controls:TwoPaneViewCX.Pane2>
|
||||
<Grid x:Name="Pane2Panel">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="248"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel x:Name="DualScreenResultPanel"
|
||||
Padding="0,0,12,0"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="Collapsed"
|
||||
x:Load="False">
|
||||
<controls:OverflowTextBlock x:Name="DualScreenExpressionText"
|
||||
Margin="6,0,6,0"
|
||||
VerticalAlignment="Bottom"
|
||||
Style="{StaticResource NormalStyle}"
|
||||
AutomationProperties.AutomationId="CalculatorExpression"
|
||||
AutomationProperties.Name="{x:Bind Model.CalculationExpressionAutomationName, Mode=OneWay}"
|
||||
IsTabStop="False"
|
||||
TokensUpdated="{x:Bind Model.AreTokensUpdated, Mode=OneWay}"/>
|
||||
|
||||
<controls:CalculationResult x:Uid="CalculatorResults"
|
||||
Style="{StaticResource ResultsStyle}"
|
||||
AutomationProperties.AutomationId="CalculatorResults"
|
||||
AutomationProperties.HeadingLevel="Level1"
|
||||
AutomationProperties.Name="{x:Bind Model.CalculationResultAutomationName, Mode=OneWay}"
|
||||
ContextCanceled="OnContextCanceled"
|
||||
ContextRequested="OnContextRequested"
|
||||
DisplayValue="{x:Bind Model.DisplayValue, Mode=OneWay}"
|
||||
IsInError="{x:Bind Model.IsInError, Mode=OneWay}"
|
||||
IsOperatorCommand="{x:Bind Model.IsOperatorCommand, Mode=OneWay}"
|
||||
MaxFontSize="72"/>
|
||||
|
||||
</StackPanel>
|
||||
<!-- Docked Pivot panel for history/memory -->
|
||||
<Border x:Name="DockPanel"
|
||||
x:Uid="DockPanel"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="2"
|
||||
BorderBrush="{ThemeResource DividerBrush}"
|
||||
BorderThickness="0"
|
||||
AutomationProperties.HeadingLevel="Level1"
|
||||
Visibility="Collapsed">
|
||||
<Border.Resources>
|
||||
|
@ -1274,4 +1343,7 @@
|
|||
</Pivot>
|
||||
</Border>
|
||||
</Grid>
|
||||
</controls:TwoPaneViewCX.Pane2>
|
||||
</controls:TwoPaneViewCX>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -674,6 +674,11 @@ void Calculator::DockPanelTapped(_In_ TappedRoutedEventArgs ^ e)
|
|||
void Calculator::UnregisterEventHandlers()
|
||||
{
|
||||
ExpressionText->UnregisterEventHandlers();
|
||||
AlwaysOnTopResults->UnregisterEventHandlers();
|
||||
if (DualScreenExpressionText != nullptr)
|
||||
{
|
||||
DualScreenExpressionText->UnregisterEventHandlers();
|
||||
}
|
||||
}
|
||||
|
||||
void Calculator::OnErrorVisualStateCompleted(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "Views/Memory.xaml.h"
|
||||
#include "Views/OperatorsPanel.xaml.h"
|
||||
#include "Views/StateTriggers/ControlSizeTrigger.h"
|
||||
#include "Views/StateTriggers/ApplicationViewModeTrigger.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
|
|
|
@ -851,21 +851,6 @@
|
|||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
<StackPanel x:Name="VariableStackPanel" x:Load="{x:Bind local:EquationInputArea.ManageEditVariablesButtonLoaded(Variables.Size), Mode=OneWay}">
|
||||
<StackPanel.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<SolidColorBrush x:Key="DividerBrush" Color="#33000000"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<SolidColorBrush x:Key="DividerBrush" Color="#60FFFFFF"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="HighContrast">
|
||||
<SolidColorBrush x:Key="DividerBrush" Color="Transparent"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
</StackPanel.Resources>
|
||||
<Rectangle Height="1"
|
||||
Margin="12"
|
||||
Fill="{ThemeResource DividerBrush}"/>
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)"
|
||||
xmlns:controls="using:CalculatorApp.Controls"
|
||||
xmlns:converters="using:CalculatorApp.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:graphControl="using:GraphControl"
|
||||
xmlns:local="using:CalculatorApp"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:states="using:CalculatorApp.Views.StateTriggers"
|
||||
x:Name="Control"
|
||||
DataContextChanged="GraphingCalculator_DataContextChanged"
|
||||
mc:Ignorable="d">
|
||||
|
@ -383,26 +386,60 @@
|
|||
<RowDefinition Height="{StaticResource HamburgerHeightGridLength}"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
<ColumnDefinition Width="1*"
|
||||
MinWidth="300"
|
||||
MaxWidth="420"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup CurrentStateChanged="OnVisualStateChanged">
|
||||
<VisualState x:Name="ColumnsState">
|
||||
<VisualStateGroup>
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<states:ApplicationViewModeTrigger ViewMode="DoubleLandscape"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="KeyGraphFeaturesControl.(Grid.Row)" Value="0"/>
|
||||
<Setter Target="EquationInputAreaControl.(Grid.Row)" Value="0"/>
|
||||
<Setter Target="GraphingNumPad.(Grid.Row)" Value="0"/>
|
||||
<Setter Target="KeyGraphFeaturesControl.(Grid.RowSpan)" Value="2"/>
|
||||
<Setter Target="EquationInputAreaControl.(Grid.RowSpan)" Value="2"/>
|
||||
<Setter Target="GraphingNumPad.(Grid.RowSpan)" Value="2"/>
|
||||
<Setter Target="KeyGraphFeaturesControl.(Grid.Column)" Value="1"/>
|
||||
<Setter Target="EquationInputAreaControl.(Grid.Column)" Value="1"/>
|
||||
<Setter Target="GraphingNumPad.(Grid.Column)" Value="0"/>
|
||||
<Setter Target="KeyGraphFeaturesControl.(Grid.ColumnSpan)" Value="1"/>
|
||||
<Setter Target="EquationInputAreaControl.(Grid.ColumnSpan)" Value="1"/>
|
||||
<Setter Target="GraphingNumPad.(Grid.ColumnSpan)" Value="1"/>
|
||||
<Setter Target="RightGrid.Margin" Value="24"/>
|
||||
<Setter Target="GraphingNumPad.Margin" Value="0,0,24,0"/>
|
||||
<Setter Target="KeyGraphFeaturesControl.Margin" Value="0,40,0,0"/>
|
||||
<Setter Target="EquationInputAreaControl.Margin" Value="0,40,0,0"/>
|
||||
<Setter Target="PaneView.TallModeConfiguration">
|
||||
<Setter.Value>
|
||||
<muxc:TwoPaneViewTallModeConfiguration>TopBottom</muxc:TwoPaneViewTallModeConfiguration>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<states:ApplicationViewModeTrigger ViewMode="DoublePortrait"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="RightGrid.Margin" Value="24,0,24,24"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="800"/>
|
||||
</VisualState.StateTriggers>
|
||||
</VisualState>
|
||||
<VisualState x:Name="SmallState">
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="0"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="Control.IsSmallState" Value="True"/>
|
||||
<Setter Target="LeftGrid.(Grid.ColumnSpan)" Value="2"/>
|
||||
<Setter Target="PaneView.WideModeConfiguration">
|
||||
<Setter.Value>
|
||||
<muxc:TwoPaneViewWideModeConfiguration>SinglePane</muxc:TwoPaneViewWideModeConfiguration>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Target="RightGrid.(Grid.ColumnSpan)" Value="2"/>
|
||||
<Setter Target="RightGrid.(Grid.Column)" Value="0"/>
|
||||
<Setter Target="SwitchModeToggleButton.Visibility" Value="Visible"/>
|
||||
|
@ -411,7 +448,6 @@
|
|||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<!-- Top panel -->
|
||||
<Grid Grid.ColumnSpan="2">
|
||||
<ToggleSwitch x:Name="SwitchModeToggleButton"
|
||||
x:Uid="SwitchModeToggleButton"
|
||||
Margin="0,0,12,2"
|
||||
|
@ -423,12 +459,19 @@
|
|||
Toggled="SwitchModeToggleButton_Toggled"
|
||||
ToolTipService.ToolTip="{x:Bind local:GraphingCalculator.GetInfoForSwitchModeToggleButton(SwitchModeToggleButton.IsOn), Mode=OneWay}"
|
||||
Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
<!-- Left portion of the screen -->
|
||||
<Grid x:Name="LeftGrid"
|
||||
|
||||
<controls:TwoPaneViewCX x:Name="PaneView"
|
||||
Grid.Row="1"
|
||||
Padding="0,4,0,0"
|
||||
Visibility="{x:Bind ShouldDisplayPanel(IsSmallState, SwitchModeToggleButton.IsOn, x:True), Mode=OneWay}">
|
||||
MinTallModeHeight="Infinity"
|
||||
MinWideModeWidth="0"
|
||||
Pane1Length="2*"
|
||||
Pane2Length="1*"
|
||||
Pane2MaxLength="420"
|
||||
Pane2MinLength="300"
|
||||
PanePriority="{x:Bind local:GraphingCalculator.GetPanePriority(SwitchModeToggleButton.IsOn), Mode=OneWay}"
|
||||
TallModeConfiguration="SinglePane">
|
||||
<controls:TwoPaneViewCX.Pane1>
|
||||
<Grid x:Name="LeftGrid" Padding="0,4,0,0">
|
||||
<Grid.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
|
@ -616,21 +659,22 @@
|
|||
AutomationProperties.LiveSetting="Polite"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<!-- Right portion of the screen -->
|
||||
<Grid x:Name="RightGrid"
|
||||
Grid.Row="1"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Visibility="{x:Bind local:GraphingCalculator.ShouldDisplayPanel(IsSmallState, SwitchModeToggleButton.IsOn, x:False), Mode=OneWay}">
|
||||
</controls:TwoPaneViewCX.Pane1>
|
||||
<controls:TwoPaneViewCX.Pane2>
|
||||
<Grid x:Name="RightGrid">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="2.2*" MaxHeight="400"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1.5*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Ideally the KeyGraphFeaturesPanel should be a frame so that navigation to and from the panel could be handled nicely -->
|
||||
<local:KeyGraphFeaturesPanel x:Name="KeyGraphFeaturesControl"
|
||||
Grid.RowSpan="2"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="0,4,0,0"
|
||||
KeyGraphFeaturesClosed="OnKeyGraphFeaturesClosed"
|
||||
ViewModel="{x:Bind ViewModel.SelectedEquation, Mode=OneWay}"
|
||||
|
@ -639,6 +683,7 @@
|
|||
|
||||
<!-- This control should be within a grid that limits the hight to keep the sticky footer functionality from breaking -->
|
||||
<local:EquationInputArea x:Name="EquationInputAreaControl"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="0,4,0,0"
|
||||
EquationFormatRequested="OnEquationFormatRequested"
|
||||
Equations="{x:Bind ViewModel.Equations}"
|
||||
|
@ -648,9 +693,12 @@
|
|||
|
||||
<local:GraphingNumPad x:Name="GraphingNumPad"
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="2,0,2,2"
|
||||
Visibility="{x:Bind IsKeyGraphFeaturesVisible, Converter={StaticResource BooleanToVisibilityNegationConverter}, Mode=OneWay}"/>
|
||||
|
||||
</Grid>
|
||||
</controls:TwoPaneViewCX.Pane2>
|
||||
</controls:TwoPaneViewCX>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -49,6 +49,7 @@ using namespace Windows::UI::Xaml::Media;
|
|||
using namespace Windows::UI::Xaml::Media::Imaging;
|
||||
using namespace Windows::UI::Popups;
|
||||
using namespace Windows::UI::ViewManagement;
|
||||
namespace MUXC = Microsoft::UI::Xaml::Controls;
|
||||
|
||||
constexpr auto sc_ViewModelPropertyName = L"ViewModel";
|
||||
|
||||
|
@ -434,9 +435,9 @@ void GraphingCalculator::OnKeyGraphFeaturesClosed(Object ^ sender, RoutedEventAr
|
|||
ViewModel->SelectedEquation->GraphEquation->IsSelected = false;
|
||||
}
|
||||
|
||||
Visibility GraphingCalculator::ShouldDisplayPanel(bool isSmallState, bool isEquationModeActivated, bool isGraphPanel)
|
||||
MUXC::TwoPaneViewPriority GraphingCalculator::GetPanePriority(bool isEquationModeActivated)
|
||||
{
|
||||
return (!isSmallState || isEquationModeActivated ^ isGraphPanel) ? ::Visibility::Visible : ::Visibility::Collapsed;
|
||||
return isEquationModeActivated ? MUXC::TwoPaneViewPriority::Pane2 : MUXC::TwoPaneViewPriority::Pane1;
|
||||
}
|
||||
|
||||
Platform::String ^ GraphingCalculator::GetInfoForSwitchModeToggleButton(bool isChecked)
|
||||
|
@ -573,7 +574,10 @@ void GraphingCalculator::DisplayGraphSettings()
|
|||
auto flyoutGraphSettings = ref new Flyout();
|
||||
flyoutGraphSettings->Content = graphSettings;
|
||||
flyoutGraphSettings->Closing += ref new TypedEventHandler<FlyoutBase ^, FlyoutBaseClosingEventArgs ^>(this, &GraphingCalculator::OnSettingsFlyout_Closing);
|
||||
flyoutGraphSettings->ShowAt(GraphSettingsButton);
|
||||
|
||||
auto options = ref new FlyoutShowOptions();
|
||||
options->Placement = FlyoutPlacementMode::BottomEdgeAlignedRight;
|
||||
flyoutGraphSettings->ShowAt(GraphSettingsButton, options);
|
||||
}
|
||||
|
||||
void CalculatorApp::GraphingCalculator::AddTracePointerShadow()
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
#include "Views\GraphingCalculator\KeyGraphFeaturesPanel.xaml.h"
|
||||
#include "Views\GraphingCalculator\GraphingNumPad.xaml.h"
|
||||
#include "Views\GraphingCalculator\GraphingSettings.xaml.h"
|
||||
#include "CalcViewModel/Common/TraceLogger.h"
|
||||
#include "Views\StateTriggers\ApplicationViewModeTrigger.h"
|
||||
#include "Controls\TwoPaneViewCX.h"
|
||||
#include "CalcViewModel\Common\TraceLogger.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
|
@ -36,7 +38,7 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
|
|||
void set(CalculatorApp::ViewModel::GraphingCalculatorViewModel^ vm);
|
||||
}
|
||||
|
||||
static Windows::UI::Xaml::Visibility ShouldDisplayPanel(bool isSmallState, bool isEquationModeActivated, bool isGraphPanel);
|
||||
static Microsoft::UI::Xaml::Controls::TwoPaneViewPriority GetPanePriority(bool isEquationModeActivated);
|
||||
static Platform::String ^ GetInfoForSwitchModeToggleButton(bool isChecked);
|
||||
static Windows::UI::Xaml::Visibility ManageEditVariablesButtonVisibility(unsigned int numberOfVariables);
|
||||
static Platform::String ^ GetTracingLegend(Platform::IBox<bool> ^ isTracing);
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "ApplicationViewModeTrigger.h"
|
||||
using namespace CalculatorApp::Views::StateTriggers;
|
||||
using namespace Windows::System::Profile;
|
||||
using namespace Windows::UI::ViewManagement;
|
||||
using namespace Windows::UI::Xaml;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(ApplicationViewModeTrigger, ViewMode);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(ApplicationViewModeTrigger, MinWindowHeight);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(ApplicationViewModeTrigger, MinWindowWidth);
|
||||
|
||||
ApplicationViewModeTrigger::ApplicationViewModeTrigger()
|
||||
{
|
||||
m_windowSizeEventToken = Window::Current->SizeChanged += ref new WindowSizeChangedEventHandler(this, &ApplicationViewModeTrigger::WindowSizeChanged);
|
||||
UpdateTrigger();
|
||||
}
|
||||
|
||||
void ApplicationViewModeTrigger::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
|
||||
UpdateTrigger();
|
||||
}
|
||||
void ApplicationViewModeTrigger::OnViewModePropertyChanged(_In_ AppViewMode /*oldValue*/, _In_ AppViewMode /*newValue*/)
|
||||
{
|
||||
UpdateTrigger();
|
||||
}
|
||||
void ApplicationViewModeTrigger::OnMinWindowHeightPropertyChanged(double /*oldValue*/, double /*newValue*/)
|
||||
{
|
||||
UpdateTrigger();
|
||||
}
|
||||
|
||||
void ApplicationViewModeTrigger::OnMinWindowWidthPropertyChanged(double /*oldValue*/, double /*newValue*/)
|
||||
{
|
||||
UpdateTrigger();
|
||||
}
|
||||
|
||||
void ApplicationViewModeTrigger::UpdateTrigger()
|
||||
{
|
||||
auto applicationView = ApplicationView::GetForCurrentView();
|
||||
auto viewMode = applicationView->ViewMode;
|
||||
if (applicationView->VisibleBounds.Width < this->MinWindowWidth || applicationView->VisibleBounds.Height < this->MinWindowHeight)
|
||||
{
|
||||
SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (static_cast<int>(viewMode))
|
||||
{
|
||||
case 0 /*ApplicationViewMode::Default*/:
|
||||
SetActive(this->ViewMode == AppViewMode::Normal);
|
||||
break;
|
||||
case 1 /*ApplicationViewMode::CompactOverlay*/:
|
||||
SetActive(this->ViewMode == AppViewMode::CompactOverlay);
|
||||
break;
|
||||
case 2 /*ApplicationViewMode::Spanning*/:
|
||||
|
||||
// We will need to update this code to use new SpanningRects API instead of DisplayRegions when the app will use the SDK for windows 10 2004.
|
||||
auto displayRegions = applicationView->GetDisplayRegions();
|
||||
if (displayRegions->Size == 2)
|
||||
{
|
||||
auto display1 = displayRegions->GetAt(0);
|
||||
auto display2 = displayRegions->GetAt(1);
|
||||
if (display1->WorkAreaOffset.X < display2->WorkAreaOffset.X && display1->WorkAreaOffset.Y == display2->WorkAreaOffset.Y)
|
||||
{
|
||||
this->SetActive(this->ViewMode == AppViewMode::DoublePortrait);
|
||||
return;
|
||||
}
|
||||
else if (display1->WorkAreaOffset.X == display2->WorkAreaOffset.X && display1->WorkAreaOffset.Y < display2->WorkAreaOffset.Y)
|
||||
{
|
||||
this->SetActive(this->ViewMode == AppViewMode::DoubleLandscape);
|
||||
return;
|
||||
}
|
||||
}
|
||||
SetActive(this->ViewMode == AppViewMode::Normal);
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
#include "CalcViewModel/Common/Utils.h"
|
||||
|
||||
namespace CalculatorApp::Views::StateTriggers
|
||||
{
|
||||
public
|
||||
enum class AppViewMode
|
||||
{
|
||||
Normal = 0,
|
||||
CompactOverlay = 1,
|
||||
DoublePortrait = 2,
|
||||
DoubleLandscape = 3
|
||||
};
|
||||
|
||||
public
|
||||
ref class ApplicationViewModeTrigger sealed : public Windows::UI::Xaml::StateTriggerBase
|
||||
{
|
||||
public:
|
||||
ApplicationViewModeTrigger();
|
||||
DEPENDENCY_PROPERTY_OWNER(ApplicationViewModeTrigger);
|
||||
|
||||
/* The view mode that will cause the trigger to fire. */
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(AppViewMode, ViewMode, AppViewMode::Normal);
|
||||
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, MinWindowHeight, -1);
|
||||
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, MinWindowWidth, -1);
|
||||
private:
|
||||
void OnViewModePropertyChanged(AppViewMode oldValue, AppViewMode newValue);
|
||||
void OnMinWindowHeightPropertyChanged(double oldValue, double newValue);
|
||||
void OnMinWindowWidthPropertyChanged(double oldValue, double newValue);
|
||||
void WindowSizeChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Core::WindowSizeChangedEventArgs ^ e);
|
||||
void UpdateTrigger();
|
||||
private:
|
||||
Windows::Foundation::EventRegistrationToken m_windowSizeEventToken;
|
||||
};
|
||||
}
|
|
@ -5,9 +5,11 @@
|
|||
#include "TitleBar.xaml.h"
|
||||
#include "CalcViewModel/Common/AppResourceProvider.h"
|
||||
#include "CalcViewModel/Common/Utils.h"
|
||||
#include "CalcViewModel/Utils/DeviceFamilyHelper.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Platform;
|
||||
using namespace CalculatorApp::ViewModel::Utils;
|
||||
using namespace Windows::ApplicationModel;
|
||||
using namespace Windows::ApplicationModel::Core;
|
||||
using namespace Windows::Foundation;
|
||||
|
@ -50,7 +52,7 @@ namespace CalculatorApp
|
|||
[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->SetTitleBarHeight();
|
||||
this->SetTitleBarPadding();
|
||||
});
|
||||
|
||||
|
@ -60,11 +62,10 @@ namespace CalculatorApp
|
|||
m_windowActivatedToken = Window::Current->Activated +=
|
||||
ref new Windows::UI::Xaml::WindowActivatedEventHandler(this, &CalculatorApp::TitleBar::OnWindowActivated);
|
||||
// Set properties
|
||||
LayoutRoot->Height = m_coreTitleBar->Height;
|
||||
SetTitleBarControlColors();
|
||||
|
||||
SetTitleBarVisibility();
|
||||
SetTitleBarPadding();
|
||||
this->SetTitleBarHeight();
|
||||
this->SetTitleBarControlColors();
|
||||
this->SetTitleBarVisibility();
|
||||
this->SetTitleBarPadding();
|
||||
}
|
||||
|
||||
void TitleBar::OnUnloaded(_In_ Object ^ /*sender*/, _In_ RoutedEventArgs ^ /*e*/)
|
||||
|
@ -84,7 +85,25 @@ namespace CalculatorApp
|
|||
|
||||
void TitleBar::SetTitleBarVisibility()
|
||||
{
|
||||
this->LayoutRoot->Visibility = m_coreTitleBar->IsVisible || IsAlwaysOnTopMode ? ::Visibility::Visible : ::Visibility::Collapsed;
|
||||
// CoreApplication::GetCurrentView()->TitleBar->IsVisible currently returns False instead of True on Windows 10X.
|
||||
// This issue is already tracked and will be fixed in a future preview version of 10X.
|
||||
this->LayoutRoot->Visibility = m_coreTitleBar->IsVisible || DeviceFamilyHelper::GetDeviceFamily() == DeviceFamily::WindowsCore || IsAlwaysOnTopMode
|
||||
? ::Visibility::Visible
|
||||
: ::Visibility::Collapsed;
|
||||
}
|
||||
|
||||
void TitleBar::SetTitleBarHeight()
|
||||
{
|
||||
if (m_coreTitleBar->Height == 0 && DeviceFamilyHelper::GetDeviceFamily() == DeviceFamily::WindowsCore)
|
||||
{
|
||||
// CoreApplication::GetCurrentView()->TitleBar doesn't return the correct height on Windows 10X.
|
||||
// This issue is already tracked and will be fixed in a future preview version of 10X.
|
||||
this->LayoutRoot->Height = 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->LayoutRoot->Height = m_coreTitleBar->Height;
|
||||
}
|
||||
}
|
||||
|
||||
void TitleBar::SetTitleBarPadding()
|
||||
|
|
|
@ -29,6 +29,7 @@ public
|
|||
|
||||
void SetTitleBarText(Platform::String ^ text);
|
||||
void SetTitleBarVisibility();
|
||||
void SetTitleBarHeight();
|
||||
void SetTitleBarPadding();
|
||||
void SetTitleBarControlColors();
|
||||
void ColorValuesChanged(_In_ Windows::UI::ViewManagement::UISettings ^ sender, _In_ Platform::Object ^ e);
|
||||
|
|
|
@ -277,36 +277,47 @@
|
|||
<Grid x:Name="UnitConverterRootGrid"
|
||||
HorizontalAlignment="Stretch"
|
||||
AutomationProperties.LandmarkType="Main">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition x:Name="RowTopNav" Height="{StaticResource HamburgerHeightGridLength}"/>
|
||||
<RowDefinition x:Name="RowDisplay1"
|
||||
Height="56*"
|
||||
MinHeight="56"/>
|
||||
<RowDefinition x:Name="RowUnit1"
|
||||
Height="32*"
|
||||
MinHeight="32"/>
|
||||
<RowDefinition x:Name="RowDisplay2"
|
||||
Height="56*"
|
||||
MinHeight="56"/>
|
||||
<RowDefinition x:Name="RowUnit2"
|
||||
Height="32*"
|
||||
MinHeight="32"/>
|
||||
<RowDefinition x:Name="RowDltrUnits"
|
||||
Height="Auto"
|
||||
MinHeight="48"/>
|
||||
<RowDefinition x:Name="RowNumPad" Height="272*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="GutterLeft" Width="0"/>
|
||||
<ColumnDefinition x:Name="ColumnLeft" Width="1*"/>
|
||||
<ColumnDefinition x:Name="ColumnRight" Width="0"/>
|
||||
<ColumnDefinition x:Name="GutterRight" Width="0"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- End ConverterNumPad -->
|
||||
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="Layout">
|
||||
<VisualState x:Name="PortraitLayout"/>
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<triggers:ApplicationViewModeTrigger ViewMode="DoubleLandscape"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="Pane2Panel.Margin" Value="12"/>
|
||||
<Setter Target="Pane1Panel.Margin" Value="24,48,0,48"/>
|
||||
<Setter Target="SupplementaryResults.VerticalAlignment" Value="Top"/>
|
||||
<Setter Target="Value1.Style" Value="{ThemeResource ValueLargeStyle}"/>
|
||||
<Setter Target="Value2.Style" Value="{ThemeResource ValueLargeStyle}"/>
|
||||
<Setter Target="CurrencySymbol1Block.Style" Value="{ThemeResource CurrencySymbolLargeStyle}"/>
|
||||
<Setter Target="CurrencySymbol2Block.Style" Value="{ThemeResource CurrencySymbolLargeStyle}"/>
|
||||
<Setter Target="Units1.Height" Value="44"/>
|
||||
<Setter Target="Units2.Height" Value="44"/>
|
||||
<Setter Target="ConverterNegateButton.FontSize" Value="{StaticResource CalcStandardOperatorCaptionSize}"/>
|
||||
<Setter Target="ClearEntryButtonPos0.FontSize" Value="{StaticResource CalcStandardOperatorCaptionSize}"/>
|
||||
<Setter Target="NumberPad.ButtonStyle" Value="{StaticResource NumericButtonStyle34}"/>
|
||||
<Setter Target="SupplementaryResultsPanelInGrid.Padding" Value="12,0"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<triggers:ApplicationViewModeTrigger ViewMode="DoublePortrait"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="Pane2Panel.Margin" Value="12"/>
|
||||
<Setter Target="Pane1Panel.Margin" Value="24,48,0,0"/>
|
||||
<Setter Target="RowDisplay1.Height" Value="4*"/>
|
||||
<Setter Target="RowUnit1.Height" Value="2*"/>
|
||||
<Setter Target="RowDisplay2.Height" Value="4*"/>
|
||||
<Setter Target="RowUnit2.Height" Value="2*"/>
|
||||
<Setter Target="RowDltrUnits.Height" Value="2*"/>
|
||||
<Setter Target="ConverterNumPad.(Grid.Row)" Value="1"/>
|
||||
<Setter Target="ConverterNumPad.(Grid.RowSpan)" Value="5"/>
|
||||
<Setter Target="SupplementaryResults.VerticalAlignment" Value="Top"/>
|
||||
<Setter Target="Pane2RowTopNav.Height" Value="{StaticResource HamburgerHeightGridLength}"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="LandscapeLayout">
|
||||
<VisualState.StateTriggers>
|
||||
<triggers:AspectRatioTrigger ActiveIfEqual="True"
|
||||
|
@ -315,23 +326,21 @@
|
|||
Threshold="1"/>
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="GutterLeft.Width" Value="48"/>
|
||||
<Setter Target="GutterRight.Width" Value="48"/>
|
||||
<Setter Target="ColumnLeft.Width" Value="1*"/>
|
||||
<Setter Target="ColumnRight.Width" Value="1*"/>
|
||||
<Setter Target="TwoPaneView.MinWideModeWidth" Value="0"/>
|
||||
<Setter Target="TwoPaneView.MinTallModeHeight" Value="Infinity"/>
|
||||
<Setter Target="TwoPaneView.Pane1Length" Value="*"/>
|
||||
<Setter Target="TwoPaneView.Pane1MinLength" Value="0"/>
|
||||
<Setter Target="TwoPaneView.Pane2Length" Value="*"/>
|
||||
<Setter Target="RowDisplay1.Height" Value="4*"/>
|
||||
<Setter Target="RowUnit1.Height" Value="2*"/>
|
||||
<Setter Target="RowDisplay2.Height" Value="4*"/>
|
||||
<Setter Target="RowUnit2.Height" Value="2*"/>
|
||||
<Setter Target="RowDltrUnits.Height" Value="2*"/>
|
||||
<Setter Target="CurrencyLoadingGrid.(Grid.ColumnSpan)" Value="2"/>
|
||||
<Setter Target="ConverterNumPad.(Grid.Row)" Value="1"/>
|
||||
<Setter Target="ConverterNumPad.(Grid.RowSpan)" Value="5"/>
|
||||
<Setter Target="ConverterNumPad.(Grid.Column)" Value="2"/>
|
||||
<Setter Target="ConverterNumPad.(Grid.ColumnSpan)" Value="2"/>
|
||||
<Setter Target="SupplementaryResults.VerticalAlignment" Value="Top"/>
|
||||
<Setter Target="RowNumPad.MinHeight" Value="0"/>
|
||||
<Setter Target="RowNumPad.Height" Value="0"/>
|
||||
<Setter Target="Pane2RowTopNav.Height" Value="{StaticResource HamburgerHeightGridLength}"/>
|
||||
<Setter Target="Pane1Panel.Margin" Value="48,0,0,0"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
@ -400,7 +409,6 @@
|
|||
<Setter Target="ClearEntryButtonPos0.Margin" Value="1"/>
|
||||
<Setter Target="BackSpaceButtonSmall.Margin" Value="1"/>
|
||||
<Setter Target="ConverterNegateButton.Margin" Value="1"/>
|
||||
|
||||
<Setter Target="NumberPad.ButtonStyle" Value="{StaticResource NumericButtonStyle18}"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
@ -437,8 +445,8 @@
|
|||
<VisualState.Setters>
|
||||
<Setter Target="CurrencySymbol1Block.Padding" Value="0,0,12,0"/>
|
||||
<Setter Target="CurrencySymbol2Block.Padding" Value="0,0,12,0"/>
|
||||
<Setter Target="CurrencySymbol1Block.(Grid.Column)" Value="2"/>
|
||||
<Setter Target="CurrencySymbol2Block.(Grid.Column)" Value="2"/>
|
||||
<Setter Target="CurrencySymbol1Block.(Grid.Column)" Value="1"/>
|
||||
<Setter Target="CurrencySymbol2Block.(Grid.Column)" Value="1"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
@ -506,11 +514,36 @@
|
|||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
|
||||
<controls:TwoPaneViewCX x:Name="TwoPaneView"
|
||||
MinTallModeHeight="0"
|
||||
MinWideModeWidth="Infinity"
|
||||
Pane1Length="16*"
|
||||
Pane1MinLength="260"
|
||||
Pane2Length="18*">
|
||||
<controls:TwoPaneViewCX.Pane1>
|
||||
<Grid x:Name="Pane1Panel">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition x:Name="RowTopNav" Height="{StaticResource HamburgerHeightGridLength}"/>
|
||||
<RowDefinition x:Name="RowDisplay1"
|
||||
Height="56*"
|
||||
MinHeight="56"/>
|
||||
<RowDefinition x:Name="RowUnit1"
|
||||
Height="32*"
|
||||
MinHeight="32"/>
|
||||
<RowDefinition x:Name="RowDisplay2"
|
||||
Height="56*"
|
||||
MinHeight="56"/>
|
||||
<RowDefinition x:Name="RowUnit2"
|
||||
Height="32*"
|
||||
MinHeight="32"/>
|
||||
<RowDefinition x:Name="RowDltrUnits"
|
||||
Height="Auto"
|
||||
MinHeight="48"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="CurrencyLoadingGrid"
|
||||
Grid.Row="1"
|
||||
Grid.RowSpan="5"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="4">
|
||||
Visibility="Collapsed">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="10*"/>
|
||||
<RowDefinition Height="7*"/>
|
||||
|
@ -528,7 +561,6 @@
|
|||
|
||||
<Grid x:Name="Value1Container"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{x:Bind FlowDirectionHorizontalAlignment}"
|
||||
Style="{ThemeResource ValueContainerStyle}">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
@ -560,7 +592,6 @@
|
|||
|
||||
<ComboBox x:Name="Units1"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{x:Bind FlowDirectionHorizontalAlignment}"
|
||||
Style="{ThemeResource ComboStyle}"
|
||||
AutomationProperties.AutomationId="Units1"
|
||||
|
@ -577,7 +608,6 @@
|
|||
|
||||
<Grid x:Name="Value2Container"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{x:Bind FlowDirectionHorizontalAlignment}"
|
||||
Style="{ThemeResource ValueContainerStyle}">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
@ -610,7 +640,6 @@
|
|||
|
||||
<ComboBox x:Name="Units2"
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{x:Bind FlowDirectionHorizontalAlignment}"
|
||||
Style="{ThemeResource ComboStyle}"
|
||||
AutomationProperties.AutomationId="Units2"
|
||||
|
@ -626,7 +655,6 @@
|
|||
|
||||
<StackPanel x:Name="SupplementaryResultsPanelInGrid"
|
||||
Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
MinHeight="48"
|
||||
Padding="12,0,6,0"
|
||||
HorizontalAlignment="{x:Bind FlowDirectionHorizontalAlignment}"
|
||||
|
@ -686,10 +714,16 @@
|
|||
</ContentControl>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</controls:TwoPaneViewCX.Pane1>
|
||||
<controls:TwoPaneViewCX.Pane2>
|
||||
<Grid x:Name="Pane2Panel">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition x:Name="Pane2RowTopNav" Height="0"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="ConverterNumPad"
|
||||
Grid.Row="6"
|
||||
Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
Margin="3,0,3,3"
|
||||
FlowDirection="LeftToRight"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
|
@ -759,6 +793,8 @@
|
|||
TabIndex="6"
|
||||
Visibility="{x:Bind Model.CurrentCategory.NegateVisibility, Mode=OneWay}"/>
|
||||
</Grid>
|
||||
<!-- End ConverterNumPad -->
|
||||
</Grid>
|
||||
</controls:TwoPaneViewCX.Pane2>
|
||||
</controls:TwoPaneViewCX>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "Converters/VisibilityNegationConverter.h"
|
||||
#include "CalcViewModel/UnitConverterViewModel.h"
|
||||
#include "Views/StateTriggers/AspectRatioTrigger.h"
|
||||
#include "Views/StateTriggers/ApplicationViewModeTrigger.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.UI.Xaml" version="2.2.190830001" targetFramework="native" />
|
||||
<package id="Microsoft.UI.Xaml" version="2.3.200213001" targetFramework="native" />
|
||||
<package id="Microsoft.WindowsCalculator.PGO" version="1.0.2" targetFramework="native" />
|
||||
</packages>
|
|
@ -41,6 +41,7 @@
|
|||
#include "winrt/Windows.System.UserProfile.h"
|
||||
#include "winrt/Windows.UI.ViewManagement.h"
|
||||
#include "winrt/Windows.UI.Xaml.h"
|
||||
#include "winrt/Windows.System.Profile.h"
|
||||
#include "winrt/Windows.Foundation.h"
|
||||
|
||||
// Project Headers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue