[Graph] Replace the Add button by a EquationTextBlock (#826)
* init * Replace the Add equation button by an EquationTextBox * Move automatically the focus to the next textbox when users press Enter * nit * localize the placeholder * rebase * rebased and disable remove context menu when the equation is the last one * replace storyboards by setters in visual states
This commit is contained in:
parent
f1bf3354c4
commit
07d012cf6b
@ -41,6 +41,7 @@ public
|
|||||||
OBSERVABLE_OBJECT();
|
OBSERVABLE_OBJECT();
|
||||||
OBSERVABLE_PROPERTY_R(GraphControl::Equation ^, GraphEquation);
|
OBSERVABLE_PROPERTY_R(GraphControl::Equation ^, GraphEquation);
|
||||||
OBSERVABLE_PROPERTY_RW(int, FunctionLabelIndex);
|
OBSERVABLE_PROPERTY_RW(int, FunctionLabelIndex);
|
||||||
|
OBSERVABLE_PROPERTY_RW(bool, IsLastItemInList);
|
||||||
|
|
||||||
property Platform::String ^ Expression
|
property Platform::String ^ Expression
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:Controls="using:CalculatorApp.Controls"
|
xmlns:Controls="using:CalculatorApp.Controls"
|
||||||
xmlns:common="using:CalculatorApp.Common"
|
xmlns:common="using:CalculatorApp.Common"
|
||||||
|
xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)"
|
||||||
xmlns:local="using:CalculatorApp">
|
xmlns:local="using:CalculatorApp">
|
||||||
|
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
@ -68,10 +69,10 @@
|
|||||||
FallbackColor="{ThemeResource SystemChromeMediumColor}"
|
FallbackColor="{ThemeResource SystemChromeMediumColor}"
|
||||||
TintColor="{ThemeResource SystemChromeLowColor}"
|
TintColor="{ThemeResource SystemChromeLowColor}"
|
||||||
TintOpacity="0.7"/>
|
TintOpacity="0.7"/>
|
||||||
|
<SolidColorBrush x:Key="EquationBoxAddBackgroundBrush" Color="#9d000000"/>
|
||||||
<SolidColorBrush x:Key="EquationBoxPointerOverBackgroundBrush" Color="{ThemeResource SystemControlBackgroundAltMediumBrush}"/>
|
<SolidColorBrush x:Key="EquationBoxPointerOverBackgroundBrush" Color="{ThemeResource SystemControlBackgroundAltMediumBrush}"/>
|
||||||
<SolidColorBrush x:Key="EquationBoxHoverButtonForegroundBrush" Color="{ThemeResource SystemBaseHighColor}"/>
|
<SolidColorBrush x:Key="EquationBoxHoverButtonForegroundBrush" Color="{ThemeResource SystemBaseHighColor}"/>
|
||||||
<SolidColorBrush x:Key="AppChromeAcrylicOperatorFlyoutBackgroundBrush" Color="#FF2F2F2F"/>
|
<SolidColorBrush x:Key="AppChromeAcrylicOperatorFlyoutBackgroundBrush" Color="#FF2F2F2F"/>
|
||||||
<SolidColorBrush x:Key="EquationTextBoxTransparentBackgroundBrush" Color="Transparent"/>
|
|
||||||
<SolidColorBrush x:Key="EquationBoxBorderBrush" Color="{ThemeResource TextControlBackground}"/>
|
<SolidColorBrush x:Key="EquationBoxBorderBrush" Color="{ThemeResource TextControlBackground}"/>
|
||||||
<SolidColorBrush x:Key="EquationButtonOverlayBackgroundBrush" Color="White"/>
|
<SolidColorBrush x:Key="EquationButtonOverlayBackgroundBrush" Color="White"/>
|
||||||
<SolidColorBrush x:Key="EquationBoxErrorBackgroundBrush" Color="#33EB5757"/>
|
<SolidColorBrush x:Key="EquationBoxErrorBackgroundBrush" Color="#33EB5757"/>
|
||||||
@ -164,6 +165,7 @@
|
|||||||
FallbackColor="{ThemeResource SystemChromeMediumColor}"
|
FallbackColor="{ThemeResource SystemChromeMediumColor}"
|
||||||
TintColor="{ThemeResource SystemChromeLowColor}"
|
TintColor="{ThemeResource SystemChromeLowColor}"
|
||||||
TintOpacity="0.8"/>
|
TintOpacity="0.8"/>
|
||||||
|
<SolidColorBrush x:Key="EquationBoxAddBackgroundBrush" Color="#D0FFFFFF"/>
|
||||||
<SolidColorBrush x:Key="EquationBoxPointerOverBackgroundBrush" Color="{ThemeResource SystemControlBackgroundAltMediumBrush}"/>
|
<SolidColorBrush x:Key="EquationBoxPointerOverBackgroundBrush" Color="{ThemeResource SystemControlBackgroundAltMediumBrush}"/>
|
||||||
<SolidColorBrush x:Key="EquationBoxHoverButtonForegroundBrush" Color="{ThemeResource SystemBaseHighColor}"/>
|
<SolidColorBrush x:Key="EquationBoxHoverButtonForegroundBrush" Color="{ThemeResource SystemBaseHighColor}"/>
|
||||||
<SolidColorBrush x:Key="EquationBoxBorderBrush" Color="{ThemeResource TextControlBackground}"/>
|
<SolidColorBrush x:Key="EquationBoxBorderBrush" Color="{ThemeResource TextControlBackground}"/>
|
||||||
@ -222,6 +224,7 @@
|
|||||||
<SolidColorBrush x:Key="AppControlHighlightCalcButtonBrush" Color="{ThemeResource SystemColorWindowColor}"/>
|
<SolidColorBrush x:Key="AppControlHighlightCalcButtonBrush" Color="{ThemeResource SystemColorWindowColor}"/>
|
||||||
<SolidColorBrush x:Key="AppControlHighlightCalcButtonToggledBrush" Color="{ThemeResource SystemColorHighlightColor}"/>
|
<SolidColorBrush x:Key="AppControlHighlightCalcButtonToggledBrush" Color="{ThemeResource SystemColorHighlightColor}"/>
|
||||||
<SolidColorBrush x:Key="AppControlHighlightCalcButtonHoverBrush" Color="{ThemeResource SystemColorHighlightColor}"/>
|
<SolidColorBrush x:Key="AppControlHighlightCalcButtonHoverBrush" Color="{ThemeResource SystemColorHighlightColor}"/>
|
||||||
|
<SolidColorBrush x:Key="EquationBoxAddBackgroundBrush" Color="{ThemeResource SystemColorButtonFaceColor}"/>
|
||||||
<SolidColorBrush x:Key="EquationBoxPointerOverBackgroundBrush" Color="{ThemeResource SystemColorHighlightColor}"/>
|
<SolidColorBrush x:Key="EquationBoxPointerOverBackgroundBrush" Color="{ThemeResource SystemColorHighlightColor}"/>
|
||||||
<SolidColorBrush x:Key="EquationBoxHoverButtonForegroundBrush" Color="{ThemeResource SystemColorCaptionTextColor}"/>
|
<SolidColorBrush x:Key="EquationBoxHoverButtonForegroundBrush" Color="{ThemeResource SystemColorCaptionTextColor}"/>
|
||||||
<SolidColorBrush x:Key="EquationBoxBorderBrush" Color="{ThemeResource SystemColorButtonTextColor}"/>
|
<SolidColorBrush x:Key="EquationBoxBorderBrush" Color="{ThemeResource SystemColorButtonTextColor}"/>
|
||||||
@ -1856,7 +1859,6 @@
|
|||||||
AutomationProperties.AccessibilityView="Raw"
|
AutomationProperties.AccessibilityView="Raw"
|
||||||
Content="{TemplateBinding Description}"
|
Content="{TemplateBinding Description}"
|
||||||
x:Load="False"/>
|
x:Load="False"/>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
@ -1890,155 +1892,71 @@
|
|||||||
|
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
<VisualStateGroup x:Name="CommonStates">
|
<VisualStateGroup x:Name="CommonStates">
|
||||||
|
|
||||||
<VisualState x:Name="Normal">
|
<VisualState x:Name="Normal">
|
||||||
<Storyboard>
|
<VisualState.Setters>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationBoxBorder" Storyboard.TargetProperty="BorderBrush">
|
<Setter Target="EquationBoxBorder.BorderBrush" Value="{ThemeResource EquationBoxBorderBrush}"/>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource EquationBoxBorderBrush}"/>
|
</VisualState.Setters>
|
||||||
</ObjectAnimationUsingKeyFrames>
|
</VisualState>
|
||||||
</Storyboard>
|
<VisualState x:Name="AddEquation">
|
||||||
|
<VisualState.Setters>
|
||||||
|
<Setter Target="RemoveButtonPanel.Visibility" Value="Collapsed"/>
|
||||||
|
<Setter Target="MathRichEditBox.PlaceholderText" Value="Enter an equation"/>
|
||||||
|
<Setter Target="EquationBoxBorder.Background" Value="{ThemeResource EquationBoxAddBackgroundBrush}"/>
|
||||||
|
<Setter Target="EquationBoxBorder.BorderBrush" Value="{ThemeResource EquationBoxBorderBrush}"/>
|
||||||
|
</VisualState.Setters>
|
||||||
</VisualState>
|
</VisualState>
|
||||||
|
|
||||||
<VisualState x:Name="Error">
|
<VisualState x:Name="Error">
|
||||||
<Storyboard>
|
<VisualState.Setters>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationBoxBorder" Storyboard.TargetProperty="BorderBrush">
|
<Setter Target="EquationBoxBorder.BorderBrush" Value="{ThemeResource EquationBoxErrorBorderBrush}"/>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource EquationBoxErrorBorderBrush}"/>
|
<Setter Target="EquationBoxBorder.Background" Value="{ThemeResource EquationBoxErrorBackgroundBrush}"/>
|
||||||
</ObjectAnimationUsingKeyFrames>
|
<Setter Target="ErrorIcon.Visibility" Value="Visible"/>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationBoxBorder" Storyboard.TargetProperty="Background">
|
</VisualState.Setters>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource EquationBoxErrorBackgroundBrush}"/>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ErrorIcon" Storyboard.TargetProperty="Visibility">
|
|
||||||
<DiscreteObjectKeyFrame KeyTime="0">
|
|
||||||
<DiscreteObjectKeyFrame.Value>
|
|
||||||
<Visibility>Visible</Visibility>
|
|
||||||
</DiscreteObjectKeyFrame.Value>
|
|
||||||
</DiscreteObjectKeyFrame>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
</Storyboard>
|
|
||||||
</VisualState>
|
</VisualState>
|
||||||
|
|
||||||
<VisualState x:Name="PointerOver">
|
<VisualState x:Name="PointerOver">
|
||||||
|
<VisualState.Setters>
|
||||||
<Storyboard>
|
<Setter Target="EquationBoxBorder.BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor}"/>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationBoxBorder" Storyboard.TargetProperty="BorderBrush">
|
<Setter Target="ColorChooserButton.Visibility" Value="Visible"/>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor}"/>
|
<Setter Target="FunctionButton.Visibility" Value="Visible"/>
|
||||||
</ObjectAnimationUsingKeyFrames>
|
<Setter Target="RemoveButton.Visibility" Value="Visible"/>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ColorChooserButton" Storyboard.TargetProperty="Visibility">
|
<Setter Target="ErrorIcon.Visibility" Value="Collapsed"/>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0">
|
</VisualState.Setters>
|
||||||
<DiscreteObjectKeyFrame.Value>
|
|
||||||
<Visibility>Visible</Visibility>
|
|
||||||
</DiscreteObjectKeyFrame.Value>
|
|
||||||
</DiscreteObjectKeyFrame>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="FunctionButton" Storyboard.TargetProperty="Visibility">
|
|
||||||
<DiscreteObjectKeyFrame KeyTime="0">
|
|
||||||
<DiscreteObjectKeyFrame.Value>
|
|
||||||
<Visibility>Visible</Visibility>
|
|
||||||
</DiscreteObjectKeyFrame.Value>
|
|
||||||
</DiscreteObjectKeyFrame>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RemoveButton" Storyboard.TargetProperty="Visibility">
|
|
||||||
<DiscreteObjectKeyFrame KeyTime="0">
|
|
||||||
<DiscreteObjectKeyFrame.Value>
|
|
||||||
<Visibility>Visible</Visibility>
|
|
||||||
</DiscreteObjectKeyFrame.Value>
|
|
||||||
</DiscreteObjectKeyFrame>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ErrorIcon" Storyboard.TargetProperty="Visibility">
|
|
||||||
<DiscreteObjectKeyFrame KeyTime="0">
|
|
||||||
<DiscreteObjectKeyFrame.Value>
|
|
||||||
<Visibility>Collapsed</Visibility>
|
|
||||||
</DiscreteObjectKeyFrame.Value>
|
|
||||||
</DiscreteObjectKeyFrame>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
</Storyboard>
|
|
||||||
</VisualState>
|
</VisualState>
|
||||||
|
|
||||||
<VisualState x:Name="PointerOverError">
|
<VisualState x:Name="PointerOverError">
|
||||||
|
<VisualState.Setters>
|
||||||
<Storyboard>
|
<Setter Target="EquationBoxBorder.BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor}"/>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationBoxBorder" Storyboard.TargetProperty="BorderBrush">
|
<Setter Target="EquationBoxBorder.Background" Value="{ThemeResource EquationBoxErrorBackgroundBrush}"/>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor}"/>
|
<Setter Target="ColorChooserButton.Visibility" Value="Visible"/>
|
||||||
</ObjectAnimationUsingKeyFrames>
|
<Setter Target="FunctionButton.Visibility" Value="Collapsed"/>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationBoxBorder" Storyboard.TargetProperty="Background">
|
<Setter Target="RemoveButton.Visibility" Value="Visible"/>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource EquationBoxErrorBackgroundBrush}"/>
|
<Setter Target="ErrorIcon.Visibility" Value="Collapsed"/>
|
||||||
</ObjectAnimationUsingKeyFrames>
|
</VisualState.Setters>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ColorChooserButton" Storyboard.TargetProperty="Visibility">
|
|
||||||
<DiscreteObjectKeyFrame KeyTime="0">
|
|
||||||
<DiscreteObjectKeyFrame.Value>
|
|
||||||
<Visibility>Visible</Visibility>
|
|
||||||
</DiscreteObjectKeyFrame.Value>
|
|
||||||
</DiscreteObjectKeyFrame>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="FunctionButton" Storyboard.TargetProperty="Visibility">
|
|
||||||
<DiscreteObjectKeyFrame KeyTime="0">
|
|
||||||
<DiscreteObjectKeyFrame.Value>
|
|
||||||
<Visibility>Collapsed</Visibility>
|
|
||||||
</DiscreteObjectKeyFrame.Value>
|
|
||||||
</DiscreteObjectKeyFrame>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RemoveButton" Storyboard.TargetProperty="Visibility">
|
|
||||||
<DiscreteObjectKeyFrame KeyTime="0">
|
|
||||||
<DiscreteObjectKeyFrame.Value>
|
|
||||||
<Visibility>Visible</Visibility>
|
|
||||||
</DiscreteObjectKeyFrame.Value>
|
|
||||||
</DiscreteObjectKeyFrame>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ErrorIcon" Storyboard.TargetProperty="Visibility">
|
|
||||||
<DiscreteObjectKeyFrame KeyTime="0">
|
|
||||||
<DiscreteObjectKeyFrame.Value>
|
|
||||||
<Visibility>Collapsed</Visibility>
|
|
||||||
</DiscreteObjectKeyFrame.Value>
|
|
||||||
</DiscreteObjectKeyFrame>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
</Storyboard>
|
|
||||||
</VisualState>
|
</VisualState>
|
||||||
|
|
||||||
<VisualState x:Name="Disabled">
|
<VisualState x:Name="Disabled">
|
||||||
<Storyboard>
|
<VisualState.Setters>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationBoxBorder" Storyboard.TargetProperty="Background">
|
<Setter Target="EquationBoxBorder.Background" Value="{ThemeResource TextBoxDisabledBackgroundThemeBrush}"/>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledBackgroundThemeBrush}"/>
|
<Setter Target="EquationBoxBorder.BorderBrush" Value="{ThemeResource TextBoxDisabledBorderThemeBrush}"/>
|
||||||
</ObjectAnimationUsingKeyFrames>
|
<Setter Target="EquationTextBox.Background" Value="{ThemeResource AppControlTransparentButtonBackgroundBrush}"/>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationBoxBorder" Storyboard.TargetProperty="BorderBrush">
|
</VisualState.Setters>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledBorderThemeBrush}"/>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationTextBox" Storyboard.TargetProperty="Background">
|
|
||||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppControlTransparentButtonBackgroundBrush}"/>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
</Storyboard>
|
|
||||||
</VisualState>
|
</VisualState>
|
||||||
|
|
||||||
<VisualState x:Name="Focused">
|
<VisualState x:Name="Focused">
|
||||||
<Storyboard>
|
<VisualState.Setters>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationBoxBorder" Storyboard.TargetProperty="BorderBrush">
|
<Setter Target="EquationBoxBorder.BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor}"/>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor}"/>
|
<Setter Target="EquationBoxBorder.Background" Value="{ThemeResource TextBoxBackgroundThemeBrush}"/>
|
||||||
</ObjectAnimationUsingKeyFrames>
|
</VisualState.Setters>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationBoxBorder" Storyboard.TargetProperty="Background">
|
|
||||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxBackgroundThemeBrush}"/>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
</Storyboard>
|
|
||||||
</VisualState>
|
</VisualState>
|
||||||
|
|
||||||
</VisualStateGroup>
|
</VisualStateGroup>
|
||||||
|
|
||||||
<VisualStateGroup x:Name="ButtonStates">
|
<VisualStateGroup x:Name="ButtonStates">
|
||||||
<VisualState x:Name="ButtonVisible">
|
<VisualState x:Name="ButtonVisible">
|
||||||
<Storyboard>
|
<VisualState.Setters>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DeleteButton" Storyboard.TargetProperty="Visibility">
|
<Setter Target="DeleteButton.Visibility" Value="Visible"/>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0">
|
<Setter Target="ErrorIcon.Visibility" Value="Collapsed"/>
|
||||||
<DiscreteObjectKeyFrame.Value>
|
</VisualState.Setters>
|
||||||
<Visibility>Visible</Visibility>
|
</VisualState>
|
||||||
</DiscreteObjectKeyFrame.Value>
|
<VisualState x:Name="ButtonHideRemove">
|
||||||
</DiscreteObjectKeyFrame>
|
<VisualState.Setters>
|
||||||
</ObjectAnimationUsingKeyFrames>
|
<Setter Target="RemoveButtonPanel.Visibility" Value="Collapsed"/>
|
||||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ErrorIcon" Storyboard.TargetProperty="Visibility">
|
<Setter Target="RemoveFunctionMenuItem.IsEnabled" Value="False"/>
|
||||||
<DiscreteObjectKeyFrame KeyTime="0">
|
</VisualState.Setters>
|
||||||
<DiscreteObjectKeyFrame.Value>
|
|
||||||
<Visibility>Collapsed</Visibility>
|
|
||||||
</DiscreteObjectKeyFrame.Value>
|
|
||||||
</DiscreteObjectKeyFrame>
|
|
||||||
</ObjectAnimationUsingKeyFrames>
|
|
||||||
</Storyboard>
|
|
||||||
</VisualState>
|
</VisualState>
|
||||||
<VisualState x:Name="ButtonCollapsed"/>
|
<VisualState x:Name="ButtonCollapsed"/>
|
||||||
</VisualStateGroup>
|
</VisualStateGroup>
|
||||||
@ -2158,8 +2076,8 @@
|
|||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Background="{ThemeResource TextControlBackground}"
|
Background="{ThemeResource TextControlBackground}"
|
||||||
BorderBrush="{TemplateBinding EquationColor}"
|
BorderBrush="{TemplateBinding EquationColor}"
|
||||||
BorderThickness="{TemplateBinding BorderThickness}">
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
contract7Present:BackgroundSizing="OuterBorderEdge">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
@ -2218,28 +2136,29 @@
|
|||||||
Visibility="Collapsed"/>
|
Visibility="Collapsed"/>
|
||||||
<FontIcon x:Name="ErrorIcon"
|
<FontIcon x:Name="ErrorIcon"
|
||||||
Grid.Column="3"
|
Grid.Column="3"
|
||||||
MinWidth="34"
|
MinWidth="28"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
AutomationProperties.AccessibilityView="Raw"
|
AutomationProperties.AccessibilityView="Raw"
|
||||||
Glyph=""
|
Glyph=""
|
||||||
Visibility="Collapsed"/>
|
Visibility="Collapsed"/>
|
||||||
<Button x:Name="RemoveButton"
|
<Grid x:Name="RemoveButtonPanel" Grid.Column="3">
|
||||||
x:Uid="removeButton"
|
<Button x:Name="RemoveButton"
|
||||||
Grid.Column="3"
|
x:Uid="removeButton"
|
||||||
MinWidth="34"
|
MinWidth="34"
|
||||||
Margin="{ThemeResource HelperButtonThemePadding}"
|
Margin="{ThemeResource HelperButtonThemePadding}"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
Style="{StaticResource EquationTextBoxButtonStyle}"
|
Style="{StaticResource EquationTextBoxButtonStyle}"
|
||||||
Background="{TemplateBinding EquationColor}"
|
Background="{TemplateBinding EquationColor}"
|
||||||
Foreground="{TemplateBinding EquationColor}"
|
Foreground="{TemplateBinding EquationColor}"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
FontFamily="{StaticResource CalculatorFontFamily}"
|
FontFamily="{StaticResource CalculatorFontFamily}"
|
||||||
AutomationProperties.AccessibilityView="Raw"
|
AutomationProperties.AccessibilityView="Raw"
|
||||||
Content=""
|
Content=""
|
||||||
IsTabStop="False"
|
IsTabStop="False"
|
||||||
Visibility="Collapsed"/>
|
Visibility="Collapsed"/>
|
||||||
|
</Grid>
|
||||||
<ToggleButton x:Name="ColorChooserButton"
|
<ToggleButton x:Name="ColorChooserButton"
|
||||||
x:Uid="colorChooserButton"
|
x:Uid="colorChooserButton"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
|
@ -262,6 +262,7 @@
|
|||||||
<DependentUpon>EquationStylePanelControl.xaml</DependentUpon>
|
<DependentUpon>EquationStylePanelControl.xaml</DependentUpon>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="TemplateSelectors\KeyGraphFeaturesTemplateSelector.h" />
|
<ClInclude Include="TemplateSelectors\KeyGraphFeaturesTemplateSelector.h" />
|
||||||
|
<ClInclude Include="Utils\VisualTree.h" />
|
||||||
<ClInclude Include="Views\Calculator.xaml.h">
|
<ClInclude Include="Views\Calculator.xaml.h">
|
||||||
<DependentUpon>Views\Calculator.xaml</DependentUpon>
|
<DependentUpon>Views\Calculator.xaml</DependentUpon>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -425,6 +426,7 @@
|
|||||||
<DependentUpon>EquationStylePanelControl.xaml</DependentUpon>
|
<DependentUpon>EquationStylePanelControl.xaml</DependentUpon>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="TemplateSelectors\KeyGraphFeaturesTemplateSelector.cpp" />
|
<ClCompile Include="TemplateSelectors\KeyGraphFeaturesTemplateSelector.cpp" />
|
||||||
|
<ClCompile Include="Utils\VisualTree.cpp" />
|
||||||
<ClCompile Include="Views\Calculator.xaml.cpp">
|
<ClCompile Include="Views\Calculator.xaml.cpp">
|
||||||
<DependentUpon>Views\Calculator.xaml</DependentUpon>
|
<DependentUpon>Views\Calculator.xaml</DependentUpon>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -221,6 +221,9 @@
|
|||||||
<Filter Include="Views\GraphingCalculator">
|
<Filter Include="Views\GraphingCalculator">
|
||||||
<UniqueIdentifier>{e23e2a6e-491b-4200-9bf7-d355a1ee695b}</UniqueIdentifier>
|
<UniqueIdentifier>{e23e2a6e-491b-4200-9bf7-d355a1ee695b}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Utils">
|
||||||
|
<UniqueIdentifier>{b491a249-26b8-4814-9f50-2c3a57018c56}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ApplicationDefinition Include="App.xaml" />
|
<ApplicationDefinition Include="App.xaml" />
|
||||||
@ -321,6 +324,9 @@
|
|||||||
<Filter>Views\GraphingCalculator</Filter>
|
<Filter>Views\GraphingCalculator</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="TemplateSelectors\KeyGraphFeaturesTemplateSelector.cpp" />
|
<ClCompile Include="TemplateSelectors\KeyGraphFeaturesTemplateSelector.cpp" />
|
||||||
|
<ClCompile Include="Utils\VisualTree.cpp">
|
||||||
|
<Filter>Utils</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
@ -421,6 +427,9 @@
|
|||||||
<Filter>Views\GraphingCalculator</Filter>
|
<Filter>Views\GraphingCalculator</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="TemplateSelectors\KeyGraphFeaturesTemplateSelector.h" />
|
<ClInclude Include="TemplateSelectors\KeyGraphFeaturesTemplateSelector.h" />
|
||||||
|
<ClInclude Include="Utils\VisualTree.h">
|
||||||
|
<Filter>Utils</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AppxManifest Include="Package.appxmanifest" />
|
<AppxManifest Include="Package.appxmanifest" />
|
||||||
@ -1551,7 +1560,5 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CopyFileToFolders Include="$(GraphingImplDll)" />
|
<CopyFileToFolders Include="$(GraphingImplDll)" />
|
||||||
<CopyFileToFolders Include="$(GraphingEngineDll)" />
|
<CopyFileToFolders Include="$(GraphingEngineDll)" />
|
||||||
<CopyFileToFolders Include="$(GraphingImplDll)" />
|
|
||||||
<CopyFileToFolders Include="$(GraphingEngineDll)" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -26,6 +26,11 @@ DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, EquationColor);
|
|||||||
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, ColorChooserFlyout);
|
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, ColorChooserFlyout);
|
||||||
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, EquationButtonContentIndex);
|
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, EquationButtonContentIndex);
|
||||||
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, HasError);
|
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, HasError);
|
||||||
|
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, IsAddEquationMode);
|
||||||
|
|
||||||
|
EquationTextBox::EquationTextBox()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void EquationTextBox::OnApplyTemplate()
|
void EquationTextBox::OnApplyTemplate()
|
||||||
{
|
{
|
||||||
@ -55,17 +60,17 @@ void EquationTextBox::OnApplyTemplate()
|
|||||||
{
|
{
|
||||||
m_equationButton->Click += ref new RoutedEventHandler(this, &EquationTextBox::OnEquationButtonClicked);
|
m_equationButton->Click += ref new RoutedEventHandler(this, &EquationTextBox::OnEquationButtonClicked);
|
||||||
|
|
||||||
auto toolTip = ref new ToolTip();
|
auto toolTip = ref new ToolTip();
|
||||||
auto equationButtonMessage = m_equationButton->IsChecked->Value ? resProvider->GetResourceString(L"showEquationButtonToolTip") : resProvider->GetResourceString(L"hideEquationButtonToolTip");
|
auto equationButtonMessage = m_equationButton->IsChecked->Value ? resProvider->GetResourceString(L"showEquationButtonToolTip")
|
||||||
toolTip->Content = equationButtonMessage;
|
: resProvider->GetResourceString(L"hideEquationButtonToolTip");
|
||||||
ToolTipService::SetToolTip(m_equationButton, toolTip);
|
toolTip->Content = equationButtonMessage;
|
||||||
AutomationProperties::SetName(m_equationButton, equationButtonMessage);
|
ToolTipService::SetToolTip(m_equationButton, toolTip);
|
||||||
|
AutomationProperties::SetName(m_equationButton, equationButtonMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_richEditContextMenu != nullptr)
|
if (m_richEditContextMenu != nullptr)
|
||||||
{
|
{
|
||||||
m_richEditContextMenu->Opening +=
|
m_richEditContextMenu->Opening += ref new Windows::Foundation::EventHandler<Platform::Object ^>(this, &EquationTextBox::OnRichEditMenuOpening);
|
||||||
ref new Windows::Foundation::EventHandler<Platform::Object ^>(this, &EquationTextBox::OnRichEditMenuOpening);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_kgfEquationButton != nullptr)
|
if (m_kgfEquationButton != nullptr)
|
||||||
@ -119,6 +124,7 @@ void EquationTextBox::OnApplyTemplate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
UpdateCommonVisualState();
|
UpdateCommonVisualState();
|
||||||
|
UpdateButtonsVisualState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationTextBox::OnPointerEntered(PointerRoutedEventArgs ^ e)
|
void EquationTextBox::OnPointerEntered(PointerRoutedEventArgs ^ e)
|
||||||
@ -149,23 +155,31 @@ void EquationTextBox::OnKeyDown(KeyRoutedEventArgs ^ e)
|
|||||||
{
|
{
|
||||||
if (e->Key == VirtualKey::Enter)
|
if (e->Key == VirtualKey::Enter)
|
||||||
{
|
{
|
||||||
EquationSubmitted(this, ref new RoutedEventArgs());
|
m_sourceSubmission = EquationSubmissionSource::ENTER_KEY;
|
||||||
if (m_functionButton && m_richEditBox->MathText != L"")
|
// We will rely on OnLostFocus to submit the equation to prevent the launch of 2 events
|
||||||
|
if (!m_HasFocus || !FocusManager::TryMoveFocusAsync(::FocusNavigationDirection::Next))
|
||||||
{
|
{
|
||||||
m_functionButton->IsEnabled = true;
|
m_sourceSubmission = EquationSubmissionSource::FOCUS_LOST;
|
||||||
|
EquationSubmitted(this, EquationSubmissionSource::ENTER_KEY);
|
||||||
|
if (m_functionButton && m_richEditBox->MathText != L"")
|
||||||
|
{
|
||||||
|
m_functionButton->IsEnabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationTextBox::OnLostFocus(RoutedEventArgs ^ e)
|
void EquationTextBox::OnLostFocus(RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
if (m_richEditBox != nullptr && !m_richEditBox->ContextFlyout->IsOpen)
|
if (m_richEditBox == nullptr || m_richEditBox->ContextFlyout->IsOpen)
|
||||||
{
|
{
|
||||||
EquationSubmitted(this, ref new RoutedEventArgs());
|
return;
|
||||||
if (m_functionButton && m_richEditBox->MathText != L"")
|
}
|
||||||
{
|
|
||||||
m_functionButton->IsEnabled = true;
|
EquationSubmitted(this, m_sourceSubmission);
|
||||||
}
|
if (m_functionButton && m_richEditBox->MathText != L"")
|
||||||
|
{
|
||||||
|
m_functionButton->IsEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,14 +198,15 @@ void EquationTextBox::OnColorFlyoutClosed(Object ^ sender, Object ^ e)
|
|||||||
|
|
||||||
void EquationTextBox::OnRichEditBoxTextChanged(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationTextBox::OnRichEditBoxTextChanged(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
UpdateDeleteButtonVisualState();
|
UpdateButtonsVisualState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationTextBox::OnRichEditBoxGotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationTextBox::OnRichEditBoxGotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
m_HasFocus = true;
|
m_HasFocus = true;
|
||||||
|
m_sourceSubmission = EquationSubmissionSource::FOCUS_LOST;
|
||||||
UpdateCommonVisualState();
|
UpdateCommonVisualState();
|
||||||
UpdateDeleteButtonVisualState();
|
UpdateButtonsVisualState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationTextBox::OnRichEditBoxLostFocus(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationTextBox::OnRichEditBoxLostFocus(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
@ -202,7 +217,7 @@ void EquationTextBox::OnRichEditBoxLostFocus(Object ^ sender, RoutedEventArgs ^
|
|||||||
}
|
}
|
||||||
|
|
||||||
UpdateCommonVisualState();
|
UpdateCommonVisualState();
|
||||||
UpdateDeleteButtonVisualState();
|
UpdateButtonsVisualState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationTextBox::OnDeleteButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationTextBox::OnDeleteButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
@ -223,7 +238,8 @@ void EquationTextBox::OnEquationButtonClicked(Object ^ sender, RoutedEventArgs ^
|
|||||||
|
|
||||||
auto toolTip = ref new ToolTip();
|
auto toolTip = ref new ToolTip();
|
||||||
auto resProvider = AppResourceProvider::GetInstance();
|
auto resProvider = AppResourceProvider::GetInstance();
|
||||||
auto equationButtonMessage = m_equationButton->IsChecked->Value ? resProvider->GetResourceString(L"showEquationButtonToolTip") : resProvider->GetResourceString(L"hideEquationButtonToolTip");
|
auto equationButtonMessage = m_equationButton->IsChecked->Value ? resProvider->GetResourceString(L"showEquationButtonToolTip")
|
||||||
|
: resProvider->GetResourceString(L"hideEquationButtonToolTip");
|
||||||
toolTip->Content = equationButtonMessage;
|
toolTip->Content = equationButtonMessage;
|
||||||
ToolTipService::SetToolTip(m_equationButton, toolTip);
|
ToolTipService::SetToolTip(m_equationButton, toolTip);
|
||||||
AutomationProperties::SetName(m_equationButton, equationButtonMessage);
|
AutomationProperties::SetName(m_equationButton, equationButtonMessage);
|
||||||
@ -236,6 +252,12 @@ void EquationTextBox::OnKGFEquationButtonClicked(Object ^ sender, RoutedEventArg
|
|||||||
|
|
||||||
void EquationTextBox::OnRemoveButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationTextBox::OnRemoveButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
|
if (IsAddEquationMode)
|
||||||
|
{
|
||||||
|
// Don't remove the last equation
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_richEditBox != nullptr)
|
if (m_richEditBox != nullptr)
|
||||||
{
|
{
|
||||||
m_richEditBox->MathText = L"";
|
m_richEditBox->MathText = L"";
|
||||||
@ -269,11 +291,15 @@ void EquationTextBox::OnFunctionButtonClicked(Object ^ sender, RoutedEventArgs ^
|
|||||||
KeyGraphFeaturesButtonClicked(this, ref new RoutedEventArgs());
|
KeyGraphFeaturesButtonClicked(this, ref new RoutedEventArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationTextBox::UpdateDeleteButtonVisualState()
|
void EquationTextBox::UpdateButtonsVisualState()
|
||||||
{
|
{
|
||||||
String ^ state;
|
String ^ state;
|
||||||
|
|
||||||
if (RichEditHasContent())
|
if (IsAddEquationMode)
|
||||||
|
{
|
||||||
|
state = "ButtonHideRemove";
|
||||||
|
}
|
||||||
|
else if (RichEditHasContent())
|
||||||
{
|
{
|
||||||
state = "ButtonVisible";
|
state = "ButtonVisible";
|
||||||
}
|
}
|
||||||
@ -287,13 +313,13 @@ void EquationTextBox::UpdateDeleteButtonVisualState()
|
|||||||
|
|
||||||
void EquationTextBox::UpdateCommonVisualState()
|
void EquationTextBox::UpdateCommonVisualState()
|
||||||
{
|
{
|
||||||
String ^ state = "Normal";
|
String ^ state = nullptr;
|
||||||
|
|
||||||
if (m_HasFocus)
|
if (m_HasFocus)
|
||||||
{
|
{
|
||||||
state = "Focused";
|
state = "Focused";
|
||||||
}
|
}
|
||||||
else if ((m_isPointerOver && HasError) || (m_isColorChooserFlyoutOpen && HasError))
|
else if (HasError && (m_isPointerOver || m_isColorChooserFlyoutOpen))
|
||||||
{
|
{
|
||||||
state = "PointerOverError";
|
state = "PointerOverError";
|
||||||
}
|
}
|
||||||
@ -305,8 +331,15 @@ void EquationTextBox::UpdateCommonVisualState()
|
|||||||
{
|
{
|
||||||
state = "Error";
|
state = "Error";
|
||||||
}
|
}
|
||||||
|
else if (IsAddEquationMode)
|
||||||
VisualStateManager::GoToState(this, state, true);
|
{
|
||||||
|
state = "AddEquation";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state = "Normal";
|
||||||
|
}
|
||||||
|
VisualStateManager::GoToState(this, state, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationTextBox::OnHasErrorPropertyChanged(bool, bool)
|
void EquationTextBox::OnHasErrorPropertyChanged(bool, bool)
|
||||||
@ -360,3 +393,17 @@ void EquationTextBox::OnRichEditMenuOpening(Object ^ /*sender*/, Object ^ /*args
|
|||||||
m_kgfEquationMenuItem->IsEnabled = EquationTextBox::RichEditHasContent();
|
m_kgfEquationMenuItem->IsEnabled = EquationTextBox::RichEditHasContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EquationTextBox::OnIsAddEquationModePropertyChanged(bool /*oldValue*/, bool /*newValue*/)
|
||||||
|
{
|
||||||
|
UpdateCommonVisualState();
|
||||||
|
UpdateButtonsVisualState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EquationTextBox::FocusTextBox()
|
||||||
|
{
|
||||||
|
if (m_richEditBox != nullptr)
|
||||||
|
{
|
||||||
|
m_richEditBox->Focus(::FocusState::Programmatic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -11,46 +11,55 @@ namespace CalculatorApp
|
|||||||
{
|
{
|
||||||
namespace Controls
|
namespace Controls
|
||||||
{
|
{
|
||||||
public ref class EquationTextBox sealed : public Windows::UI::Xaml::Controls::Control
|
public
|
||||||
|
enum class EquationSubmissionSource
|
||||||
|
{
|
||||||
|
FOCUS_LOST,
|
||||||
|
ENTER_KEY
|
||||||
|
};
|
||||||
|
|
||||||
|
public
|
||||||
|
ref class EquationTextBox sealed : public Windows::UI::Xaml::Controls::Control
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EquationTextBox()
|
EquationTextBox();
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DEPENDENCY_PROPERTY_OWNER(EquationTextBox);
|
DEPENDENCY_PROPERTY_OWNER(EquationTextBox);
|
||||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::SolidColorBrush^, EquationColor);
|
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::SolidColorBrush ^, EquationColor);
|
||||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Controls::Flyout^, ColorChooserFlyout);
|
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Controls::Flyout ^, ColorChooserFlyout);
|
||||||
DEPENDENCY_PROPERTY(Platform::String ^, EquationButtonContentIndex);
|
DEPENDENCY_PROPERTY(Platform::String ^, EquationButtonContentIndex);
|
||||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, HasError);
|
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, HasError);
|
||||||
|
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsAddEquationMode);
|
||||||
|
|
||||||
PROPERTY_R(bool, HasFocus);
|
PROPERTY_R(bool, HasFocus);
|
||||||
|
|
||||||
event Windows::UI::Xaml::RoutedEventHandler ^ RemoveButtonClicked;
|
event Windows::UI::Xaml::RoutedEventHandler ^ RemoveButtonClicked;
|
||||||
event Windows::UI::Xaml::RoutedEventHandler ^ KeyGraphFeaturesButtonClicked;
|
event Windows::UI::Xaml::RoutedEventHandler ^ KeyGraphFeaturesButtonClicked;
|
||||||
event Windows::UI::Xaml::RoutedEventHandler ^ EquationSubmitted;
|
event Windows::Foundation::EventHandler<EquationSubmissionSource> ^ EquationSubmitted;
|
||||||
event Windows::UI::Xaml::RoutedEventHandler ^ EquationButtonClicked;
|
event Windows::UI::Xaml::RoutedEventHandler ^ EquationButtonClicked;
|
||||||
|
|
||||||
Platform::String^ GetEquationText();
|
Platform::String ^ GetEquationText();
|
||||||
void SetEquationText(Platform::String^ equationText);
|
void SetEquationText(Platform::String ^ equationText);
|
||||||
|
void FocusTextBox();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnApplyTemplate() override;
|
virtual void OnApplyTemplate() override;
|
||||||
virtual void OnPointerEntered(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
|
virtual void OnPointerEntered(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||||
virtual void OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
|
virtual void OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||||
virtual void OnPointerCanceled(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
|
virtual void OnPointerCanceled(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||||
virtual void OnPointerCaptureLost(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
|
virtual void OnPointerCaptureLost(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||||
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override;
|
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
|
||||||
virtual void OnLostFocus(Windows::UI::Xaml::RoutedEventArgs^ e) override;
|
virtual void OnLostFocus(Windows::UI::Xaml::RoutedEventArgs ^ e) override;
|
||||||
|
void OnIsAddEquationModePropertyChanged(bool oldValue, bool newValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateCommonVisualState();
|
void UpdateCommonVisualState();
|
||||||
void UpdateDeleteButtonVisualState();
|
void UpdateButtonsVisualState();
|
||||||
bool RichEditHasContent();
|
bool RichEditHasContent();
|
||||||
|
|
||||||
void OnRichEditBoxGotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void OnRichEditBoxGotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void OnRichEditBoxLostFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void OnRichEditBoxLostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void OnRichEditBoxTextChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void OnRichEditBoxTextChanged(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
|
|
||||||
void OnDeleteButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void OnDeleteButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
void OnEquationButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void OnEquationButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
@ -60,18 +69,18 @@ namespace CalculatorApp
|
|||||||
void OnFunctionButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void OnFunctionButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
void OnRichEditMenuOpening(Platform::Object ^ sender, Platform::Object ^ args);
|
void OnRichEditMenuOpening(Platform::Object ^ sender, Platform::Object ^ args);
|
||||||
|
|
||||||
void OnColorFlyoutOpened(Platform::Object^ sender, Platform::Object^ e);
|
void OnColorFlyoutOpened(Platform::Object ^ sender, Platform::Object ^ e);
|
||||||
void OnColorFlyoutClosed(Platform::Object^ sender, Platform::Object^ e);
|
void OnColorFlyoutClosed(Platform::Object ^ sender, Platform::Object ^ e);
|
||||||
|
|
||||||
void OnHasErrorPropertyChanged(bool oldValue, bool newValue);
|
void OnHasErrorPropertyChanged(bool oldValue, bool newValue);
|
||||||
|
|
||||||
CalculatorApp::Controls::MathRichEditBox^ m_richEditBox;
|
CalculatorApp::Controls::MathRichEditBox ^ m_richEditBox;
|
||||||
Windows::UI::Xaml::Controls::Primitives::ToggleButton^ m_equationButton;
|
Windows::UI::Xaml::Controls::Primitives::ToggleButton ^ m_equationButton;
|
||||||
Windows::UI::Xaml::Controls::Button^ m_kgfEquationButton;
|
Windows::UI::Xaml::Controls::Button ^ m_kgfEquationButton;
|
||||||
Windows::UI::Xaml::Controls::Button^ m_deleteButton;
|
Windows::UI::Xaml::Controls::Button ^ m_deleteButton;
|
||||||
Windows::UI::Xaml::Controls::Button^ m_removeButton;
|
Windows::UI::Xaml::Controls::Button ^ m_removeButton;
|
||||||
Windows::UI::Xaml::Controls::Button^ m_functionButton;
|
Windows::UI::Xaml::Controls::Button ^ m_functionButton;
|
||||||
Windows::UI::Xaml::Controls::Primitives::ToggleButton^ m_colorChooserButton;
|
Windows::UI::Xaml::Controls::Primitives::ToggleButton ^ m_colorChooserButton;
|
||||||
|
|
||||||
Windows::UI::Xaml::Controls::MenuFlyout^ m_richEditContextMenu;
|
Windows::UI::Xaml::Controls::MenuFlyout^ m_richEditContextMenu;
|
||||||
Windows::UI::Xaml::Controls::MenuFlyoutItem^ m_kgfEquationMenuItem;
|
Windows::UI::Xaml::Controls::MenuFlyoutItem^ m_kgfEquationMenuItem;
|
||||||
@ -80,6 +89,7 @@ namespace CalculatorApp
|
|||||||
|
|
||||||
bool m_isPointerOver;
|
bool m_isPointerOver;
|
||||||
bool m_isColorChooserFlyoutOpen;
|
bool m_isColorChooserFlyoutOpen;
|
||||||
};
|
EquationSubmissionSource m_sourceSubmission;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3907,7 +3907,7 @@
|
|||||||
<value>Zoom Out</value>
|
<value>Zoom Out</value>
|
||||||
<comment>Screen reader prompt for the zoom out button.</comment>
|
<comment>Screen reader prompt for the zoom out button.</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="EquationInputButtonPlaceholder.Text" xml:space="preserve">
|
<data name="EquationTextBoxAddPanel.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||||
<value>Add Equation</value>
|
<value>Add Equation</value>
|
||||||
<comment>Placeholder text for the equation input button</comment>
|
<comment>Placeholder text for the equation input button</comment>
|
||||||
</data>
|
</data>
|
||||||
@ -4218,4 +4218,8 @@
|
|||||||
<value>Current mode is graph mode</value>
|
<value>Current mode is graph mode</value>
|
||||||
<comment>Announcement used in Graphing Calculator when switching to the graph mode</comment>
|
<comment>Announcement used in Graphing Calculator when switching to the graph mode</comment>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
<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>
|
||||||
|
</root>
|
104
src/Calculator/Utils/VisualTree.cpp
Normal file
104
src/Calculator/Utils/VisualTree.cpp
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
#include "VisualTree.h"
|
||||||
|
|
||||||
|
using namespace Windows::Foundation::Collections;
|
||||||
|
using namespace Windows::UI::Xaml;
|
||||||
|
using namespace Platform;
|
||||||
|
using namespace Windows::UI::Xaml::Interop;
|
||||||
|
using namespace Windows::UI::Xaml::Media;
|
||||||
|
using namespace Calculator::Utils;
|
||||||
|
|
||||||
|
FrameworkElement ^ VisualTree::FindDescendantByName(DependencyObject ^ element, String ^ name)
|
||||||
|
{
|
||||||
|
if (element == nullptr || name == nullptr || name->Length() == 0)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto frameworkElement = dynamic_cast<FrameworkElement ^>(element);
|
||||||
|
auto nsame = frameworkElement->Name->Data();
|
||||||
|
nsame = nsame;
|
||||||
|
if (frameworkElement != nullptr && name->Equals(frameworkElement->Name))
|
||||||
|
{
|
||||||
|
return frameworkElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto childCount = VisualTreeHelper::GetChildrenCount(element);
|
||||||
|
for (int i = 0; i < childCount; i++)
|
||||||
|
{
|
||||||
|
auto result = FindDescendantByName(VisualTreeHelper::GetChild(element, i), name);
|
||||||
|
if (result != nullptr)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
DependencyObject ^ VisualTree::FindDescendant(DependencyObject ^ element, TypeName typeName)
|
||||||
|
{
|
||||||
|
DependencyObject ^ retValue = nullptr;
|
||||||
|
auto childrenCount = VisualTreeHelper::GetChildrenCount(element);
|
||||||
|
|
||||||
|
for (auto i = 0; i < childrenCount; i++)
|
||||||
|
{
|
||||||
|
auto child = VisualTreeHelper::GetChild(element, i);
|
||||||
|
if (child->GetType() == typeName)
|
||||||
|
{
|
||||||
|
retValue = child;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
retValue = FindDescendant(child, typeName);
|
||||||
|
|
||||||
|
if (retValue != nullptr)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FrameworkElement ^ VisualTree::FindAscendantByName(DependencyObject ^ element, String ^ name)
|
||||||
|
{
|
||||||
|
if (element == nullptr || name == nullptr || name->Length() == 0)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto parent = VisualTreeHelper::GetParent(element);
|
||||||
|
|
||||||
|
if (parent == nullptr)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto frameworkElement = dynamic_cast<FrameworkElement ^>(parent);
|
||||||
|
if (frameworkElement != nullptr && name->Equals(frameworkElement->Name))
|
||||||
|
{
|
||||||
|
return frameworkElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FindAscendantByName(parent, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Object ^ VisualTree::FindAscendant(DependencyObject ^ element, TypeName typeName)
|
||||||
|
{
|
||||||
|
auto parent = VisualTreeHelper::GetParent(element);
|
||||||
|
|
||||||
|
if (parent == nullptr)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent->GetType() == typeName)
|
||||||
|
{
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FindAscendant(parent, typeName);
|
||||||
|
}
|
50
src/Calculator/Utils/VisualTree.h
Normal file
50
src/Calculator/Utils/VisualTree.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
// Light C++/CX port of Microsoft.Toolkit.Uwp.UI.Extensions.VisualTree from the Windows Community toolkit
|
||||||
|
// Original version here:
|
||||||
|
// https://raw.githubusercontent.com/windows-toolkit/WindowsCommunityToolkit/master/Microsoft.Toolkit.Uwp.UI/Extensions/Tree/VisualTree.cs
|
||||||
|
|
||||||
|
namespace Calculator::Utils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines a collection of extensions methods for UI.
|
||||||
|
/// </summary>
|
||||||
|
ref class VisualTree sealed
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Find descendant <see cref="Windows::UI::Xaml::FrameworkElement ^"/> control using its name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="element">Parent element.</param>
|
||||||
|
/// <param name="name">Name of the control to find</param>
|
||||||
|
/// <returns>Descendant control or null if not found.</returns>
|
||||||
|
internal : static Windows::UI::Xaml::FrameworkElement ^ FindDescendantByName(Windows::UI::Xaml::DependencyObject ^ element, Platform::String ^ name);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find first descendant control of a specified type.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="element">Parent element.</param>
|
||||||
|
/// <param name="type">Type of descendant.</param>
|
||||||
|
/// <returns>Descendant control or null if not found.</returns>
|
||||||
|
static Windows::UI::Xaml::DependencyObject
|
||||||
|
^ FindDescendant(Windows::UI::Xaml::DependencyObject ^ element, Windows::UI::Xaml::Interop::TypeName typeName);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find visual ascendant <see cref="Windows::UI::Xaml::FrameworkElement ^"/> control using its name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="element">Parent element.</param>
|
||||||
|
/// <param name="name">Name of the control to find</param>
|
||||||
|
/// <returns>Descendant control or null if not found.</returns>
|
||||||
|
static Windows::UI::Xaml::FrameworkElement ^ FindAscendantByName(Windows::UI::Xaml::DependencyObject ^ element, Platform::String ^ name);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find first visual ascendant control of a specified type.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="element">Child element.</param>
|
||||||
|
/// <param name="type">Type of ascendant to look for.</param>
|
||||||
|
/// <returns>Ascendant control or null if not found.</returns>
|
||||||
|
static Platform::Object ^ FindAscendant(Windows::UI::Xaml::DependencyObject ^ element, Windows::UI::Xaml::Interop::TypeName type);
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
@ -2,7 +2,6 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:controls="using:CalculatorApp.Controls"
|
xmlns:controls="using:CalculatorApp.Controls"
|
||||||
xmlns:converters="using:CalculatorApp.Converters"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="using:CalculatorApp"
|
xmlns:local="using:CalculatorApp"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
@ -10,25 +9,19 @@
|
|||||||
d:DesignHeight="300"
|
d:DesignHeight="300"
|
||||||
d:DesignWidth="400"
|
d:DesignWidth="400"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<Grid VerticalAlignment="Top">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="Auto"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
|
|
||||||
|
<Grid>
|
||||||
<ListView x:Name="EquationInputList"
|
<ListView x:Name="EquationInputList"
|
||||||
IsItemClickEnabled="False"
|
IsItemClickEnabled="False"
|
||||||
ItemsSource="{x:Bind Equations}"
|
ItemsSource="{x:Bind Equations}"
|
||||||
SelectionMode="None">
|
SelectionMode="None">
|
||||||
|
|
||||||
<!-- Removes animations from the ListView Style. -->
|
<!-- Removes animations from the ListView Style. -->
|
||||||
<ListView.Style>
|
<ListView.Style>
|
||||||
<Style TargetType="ListView">
|
<Style TargetType="ListView">
|
||||||
<Setter Property="ItemContainerTransitions">
|
<Setter Property="ItemContainerTransitions">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<TransitionCollection>
|
<TransitionCollection/>
|
||||||
</TransitionCollection>
|
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
@ -43,22 +36,23 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</ListView.ItemContainerStyle>
|
</ListView.ItemContainerStyle>
|
||||||
|
|
||||||
|
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate x:DataType="vm:EquationViewModel">
|
<DataTemplate x:DataType="vm:EquationViewModel">
|
||||||
<controls:EquationTextBox x:Uid="EquationInputButton"
|
<controls:EquationTextBox x:Name="EquationInputButton"
|
||||||
Margin="1,0,1,0"
|
x:Uid="EquationInputButton"
|
||||||
|
Margin="1"
|
||||||
Style="{StaticResource EquationTextBoxStyle}"
|
Style="{StaticResource EquationTextBoxStyle}"
|
||||||
EquationColor="{x:Bind LineColor, Mode=OneWay}"
|
|
||||||
EquationButtonClicked="EquationTextBox_EquationButtonClicked"
|
EquationButtonClicked="EquationTextBox_EquationButtonClicked"
|
||||||
EquationButtonContentIndex="{x:Bind FunctionLabelIndex, Mode=OneWay}"
|
EquationButtonContentIndex="{x:Bind FunctionLabelIndex, Mode=OneWay}"
|
||||||
|
EquationColor="{x:Bind LineColor, Mode=OneWay}"
|
||||||
EquationSubmitted="InputTextBox_Submitted"
|
EquationSubmitted="InputTextBox_Submitted"
|
||||||
GotFocus="InputTextBox_GotFocus"
|
GotFocus="InputTextBox_GotFocus"
|
||||||
HasError="{x:Bind GraphEquation.HasGraphError, Mode=OneWay}"
|
HasError="{x:Bind GraphEquation.HasGraphError, Mode=OneWay}"
|
||||||
|
IsAddEquationMode="{x:Bind IsLastItemInList, Mode=OneWay}"
|
||||||
|
KeyGraphFeaturesButtonClicked="EquationTextBox_KeyGraphFeaturesButtonClicked"
|
||||||
Loaded="EquationTextBoxLoaded"
|
Loaded="EquationTextBoxLoaded"
|
||||||
LostFocus="InputTextBox_LostFocus"
|
LostFocus="InputTextBox_LostFocus"
|
||||||
RemoveButtonClicked="EquationTextBox_RemoveButtonClicked"
|
RemoveButtonClicked="EquationTextBox_RemoveButtonClicked">
|
||||||
KeyGraphFeaturesButtonClicked="EquationTextBox_KeyGraphFeaturesButtonClicked">
|
|
||||||
<controls:EquationTextBox.ColorChooserFlyout>
|
<controls:EquationTextBox.ColorChooserFlyout>
|
||||||
<Flyout x:Name="ColorChooserFlyout"
|
<Flyout x:Name="ColorChooserFlyout"
|
||||||
x:Uid="ColorChooserFlyout"
|
x:Uid="ColorChooserFlyout"
|
||||||
@ -70,35 +64,5 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
</ListView>
|
</ListView>
|
||||||
<Button Grid.Row="1"
|
|
||||||
MinHeight="44"
|
|
||||||
Margin="2,0,2,1"
|
|
||||||
Padding="0"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
HorizontalContentAlignment="Stretch"
|
|
||||||
VerticalContentAlignment="Stretch"
|
|
||||||
Style="{ThemeResource CaptionButtonStyle}"
|
|
||||||
FontSize="14"
|
|
||||||
FontWeight="Normal"
|
|
||||||
Click="AddEquationButton_Click">
|
|
||||||
<Button.Content>
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto"/>
|
|
||||||
<ColumnDefinition Width="1*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
|
|
||||||
<FontIcon MinWidth="44"
|
|
||||||
FontFamily="{StaticResource SymbolThemeFontFamily}"
|
|
||||||
Glyph=""/>
|
|
||||||
|
|
||||||
<TextBlock x:Uid="EquationInputButtonPlaceholder"
|
|
||||||
Grid.Column="1"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
VerticalAlignment="Center"/>
|
|
||||||
</Grid>
|
|
||||||
</Button.Content>
|
|
||||||
</Button>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "EquationInputArea.xaml.h"
|
#include "EquationInputArea.xaml.h"
|
||||||
|
#include "Utils/VisualTree.h"
|
||||||
|
|
||||||
using namespace CalculatorApp;
|
using namespace CalculatorApp;
|
||||||
using namespace CalculatorApp::Common;
|
using namespace CalculatorApp::Common;
|
||||||
@ -21,6 +22,7 @@ using namespace Windows::UI::Xaml::Controls;
|
|||||||
using namespace Windows::UI::Xaml::Controls::Primitives;
|
using namespace Windows::UI::Xaml::Controls::Primitives;
|
||||||
using namespace Windows::UI::Xaml::Input;
|
using namespace Windows::UI::Xaml::Input;
|
||||||
using namespace GraphControl;
|
using namespace GraphControl;
|
||||||
|
using namespace Calculator::Utils;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -31,6 +33,7 @@ EquationInputArea::EquationInputArea()
|
|||||||
: m_lastLineColorIndex{ -1 }
|
: m_lastLineColorIndex{ -1 }
|
||||||
, m_AvailableColors{ ref new Vector<SolidColorBrush ^>() }
|
, m_AvailableColors{ ref new Vector<SolidColorBrush ^>() }
|
||||||
, m_accessibilitySettings{ ref new AccessibilitySettings() }
|
, m_accessibilitySettings{ ref new AccessibilitySettings() }
|
||||||
|
, m_equationToFocus{ nullptr }
|
||||||
{
|
{
|
||||||
m_accessibilitySettings->HighContrastChanged +=
|
m_accessibilitySettings->HighContrastChanged +=
|
||||||
ref new TypedEventHandler<AccessibilitySettings ^, Object ^>(this, &EquationInputArea::OnHighContrastChanged);
|
ref new TypedEventHandler<AccessibilitySettings ^, Object ^>(this, &EquationInputArea::OnHighContrastChanged);
|
||||||
@ -56,14 +59,15 @@ void EquationInputArea::OnEquationsPropertyChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationInputArea::AddEquationButton_Click(Object ^ sender, RoutedEventArgs ^ e)
|
|
||||||
{
|
|
||||||
AddNewEquation();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EquationInputArea::AddNewEquation()
|
void EquationInputArea::AddNewEquation()
|
||||||
{
|
{
|
||||||
auto eq = ref new EquationViewModel(ref new Equation());
|
auto eq = ref new EquationViewModel(ref new Equation());
|
||||||
|
eq->IsLastItemInList = true;
|
||||||
|
|
||||||
|
if (Equations->Size > 0)
|
||||||
|
{
|
||||||
|
Equations->GetAt(Equations->Size - 1)->IsLastItemInList = false;
|
||||||
|
}
|
||||||
|
|
||||||
m_lastLineColorIndex = (m_lastLineColorIndex + 1) % AvailableColors->Size;
|
m_lastLineColorIndex = (m_lastLineColorIndex + 1) % AvailableColors->Size;
|
||||||
|
|
||||||
@ -71,7 +75,7 @@ void EquationInputArea::AddNewEquation()
|
|||||||
eq->IsLineEnabled = true;
|
eq->IsLineEnabled = true;
|
||||||
eq->FunctionLabelIndex = ++m_lastFunctionLabelIndex;
|
eq->FunctionLabelIndex = ++m_lastFunctionLabelIndex;
|
||||||
Equations->Append(eq);
|
Equations->Append(eq);
|
||||||
EquationInputList->ScrollIntoView(eq);
|
m_equationToFocus = eq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationInputArea::InputTextBox_GotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationInputArea::InputTextBox_GotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
@ -84,20 +88,65 @@ void EquationInputArea::InputTextBox_LostFocus(Object ^ sender, RoutedEventArgs
|
|||||||
KeyboardShortcutManager::HonorShortcuts(true);
|
KeyboardShortcutManager::HonorShortcuts(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationInputArea::InputTextBox_Submitted(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationInputArea::InputTextBox_Submitted(Object ^ sender, EquationSubmissionSource source)
|
||||||
{
|
{
|
||||||
auto tb = static_cast<EquationTextBox ^>(sender);
|
auto tb = static_cast<EquationTextBox ^>(sender);
|
||||||
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
|
if (tb == nullptr)
|
||||||
|
|
||||||
// eq can be null if the equation has been removed
|
|
||||||
if (eq != nullptr)
|
|
||||||
{
|
{
|
||||||
eq->Expression = tb->GetEquationText();
|
return;
|
||||||
|
}
|
||||||
|
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
|
||||||
|
if (eq == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb->HasFocus)
|
auto expressionText = tb->GetEquationText();
|
||||||
|
if (source == EquationSubmissionSource::FOCUS_LOST && eq->Expression == expressionText)
|
||||||
{
|
{
|
||||||
FocusManager::TryMoveFocus(::FocusNavigationDirection::Left);
|
// The expression didn't change.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
eq->Expression = expressionText;
|
||||||
|
|
||||||
|
if (source == EquationSubmissionSource::ENTER_KEY || eq->Expression != nullptr && eq->Expression->Length() > 0)
|
||||||
|
{
|
||||||
|
unsigned int index = 0;
|
||||||
|
if (Equations->IndexOf(eq, &index) && index == Equations->Size - 1)
|
||||||
|
{
|
||||||
|
// If it's the last equation of the list
|
||||||
|
AddNewEquation();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto nextEquation = Equations->GetAt(index + 1);
|
||||||
|
FocusEquationTextBox(nextEquation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EquationInputArea::FocusEquationTextBox(EquationViewModel ^ equation)
|
||||||
|
{
|
||||||
|
auto nextContainer = EquationInputList->ContainerFromItem(equation);
|
||||||
|
if (nextContainer == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto listviewItem = dynamic_cast<ListViewItem ^>(nextContainer);
|
||||||
|
if (listviewItem == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto equationInput = VisualTree::FindDescendantByName(nextContainer, "EquationInputButton");
|
||||||
|
if (equationInput == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto equationTextBox = dynamic_cast<EquationTextBox ^>(equationInput);
|
||||||
|
if (equationTextBox != nullptr)
|
||||||
|
{
|
||||||
|
equationTextBox->FocusTextBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +162,10 @@ void EquationInputArea::EquationTextBox_RemoveButtonClicked(Object ^ sender, Rou
|
|||||||
m_lastFunctionLabelIndex--;
|
m_lastFunctionLabelIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (index == Equations->Size - 1 && Equations->Size > 1)
|
||||||
|
{
|
||||||
|
Equations->GetAt(Equations->Size - 2)->IsLastItemInList = true;
|
||||||
|
}
|
||||||
Equations->RemoveAt(index);
|
Equations->RemoveAt(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,7 +177,7 @@ void EquationInputArea::EquationTextBox_KeyGraphFeaturesButtonClicked(Object ^ s
|
|||||||
// ensure the equation has been submitted before trying to get key graph features out of it
|
// ensure the equation has been submitted before trying to get key graph features out of it
|
||||||
if (tb->HasFocus)
|
if (tb->HasFocus)
|
||||||
{
|
{
|
||||||
EquationInputArea::InputTextBox_Submitted(sender, e);
|
EquationInputArea::InputTextBox_Submitted(sender, EquationSubmissionSource::FOCUS_LOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
|
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
|
||||||
@ -143,10 +196,15 @@ void EquationInputArea::EquationTextBox_EquationButtonClicked(Object ^ sender, R
|
|||||||
void EquationInputArea::EquationTextBoxLoaded(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationInputArea::EquationTextBoxLoaded(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
auto tb = static_cast<EquationTextBox ^>(sender);
|
auto tb = static_cast<EquationTextBox ^>(sender);
|
||||||
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
|
|
||||||
|
|
||||||
auto colorChooser = static_cast<EquationStylePanelControl ^>(tb->ColorChooserFlyout->Content);
|
auto colorChooser = static_cast<EquationStylePanelControl ^>(tb->ColorChooserFlyout->Content);
|
||||||
colorChooser->AvailableColors = AvailableColors;
|
colorChooser->AvailableColors = AvailableColors;
|
||||||
|
|
||||||
|
if (tb->DataContext == m_equationToFocus)
|
||||||
|
{
|
||||||
|
m_equationToFocus = nullptr;
|
||||||
|
tb->FocusTextBox();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationInputArea::OnHighContrastChanged(AccessibilitySettings ^ sender, Object ^ args)
|
void EquationInputArea::OnHighContrastChanged(AccessibilitySettings ^ sender, Object ^ args)
|
||||||
|
@ -29,23 +29,25 @@ namespace CalculatorApp
|
|||||||
void OnPropertyChanged(Platform::String^ propertyName);
|
void OnPropertyChanged(Platform::String^ propertyName);
|
||||||
void OnEquationsPropertyChanged();
|
void OnEquationsPropertyChanged();
|
||||||
|
|
||||||
void AddEquationButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
|
||||||
void AddNewEquation();
|
void AddNewEquation();
|
||||||
|
|
||||||
void InputTextBox_GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void InputTextBox_GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
void InputTextBox_LostFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void InputTextBox_LostFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
void InputTextBox_Submitted(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void InputTextBox_Submitted(Platform::Object ^ sender, CalculatorApp::Controls::EquationSubmissionSource e);
|
||||||
|
|
||||||
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^ sender, Platform::Object ^ args);
|
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^ sender, Platform::Object ^ args);
|
||||||
void ReloadAvailableColors(bool isHighContrast);
|
void ReloadAvailableColors(bool isHighContrast);
|
||||||
|
void FocusEquationTextBox(ViewModel::EquationViewModel ^ equation);
|
||||||
|
|
||||||
|
void EquationTextBox_RemoveButtonClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
|
void EquationTextBox_KeyGraphFeaturesButtonClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
|
void EquationTextBox_EquationButtonClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
|
void EquationTextBoxLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Windows::UI::ViewManagement::AccessibilitySettings ^ m_accessibilitySettings;
|
Windows::UI::ViewManagement::AccessibilitySettings ^ m_accessibilitySettings;
|
||||||
int m_lastLineColorIndex;
|
int m_lastLineColorIndex;
|
||||||
int m_lastFunctionLabelIndex;
|
int m_lastFunctionLabelIndex;
|
||||||
void EquationTextBox_RemoveButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
ViewModel::EquationViewModel ^ m_equationToFocus;
|
||||||
void EquationTextBox_KeyGraphFeaturesButtonClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
|
||||||
void EquationTextBox_EquationButtonClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
|
||||||
void EquationTextBoxLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user