Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust minimum percentage of the Library zoom scale #13789

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1297,15 +1297,15 @@
</StackPanel>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1" Margin="0,0,0,3">
<TextBlock Text="10%"></TextBlock>
<TextBlock Text="25%"></TextBlock>

<Slider
x:Name="LibraryZoomScalingSlider"
Style="{StaticResource SliderStyle}"
ValueChanged="zoomScaleLevel_ValueChanged"
Width="400"
Margin="5,0,5,0"
Minimum="10"
Minimum="25"
IsSnapToTickEnabled="True"
TickFrequency="1"
Maximum="300">
Expand Down
18 changes: 14 additions & 4 deletions src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -84,6 +84,7 @@ public PreferencesView(DynamoView dynamoView)
viewModel.RequestShowFileDialog += OnRequestShowFileDialog;

LibraryZoomScalingSlider.Value = dynViewModel.Model.PreferenceSettings.LibraryZoomScale;
updateLibraryZoomScaleValueLabel(LibraryZoomScalingSlider);
}

/// <summary>
Expand Down Expand Up @@ -535,10 +536,19 @@ private void zoomScaleLevel_ValueChanged(object sender, RoutedPropertyChangedEve
{
Slider slider = (Slider)sender;

//Since the percentage goes from 10 to 300, the value is decremented by 10 to standardize.
double percentage = slider.Value - 10;
updateLibraryZoomScaleValueLabel(slider);
}

private void updateLibraryZoomScaleValueLabel(Slider slider)
{
//Since the percentage goes from 25 to 300, the value is decremented by 25 to standardize.
double percentage = slider.Value - 25;

//The margin value for the label goes from - 480 to 310, resulting in 790 pixels from the starting point to the end.
//We also standardized the values ​​of the percentage(from 0 to 275).
//The value is decreased to 480 because the margin begins at - 480
//This is the relation between the margin in pixels and the value of the percentage
double marginValue = (79 * percentage / 29) - 480;
double marginValue = (790 * percentage / 275) - 480;
if (lblZoomScalingValue != null)
{
lblZoomScalingValue.Margin = new Thickness(marginValue, 0, 0, 0);
Expand Down
19 changes: 15 additions & 4 deletions src/LibraryViewExtensionWebView2/LibraryViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class LibraryViewController : IDisposable
private const int standardFontSize = 14;
private const int standardScreenHeight = 1080;
private double libraryFontSize;

private const double minimumZoomScale = 0.25;

/// <summary>
/// Creates a LibraryViewController.
Expand Down Expand Up @@ -339,9 +339,14 @@ private void Browser_CoreWebView2InitializationCompleted(object sender, CoreWebV
}

SetLibraryFontSize();
//The default value of the zoom factor is 1.0. The value that comes from the slider is in percentage, so we divide by 100 to be equivalent
double zoomFactor = (dynamoViewModel.Model.PreferenceSettings.LibraryZoomScale / 100);

//The default value of the zoom factor is 1.0. The value that comes from the slider is in percentage, so we divide by 100 to be equivalent
browser.ZoomFactor = (double)dynamoViewModel.Model.PreferenceSettings.LibraryZoomScale / 100;
//To avoid an invalid value for the zoom factor
if (zoomFactor < minimumZoomScale)
zoomFactor = minimumZoomScale;

browser.ZoomFactor = zoomFactor;
browser.ZoomFactorChanged += Browser_ZoomFactorChanged;
}

Expand Down Expand Up @@ -557,7 +562,13 @@ private void DynamoSliderValueChanged(object sender, EventArgs e)
{
Slider slider = (Slider)sender;
//The default value of the zoom factor is 1.0. The value that comes from the slider is in percentage, so we divide by 100 to be equivalent
browser.ZoomFactor = (double)slider.Value / 100;
double zoomFactor = slider.Value / 100;

//To avoid an invalid value for the zoom factor
if (zoomFactor < minimumZoomScale)
zoomFactor = minimumZoomScale;

browser.ZoomFactor = zoomFactor;
dynamoViewModel.Model.PreferenceSettings.LibraryZoomScale = ((int)slider.Value);
}

Expand Down