mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
- Expose MoveRangeByRatio from the UI
This commit is contained in:
parent
969936d04f
commit
fdc65a7045
5 changed files with 55 additions and 7 deletions
|
@ -57,6 +57,23 @@
|
||||||
<local:EquationInputArea Grid.Row="0" Equations="{x:Bind ViewModel.Equations}"/>
|
<local:EquationInputArea Grid.Row="0" Equations="{x:Bind ViewModel.Equations}"/>
|
||||||
|
|
||||||
<StackPanel Grid.Row="1" Orientation="Vertical">
|
<StackPanel Grid.Row="1" Orientation="Vertical">
|
||||||
|
<TextBlock Text="Move Range By Ratio"/>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBox x:Name="RatioXTextBox"
|
||||||
|
Grid.Column="0"
|
||||||
|
KeyDown="MoveRangeByRatioTextBox_KeyDown"
|
||||||
|
PlaceholderText="RatioX"/>
|
||||||
|
<TextBox x:Name="RatioYTextBox"
|
||||||
|
Grid.Column="1"
|
||||||
|
KeyDown="MoveRangeByRatioTextBox_KeyDown"
|
||||||
|
PlaceholderText="RatioY"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<TextBlock Text="Scale Range"/>
|
<TextBlock Text="Scale Range"/>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
|
|
@ -24,7 +24,15 @@ using namespace Windows::UI::Xaml::Input;
|
||||||
using namespace Windows::UI::Xaml::Media;
|
using namespace Windows::UI::Xaml::Media;
|
||||||
using namespace Windows::UI::Xaml::Media::Imaging;
|
using namespace Windows::UI::Xaml::Media::Imaging;
|
||||||
|
|
||||||
constexpr auto sc_ViewModelPropertyName = L"ViewModel";
|
namespace
|
||||||
|
{
|
||||||
|
constexpr auto sc_ViewModelPropertyName = L"ViewModel";
|
||||||
|
|
||||||
|
double valFromTB(TextBox^ tb)
|
||||||
|
{
|
||||||
|
return stod(tb->Text->Data());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
GraphingCalculator::GraphingCalculator()
|
GraphingCalculator::GraphingCalculator()
|
||||||
{
|
{
|
||||||
|
@ -56,12 +64,6 @@ void GraphingCalculator::ScaleRangeTextBox_KeyDown(Object^ sender, KeyRoutedEven
|
||||||
{
|
{
|
||||||
if (e->Key == VirtualKey::Enter)
|
if (e->Key == VirtualKey::Enter)
|
||||||
{
|
{
|
||||||
auto valFromTB = [](TextBox^ tb)
|
|
||||||
{
|
|
||||||
wstring text = tb->Text->Data();
|
|
||||||
return stod(text);
|
|
||||||
};
|
|
||||||
|
|
||||||
double centerX = valFromTB(CenterXTextBox);
|
double centerX = valFromTB(CenterXTextBox);
|
||||||
double centerY = valFromTB(CenterYTextBox);
|
double centerY = valFromTB(CenterYTextBox);
|
||||||
double scale = valFromTB(ScaleTextBox);
|
double scale = valFromTB(ScaleTextBox);
|
||||||
|
@ -71,3 +73,16 @@ void GraphingCalculator::ScaleRangeTextBox_KeyDown(Object^ sender, KeyRoutedEven
|
||||||
e->Handled = true;
|
e->Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphingCalculator::MoveRangeByRatioTextBox_KeyDown(Object^ sender, KeyRoutedEventArgs^ e)
|
||||||
|
{
|
||||||
|
if (e->Key == VirtualKey::Enter)
|
||||||
|
{
|
||||||
|
double ratioX = valFromTB(RatioXTextBox);
|
||||||
|
double ratioY = valFromTB(RatioYTextBox);
|
||||||
|
|
||||||
|
Graph->MoveRangeByRatio(ratioX, ratioY);
|
||||||
|
|
||||||
|
e->Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace CalculatorApp
|
||||||
void GraphingCalculator_DataContextChanged(Windows::UI::Xaml::FrameworkElement^ sender, Windows::UI::Xaml::DataContextChangedEventArgs^ args);
|
void GraphingCalculator_DataContextChanged(Windows::UI::Xaml::FrameworkElement^ sender, Windows::UI::Xaml::DataContextChangedEventArgs^ args);
|
||||||
|
|
||||||
void ScaleRangeTextBox_KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
|
void ScaleRangeTextBox_KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
|
||||||
|
void MoveRangeByRatioTextBox_KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CalculatorApp::ViewModel::GraphingCalculatorViewModel^ m_viewModel;
|
CalculatorApp::ViewModel::GraphingCalculatorViewModel^ m_viewModel;
|
||||||
|
|
|
@ -80,6 +80,20 @@ namespace GraphControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Grapher::MoveRangeByRatio(double ratioX, double ratioY)
|
||||||
|
{
|
||||||
|
if (m_graph)
|
||||||
|
{
|
||||||
|
if (auto renderer = m_graph->GetRenderer())
|
||||||
|
{
|
||||||
|
if (SUCCEEDED(renderer->MoveRangeByRatio(ratioX, ratioY)))
|
||||||
|
{
|
||||||
|
m_renderMain->RunRenderPass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Grapher::OnApplyTemplate()
|
void Grapher::OnApplyTemplate()
|
||||||
{
|
{
|
||||||
auto swapChainPanel = dynamic_cast<SwapChainPanel^>(GetTemplateChild(StringReference(s_templateKey_SwapChainPanel)));
|
auto swapChainPanel = dynamic_cast<SwapChainPanel^>(GetTemplateChild(StringReference(s_templateKey_SwapChainPanel)));
|
||||||
|
|
|
@ -101,6 +101,7 @@ namespace GraphControl
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
void ScaleRange(double centerX, double centerY, double scale);
|
void ScaleRange(double centerX, double centerY, double scale);
|
||||||
|
void MoveRangeByRatio(double ratioX, double ratioY);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#pragma region Control Overrides
|
#pragma region Control Overrides
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue