Add Graph Settings (#879)

This commit is contained in:
Rudy Huyn
2020-01-03 15:06:14 -08:00
committed by GitHub
parent 234ac8deb3
commit 8357f5d5c5
35 changed files with 1882 additions and 195 deletions

View File

@@ -226,7 +226,7 @@
<AppVersion Condition="'$(AppVersion)' == ''">0.0.0.0</AppVersion>
</PropertyGroup>
<PropertyGroup>
<GenerateProjectSpecificOutputFolder>true</GenerateProjectSpecificOutputFolder>
<GenerateProjectSpecificOutputFolder>true</GenerateProjectSpecificOutputFolder>
</PropertyGroup>
<ItemGroup>
<ResourceCompile Include="Calculator.rc" PreprocessorDefinitions="%(PreprocessorDefinitions);APP_VERSION_MAJOR=$(AppVersion.Split(`.`)[0]);APP_VERSION_MINOR=$(AppVersion.Split(`.`)[1]);APP_VERSION_BUILD=$(AppVersion.Split(`.`)[2]);APP_VERSION_REVISION=$(AppVersion.Split(`.`)[3])" />
@@ -296,6 +296,9 @@
<ClInclude Include="Views\GraphingCalculator\GraphingCalculator.xaml.h">
<DependentUpon>Views\GraphingCalculator\GraphingCalculator.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="Views\GraphingCalculator\GraphingSettings.xaml.h">
<DependentUpon>Views\GraphingCalculator\GraphingSettings.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="Views\GraphingCalculator\KeyGraphFeaturesPanel.xaml.h">
<DependentUpon>Views\GraphingCalculator\KeyGraphFeaturesPanel.xaml</DependentUpon>
</ClInclude>
@@ -363,8 +366,9 @@
<Page Include="Views\DelighterUnitStyles.xaml" />
<Page Include="Views\GraphingCalculator\EquationInputArea.xaml" />
<Page Include="Views\GraphingCalculator\GraphingCalculator.xaml" />
<Page Include="Views\GraphingCalculator\GraphingSettings.xaml" />
<Page Include="Views\GraphingCalculator\KeyGraphFeaturesPanel.xaml" />
<Page Include="Views\GraphingCalculator\GraphingNumPad.xaml"/>
<Page Include="Views\GraphingCalculator\GraphingNumPad.xaml" />
<Page Include="Views\HistoryList.xaml" />
<Page Include="Views\MainPage.xaml" />
<Page Include="Views\Memory.xaml" />
@@ -460,6 +464,9 @@
<ClCompile Include="Views\GraphingCalculator\GraphingCalculator.xaml.cpp">
<DependentUpon>Views\GraphingCalculator\GraphingCalculator.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="Views\GraphingCalculator\GraphingSettings.xaml.cpp">
<DependentUpon>Views\GraphingCalculator\GraphingSettings.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="Views\GraphingCalculator\KeyGraphFeaturesPanel.xaml.cpp">
<DependentUpon>Views\GraphingCalculator\KeyGraphFeaturesPanel.xaml</DependentUpon>
</ClCompile>
@@ -891,4 +898,4 @@
<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'))" />
</Target>
</Project>
</Project>

View File

@@ -509,6 +509,8 @@
<Page Include="Views\GraphingCalculator\KeyGraphFeaturesPanel.xaml">
<Filter>Views\GraphingCalculator</Filter>
</Page>
<Page Include="Views\GraphingCalculator\GraphingSettings.xaml">
<Filter>Views\GraphingCalculator</Filter>
<Page Include="Views\GraphingCalculator\GraphingNumPad.xaml">
<Filter>Views\GraphingCalculator</Filter>
</Page>

View File

@@ -4202,12 +4202,60 @@
<value>Current mode is graph mode</value>
<comment>Announcement used in Graphing Calculator when switching to the graph mode</comment>
</data>
<data name="GridHeading.Text" xml:space="preserve">
<value>Grid</value>
<comment>Heading for grid extents on the settings </comment>
</data>
<data name="TrigModeDegrees.Content" xml:space="preserve">
<value>Degrees</value>
<comment>Degrees mode on settings page</comment>
</data>
<data name="TrigModeGradians.Content" xml:space="preserve">
<value>Gradians</value>
<comment>Gradian mode on settings page</comment>
</data>
<data name="TrigModeRadians.Content" xml:space="preserve">
<value>Radians</value>
<comment>Radians mode on settings page</comment>
</data>
<data name="UnitsHeading.Text" xml:space="preserve">
<value>Units</value>
<comment>Heading for Unit's on the settings</comment>
</data>
<data name="GraphSettingsXMax.Header" xml:space="preserve">
<value>X-Max</value>
<comment>X maximum value header</comment>
</data>
<data name="GraphSettingsXMin.Header" xml:space="preserve">
<value>X-Min</value>
<comment>X minimum value header</comment>
</data>
<data name="GraphSettingsYMax.Header" xml:space="preserve">
<value>Y-Max</value>
<comment>Y Maximum value header</comment>
</data>
<data name="GraphSettingsYMin.Header" xml:space="preserve">
<value>Y-Min</value>
<comment>Y minimum value header</comment>
</data>
<data name="equationMathRichEditBox.PlaceholderText" xml:space="preserve">
<value>Enter an equation</value>
<comment>Used in the Graphing Calculator to indicate to users that they can enter an equation in the textbox</comment>
</data>
<data name="graphSettingsButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Grid options</value>
<comment>This is the tooltip text for the grid options button in Graphing Calculator</comment>
</data>
<data name="graphSettingsButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Grid options</value>
<comment>This is the automation name text for the grid options button in Graphing Calculator</comment>
</data>
<data name="GraphOptionsHeading.Text" xml:space="preserve">
<value>Graph Options</value>
<comment>Heading for the Graph Options flyout in Graphing mode.</comment>
</data>
<data name="mathRichEditBox.PlaceholderText" xml:space="preserve">
<value>Enter an equation</value>
<comment>this is the placeholder text used by the textbox to enter an equation</comment>
</data>
</root>
</root>

View File

@@ -7,7 +7,6 @@
xmlns:graphControl="using:GraphControl"
xmlns:local="using:CalculatorApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:CalculatorApp.ViewModel"
x:Name="Control"
DataContextChanged="GraphingCalculator_DataContextChanged"
mc:Ignorable="d">
@@ -416,12 +415,23 @@
x:Uid="shareButton"
MinWidth="40"
Style="{ThemeResource ThemedGraphButtonStyle}"
contract7Present:CornerRadius="{ThemeResource RightButtonCornerRadius}"
Click="OnShareClick">
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}"
FontSize="18"
Glyph="&#xE72D;"/>
</Button>
<Button x:Name="GraphSettingsButton"
x:Uid="graphSettingsButton"
MinWidth="40"
Style="{ThemeResource ThemedGraphButtonStyle}"
contract7Present:CornerRadius="{ThemeResource RightButtonCornerRadius}"
Click="GraphSettingsButton_Click"
RequestedTheme="Light">
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}"
FontSize="18"
Glyph="&#xE3B4;"/>
</Button>
</StackPanel>
</Border>
<Border x:Name="TracePointer"
@@ -533,7 +543,7 @@
Variables="{x:Bind ViewModel.Variables}"
Visibility="{x:Bind IsKeyGraphFeaturesVisible, Converter={StaticResource BooleanToVisibilityNegationConverter}, Mode=OneWay}"/>
<local:GraphingNumPad x:Name="GraphingNumberPad"
<local:GraphingNumPad x:Name="GraphingNumPad"
Grid.Row="1"
Margin="2,0,2,2"
Visibility="{x:Bind IsKeyGraphFeaturesVisible, Converter={StaticResource BooleanToVisibilityNegationConverter}, Mode=OneWay}"/>

View File

@@ -15,6 +15,7 @@
#include "Calculator/Controls/EquationTextBox.h"
#include "Calculator/Views/GraphingCalculator/EquationInputArea.xaml.h"
#include "CalcViewModel/Common/Utils.h"
#include "GraphingSettings.xaml.h"
using namespace CalculatorApp;
using namespace CalculatorApp::Common;
@@ -42,6 +43,7 @@ using namespace Windows::UI::Xaml::Automation;
using namespace Windows::UI::Xaml::Automation::Peers;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Media::Imaging;
@@ -72,12 +74,12 @@ GraphingCalculator::GraphingCalculator()
// OemMinus and OemAdd aren't declared in the VirtualKey enum, we can't add this accelerator XAML-side
auto virtualKey = ref new KeyboardAccelerator();
virtualKey->Key = (VirtualKey)187; //OemMinus key
virtualKey->Key = (VirtualKey)189; // OemPlus key
virtualKey->Modifiers = VirtualKeyModifiers::Control;
ZoomOutButton->KeyboardAccelerators->Append(virtualKey);
virtualKey = ref new KeyboardAccelerator();
virtualKey->Key = (VirtualKey)189; //OemAdd key
virtualKey->Key = (VirtualKey)187; // OemAdd key
virtualKey->Modifiers = VirtualKeyModifiers::Control;
ZoomInButton->KeyboardAccelerators->Append(virtualKey);
}
@@ -161,7 +163,7 @@ void GraphingCalculator::OnEquationsVectorChanged(IObservableVector<EquationView
GraphingControl->PlotGraph();
}
void GraphingCalculator::OnTracePointChanged(Windows::Foundation::Point newPoint)
void GraphingCalculator::OnTracePointChanged(Point newPoint)
{
wstringstream traceValueString;
@@ -485,7 +487,7 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_Checked(Platform::Object ^
FocusManager::TryFocusAsync(GraphingControl, ::FocusState::Programmatic);
m_activeTracingKeyUpToken = Window::Current->CoreWindow->KeyUp +=
ref new Windows::Foundation::TypedEventHandler<Windows::UI::Core::CoreWindow ^, Windows::UI::Core::KeyEventArgs ^>(
ref new TypedEventHandler<Windows::UI::Core::CoreWindow ^, Windows::UI::Core::KeyEventArgs ^>(
this, &CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp);
KeyboardShortcutManager::IgnoreEscape(false);
@@ -519,3 +521,25 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp(Windows::UI::Core::C
args->Handled = true;
}
}
void GraphingCalculator::GraphSettingsButton_Click(Object ^ sender, RoutedEventArgs ^ e)
{
DisplayGraphSettings();
}
void GraphingCalculator::DisplayGraphSettings()
{
auto graphSettings = ref new GraphingSettings();
graphSettings->SetGrapher(this->GraphingControl);
auto flyoutGraphSettings = ref new Flyout();
flyoutGraphSettings->Content = graphSettings;
flyoutGraphSettings->Closing += ref new TypedEventHandler<FlyoutBase ^, FlyoutBaseClosingEventArgs ^>(this, &GraphingCalculator::OnSettingsFlyout_Closing);
flyoutGraphSettings->ShowAt(GraphSettingsButton);
}
void GraphingCalculator::OnSettingsFlyout_Closing(FlyoutBase ^ sender, FlyoutBaseClosingEventArgs ^ args)
{
auto flyout = static_cast<Flyout ^>(sender);
auto graphingSetting = static_cast<GraphingSettings ^>(flyout->Content);
args->Cancel = graphingSetting->CanBeClose();
}

View File

@@ -8,6 +8,7 @@
#include "Views\NumberPad.xaml.h"
#include "Views\GraphingCalculator\KeyGraphFeaturesPanel.xaml.h"
#include "Views\GraphingCalculator\GraphingNumPad.xaml.h"
#include "Views\GraphingCalculator\GraphingSettings.xaml.h"
namespace CalculatorApp
{
@@ -74,6 +75,10 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
void ActiveTracing_Unchecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void ActiveTracing_KeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args);
void ActiveTracing_PointerCaptureLost(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e);
void GraphSettingsButton_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void DisplayGraphSettings();
private:
Windows::Foundation::EventRegistrationToken m_dataRequestedToken;
Windows::Foundation::EventRegistrationToken m_vectorChangedToken;
@@ -81,6 +86,8 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
Windows::Foundation::EventRegistrationToken m_activeTracingKeyUpToken;
Windows::Foundation::EventRegistrationToken m_ActiveTracingPointerCaptureLost;
CalculatorApp::ViewModel::GraphingCalculatorViewModel ^ m_viewModel;
void
OnSettingsFlyout_Closing(Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender, Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args);
};
}

View File

@@ -0,0 +1,172 @@
<UserControl x:Class="CalculatorApp.GraphingSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:CalculatorApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="GraphSettingsErrorBackgroundBrush" Color="#33EB5757"/>
<SolidColorBrush x:Key="GraphSettingsErrorBorderBrush" Color="#FFEB5757"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="GraphSettingsErrorBackgroundBrush" Color="#33EB5757"/>
<SolidColorBrush x:Key="GraphSettingsErrorBorderBrush" Color="#FFEB5757"/>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="GraphSettingsErrorBackgroundBrush" Color="{ThemeResource SystemColorButtonFaceColor}"/>
<SolidColorBrush x:Key="GraphSettingsErrorBorderBrush" Color="Red"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<Style x:Key="TrigUnitsRadioButtonStyle" TargetType="RadioButton">
<Setter Property="MinHeight" Value="38"/>
<Setter Property="MinWidth" Value="90"/>
<Setter Property="Padding" Value="4,0"/>
<Setter Property="FocusVisualMargin" Value="0"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid Name="LayoutRoot" Background="{ThemeResource ToggleButtonBackground}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="LayoutRoot.Background" Value="{ThemeResource ToggleButtonBackgroundPointerOver}"/>
<Setter Target="AccessibilityBorder.BorderBrush" Value="{ThemeResource ToggleButtonBorderBrushPointerOver}"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Target="LayoutRoot.Background" Value="{ThemeResource ToggleButtonBackgroundPressed}"/>
<Setter Target="AccessibilityBorder.BorderBrush" Value="{ThemeResource ToggleButtonBorderBrushPressed}"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="CheckStates">
<VisualState x:Name="Checked">
<VisualState.Setters>
<Setter Target="SelectedBackgroundRectangle.Opacity" Value="1"/>
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource ToggleButtonForegroundChecked}"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Unchecked"/>
<VisualState x:Name="Indeterminate"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border Name="AccessibilityBorder"
BorderBrush="{ThemeResource ToggleButtonBorderBrush}"
BorderThickness="1"/>
<Rectangle Name="SelectedBackgroundRectangle"
Fill="{ThemeResource ToggleButtonBackgroundChecked}"
Opacity="0"/>
<ContentPresenter Name="ContentPresenter"
Grid.Column="1"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{TemplateBinding Foreground}"
AutomationProperties.AccessibilityView="Raw"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SubTitleTextBoxStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="16"/>
<Setter Property="FontWeight" Value="SemiBold"/>
</Style>
<Style x:Key="ErrorTextBoxStyle" TargetType="TextBox">
<Setter Property="BorderBrush" Value="{ThemeResource GraphSettingsErrorBorderBrush}"/>
<Setter Property="Background" Value="{ThemeResource GraphSettingsErrorBackgroundBrush}"/>
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<StackPanel Margin="4,0,4,4">
<TextBlock x:Name="GraphOptionsHeading"
x:Uid="GraphOptionsHeading"
FontSize="22"
AutomationProperties.HeadingLevel="Level1"/>
<TextBlock x:Name="GridHeading"
x:Uid="GridHeading"
Margin="0,12,0,6"
Style="{StaticResource SubTitleTextBoxStyle}"
AutomationProperties.HeadingLevel="Level2"/>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="10"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBox x:Name="SettingsXMin"
x:Uid="GraphSettingsXMin"
MaxWidth="160"
Style="{x:Bind SelectTextBoxStyle(ViewModel.XError, ViewModel.XMinError), Mode=OneWay}"
PreviewKeyDown="GridSettingsTextBox_PreviewKeyDown"
Text="{x:Bind ViewModel.XMin, Mode=TwoWay}"/>
<TextBox x:Name="SettingsXMax"
x:Uid="GraphSettingsXMax"
Grid.Column="2"
MaxWidth="160"
Style="{x:Bind SelectTextBoxStyle(ViewModel.XError, ViewModel.XMaxError), Mode=OneWay}"
PreviewKeyDown="GridSettingsTextBox_PreviewKeyDown"
Text="{x:Bind ViewModel.XMax, Mode=TwoWay}"/>
<TextBox x:Name="SettingsYMin"
x:Uid="GraphSettingsYMin"
Grid.Row="2"
MaxWidth="160"
Style="{x:Bind SelectTextBoxStyle(ViewModel.YError, ViewModel.YMinError), Mode=OneWay}"
PreviewKeyDown="GridSettingsTextBox_PreviewKeyDown"
Text="{x:Bind ViewModel.YMin, Mode=TwoWay}"/>
<TextBox x:Name="SettingsYMax"
x:Uid="GraphSettingsYMax"
Grid.Row="2"
Grid.Column="2"
MaxWidth="160"
Style="{x:Bind SelectTextBoxStyle(ViewModel.YError, ViewModel.YMaxError), Mode=OneWay}"
PreviewKeyDown="GridSettingsTextBox_PreviewKeyDown"
Text="{x:Bind ViewModel.YMax, Mode=TwoWay}"/>
</Grid>
<TextBlock x:Name="UnitsHeading"
x:Uid="UnitsHeading"
Margin="0,16,0,6"
Style="{StaticResource SubTitleTextBoxStyle}"
AutomationProperties.HeadingLevel="Level2"/>
<StackPanel Orientation="Horizontal">
<RadioButton x:Name="Radians"
x:Uid="TrigModeRadians"
Style="{StaticResource TrigUnitsRadioButtonStyle}"
IsChecked="{x:Bind ViewModel.TrigModeRadians, Mode=TwoWay}"/>
<RadioButton x:Name="Degrees"
x:Uid="TrigModeDegrees"
Margin="1,0"
Style="{StaticResource TrigUnitsRadioButtonStyle}"
IsChecked="{x:Bind ViewModel.TrigModeDegrees, Mode=TwoWay}"/>
<RadioButton x:Name="Gradians"
x:Uid="TrigModeGradians"
Style="{StaticResource TrigUnitsRadioButtonStyle}"
IsChecked="{x:Bind ViewModel.TrigModeGradians, Mode=TwoWay}"/>
</StackPanel>
</StackPanel>
</Grid>
</UserControl>

View File

@@ -0,0 +1,94 @@
#include "pch.h"
#include "GraphingSettings.xaml.h"
#include "CalcViewModel\Common\AppResourceProvider.cpp"
using namespace std;
using namespace Graphing;
using namespace GraphControl;
using namespace CalculatorApp;
using namespace CalculatorApp::ViewModel;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::System;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
GraphingSettings::GraphingSettings()
: m_ViewModel(ref new GraphingSettingsViewModel())
{
InitializeComponent();
}
void GraphingSettings::SetGrapher(Grapher ^ grapher)
{
m_ViewModel->SetGrapher(grapher);
}
Style ^ GraphingSettings::SelectTextBoxStyle(bool incorrectRange, bool error)
{
if (incorrectRange || error)
{
return static_cast<::Style ^>(this->Resources->Lookup(L"ErrorTextBoxStyle"));
}
else
{
return nullptr;
}
}
void GraphingSettings::GridSettingsTextBox_PreviewKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e)
{
if (e->Key == VirtualKey::Enter)
{
if (!FocusManager::TryMoveFocusAsync(FocusNavigationDirection::Next))
{
FocusManager::TryMoveFocusAsync(FocusNavigationDirection::Previous);
}
e->Handled = true;
}
}
bool GraphingSettings::CanBeClose()
{
auto focusedElement = FocusManager::GetFocusedElement();
// Move focus so we are sure all values are in sync with the VM
if (focusedElement != nullptr)
{
if (focusedElement->Equals(SettingsXMin))
{
auto textbox = static_cast<TextBox ^>(focusedElement);
ViewModel->XMin = textbox->Text;
}
else if (focusedElement->Equals(SettingsXMax))
{
auto textbox = static_cast<TextBox ^>(focusedElement);
ViewModel->XMax = textbox->Text;
}
else if (focusedElement->Equals(SettingsYMin))
{
auto textbox = static_cast<TextBox ^>(focusedElement);
ViewModel->YMin = textbox->Text;
}
else if (focusedElement->Equals(SettingsYMax))
{
auto textbox = static_cast<TextBox ^>(focusedElement);
ViewModel->YMax = textbox->Text;
}
}
return ViewModel != nullptr && ViewModel->HasError();
}
void GraphingSettings::RefreshRanges()
{
ViewModel->InitRanges();
}

View File

@@ -0,0 +1,28 @@
//
// MyUserControl.xaml.h
// Declaration of the MyUserControl class
//
#pragma once
#include "CalcViewModel/Common/Utils.h"
#include "CalcViewModel/GraphingCalculator/GraphingSettingsViewModel.h"
#include "Views\GraphingCalculator\GraphingSettings.g.h"
#include <CalcViewModel\GraphingCalculator\GraphingCalculatorViewModel.h>
namespace CalculatorApp
{
[Windows::Foundation::Metadata::WebHostHidden] public ref class GraphingSettings sealed
{
public:
GraphingSettings();
PROPERTY_R(CalculatorApp::ViewModel::GraphingSettingsViewModel ^, ViewModel);
Windows::UI::Xaml::Style ^ SelectTextBoxStyle(bool incorrectRange, bool error);
void SetGrapher(GraphControl::Grapher ^ grapher);
bool CanBeClose();
void RefreshRanges();
private:
void GridSettingsTextBox_PreviewKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e);
};
}