Update color picker (#668)
This commit is contained in:
parent
b2dd55a64f
commit
7864fe6413
@ -1,26 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Common">
|
||||
<UniqueIdentifier>{1daab7c4-63f6-4266-a259-f34acad66d09}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Common\Automation">
|
||||
<UniqueIdentifier>{8d4edf06-c312-4312-978a-b6c2beb8295a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="DataLoaders">
|
||||
<UniqueIdentifier>{0184f727-b8aa-4af8-a699-63f1b56e7853}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="GraphingCalculator">
|
||||
<UniqueIdentifier>{cf7dca32-9727-4f98-83c3-1c0ca7dd1e0c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="ApplicationViewModel.cpp" />
|
||||
<ClCompile Include="DateCalculatorViewModel.cpp" />
|
||||
<ClCompile Include="HistoryItemViewModel.cpp" />
|
||||
<ClCompile Include="HistoryViewModel.cpp" />
|
||||
<ClCompile Include="MemoryItemViewModel.cpp" />
|
||||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="StandardCalculatorViewModel.cpp" />
|
||||
<ClCompile Include="UnitConverterViewModel.cpp" />
|
||||
<ClCompile Include="ViewState.cpp" />
|
||||
@ -72,9 +58,6 @@
|
||||
<ClCompile Include="Common\Utils.cpp">
|
||||
<Filter>Common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Common\Automation\LiveRegionHost.cpp">
|
||||
<Filter>Common\Automation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Common\Automation\NarratorAnnouncement.cpp">
|
||||
<Filter>Common\Automation</Filter>
|
||||
</ClCompile>
|
||||
@ -87,46 +70,49 @@
|
||||
<ClCompile Include="Common\Automation\NotificationHost.cpp">
|
||||
<Filter>Common\Automation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DataLoaders\CurrencyDataLoader.cpp">
|
||||
<ClCompile Include="Common\Automation\LiveRegionHost.cpp">
|
||||
<Filter>Common\Automation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DataLoaders\UnitConverterDataLoader.cpp">
|
||||
<Filter>DataLoaders</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DataLoaders\CurrencyHttpClient.cpp">
|
||||
<Filter>DataLoaders</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DataLoaders\UnitConverterDataLoader.cpp">
|
||||
<Filter>DataLoaders</Filter>
|
||||
<ClCompile Include="GraphingCalculator\GraphingCalculatorViewModel.cpp">
|
||||
<Filter>GraphingCalculator</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GraphingCalculator\EquationViewModel.cpp">
|
||||
<Filter>GraphingCalculator</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="GraphingCalculator\GraphingCalculatorViewModel.cpp">
|
||||
<Filter>GraphingCalculator</Filter>
|
||||
</ClInclude>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DataLoaders\CurrencyDataLoader.cpp">
|
||||
<Filter>DataLoaders</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="ApplicationViewModel.h" />
|
||||
<ClInclude Include="DateCalculatorViewModel.h" />
|
||||
<ClInclude Include="HistoryItemViewModel.h" />
|
||||
<ClInclude Include="HistoryViewModel.h" />
|
||||
<ClInclude Include="MemoryItemViewModel.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="StandardCalculatorViewModel.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="UnitConverterViewModel.h" />
|
||||
<ClInclude Include="ViewState.h" />
|
||||
<ClInclude Include="Common\AlwaysSelectedCollectionView.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\AppResourceProvider.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\BindableBase.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\CalculatorButtonPressedEventArgs.h">
|
||||
<ClInclude Include="Common\AlwaysSelectedCollectionView.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\CalculatorButtonUser.h">
|
||||
<ClInclude Include="Common\BitLength.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\CalculatorButtonPressedEventArgs.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\CalculatorDisplay.h">
|
||||
@ -159,22 +145,25 @@
|
||||
<ClInclude Include="Common\KeyboardShortcutManager.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\LocalizationStringUtil.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\LocalizationService.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\LocalizationSettings.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\LocalizationStringUtil.h">
|
||||
<ClInclude Include="Common\NavCategory.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\MyVirtualKey.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\NavCategory.h">
|
||||
<ClInclude Include="Common\NetworkManager.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\NetworkManager.h">
|
||||
<ClInclude Include="Common\TraceActivity.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\TraceLogger.h">
|
||||
@ -186,11 +175,8 @@
|
||||
<ClInclude Include="Common\ValidatingConverters.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\Automation\INarratorAnnouncementHost.h">
|
||||
<Filter>Common\Automation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\Automation\LiveRegionHost.h">
|
||||
<Filter>Common\Automation</Filter>
|
||||
<ClInclude Include="Common\CalculatorButtonUser.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\Automation\NarratorAnnouncement.h">
|
||||
<Filter>Common\Automation</Filter>
|
||||
@ -204,11 +190,11 @@
|
||||
<ClInclude Include="Common\Automation\NotificationHost.h">
|
||||
<Filter>Common\Automation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DataLoaders\CurrencyDataLoader.h">
|
||||
<Filter>DataLoaders</Filter>
|
||||
<ClInclude Include="Common\Automation\INarratorAnnouncementHost.h">
|
||||
<Filter>Common\Automation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DataLoaders\CurrencyHttpClient.h">
|
||||
<Filter>DataLoaders</Filter>
|
||||
<ClInclude Include="Common\Automation\LiveRegionHost.h">
|
||||
<Filter>Common\Automation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DataLoaders\ICurrencyHttpClient.h">
|
||||
<Filter>DataLoaders</Filter>
|
||||
@ -219,29 +205,40 @@
|
||||
<ClInclude Include="DataLoaders\UnitConverterDataLoader.h">
|
||||
<Filter>DataLoaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\TraceActivity.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DataLoaders\DataLoaderMockConstants.h">
|
||||
<Filter>DataLoaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DataLoaders\DataLoaderConstants.h">
|
||||
<ClInclude Include="DataLoaders\CurrencyHttpClient.h">
|
||||
<Filter>DataLoaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\BitLength.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GraphingCalculator\EquationViewModel.h">
|
||||
<Filter>GraphingCalculator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GraphingCalculator\GraphingCalculatorViewModel.h">
|
||||
<Filter>GraphingCalculator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GraphingCalculator\EquationViewModel.h">
|
||||
<Filter>GraphingCalculator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DataLoaders\CurrencyDataLoader.h">
|
||||
<Filter>DataLoaders</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="DataLoaders\DefaultFromToCurrency.json">
|
||||
<Filter>DataLoaders</Filter>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Common\Automation">
|
||||
<UniqueIdentifier>{98717b14-c8c7-4fb6-9861-abb9124b34f0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="GraphingCalculator">
|
||||
<UniqueIdentifier>{07311281-a1fd-4dd9-baef-007f159e33ed}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Common">
|
||||
<UniqueIdentifier>{14ddcbc1-10a4-4940-ad53-3a751b9ebea0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="DataLoaders">
|
||||
<UniqueIdentifier>{b017a5e6-6d25-4799-a517-99f88d65b82f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -7,9 +7,8 @@ using namespace Windows::UI::Xaml;
|
||||
namespace CalculatorApp::ViewModel
|
||||
{
|
||||
EquationViewModel::EquationViewModel()
|
||||
: m_LineColor{ Colors::Transparent },
|
||||
m_KeyGraphFeaturesVisibility{ ::Visibility::Collapsed },
|
||||
m_Expression{ "" }
|
||||
: m_LineColor{ nullptr }, m_KeyGraphFeaturesVisibility{ ::Visibility::Collapsed }
|
||||
, m_Expression{ "" }
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace CalculatorApp::ViewModel
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Expression);
|
||||
OBSERVABLE_PROPERTY_RW(Windows::UI::Color, LineColor);
|
||||
OBSERVABLE_PROPERTY_RW(Windows::UI::Xaml::Media::SolidColorBrush ^, LineColor);
|
||||
OBSERVABLE_PROPERTY_RW(Windows::UI::Xaml::Visibility, KeyGraphFeaturesVisibility);
|
||||
};
|
||||
}
|
||||
|
@ -46,8 +46,28 @@
|
||||
FallbackColor="{ThemeResource SystemChromeMediumColor}"
|
||||
TintColor="{ThemeResource SystemChromeLowColor}"
|
||||
TintOpacity="0.7"/>
|
||||
<SolidColorBrush x:Key="EquationTextBoxTransparentBackgroundBrush" Color="Transparent"/>
|
||||
<SolidColorBrush x:Key="EquationBoxPointerOverBackgroundBrush" Color="{ThemeResource SystemControlBackgroundAltMediumBrush}"/>
|
||||
<SolidColorBrush x:Key="EquationBoxHoverButtonForegroundBrush" Color="{ThemeResource SystemBaseHighColor}"/>
|
||||
<SolidColorBrush x:Key="EquationBoxBorderBrush" Color="{ThemeResource TextControlBackground}"/>
|
||||
<SolidColorBrush x:Key="AppControlTransparentButtonBackgroundBrush" Color="Transparent"/>
|
||||
|
||||
<SolidColorBrush x:Key="EquationBrush1" Color="#FF0078D7"/>
|
||||
<SolidColorBrush x:Key="EquationBrush2" Color="#FFFFB900"/>
|
||||
<SolidColorBrush x:Key="EquationBrush3" Color="#FFFF8C00"/>
|
||||
<SolidColorBrush x:Key="EquationBrush4" Color="#FFF7630C"/>
|
||||
<SolidColorBrush x:Key="EquationBrush5" Color="#FFCA5010"/>
|
||||
<SolidColorBrush x:Key="EquationBrush6" Color="#FFE3008C"/>
|
||||
<SolidColorBrush x:Key="EquationBrush7" Color="#FFBF0077"/>
|
||||
<SolidColorBrush x:Key="EquationBrush8" Color="#FFC239B3"/>
|
||||
<SolidColorBrush x:Key="EquationBrush9" Color="#FF0063B1"/>
|
||||
<SolidColorBrush x:Key="EquationBrush10" Color="#FF2D7D9A"/>
|
||||
<SolidColorBrush x:Key="EquationBrush11" Color="#FF00B7C3"/>
|
||||
<SolidColorBrush x:Key="EquationBrush12" Color="#FF00CC6A"/>
|
||||
<SolidColorBrush x:Key="EquationBrush13" Color="#FF00B294"/>
|
||||
<SolidColorBrush x:Key="EquationBrush14" Color="#FF018574"/>
|
||||
<SolidColorBrush x:Key="EquationBrush15" Color="#FF10893E"/>
|
||||
<SolidColorBrush x:Key="EquationBrush16" Color="#FF000000"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<Thickness x:Key="HighContrastThicknessTop">0,0,0,0</Thickness>
|
||||
@ -85,6 +105,25 @@
|
||||
TintOpacity="0.7"/>
|
||||
<SolidColorBrush x:Key="EquationBoxPointerOverBackgroundBrush" Color="{ThemeResource SystemControlBackgroundAltMediumBrush}"/>
|
||||
<SolidColorBrush x:Key="EquationBoxHoverButtonForegroundBrush" Color="{ThemeResource SystemBaseHighColor}"/>
|
||||
<SolidColorBrush x:Key="EquationBoxBorderBrush" Color="{ThemeResource TextControlBackground}"/>
|
||||
<SolidColorBrush x:Key="AppControlTransparentButtonBackgroundBrush" Color="Transparent"/>
|
||||
|
||||
<SolidColorBrush x:Key="EquationBrush1" Color="#FF0078D7"/>
|
||||
<SolidColorBrush x:Key="EquationBrush2" Color="#FFFFB900"/>
|
||||
<SolidColorBrush x:Key="EquationBrush3" Color="#FFFF8C00"/>
|
||||
<SolidColorBrush x:Key="EquationBrush4" Color="#FFF7630C"/>
|
||||
<SolidColorBrush x:Key="EquationBrush5" Color="#FFCA5010"/>
|
||||
<SolidColorBrush x:Key="EquationBrush6" Color="#FFE3008C"/>
|
||||
<SolidColorBrush x:Key="EquationBrush7" Color="#FFBF0077"/>
|
||||
<SolidColorBrush x:Key="EquationBrush8" Color="#FFC239B3"/>
|
||||
<SolidColorBrush x:Key="EquationBrush9" Color="#FF0063B1"/>
|
||||
<SolidColorBrush x:Key="EquationBrush10" Color="#FF2D7D9A"/>
|
||||
<SolidColorBrush x:Key="EquationBrush11" Color="#FF00B7C3"/>
|
||||
<SolidColorBrush x:Key="EquationBrush12" Color="#FF00CC6A"/>
|
||||
<SolidColorBrush x:Key="EquationBrush13" Color="#FF00B294"/>
|
||||
<SolidColorBrush x:Key="EquationBrush14" Color="#FF018574"/>
|
||||
<SolidColorBrush x:Key="EquationBrush15" Color="#FF10893E"/>
|
||||
<SolidColorBrush x:Key="EquationBrush16" Color="#FF000000"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="HighContrast">
|
||||
<Thickness x:Key="HighContrastThicknessTop">0,1,0,0</Thickness>
|
||||
@ -106,8 +145,28 @@
|
||||
<SolidColorBrush x:Key="AppControlBackgroundListAccentHighRevealBackgroundBrush" Color="{ThemeResource SystemColorButtonFaceColor}"/>
|
||||
<SolidColorBrush x:Key="AppControlListLowRevealHighlightBrush" Color="{ThemeResource SystemColorHighlightColor}"/>
|
||||
<SolidColorBrush x:Key="AppChromeAcrylicHostBackdropMediumLowBrush" Color="{ThemeResource SystemColorWindowColor}"/>
|
||||
<SolidColorBrush x:Key="EquationBoxBorderBrush" Color="{ThemeResource SystemColorButtonTextColor}"/>
|
||||
<SolidColorBrush x:Key="EquationBoxPointerOverBackgroundBrush" Color="{ThemeResource SystemColorHighlightColor}"/>
|
||||
<SolidColorBrush x:Key="EquationBoxHoverButtonForegroundBrush" Color="{ThemeResource SystemColorCaptionTextColor}"/>
|
||||
<SolidColorBrush x:Key="EquationBoxHoverButtonForegroundBrush" Color="{ThemeResource SystemColorButtonTextColor}"/>
|
||||
<SolidColorBrush x:Key="AppControlTransparentButtonBackgroundBrush" Color="{ThemeResource SystemColorButtonFaceColor}"/>
|
||||
|
||||
<!-- TODO: Add high contrast colors mapping -->
|
||||
<SolidColorBrush x:Key="EquationBrush1" Color="#FFFF0000"/>
|
||||
<SolidColorBrush x:Key="EquationBrush2" Color="#FFFFB900"/>
|
||||
<SolidColorBrush x:Key="EquationBrush3" Color="#FFFF8C00"/>
|
||||
<SolidColorBrush x:Key="EquationBrush4" Color="#FFF7630C"/>
|
||||
<SolidColorBrush x:Key="EquationBrush5" Color="#FFCA5010"/>
|
||||
<SolidColorBrush x:Key="EquationBrush6" Color="#FFE3008C"/>
|
||||
<SolidColorBrush x:Key="EquationBrush7" Color="#FFBF0077"/>
|
||||
<SolidColorBrush x:Key="EquationBrush8" Color="#FFC239B3"/>
|
||||
<SolidColorBrush x:Key="EquationBrush9" Color="#FF0063B1"/>
|
||||
<SolidColorBrush x:Key="EquationBrush10" Color="#FF2D7D9A"/>
|
||||
<SolidColorBrush x:Key="EquationBrush11" Color="#FF00B7C3"/>
|
||||
<SolidColorBrush x:Key="EquationBrush12" Color="#FF00CC6A"/>
|
||||
<SolidColorBrush x:Key="EquationBrush13" Color="#FF00B294"/>
|
||||
<SolidColorBrush x:Key="EquationBrush14" Color="#FF018574"/>
|
||||
<SolidColorBrush x:Key="EquationBrush15" Color="#FF10893E"/>
|
||||
<SolidColorBrush x:Key="EquationBrush16" Color="#FF000000"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
|
||||
@ -1147,7 +1206,7 @@
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlButtonBorderBrushPressed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlButtonForegroundPressed}"/>
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemChromeWhiteColor}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
@ -1176,183 +1235,6 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Name="EquationTextBoxToggleButtonStyle" TargetType="ToggleButton">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="Transparent"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Grid x:Name="ButtonLayoutGrid"
|
||||
Background="Transparent"
|
||||
BorderBrush="{ThemeResource TextControlButtonBorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal"/>
|
||||
|
||||
<VisualState x:Name="PointerOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlButtonBorderBrushPointerOver}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
|
||||
<VisualState x:Name="Pressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlButtonBorderBrushPressed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlButtonForegroundPressed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Duration="0"
|
||||
Storyboard.TargetName="ButtonLayoutGrid"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Checked">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlButtonForegroundPressed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushChecked}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<PointerUpThemeAnimation Storyboard.TargetName="ButtonLayoutGrid"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="CheckedPointerOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushCheckedPointerOver}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlButtonForegroundPressed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<PointerUpThemeAnimation Storyboard.TargetName="ButtonLayoutGrid"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="CheckedPressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlButtonForegroundPressed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushCheckedPressed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<PointerDownThemeAnimation Storyboard.TargetName="ButtonLayoutGrid"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="CheckedDisabled">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBackgroundCheckedDisabled}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonForegroundCheckedDisabled}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushCheckedDisabled}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Indeterminate">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBackgroundIndeterminate}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonForegroundIndeterminate}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushIndeterminate}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<PointerUpThemeAnimation Storyboard.TargetName="ButtonLayoutGrid"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="IndeterminatePointerOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBackgroundIndeterminatePointerOver}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushIndeterminatePointerOver}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonForegroundIndeterminatePointerOver}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<PointerUpThemeAnimation Storyboard.TargetName="ButtonLayoutGrid"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="IndeterminatePressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBackgroundIndeterminatePressed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushIndeterminatePressed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonForegroundIndeterminatePressed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<PointerDownThemeAnimation Storyboard.TargetName="ButtonLayoutGrid"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="IndeterminateDisabled">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBackgroundIndeterminateDisabled}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonForegroundIndeterminateDisabled}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushIndeterminateDisabled}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<TextBlock x:Name="GlyphElement"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{ThemeResource EquationBoxHoverButtonForegroundBrush}"
|
||||
FontFamily="{TemplateBinding FontFamily}"
|
||||
FontSize="12"
|
||||
FontStyle="Normal"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
Text="{TemplateBinding Content}"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="EquationTextBoxStyle" TargetType="RichEditBox">
|
||||
<Setter Property="Foreground" Value="{ThemeResource TextControlForeground}"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
@ -1543,7 +1425,7 @@
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackground}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationBoxBorder" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource EquationBoxBorderBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
@ -1590,7 +1472,7 @@
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledBorderThemeBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EquationTextBox" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppControlTransparentButtonBackgroundBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
@ -1641,7 +1523,7 @@
|
||||
<Border x:Name="EquationBoxBorder"
|
||||
Grid.Column="1"
|
||||
Background="{ThemeResource TextControlBackground}"
|
||||
BorderBrush="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding EquationColor}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
|
||||
<Grid>
|
||||
@ -1664,7 +1546,7 @@
|
||||
InputScope="Text"
|
||||
MaxLength="2048"
|
||||
TextWrapping="NoWrap"/>
|
||||
<!-- TODO: Consider overwiting the hover color instead of hijacking the foreground/background property -->
|
||||
<!-- TODO: Use brush overrides here instead of a new style, use a new style for the EquationButton above once that has more functionality -->
|
||||
<Button x:Name="DeleteButton"
|
||||
Grid.Column="3"
|
||||
MinWidth="34"
|
||||
@ -1673,7 +1555,7 @@
|
||||
Style="{StaticResource EquationTextBoxButtonStyle}"
|
||||
Background="{TemplateBinding EquationColor}"
|
||||
Foreground="{TemplateBinding EquationColor}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderThickness="0"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
@ -1688,7 +1570,7 @@
|
||||
Style="{StaticResource EquationTextBoxButtonStyle}"
|
||||
Background="{TemplateBinding EquationColor}"
|
||||
Foreground="{TemplateBinding EquationColor}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderThickness="0"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
@ -1700,16 +1582,26 @@
|
||||
MinWidth="34"
|
||||
Margin="{ThemeResource HelperButtonThemePadding}"
|
||||
VerticalAlignment="Stretch"
|
||||
Style="{StaticResource EquationTextBoxToggleButtonStyle}"
|
||||
Background="{TemplateBinding EquationColor}"
|
||||
Foreground="{TemplateBinding EquationColor}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{ThemeResource AppControlTransparentButtonBackgroundBrush}"
|
||||
BorderThickness="0"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
Content=""
|
||||
IsTabStop="False"
|
||||
Visibility="Collapsed"/>
|
||||
Visibility="Collapsed">
|
||||
<ToggleButton.Resources>
|
||||
<SolidColorBrush x:Name="ToggleButtonBackgroundPointerOver" Color="{ThemeResource AppControlTransparentButtonBackgroundBrush}"/>
|
||||
<SolidColorBrush x:Name="ToggleButtonBorderBrushPointerOver" Color="{ThemeResource AppControlTransparentButtonBackgroundBrush}"/>
|
||||
<SolidColorBrush x:Name="ToggleButtonForegroundPressed" Color="{ThemeResource SystemChromeWhiteColor}"/>
|
||||
<SolidColorBrush x:Name="ToggleButtonForegroundChecked" Color="{ThemeResource SystemChromeWhiteColor}"/>
|
||||
<SolidColorBrush x:Name="ToggleButtonForegroundPointerOver" Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor.Color}"/>
|
||||
<SolidColorBrush x:Name="ToggleButtonBackgroundChecked" Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor.Color}"/>
|
||||
<SolidColorBrush x:Name="ToggleButtonBackgroundCheckedPointerOver" Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor.Color}"/>
|
||||
<SolidColorBrush x:Name="ToggleButtonBackgroundCheckedPressed" Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor.Color}"/>
|
||||
<SolidColorBrush x:Name="ToggleButtonBackgroundPressed" Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor.Color}"/>
|
||||
</ToggleButton.Resources>
|
||||
</ToggleButton>
|
||||
<Button x:Name="FunctionButton"
|
||||
Grid.Column="1"
|
||||
MinWidth="34"
|
||||
|
@ -255,6 +255,9 @@
|
||||
<ClInclude Include="App.xaml.h">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EquationStylePanelControl.xaml.h">
|
||||
<DependentUpon>EquationStylePanelControl.xaml</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Views\Calculator.xaml.h">
|
||||
<DependentUpon>Views\Calculator.xaml</DependentUpon>
|
||||
</ClInclude>
|
||||
@ -323,6 +326,9 @@
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="AboutFlyout.xaml" />
|
||||
<Page Include="EquationStylePanelControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\Calculator.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
@ -399,6 +405,9 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EquationStylePanelControl.xaml.cpp">
|
||||
<DependentUpon>EquationStylePanelControl.xaml</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Views\Calculator.xaml.cpp">
|
||||
<DependentUpon>Views\Calculator.xaml</DependentUpon>
|
||||
</ClCompile>
|
||||
|
@ -467,6 +467,9 @@
|
||||
<Filter>Views\GraphingCalculator</Filter>
|
||||
</Page>
|
||||
<Page Include="$(MSBuildThisFileDirectory)DensityStyles\Compact.xaml" />
|
||||
<Page Include="EquationStylePanelControl.xaml">
|
||||
<Filter>Views\GraphingCalculator</Filter>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PRIResource Include="Resources\en-US\CEngineStrings.resw">
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include "pch.h"
|
||||
#include "EquationTextBox.h"
|
||||
#include "CalcViewModel/GraphingCalculator/EquationViewModel.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Platform;
|
||||
@ -72,6 +71,8 @@ void EquationTextBox::OnApplyTemplate()
|
||||
ColorChooserFlyout->Opened += ref new EventHandler<Object ^>(this, &EquationTextBox::OnColorFlyoutOpened);
|
||||
ColorChooserFlyout->Closed += ref new EventHandler<Object ^>(this, &EquationTextBox::OnColorFlyoutClosed);
|
||||
}
|
||||
|
||||
UpdateCommonVisualState();
|
||||
}
|
||||
|
||||
void EquationTextBox::OnPointerEntered(PointerRoutedEventArgs ^ e)
|
||||
@ -260,6 +261,5 @@ bool EquationTextBox::ShouldDeleteButtonBeVisible()
|
||||
{
|
||||
m_richEditBox->TextDocument->GetMath(&text);
|
||||
}
|
||||
|
||||
return (!text->IsEmpty() && m_isFocused);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CalcViewModel/Common/Utils.h"
|
||||
#include "CalcViewModel/GraphingCalculator/EquationViewModel.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
|
91
src/Calculator/EquationStylePanelControl.xaml
Normal file
91
src/Calculator/EquationStylePanelControl.xaml
Normal file
@ -0,0 +1,91 @@
|
||||
<UserControl x:Class="CalculatorApp.EquationStylePanelControl"
|
||||
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"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<GridView x:Name="ColorChooser"
|
||||
ItemsSource="{x:Bind AvailableColors}"
|
||||
Loaded="ColorChooserLoaded"
|
||||
SelectionChanged="SelectionChanged"
|
||||
SingleSelectionFollowsFocus="False">
|
||||
<GridView.ItemContainerStyle>
|
||||
<Style TargetType="GridViewItem">
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="MinHeight" Value="52"/>
|
||||
<Setter Property="MinWidth" Value="52"/>
|
||||
<Setter Property="Height" Value="52"/>
|
||||
<Setter Property="Width" Value="52"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GridViewItem">
|
||||
<Grid>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal"/>
|
||||
<VisualState x:Name="PointerOver">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ItemContent.Margin" Value="-2,-2,-2,-2"/>
|
||||
<Setter Target="ItemBorder.Margin" Value="2,2,2,2"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Pressed">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ItemContent.Margin" Value="-2,-2,-2,-2"/>
|
||||
<Setter Target="ItemBorder.Stroke" Value="{ThemeResource InkToolbarFlyoutItemBorderPressedThemeBrush}"/>
|
||||
<Setter Target="ItemBorder.Margin" Value="2,2,2,2"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Selected">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ItemContent.Margin" Value="2,2,2,2"/>
|
||||
<Setter Target="ItemBorder.Stroke" Value="{ThemeResource InkToolbarFlyoutItemBorderSelectedThemeBrush}"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="FocusStates">
|
||||
<VisualState x:Name="Focused"/>
|
||||
<VisualState x:Name="Unfocused"/>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Ellipse x:Name="ItemBorder"
|
||||
Margin="6,6,6,6"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Fill="Transparent"
|
||||
Stroke="Transparent"
|
||||
StrokeThickness="2"
|
||||
UseLayoutRounding="false"/>
|
||||
<ContentPresenter x:Name="ItemContent" UseLayoutRounding="false"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</GridView.ItemContainerStyle>
|
||||
<GridView.Header>
|
||||
<TextBlock x:Uid="LineColorText" Margin="8,0,8,8"/>
|
||||
</GridView.Header>
|
||||
<GridView.ItemTemplate>
|
||||
<DataTemplate x:DataType="Brush">
|
||||
<Ellipse Margin="8,8,8,8"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Fill="{x:Bind}"
|
||||
StrokeThickness="0"
|
||||
UseLayoutRounding="false"/>
|
||||
</DataTemplate>
|
||||
</GridView.ItemTemplate>
|
||||
<GridView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsWrapGrid MaximumRowsOrColumns="7" Orientation="Horizontal"/>
|
||||
</ItemsPanelTemplate>
|
||||
</GridView.ItemsPanel>
|
||||
</GridView>
|
||||
</UserControl>
|
92
src/Calculator/EquationStylePanelControl.xaml.cpp
Normal file
92
src/Calculator/EquationStylePanelControl.xaml.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "EquationStylePanelControl.xaml.h"
|
||||
|
||||
using namespace CalculatorApp;
|
||||
|
||||
using namespace Platform;
|
||||
using namespace Platform::Collections;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::Foundation::Collections;
|
||||
using namespace Windows::UI;
|
||||
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;
|
||||
using namespace Windows::UI::Xaml::Shapes;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(EquationStylePanelControl, SelectedColor);
|
||||
|
||||
EquationStylePanelControl::EquationStylePanelControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeAvailableColors();
|
||||
}
|
||||
|
||||
void EquationStylePanelControl::InitializeAvailableColors()
|
||||
{
|
||||
// TODO: Handle dynamically switching these to high contrast equivalents
|
||||
m_AvailableColors = ref new Vector<SolidColorBrush ^>();
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush1")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush2")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush3")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush4")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush5")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush6")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush7")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush8")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush9")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush10")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush11")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush12")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush13")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush14")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush15")));
|
||||
m_AvailableColors->Append(safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush16")));
|
||||
}
|
||||
|
||||
void EquationStylePanelControl::SelectionChanged(Object ^ /*sender */, SelectionChangedEventArgs ^ e)
|
||||
{
|
||||
if (e->AddedItems->Size > 0)
|
||||
{
|
||||
SelectedColor = static_cast<SolidColorBrush ^>(e->AddedItems->GetAt(0));
|
||||
}
|
||||
}
|
||||
|
||||
void EquationStylePanelControl::OnSelectedColorPropertyChanged(SolidColorBrush ^ /*oldColor*/, SolidColorBrush ^ newColor)
|
||||
{
|
||||
SelectColor(newColor);
|
||||
}
|
||||
|
||||
void EquationStylePanelControl::ColorChooserLoaded(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
SelectColor(SelectedColor);
|
||||
}
|
||||
|
||||
void EquationStylePanelControl::SelectColor(SolidColorBrush ^ selectedColor)
|
||||
{
|
||||
for (auto item : ColorChooser->Items->GetView())
|
||||
{
|
||||
auto brush = static_cast<SolidColorBrush ^>(item);
|
||||
auto gridViewItem = dynamic_cast<GridViewItem ^>(ColorChooser->ContainerFromItem(brush));
|
||||
|
||||
if (!gridViewItem)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (brush->Color == selectedColor->Color)
|
||||
{
|
||||
gridViewItem->IsSelected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
gridViewItem->IsSelected = false;
|
||||
}
|
||||
}
|
||||
}
|
35
src/Calculator/EquationStylePanelControl.xaml.h
Normal file
35
src/Calculator/EquationStylePanelControl.xaml.h
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "EquationStylePanelControl.g.h"
|
||||
#include "CalcViewModel/Common/Utils.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class EquationStylePanelControl sealed
|
||||
{
|
||||
public:
|
||||
EquationStylePanelControl();
|
||||
DEPENDENCY_PROPERTY_OWNER(EquationStylePanelControl);
|
||||
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(Windows::UI::Xaml::Media::SolidColorBrush ^, SelectedColor);
|
||||
|
||||
property Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Media::SolidColorBrush^>^ AvailableColors
|
||||
{
|
||||
Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Media::SolidColorBrush^>^ get() {
|
||||
return m_AvailableColors;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void InitializeAvailableColors();
|
||||
void SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
|
||||
void OnSelectedColorPropertyChanged(Windows::UI::Xaml::Media::SolidColorBrush ^ oldValue, Windows::UI::Xaml::Media::SolidColorBrush ^ newValue);
|
||||
void ColorChooserLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void SelectColor(Windows::UI::Xaml::Media::SolidColorBrush ^ selectedColor);
|
||||
|
||||
Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Media::SolidColorBrush ^>^ m_AvailableColors;
|
||||
};
|
||||
}
|
@ -3527,4 +3527,8 @@
|
||||
<value>Max</value>
|
||||
<comment>Label text for the max text box</comment>
|
||||
</data>
|
||||
<data name="LineColorText.Text" xml:space="preserve">
|
||||
<value>Line Color</value>
|
||||
<comment>Label for the Line Color section of the style picker</comment>
|
||||
</data>
|
||||
</root>
|
||||
|
@ -3,80 +3,59 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:CalculatorApp.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:CalculatorApp"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:CalculatorApp.ViewModel"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="400"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ListView x:Name="EquationInputList"
|
||||
VerticalContentAlignment="Top"
|
||||
IsItemClickEnabled="False"
|
||||
ItemsSource="{x:Bind Equations}"
|
||||
SelectionMode="None">
|
||||
|
||||
<ListView x:Name="EquationInputList"
|
||||
Grid.Row="0"
|
||||
Margin="0,8,0,0"
|
||||
IsItemClickEnabled="False"
|
||||
ItemsSource="{x:Bind Equations}"
|
||||
SelectionMode="None">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="Margin" Value="0,0,0,2"/>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="Margin" Value="0,0,0,2"/>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:EquationViewModel">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.Resources>
|
||||
<SolidColorBrush x:Key="LineColorBrush" Color="{x:Bind LineColor, Mode=OneWay}"/>
|
||||
</Grid.Resources>
|
||||
|
||||
<controls:EquationTextBox x:Uid="EquationInputButton"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,3,0"
|
||||
Style="{StaticResource EquationTextBoxStyle}"
|
||||
EquationSubmitted="InputTextBox_Submitted"
|
||||
GotFocus="InputTextBox_GotFocus"
|
||||
LostFocus="InputTextBox_LostFocus"
|
||||
RemoveButtonClicked="EquationTextBox_RemoveButtonClicked">
|
||||
<controls:EquationTextBox.EquationColor>
|
||||
<SolidColorBrush x:Name="EquationLineColor" Color="{x:Bind LineColor, Mode=OneWay}"/>
|
||||
</controls:EquationTextBox.EquationColor>
|
||||
<controls:EquationTextBox.KeyGraphFeaturesContent>
|
||||
<StackPanel x:Name="KeyGraphFeaturesGrid" Visibility="{x:Bind KeyGraphFeaturesVisibility, Mode=OneWay}">
|
||||
<TextBlock Text="Key Graph Features"/>
|
||||
<TextBlock Text="{x:Bind Expression, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
</controls:EquationTextBox.KeyGraphFeaturesContent>
|
||||
<controls:EquationTextBox.ColorChooserFlyout>
|
||||
<Flyout x:Name="ColorChooserFlyout"
|
||||
x:Uid="ColorChooserFlyout"
|
||||
Placement="Bottom">
|
||||
<StackPanel>
|
||||
<ColorPicker x:Name="EquationColorPicker" Color="{x:Bind LineColor, Mode=TwoWay}"/>
|
||||
</StackPanel>
|
||||
</Flyout>
|
||||
</controls:EquationTextBox.ColorChooserFlyout>
|
||||
</controls:EquationTextBox>
|
||||
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
|
||||
<Button Grid.Row="1"
|
||||
Margin="4"
|
||||
Click="AddEquationButton_Click"
|
||||
Content="+"/>
|
||||
</Grid>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:EquationViewModel">
|
||||
<controls:EquationTextBox x:Uid="EquationInputButton"
|
||||
Margin="0,0,3,0"
|
||||
Style="{StaticResource EquationTextBoxStyle}"
|
||||
EquationColor="{x:Bind LineColor, Mode=OneWay}"
|
||||
EquationSubmitted="InputTextBox_Submitted"
|
||||
GotFocus="InputTextBox_GotFocus"
|
||||
Loaded="EquationTextBoxLoaded"
|
||||
LostFocus="InputTextBox_LostFocus"
|
||||
RemoveButtonClicked="EquationTextBox_RemoveButtonClicked">
|
||||
<controls:EquationTextBox.KeyGraphFeaturesContent>
|
||||
<StackPanel x:Name="KeyGraphFeaturesGrid" Visibility="{x:Bind KeyGraphFeaturesVisibility, Mode=OneWay}">
|
||||
<TextBlock Text="Key Graph Features"/>
|
||||
<TextBlock Text="{x:Bind Expression, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
</controls:EquationTextBox.KeyGraphFeaturesContent>
|
||||
<controls:EquationTextBox.ColorChooserFlyout>
|
||||
<Flyout x:Name="ColorChooserFlyout"
|
||||
x:Uid="ColorChooserFlyout"
|
||||
Placement="Bottom">
|
||||
<local:EquationStylePanelControl SelectedColor="{x:Bind LineColor, Mode=TwoWay}"/>
|
||||
</Flyout>
|
||||
</controls:EquationTextBox.ColorChooserFlyout>
|
||||
</controls:EquationTextBox>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
<ListView.Footer>
|
||||
<Button Margin="4"
|
||||
Click="AddEquationButton_Click"
|
||||
Content="+"/>
|
||||
</ListView.Footer>
|
||||
</ListView>
|
||||
</UserControl>
|
||||
|
@ -1,7 +1,5 @@
|
||||
#include "pch.h"
|
||||
#include "EquationInputArea.xaml.h"
|
||||
#include "CalcViewModel/Common/KeyboardShortcutManager.h"
|
||||
#include "Controls/EquationTextBox.h"
|
||||
|
||||
using namespace CalculatorApp;
|
||||
using namespace CalculatorApp::Common;
|
||||
@ -13,25 +11,14 @@ using namespace Windows::System;
|
||||
using namespace Windows::UI;
|
||||
using namespace Windows::UI::ViewManagement;
|
||||
using namespace Windows::UI::Xaml;
|
||||
using namespace Windows::UI::Xaml::Media;
|
||||
using namespace Windows::UI::Xaml::Controls;
|
||||
using namespace Windows::UI::Xaml::Controls::Primitives;
|
||||
using namespace Windows::UI::Xaml::Input;
|
||||
using namespace GraphControl;
|
||||
|
||||
namespace
|
||||
{
|
||||
const Color accentColor = (ref new UISettings())->GetColorValue(UIColorType::Accent);
|
||||
const Color lineColors[] = {
|
||||
accentColor,
|
||||
Colors::DarkOrange,
|
||||
Colors::MediumPurple,
|
||||
Colors::ForestGreen,
|
||||
Colors::BlueViolet,
|
||||
Colors::DarkRed,
|
||||
Colors::LightGoldenrodYellow,
|
||||
Colors::DarkOliveGreen
|
||||
};
|
||||
const size_t lineColorsSize = std::size(lineColors);
|
||||
|
||||
StringReference EquationsPropertyName(L"Equations");
|
||||
}
|
||||
|
||||
@ -65,8 +52,6 @@ void EquationInputArea::AddEquationButton_Click(Object^ sender, RoutedEventArgs^
|
||||
void EquationInputArea::AddNewEquation()
|
||||
{
|
||||
auto eq = ref new EquationViewModel();
|
||||
eq->LineColor = GetNextLineColor();
|
||||
|
||||
Equations->Append(eq);
|
||||
}
|
||||
|
||||
@ -85,15 +70,9 @@ void EquationInputArea::InputTextBox_Submitted(Object ^ sender, RoutedEventArgs
|
||||
auto tb = static_cast<EquationTextBox^>(sender);
|
||||
auto eq = static_cast<EquationViewModel^>(tb->DataContext);
|
||||
eq->Expression = tb->GetEquationText();
|
||||
FocusManager::TryMoveFocus(::FocusNavigationDirection::Left);
|
||||
}
|
||||
|
||||
Color EquationInputArea::GetNextLineColor()
|
||||
{
|
||||
m_lastLineColorIndex = (m_lastLineColorIndex + 1) % lineColorsSize;
|
||||
return lineColors[m_lastLineColorIndex];
|
||||
}
|
||||
|
||||
|
||||
void EquationInputArea::EquationTextBox_RemoveButtonClicked(Object^ sender, RoutedEventArgs^ e)
|
||||
{
|
||||
auto tb = static_cast<EquationTextBox^>(sender);
|
||||
@ -104,3 +83,15 @@ void EquationInputArea::EquationTextBox_RemoveButtonClicked(Object^ sender, Rout
|
||||
Equations->RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
void EquationInputArea::EquationTextBoxLoaded(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
auto tb = static_cast<EquationTextBox ^>(sender);
|
||||
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
|
||||
|
||||
auto colorChooser = static_cast<EquationStylePanelControl ^>(tb->ColorChooserFlyout->Content);
|
||||
|
||||
m_lastLineColorIndex = (m_lastLineColorIndex + 1) % colorChooser->AvailableColors->Size;
|
||||
|
||||
eq->LineColor = colorChooser->AvailableColors->GetAt(m_lastLineColorIndex);
|
||||
}
|
||||
|
@ -3,6 +3,9 @@
|
||||
#include "Views/GraphingCalculator/EquationInputArea.g.h"
|
||||
#include "CalcViewModel/Common/Utils.h"
|
||||
#include "CalcViewModel/GraphingCalculator/EquationViewModel.h"
|
||||
#include "EquationStylePanelControl.xaml.h"
|
||||
#include "CalcViewModel/Common/KeyboardShortcutManager.h"
|
||||
#include "Controls/EquationTextBox.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
@ -25,10 +28,9 @@ namespace CalculatorApp
|
||||
void InputTextBox_LostFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void InputTextBox_Submitted(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
Windows::UI::Color GetNextLineColor();
|
||||
|
||||
private:
|
||||
int m_lastLineColorIndex;
|
||||
void EquationTextBox_RemoveButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void EquationTextBoxLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@ -365,18 +365,23 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="5*"/>
|
||||
<RowDefinition Height="3*"/>
|
||||
<RowDefinition Height="3*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button x:Name="Share" Click="OnShareClick">
|
||||
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph=""/>
|
||||
</Button>
|
||||
<local:EquationInputArea Grid.Row="0" Equations="{x:Bind ViewModel.Equations}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<local:EquationInputArea Grid.Row="1"
|
||||
Margin="0,8,0,0"
|
||||
Equations="{x:Bind ViewModel.Equations}"/>
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="ButtonContainerGrid"
|
||||
Grid.Row="2"
|
||||
Grid.Row="1"
|
||||
Margin="3,0,3,3"
|
||||
UseLayoutRounding="False">
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -92,7 +92,7 @@ void GraphingCalculator::OnDataRequested(DataTransferManager^ sender, DataReques
|
||||
for (unsigned i = 0; i < equations->Size; i++)
|
||||
{
|
||||
auto expression = equations->GetAt(i)->Expression->Data();
|
||||
auto color = equations->GetAt(i)->LineColor;
|
||||
auto color = equations->GetAt(i)->LineColor->Color;
|
||||
|
||||
if (equations->GetAt(i)->Expression->Length() == 0)
|
||||
{
|
||||
@ -204,11 +204,11 @@ void GraphingCalculator::SubmitTextbox(TextBox^ sender)
|
||||
}
|
||||
else if (sender->Name == "MaxTextBox")
|
||||
{
|
||||
variableViewModel->Step = validateDouble(sender->Text, variableViewModel->Step);
|
||||
variableViewModel->Max = validateDouble(sender->Text, variableViewModel->Max);
|
||||
}
|
||||
else if (sender->Name == "StepTextBox")
|
||||
{
|
||||
variableViewModel->Max = validateDouble(sender->Text, variableViewModel->Max);
|
||||
variableViewModel->Step = validateDouble(sender->Text, variableViewModel->Step);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ using namespace std;
|
||||
using namespace Windows::UI;
|
||||
using namespace Windows::UI::ViewManagement;
|
||||
using namespace Windows::UI::Xaml;
|
||||
using namespace Windows::UI::Xaml::Media;
|
||||
|
||||
namespace GraphControl
|
||||
{
|
||||
@ -41,14 +42,13 @@ namespace GraphControl
|
||||
{
|
||||
// Default line color should be the user's accent color
|
||||
auto uiSettings = ref new UISettings();
|
||||
Color accentColor = uiSettings->GetColorValue(UIColorType::Accent);
|
||||
|
||||
s_lineColorProperty = DependencyProperty::Register(
|
||||
EquationProperties::LineColor,
|
||||
Color::typeid,
|
||||
SolidColorBrush::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(
|
||||
accentColor,
|
||||
nullptr,
|
||||
ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
}
|
||||
|
@ -4,22 +4,23 @@ namespace GraphControl
|
||||
{
|
||||
namespace EquationProperties
|
||||
{
|
||||
extern Platform::String^ Expression;
|
||||
extern Platform::String^ LineColor;
|
||||
extern Platform::String ^ Expression;
|
||||
extern Platform::String ^ LineColor;
|
||||
}
|
||||
|
||||
ref class Equation;
|
||||
delegate void PropertyChangedEventHandler(Equation^ sender, Platform::String^ propertyName);
|
||||
delegate void PropertyChangedEventHandler(Equation ^ sender, Platform::String ^ propertyName);
|
||||
|
||||
[Windows::UI::Xaml::Data::Bindable]
|
||||
public ref class Equation sealed : public Windows::UI::Xaml::FrameworkElement
|
||||
[Windows::UI::Xaml::Data::Bindable] public ref class Equation sealed : public Windows::UI::Xaml::FrameworkElement
|
||||
{
|
||||
public:
|
||||
Equation() {}
|
||||
Equation()
|
||||
{
|
||||
}
|
||||
|
||||
static void RegisterDependencyProperties();
|
||||
|
||||
#pragma region Platform::String^ Expression DependencyProperty
|
||||
#pragma region Platform::String ^ Expression DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ ExpressionProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
@ -38,9 +39,9 @@ namespace GraphControl
|
||||
SetValue(s_expressionProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Windows::UI::Color LineColor DependencyProperty
|
||||
#pragma region Windows::UI::Xaml::Media::SolidColorBrush ^ LineColor DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ LineColorProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
@ -48,18 +49,22 @@ namespace GraphControl
|
||||
return s_lineColorProperty;
|
||||
}
|
||||
}
|
||||
property Windows::UI::Color LineColor
|
||||
property Windows::UI::Xaml::Media::SolidColorBrush^ LineColor
|
||||
{
|
||||
Windows::UI::Color get()
|
||||
Windows::UI::Xaml::Media::SolidColorBrush^ get()
|
||||
{
|
||||
return static_cast<Windows::UI::Color>(GetValue(s_lineColorProperty));
|
||||
return static_cast<Windows::UI::Xaml::Media::SolidColorBrush^>(GetValue(s_lineColorProperty));
|
||||
}
|
||||
void set(Windows::UI::Color value)
|
||||
void set(Windows::UI::Xaml::Media::SolidColorBrush^ value)
|
||||
{
|
||||
SetValue(s_lineColorProperty, value);
|
||||
if (value == nullptr || LineColor == nullptr || (value->Color.A != LineColor->Color.A) || (value->Color.R != LineColor->Color.R) || (value->Color.G != LineColor->Color.G)
|
||||
|| (value->Color.B != LineColor->Color.B))
|
||||
{
|
||||
SetValue(s_lineColorProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
internal:
|
||||
event PropertyChangedEventHandler^ PropertyChanged;
|
||||
@ -67,14 +72,14 @@ namespace GraphControl
|
||||
std::wstring GetRequest();
|
||||
|
||||
private:
|
||||
static void OnCustomDependencyPropertyChanged(Windows::UI::Xaml::DependencyObject^ obj, Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ args);
|
||||
static void OnCustomDependencyPropertyChanged(Windows::UI::Xaml::DependencyObject ^ obj, Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ args);
|
||||
|
||||
std::wstring GetRequestHeader();
|
||||
std::wstring GetExpression();
|
||||
std::wstring GetLineColor();
|
||||
|
||||
private:
|
||||
static Windows::UI::Xaml::DependencyProperty^ s_expressionProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty^ s_lineColorProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_expressionProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_lineColorProperty;
|
||||
};
|
||||
}
|
||||
|
@ -6,21 +6,22 @@ namespace GraphControl
|
||||
{
|
||||
delegate void EquationChangedEventHandler();
|
||||
|
||||
public ref class EquationCollection sealed : public Windows::Foundation::Collections::IObservableVector< GraphControl::Equation^ >
|
||||
public
|
||||
ref class EquationCollection sealed : public Windows::Foundation::Collections::IObservableVector<GraphControl::Equation ^>
|
||||
{
|
||||
public:
|
||||
virtual ~EquationCollection()
|
||||
{
|
||||
}
|
||||
|
||||
#pragma region IIterable
|
||||
#pragma region IIterable
|
||||
virtual Windows::Foundation::Collections::IIterator< GraphControl::Equation^ >^ First()
|
||||
{
|
||||
return m_vector->First();
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
#pragma region IVector
|
||||
#pragma region IVector
|
||||
virtual property unsigned int Size
|
||||
{
|
||||
unsigned int get()
|
||||
@ -29,12 +30,11 @@ namespace GraphControl
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Append(GraphControl::Equation^ value)
|
||||
virtual void Append(GraphControl::Equation ^ value)
|
||||
{
|
||||
m_vector->Append(value);
|
||||
m_tokens.emplace_back(
|
||||
value->PropertyChanged += ref new GraphControl::PropertyChangedEventHandler(this, &EquationCollection::OnEquationPropertyChanged)
|
||||
);
|
||||
value->PropertyChanged += ref new GraphControl::PropertyChangedEventHandler(this, &EquationCollection::OnEquationPropertyChanged));
|
||||
}
|
||||
|
||||
virtual void Clear()
|
||||
@ -49,12 +49,10 @@ namespace GraphControl
|
||||
m_tokens.clear();
|
||||
}
|
||||
|
||||
virtual GraphControl::Equation^ GetAt(unsigned int index)
|
||||
{
|
||||
return m_vector->GetAt(index);
|
||||
}
|
||||
virtual GraphControl::Equation
|
||||
^ GetAt(unsigned int index) { return m_vector->GetAt(index); }
|
||||
|
||||
virtual unsigned int GetMany(unsigned int startIndex, Platform::WriteOnlyArray< GraphControl::Equation^ >^ items)
|
||||
virtual unsigned int GetMany(unsigned int startIndex, Platform::WriteOnlyArray<GraphControl::Equation ^> ^ items)
|
||||
{
|
||||
return m_vector->GetMany(startIndex, items);
|
||||
}
|
||||
@ -69,13 +67,11 @@ namespace GraphControl
|
||||
return m_vector->IndexOf(value, index);
|
||||
}
|
||||
|
||||
virtual void InsertAt(unsigned int index, GraphControl::Equation^ value)
|
||||
virtual void InsertAt(unsigned int index, GraphControl::Equation ^ value)
|
||||
{
|
||||
m_vector->InsertAt(index, value);
|
||||
m_tokens.insert(
|
||||
m_tokens.begin() + index,
|
||||
value->PropertyChanged += ref new PropertyChangedEventHandler(this, &EquationCollection::OnEquationPropertyChanged)
|
||||
);
|
||||
m_tokens.begin() + index, value->PropertyChanged += ref new PropertyChangedEventHandler(this, &EquationCollection::OnEquationPropertyChanged));
|
||||
}
|
||||
|
||||
virtual void RemoveAt(unsigned int index)
|
||||
@ -98,7 +94,7 @@ namespace GraphControl
|
||||
m_vector->RemoveAtEnd();
|
||||
}
|
||||
|
||||
virtual void ReplaceAll(const Platform::Array< GraphControl::Equation^ >^ items)
|
||||
virtual void ReplaceAll(const Platform::Array<GraphControl::Equation ^> ^ items)
|
||||
{
|
||||
auto size = m_vector->Size;
|
||||
for (auto i = 0u; i < size; i++)
|
||||
@ -116,17 +112,16 @@ namespace GraphControl
|
||||
m_vector->ReplaceAll(items);
|
||||
}
|
||||
|
||||
virtual void SetAt(unsigned int index, GraphControl::Equation^ value)
|
||||
virtual void SetAt(unsigned int index, GraphControl::Equation ^ value)
|
||||
{
|
||||
m_vector->GetAt(index)->PropertyChanged -= m_tokens[index];
|
||||
|
||||
m_vector->SetAt(index, value);
|
||||
m_tokens[index] =
|
||||
value->PropertyChanged += ref new PropertyChangedEventHandler(this, &EquationCollection::OnEquationPropertyChanged);
|
||||
m_tokens[index] = value->PropertyChanged += ref new PropertyChangedEventHandler(this, &EquationCollection::OnEquationPropertyChanged);
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
#pragma region IObservableVector
|
||||
#pragma region IObservableVector
|
||||
virtual event Windows::Foundation::Collections::VectorChangedEventHandler< GraphControl::Equation^ >^ VectorChanged
|
||||
{
|
||||
Windows::Foundation::EventRegistrationToken add(Windows::Foundation::Collections::VectorChangedEventHandler< GraphControl::Equation^ >^ handler)
|
||||
@ -139,7 +134,7 @@ namespace GraphControl
|
||||
m_vector->VectorChanged -= token;
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
internal:
|
||||
EquationCollection() :
|
||||
@ -147,16 +142,24 @@ namespace GraphControl
|
||||
{
|
||||
}
|
||||
|
||||
event EquationChangedEventHandler^ EquationChanged;
|
||||
event EquationChangedEventHandler ^ EquationChanged;
|
||||
event EquationChangedEventHandler ^ EquationStyleChanged;
|
||||
|
||||
private:
|
||||
void OnEquationPropertyChanged(GraphControl::Equation^, Platform::String^ propertyName)
|
||||
void OnEquationPropertyChanged(GraphControl::Equation ^, Platform::String ^ propertyName)
|
||||
{
|
||||
EquationChanged();
|
||||
if (propertyName == L"LineColor")
|
||||
{
|
||||
EquationStyleChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
EquationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Platform::Collections::Vector< GraphControl::Equation^ >^ m_vector;
|
||||
Platform::Collections::Vector<GraphControl::Equation ^> ^ m_vector;
|
||||
std::vector<Windows::Foundation::EventRegistrationToken> m_tokens;
|
||||
};
|
||||
}
|
||||
|
@ -39,17 +39,17 @@ namespace
|
||||
// Translate the pointer position to the [-1, 1] bounds.
|
||||
__inline pair<double, double> PointerPositionToGraphPosition(double posX, double posY, double width, double height)
|
||||
{
|
||||
return make_pair(( 2 * posX / width - 1 ), ( 1 - 2 * posY / height ));
|
||||
return make_pair((2 * posX / width - 1), (1 - 2 * posY / height));
|
||||
}
|
||||
}
|
||||
|
||||
namespace GraphControl
|
||||
{
|
||||
DependencyProperty^ Grapher::s_equationTemplateProperty;
|
||||
DependencyProperty^ Grapher::s_equationsProperty;
|
||||
DependencyProperty^ Grapher::s_equationsSourceProperty;
|
||||
DependencyProperty^ Grapher::s_variablesProperty;
|
||||
DependencyProperty^ Grapher::s_forceProportionalAxesTemplateProperty;
|
||||
DependencyProperty ^ Grapher::s_equationTemplateProperty;
|
||||
DependencyProperty ^ Grapher::s_equationsProperty;
|
||||
DependencyProperty ^ Grapher::s_equationsSourceProperty;
|
||||
DependencyProperty ^ Grapher::s_variablesProperty;
|
||||
DependencyProperty ^ Grapher::s_forceProportionalAxesTemplateProperty;
|
||||
|
||||
Grapher::Grapher()
|
||||
: m_solver{ IMathSolver::CreateMathSolver() }
|
||||
@ -60,33 +60,29 @@ namespace GraphControl
|
||||
DefaultStyleKey = StringReference(s_defaultStyleKey);
|
||||
|
||||
this->SetValue(EquationsProperty, ref new EquationCollection());
|
||||
this->SetValue(VariablesProperty, ref new Map<String^, double>());
|
||||
this->SetValue(VariablesProperty, ref new Map<String ^, double>());
|
||||
|
||||
this->Loaded += ref new RoutedEventHandler(this, &Grapher::OnLoaded);
|
||||
this->Unloaded += ref new RoutedEventHandler(this, &Grapher::OnUnloaded);
|
||||
|
||||
this->ManipulationMode =
|
||||
ManipulationModes::TranslateX |
|
||||
ManipulationModes::TranslateY |
|
||||
ManipulationModes::TranslateInertia |
|
||||
ManipulationModes::Scale |
|
||||
ManipulationModes::ScaleInertia;
|
||||
this->ManipulationMode = ManipulationModes::TranslateX | ManipulationModes::TranslateY | ManipulationModes::TranslateInertia | ManipulationModes::Scale
|
||||
| ManipulationModes::ScaleInertia;
|
||||
}
|
||||
|
||||
void Grapher::OnLoaded(Object^ sender, RoutedEventArgs^ args)
|
||||
void Grapher::OnLoaded(Object ^ sender, RoutedEventArgs ^ args)
|
||||
{
|
||||
if (auto backgroundBrush = safe_cast<SolidColorBrush^>(this->Background))
|
||||
if (auto backgroundBrush = safe_cast<SolidColorBrush ^>(this->Background))
|
||||
{
|
||||
m_tokenBackgroundColorChanged.Value =
|
||||
backgroundBrush->RegisterPropertyChangedCallback(SolidColorBrush::ColorProperty, ref new DependencyPropertyChangedCallback(this, &Grapher::OnDependencyPropertyChanged));
|
||||
m_tokenBackgroundColorChanged.Value = backgroundBrush->RegisterPropertyChangedCallback(
|
||||
SolidColorBrush::ColorProperty, ref new DependencyPropertyChangedCallback(this, &Grapher::OnDependencyPropertyChanged));
|
||||
|
||||
OnBackgroundColorChanged(backgroundBrush->Color);
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnUnloaded(Object^ sender, RoutedEventArgs^ args)
|
||||
void Grapher::OnUnloaded(Object ^ sender, RoutedEventArgs ^ args)
|
||||
{
|
||||
if (auto backgroundBrush = safe_cast<SolidColorBrush^>(this->Background))
|
||||
if (auto backgroundBrush = safe_cast<SolidColorBrush ^>(this->Background))
|
||||
{
|
||||
this->UnregisterPropertyChangedCallback(BackgroundProperty, m_tokenBackgroundColorChanged.Value);
|
||||
}
|
||||
@ -127,7 +123,7 @@ namespace GraphControl
|
||||
|
||||
void Grapher::OnApplyTemplate()
|
||||
{
|
||||
auto swapChainPanel = dynamic_cast<SwapChainPanel^>(GetTemplateChild(StringReference(s_templateKey_SwapChainPanel)));
|
||||
auto swapChainPanel = dynamic_cast<SwapChainPanel ^>(GetTemplateChild(StringReference(s_templateKey_SwapChainPanel)));
|
||||
if (swapChainPanel)
|
||||
{
|
||||
m_renderMain = ref new RenderMain(swapChainPanel);
|
||||
@ -144,9 +140,7 @@ namespace GraphControl
|
||||
StringReference(s_propertyName_Equations),
|
||||
EquationCollection::typeid,
|
||||
Grapher::typeid,
|
||||
ref new PropertyMetadata(
|
||||
nullptr,
|
||||
ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_equationsSourceProperty)
|
||||
@ -155,9 +149,7 @@ namespace GraphControl
|
||||
StringReference(s_propertyName_EquationsSource),
|
||||
Object::typeid,
|
||||
Grapher::typeid,
|
||||
ref new PropertyMetadata(
|
||||
nullptr,
|
||||
ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_equationTemplateProperty)
|
||||
@ -166,37 +158,31 @@ namespace GraphControl
|
||||
StringReference(s_propertyName_EquationTemplate),
|
||||
DataTemplate::typeid,
|
||||
Grapher::typeid,
|
||||
ref new PropertyMetadata(
|
||||
nullptr,
|
||||
ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_variablesProperty)
|
||||
{
|
||||
s_variablesProperty = DependencyProperty::Register(
|
||||
StringReference(s_propertyName_Variables),
|
||||
IObservableMap<String^, double>::typeid,
|
||||
IObservableMap<String ^, double>::typeid,
|
||||
Grapher::typeid,
|
||||
ref new PropertyMetadata(
|
||||
nullptr,
|
||||
ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_forceProportionalAxesTemplateProperty)
|
||||
{
|
||||
s_forceProportionalAxesTemplateProperty = DependencyProperty::Register(
|
||||
StringReference(s_propertyName_ForceProportionalAxes),
|
||||
bool::typeid,
|
||||
bool ::typeid,
|
||||
Grapher::typeid,
|
||||
ref new PropertyMetadata(
|
||||
true,
|
||||
ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
ref new PropertyMetadata(true, ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnCustomDependencyPropertyChanged(DependencyObject^ obj, DependencyPropertyChangedEventArgs^ args)
|
||||
void Grapher::OnCustomDependencyPropertyChanged(DependencyObject ^ obj, DependencyPropertyChangedEventArgs ^ args)
|
||||
{
|
||||
auto self = static_cast<Grapher^>(obj);
|
||||
auto self = static_cast<Grapher ^>(obj);
|
||||
if (self)
|
||||
{
|
||||
if (args->Property == EquationsProperty)
|
||||
@ -218,21 +204,21 @@ namespace GraphControl
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnDependencyPropertyChanged(DependencyObject^ obj, DependencyProperty^ p)
|
||||
void Grapher::OnDependencyPropertyChanged(DependencyObject ^ obj, DependencyProperty ^ p)
|
||||
{
|
||||
if (p == SolidColorBrush::ColorProperty)
|
||||
{
|
||||
auto brush = static_cast<SolidColorBrush^>(obj);
|
||||
auto brush = static_cast<SolidColorBrush ^>(obj);
|
||||
OnBackgroundColorChanged(brush->Color);
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnEquationTemplateChanged(DependencyPropertyChangedEventArgs^ args)
|
||||
void Grapher::OnEquationTemplateChanged(DependencyPropertyChangedEventArgs ^ args)
|
||||
{
|
||||
SyncEquationsWithItemsSource();
|
||||
}
|
||||
|
||||
void Grapher::OnEquationsSourceChanged(DependencyPropertyChangedEventArgs^ args)
|
||||
void Grapher::OnEquationsSourceChanged(DependencyPropertyChangedEventArgs ^ args)
|
||||
{
|
||||
if (m_dataSource && m_tokenDataSourceChanged.Value != 0)
|
||||
{
|
||||
@ -242,14 +228,14 @@ namespace GraphControl
|
||||
m_dataSource = args->NewValue ? ref new InspectingDataSource(args->NewValue) : nullptr;
|
||||
if (m_dataSource)
|
||||
{
|
||||
m_tokenDataSourceChanged =
|
||||
m_dataSource->DataSourceChanged += ref new TypedEventHandler<InspectingDataSource^, DataSourceChangedEventArgs>(this, &Grapher::OnDataSourceChanged);
|
||||
m_tokenDataSourceChanged = m_dataSource->DataSourceChanged +=
|
||||
ref new TypedEventHandler<InspectingDataSource ^, DataSourceChangedEventArgs>(this, &Grapher::OnDataSourceChanged);
|
||||
}
|
||||
|
||||
SyncEquationsWithItemsSource();
|
||||
}
|
||||
|
||||
void Grapher::OnDataSourceChanged(InspectingDataSource^ sender, DataSourceChangedEventArgs args)
|
||||
void Grapher::OnDataSourceChanged(InspectingDataSource ^ sender, DataSourceChangedEventArgs args)
|
||||
{
|
||||
switch (args.Action)
|
||||
{
|
||||
@ -276,7 +262,7 @@ namespace GraphControl
|
||||
{
|
||||
for (int i = index + count - 1; i >= index; i--)
|
||||
{
|
||||
auto eq = safe_cast<Equation^>(EquationTemplate->LoadContent());
|
||||
auto eq = safe_cast<Equation ^>(EquationTemplate->LoadContent());
|
||||
eq->DataContext = m_dataSource->GetAt(i);
|
||||
|
||||
Equations->InsertAt(index, eq);
|
||||
@ -299,7 +285,7 @@ namespace GraphControl
|
||||
auto size = m_dataSource->GetSize();
|
||||
for (auto i = 0u; i < size; i++)
|
||||
{
|
||||
auto eq = safe_cast<Equation^>(EquationTemplate->LoadContent());
|
||||
auto eq = safe_cast<Equation ^>(EquationTemplate->LoadContent());
|
||||
eq->DataContext = m_dataSource->GetAt(i);
|
||||
|
||||
Equations->Append(eq);
|
||||
@ -307,9 +293,9 @@ namespace GraphControl
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnEquationsChanged(DependencyPropertyChangedEventArgs^ args)
|
||||
void Grapher::OnEquationsChanged(DependencyPropertyChangedEventArgs ^ args)
|
||||
{
|
||||
if (auto older = static_cast<EquationCollection^>(args->OldValue))
|
||||
if (auto older = static_cast<EquationCollection ^>(args->OldValue))
|
||||
{
|
||||
if (m_tokenEquationsChanged.Value != 0)
|
||||
{
|
||||
@ -321,21 +307,27 @@ namespace GraphControl
|
||||
older->EquationChanged -= m_tokenEquationChanged;
|
||||
m_tokenEquationChanged.Value = 0;
|
||||
}
|
||||
|
||||
if (m_tokenEquationStyleChanged.Value != 0)
|
||||
{
|
||||
older->EquationStyleChanged -= m_tokenEquationStyleChanged;
|
||||
m_tokenEquationStyleChanged.Value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto newer = static_cast<EquationCollection^>(args->NewValue))
|
||||
if (auto newer = static_cast<EquationCollection ^>(args->NewValue))
|
||||
{
|
||||
m_tokenEquationsChanged =
|
||||
newer->VectorChanged += ref new VectorChangedEventHandler<Equation^>(this, &Grapher::OnEquationsVectorChanged);
|
||||
m_tokenEquationsChanged = newer->VectorChanged += ref new VectorChangedEventHandler<Equation ^>(this, &Grapher::OnEquationsVectorChanged);
|
||||
|
||||
m_tokenEquationChanged =
|
||||
newer->EquationChanged += ref new EquationChangedEventHandler(this, &Grapher::OnEquationChanged);
|
||||
m_tokenEquationChanged = newer->EquationChanged += ref new EquationChangedEventHandler(this, &Grapher::OnEquationChanged);
|
||||
|
||||
m_tokenEquationStyleChanged = newer->EquationStyleChanged += ref new EquationChangedEventHandler(this, &Grapher::OnEquationStyleChanged);
|
||||
}
|
||||
|
||||
UpdateGraph();
|
||||
}
|
||||
|
||||
void Grapher::OnEquationsVectorChanged(IObservableVector<Equation^>^ sender, IVectorChangedEventArgs^ event)
|
||||
void Grapher::OnEquationsVectorChanged(IObservableVector<Equation ^> ^ sender, IVectorChangedEventArgs ^ event)
|
||||
{
|
||||
if (event->CollectionChange == ::CollectionChange::ItemInserted || event->CollectionChange == ::CollectionChange::ItemChanged)
|
||||
{
|
||||
@ -356,6 +348,19 @@ namespace GraphControl
|
||||
UpdateGraph();
|
||||
}
|
||||
|
||||
void Grapher::OnEquationStyleChanged()
|
||||
{
|
||||
if (m_graph)
|
||||
{
|
||||
UpdateGraphOptions(m_graph->GetOptions(), GetValidEquations());
|
||||
}
|
||||
|
||||
if (m_renderMain)
|
||||
{
|
||||
m_renderMain->RunRenderPass();
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::UpdateGraph()
|
||||
{
|
||||
if (m_renderMain && m_graph != nullptr)
|
||||
@ -368,7 +373,7 @@ namespace GraphControl
|
||||
ss << L"<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><mi>show2d</mi><mfenced separators=\"\">";
|
||||
|
||||
int numValidEquations = 0;
|
||||
for (Equation^ eq : validEqs)
|
||||
for (Equation ^ eq : validEqs)
|
||||
{
|
||||
if (numValidEquations++ > 0)
|
||||
{
|
||||
@ -423,7 +428,7 @@ namespace GraphControl
|
||||
|
||||
void Grapher::UpdateVariables()
|
||||
{
|
||||
auto updatedVariables = ref new Map<String^, double>();
|
||||
auto updatedVariables = ref new Map<String ^, double>();
|
||||
if (m_graph)
|
||||
{
|
||||
auto graphVariables = m_graph->GetVariables();
|
||||
@ -449,7 +454,7 @@ namespace GraphControl
|
||||
VariablesUpdated(this, Variables);
|
||||
}
|
||||
|
||||
void Grapher::SetVariable(Platform::String^ variableName, double newValue)
|
||||
void Grapher::SetVariable(Platform::String ^ variableName, double newValue)
|
||||
{
|
||||
if (Variables->HasKey(variableName))
|
||||
{
|
||||
@ -474,7 +479,7 @@ namespace GraphControl
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::UpdateGraphOptions(IGraphingOptions& options, const vector<Equation^>& validEqs)
|
||||
void Grapher::UpdateGraphOptions(IGraphingOptions& options, const vector<Equation ^>& validEqs)
|
||||
{
|
||||
options.SetForceProportional(ForceProportionalAxes);
|
||||
|
||||
@ -482,24 +487,20 @@ namespace GraphControl
|
||||
{
|
||||
vector<Graphing::Color> graphColors;
|
||||
graphColors.reserve(validEqs.size());
|
||||
for (Equation^ eq : validEqs)
|
||||
for (Equation ^ eq : validEqs)
|
||||
{
|
||||
auto lineColor = eq->LineColor;
|
||||
graphColors.emplace_back(
|
||||
lineColor.R,
|
||||
lineColor.G,
|
||||
lineColor.B,
|
||||
lineColor.A);
|
||||
auto lineColor = eq->LineColor->Color;
|
||||
graphColors.emplace_back(lineColor.R, lineColor.G, lineColor.B, lineColor.A);
|
||||
}
|
||||
options.SetGraphColors(graphColors);
|
||||
}
|
||||
}
|
||||
|
||||
vector<Equation^> Grapher::GetValidEquations()
|
||||
vector<Equation ^> Grapher::GetValidEquations()
|
||||
{
|
||||
vector<Equation^> validEqs;
|
||||
vector<Equation ^> validEqs;
|
||||
|
||||
for (Equation^ eq : Equations)
|
||||
for (Equation ^ eq : Equations)
|
||||
{
|
||||
if (!eq->Expression->IsEmpty())
|
||||
{
|
||||
@ -510,7 +511,7 @@ namespace GraphControl
|
||||
return validEqs;
|
||||
}
|
||||
|
||||
void Grapher::OnForceProportionalAxesChanged(DependencyPropertyChangedEventArgs^ args)
|
||||
void Grapher::OnForceProportionalAxesChanged(DependencyPropertyChangedEventArgs ^ args)
|
||||
{
|
||||
UpdateGraph();
|
||||
}
|
||||
@ -523,7 +524,7 @@ namespace GraphControl
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnPointerEntered(PointerRoutedEventArgs^ e)
|
||||
void Grapher::OnPointerEntered(PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
if (m_renderMain)
|
||||
{
|
||||
@ -534,18 +535,18 @@ namespace GraphControl
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnPointerMoved(PointerRoutedEventArgs^ e)
|
||||
void Grapher::OnPointerMoved(PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
if (m_renderMain)
|
||||
{
|
||||
PointerPoint^ currPoint = e->GetCurrentPoint(/* relativeTo */ this);
|
||||
PointerPoint ^ currPoint = e->GetCurrentPoint(/* relativeTo */ this);
|
||||
m_renderMain->PointerLocation = currPoint->Position;
|
||||
|
||||
e->Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnPointerExited(PointerRoutedEventArgs^ e)
|
||||
void Grapher::OnPointerExited(PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
if (m_renderMain)
|
||||
{
|
||||
@ -554,9 +555,9 @@ namespace GraphControl
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnPointerWheelChanged(PointerRoutedEventArgs^ e)
|
||||
void Grapher::OnPointerWheelChanged(PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
PointerPoint^ currentPointer = e->GetCurrentPoint(/*relative to*/ this);
|
||||
PointerPoint ^ currentPointer = e->GetCurrentPoint(/*relative to*/ this);
|
||||
|
||||
double delta = currentPointer->Properties->MouseWheelDelta;
|
||||
|
||||
@ -582,24 +583,24 @@ namespace GraphControl
|
||||
e->Handled = true;
|
||||
}
|
||||
|
||||
void Grapher::OnPointerPressed(PointerRoutedEventArgs^ e)
|
||||
void Grapher::OnPointerPressed(PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
// Set the pointer capture to the element being interacted with so that only it
|
||||
// will fire pointer-related events
|
||||
CapturePointer(e->Pointer);
|
||||
}
|
||||
|
||||
void Grapher::OnPointerReleased(PointerRoutedEventArgs^ e)
|
||||
void Grapher::OnPointerReleased(PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
ReleasePointerCapture(e->Pointer);
|
||||
}
|
||||
|
||||
void Grapher::OnPointerCanceled(PointerRoutedEventArgs^ e)
|
||||
void Grapher::OnPointerCanceled(PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
ReleasePointerCapture(e->Pointer);
|
||||
}
|
||||
|
||||
void Grapher::OnManipulationDelta(ManipulationDeltaRoutedEventArgs^ e)
|
||||
void Grapher::OnManipulationDelta(ManipulationDeltaRoutedEventArgs ^ e)
|
||||
{
|
||||
if (m_renderMain != nullptr && m_graph != nullptr)
|
||||
{
|
||||
@ -656,16 +657,15 @@ namespace GraphControl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RandomAccessStreamReference^ Grapher::GetGraphBitmapStream()
|
||||
RandomAccessStreamReference ^ Grapher::GetGraphBitmapStream()
|
||||
{
|
||||
RandomAccessStreamReference^ outputStream;
|
||||
RandomAccessStreamReference ^ outputStream;
|
||||
|
||||
if (m_renderMain != nullptr && m_graph != nullptr)
|
||||
{
|
||||
if (auto renderer = m_graph->GetRenderer())
|
||||
{
|
||||
std::shared_ptr < Graphing::IBitmap> BitmapOut;
|
||||
std::shared_ptr<Graphing::IBitmap> BitmapOut;
|
||||
bool hasSomeMissingDataOut = false;
|
||||
HRESULT hr = E_FAIL;
|
||||
hr = renderer->GetBitmap(BitmapOut, hasSomeMissingDataOut);
|
||||
@ -676,9 +676,9 @@ namespace GraphControl
|
||||
auto arr = ref new Array<BYTE>(&byteVector[0], (unsigned int)byteVector.size());
|
||||
|
||||
// create a memory stream wrapper
|
||||
InMemoryRandomAccessStream^ stream = ref new InMemoryRandomAccessStream();
|
||||
InMemoryRandomAccessStream ^ stream = ref new InMemoryRandomAccessStream();
|
||||
|
||||
// Get a writer to transfer the data
|
||||
// Get a writer to transfer the data
|
||||
auto writer = ref new DataWriter(stream->GetOutputStreamAt(0));
|
||||
|
||||
// write the data
|
||||
|
@ -159,6 +159,7 @@ namespace GraphControl
|
||||
void OnEquationsChanged(Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ args);
|
||||
void OnEquationsVectorChanged(Windows::Foundation::Collections::IObservableVector<GraphControl::Equation ^> ^sender, Windows::Foundation::Collections::IVectorChangedEventArgs^ event);
|
||||
void OnEquationChanged();
|
||||
void OnEquationStyleChanged();
|
||||
|
||||
void UpdateGraph();
|
||||
void UpdateGraphOptions(Graphing::IGraphingOptions& options, const std::vector<Equation^>& validEqs);
|
||||
@ -188,6 +189,7 @@ namespace GraphControl
|
||||
static Windows::UI::Xaml::DependencyProperty^ s_equationsProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty^ s_variablesProperty;
|
||||
Windows::Foundation::EventRegistrationToken m_tokenEquationsChanged;
|
||||
Windows::Foundation::EventRegistrationToken m_tokenEquationStyleChanged;
|
||||
Windows::Foundation::EventRegistrationToken m_tokenEquationChanged;
|
||||
|
||||
static Windows::UI::Xaml::DependencyProperty^ s_forceProportionalAxesTemplateProperty;
|
||||
|
Loading…
Reference in New Issue
Block a user