calculator/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.cpp
Stephanie Anderl cf735bbcf5
Dark Theme For Graph Control (#1106)
* Added dark them to graph control, started dark theme for the controls on the graph

* Dark theme for graphing mode updated to use event model, diagnostics added, cleaned up code that wasn't needed

* Updated prepare-release-internalonly.yaml internal package version

* Updated Theme Settings properties, removed version change, other small changes from PR feedback>

* Updated the localSettings check and updated the GraphTheme event to send bool instead of string

* Updated the equation line color to change with the graph theme

* Rebased onto master and issues created during the rebase

* Updates per code review feedback

* Update settings properties to just have IsMatchAppTheme property and updated the high contrast settings for the graph control

* Match version to current in master

* Updated per PR feedback

* Fix resetting the m_lastLineColorIndex to only happen when reassignColors is true

* Changed second if to else if in the OnPropertyChanged method

* fixed control button and equation line colors
2020-03-27 17:20:35 -07:00

102 lines
2.8 KiB
C++

#include "pch.h"
#include "GraphingSettings.xaml.h"
#include "CalcViewModel\Common\AppResourceProvider.cpp"
using namespace std;
using namespace Graphing;
using namespace GraphControl;
using namespace CalculatorApp;
using namespace CalculatorApp::ViewModel;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Storage;
using namespace Windows::System;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
GraphingSettings::GraphingSettings()
: m_ViewModel(ref new GraphingSettingsViewModel())
, m_IsMatchAppTheme(false)
{
InitializeComponent();
}
void GraphingSettings::SetGrapher(Grapher ^ grapher)
{
m_ViewModel->SetGrapher(grapher);
}
Style ^ GraphingSettings::SelectTextBoxStyle(bool incorrectRange, bool error)
{
if (incorrectRange || error)
{
return static_cast<::Style ^>(this->Resources->Lookup(L"ErrorTextBoxStyle"));
}
else
{
return nullptr;
}
}
void GraphingSettings::GridSettingsTextBox_PreviewKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e)
{
if (e->Key == VirtualKey::Enter)
{
if (!FocusManager::TryMoveFocusAsync(FocusNavigationDirection::Next))
{
FocusManager::TryMoveFocusAsync(FocusNavigationDirection::Previous);
}
e->Handled = true;
}
}
void GraphingSettings::RefreshRanges()
{
ViewModel->InitRanges();
}
void GraphingSettings::ResetViewButton_Clicked(Object ^ sender, RoutedEventArgs ^ e)
{
ViewModel->ResetView();
}
String ^ GraphingSettings::GetLineWidthAutomationName(double width)
{
auto resourceLoader = AppResourceProvider::GetInstance();
if (width == 1.0)
{
return resourceLoader->GetResourceString("SmallLineWidthAutomationName");
}
else if(width == 2.0)
{
return resourceLoader->GetResourceString("MediumLineWidthAutomationName");
}
else if (width == 3.0)
{
return resourceLoader->GetResourceString("LargeLineWidthAutomationName");
}
else
{
return resourceLoader->GetResourceString("ExtraLargeLineWidthAutomationName");
}
}
void GraphingSettings::SetGraphTheme(bool isMatchAppTheme)
{
String ^ propertyName = isMatchAppTheme ? L"IsMatchAppTheme" : L"IsAlwaysLightTheme";
ApplicationDataContainer ^ localSettings = ApplicationData::Current->LocalSettings;
localSettings->Values->Insert(L"IsGraphThemeMatchApp", isMatchAppTheme);
GraphThemeSettingChanged(this, isMatchAppTheme);
TraceLogger::GetInstance()->LogGraphSettingsChanged(GraphSettingsType::Theme, propertyName);
}