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

DYN-4964-WorkingRange-Popup #13656

Merged
merged 13 commits into from
Jan 27, 2023
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
7 changes: 6 additions & 1 deletion src/DynamoCore/Configuration/IPreferences.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Dynamo.Graph.Connectors;

Expand Down Expand Up @@ -40,6 +40,11 @@ public interface IPreferences
/// </summary>
bool IsBackgroundGridVisible { get; set; }

/// <summary>
/// Indicates the Default Geometry Scaling value from the Preferences panel
/// </summary>
double DefaultScaleFactor { get; set; }

/// <summary>
/// Indicates whether background preview is active or not.
/// </summary>
Expand Down
19 changes: 19 additions & 0 deletions src/DynamoCore/Configuration/PreferenceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class PreferenceSettings : NotificationObject, IPreferences, IRenderPreci
private string lastUpdateDownloadPath;
private int maxNumRecentFiles;
private bool isBackgroundGridVisible;
private double defaultScaleFactor;
private bool disableTrustWarnings = false;
private bool isNotificationCenterEnabled;
private bool isStaticSplashScreenEnabled;
Expand Down Expand Up @@ -230,6 +231,24 @@ public bool IsBackgroundGridVisible
}
}

/// <summary>
/// Default geometry scale factor for a new workspace
/// </summary>
public double DefaultScaleFactor
{
get
{
return defaultScaleFactor;
}
set
{
if (value == defaultScaleFactor) return;
defaultScaleFactor = value;

RaisePropertyChanged(nameof(DefaultScaleFactor));
}
}


/// <summary>
/// Indicates whether background preview is active or not.
Expand Down
10 changes: 10 additions & 0 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<ItemGroup>
<None Remove="node_modules\%40dynamods\splash-screen\build\index.bundle.js" />
<None Remove="node_modules\%40dynamods\splash-screen\build\index.html" />
<None Remove="UI\Images\Canvas\canvas-button-geometry-scaling.png" />
<None Remove="Views\Core\GeometryScalingPopup.xaml" />
<None Remove="UI\Images\question-hover-blue-16px.png" />
<None Remove="Views\SplashScreen\WebApp\splashScreenBackground.png" />
</ItemGroup>
Expand Down Expand Up @@ -308,6 +310,7 @@
<Compile Include="ViewModels\Core\Converters\DynamoPythonScriptEditorTextOptions.cs" />
<Compile Include="ViewModels\Core\Converters\SerializationConverters.cs" />
<Compile Include="ViewModels\Core\DynamoViewModelBranding.cs" />
<Compile Include="ViewModels\Core\GeometryScalingViewModel.cs" />
<Compile Include="ViewModels\Core\HomeWorkspaceViewModel.cs" />
<Compile Include="ViewModels\Core\InPortViewModel.cs" />
<Compile Include="ViewModels\Core\OutPortViewModel.cs" />
Expand Down Expand Up @@ -358,6 +361,9 @@
<Compile Include="Views\Core\ConnectorPinView.xaml.cs">
<DependentUpon>ConnectorPinView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Core\GeometryScalingPopup.xaml.cs">
<DependentUpon>GeometryScalingPopup.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Debug\DebugModesWindow.xaml.cs">
<DependentUpon>DebugModesWindow.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -519,6 +525,9 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Core\GeometryScalingPopup.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\FileTrust\FileTrustWarning.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -684,6 +693,7 @@
<Resource Include="UI\Images\Alignment\align_x_distribute.png" />
<Resource Include="UI\Images\Alignment\align_y_average.png" />
<Resource Include="UI\Images\Alignment\align_y_distribute.png" />
<Resource Include="UI\Images\Canvas\canvas-button-geometry-scaling.png" />
<Resource Include="UI\Images\caret_up.png" />
<EmbeddedResource Include="Views\GuidedTour\HtmlPages\Resources\ArtifaktElement-Regular.woff" />
<Resource Include="UI\Images\cursors.psd" />
Expand Down
11 changes: 10 additions & 1 deletion src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2375,7 +2375,7 @@ You can try disabling loading packages from built-in package paths, or unload th
Do you wish to uninstall {1}? Restart {2} to complete the uninstall and try downloading {0} again.</value>
</data>
<data name="PreferencesViewVisualSettingsGeoScaling" xml:space="preserve">
<value>Geometry Scaling</value>
<value>Default Geometry Scaling</value>
<comment>Expander Header Name</comment>
</data>
<data name="PreferencesViewVisualSettingsGroupStyles" xml:space="preserve">
Expand Down Expand Up @@ -3482,6 +3482,9 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<data name="SplashScreenSigningIn" xml:space="preserve">
<value>Signing In</value>
</data>
<data name="InCanvasGeometryScalingToolTip" xml:space="preserve">
<value>Workspace Geometry Scaling</value>
</data>
<data name="GroupContextMenuPreview" xml:space="preserve">
<value>Preview Geometry</value>
</data>
Expand Down
5 changes: 4 additions & 1 deletion src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2591,7 +2591,7 @@ You can try disabling loading packages from built-in package paths, or unload th
Do you wish to uninstall {1}? Restart {2} to complete the uninstall and try downloading {0} again.</value>
</data>
<data name="PreferencesViewVisualSettingsGeoScaling" xml:space="preserve">
<value>Geometry Scaling</value>
<value>Default Geometry Scaling</value>
<comment>Expander Header Name</comment>
</data>
<data name="PreferencesViewVisualSettingsGroupStyles" xml:space="preserve">
Expand Down Expand Up @@ -3469,6 +3469,9 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<data name="SplashScreenSigningIn" xml:space="preserve">
<value>Signing In</value>
</data>
<data name="InCanvasGeometryScalingToolTip" xml:space="preserve">
<value>Workspace Geometry Scaling</value>
</data>
<data name="GroupContextMenuPreview" xml:space="preserve">
<value>Preview Geometry</value>
</data>
Expand Down
18 changes: 18 additions & 0 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3424,6 +3424,24 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
}
}

/// <summary>
/// Receive a GeometryScaleSize value and if it matches the parameter passed will return a brush with a specific color
/// </summary>
public class ScaleSizeBackgroundConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value.Equals(parameter))
return new SolidColorBrush(Color.FromRgb(217, 217, 217));
return new SolidColorBrush(Color.FromRgb(71, 71, 71));

}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value.Equals(true) ? parameter : Binding.DoNothing;
}
}

/// <summary>
/// This converter was designed for Expanders, so it will store/fetch the current Expander state
/// </summary>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 25 additions & 1 deletion src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
using Dynamo.Wpf.ViewModels.FileTrust;
using Dynamo.Wpf.ViewModels.Watch3D;
using DynamoUtilities;
using ViewModels.Core;
using ISelectable = Dynamo.Selection.ISelectable;
using WpfResources = Dynamo.Wpf.Properties.Resources;

Expand Down Expand Up @@ -98,6 +99,8 @@ internal PreferencesViewModel PreferencesViewModel
}
}



/// <summary>
/// Guided Tour Manager
/// </summary>
Expand Down Expand Up @@ -743,6 +746,7 @@ protected DynamoViewModel(StartConfiguration startConfiguration)

preferencesViewModel = new PreferencesViewModel(this);


if (!DynamoModel.IsTestMode && !DynamoModel.IsHeadless)
{
model.State = DynamoModel.DynamoModelState.StartedUI;
Expand Down Expand Up @@ -2207,6 +2211,8 @@ private void ShowNewFunctionDialogAndMakeFunction(object parameter)
this.ExecuteCommand(new DynamoModel.CreateCustomNodeCommand(Guid.NewGuid(),
args.Name, args.Category, args.Description, true));
this.ShowStartPage = false;

SetDefaultScaleFactor();
}
}

Expand Down Expand Up @@ -2514,11 +2520,13 @@ internal bool CanSelectAll(object parameter)
public void MakeNewHomeWorkspace(object parameter)
{
if (ClearHomeWorkspaceInternal())
{
{
var t = new DelegateBasedAsyncTask(model.Scheduler, () => model.ResetEngine());
model.Scheduler.ScheduleForExecution(t);

ShowStartPage = false; // Hide start page if there's one.

SetDefaultScaleFactor();
}
}

Expand Down Expand Up @@ -2563,6 +2571,11 @@ internal bool ClearHomeWorkspaceInternal()

model.ClearCurrentWorkspace();

var defaultWorkspace = Workspaces.FirstOrDefault();
//Every time that a new workspace is created we have to assign the Default Geometry Scaling value defined in Preferences
if (defaultWorkspace !=null && defaultWorkspace.GeoScalingViewModel != null && preferencesViewModel != null)
defaultWorkspace.GeoScalingViewModel.ScaleSize = preferencesViewModel.DefaultGeometryScaling;

return true;
}

Expand Down Expand Up @@ -3163,6 +3176,17 @@ private bool CanSetNumberFormat(object parameter)
return true;
}

private void SetDefaultScaleFactor()
{
var defaultWorkspace = Workspaces.FirstOrDefault();

if (defaultWorkspace != null)
{
defaultWorkspace.GeoScalingViewModel.ScaleValue = PreferenceSettings.DefaultScaleFactor;
defaultWorkspace.GeoScalingViewModel.UpdateGeometryScale(PreferenceSettings.DefaultScaleFactor);
}
}

#region Shutdown related methods

/// <summary>
Expand Down
80 changes: 80 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/GeometryScalingViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using Dynamo.Core;
using Dynamo.ViewModels;

namespace ViewModels.Core
{
/// <summary>
/// This class will be contain information about the current Geometry Scale selected in the Dynamo Workspace
/// </summary>
public class GeometryScalingViewModel : NotificationObject
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
{
private DynamoViewModel dynViewModel;
private GeometryScaleSize scaleSize;
private double scaleValue = 0;
internal double ScaleValue
{
get
{
return scaleValue;
}
set
{
scaleValue = value;
UpdateGeometryScale(scaleValue);
}
}

internal GeometryScalingViewModel(DynamoViewModel dynViewModel)
{
this.dynViewModel = dynViewModel;
}

internal Tuple<string, string, string> ScaleRange
{
get
{
return scaleRanges[ScaleSize];
}
}


internal static Dictionary<GeometryScaleSize, Tuple<string, string, string>> scaleRanges = new Dictionary<GeometryScaleSize, Tuple<string, string, string>>
{
{GeometryScaleSize.Medium, new Tuple<string, string, string>("medium", "0.0001", "10,000")},
{GeometryScaleSize.Small, new Tuple<string, string, string>("small", "0.000,001", "100")},
{GeometryScaleSize.Large, new Tuple<string, string, string>("large", "0.01", "1,000,000")},
{GeometryScaleSize.ExtraLarge, new Tuple<string, string, string>("extra large", "1", "100,000,000")}
};

/// <summary>
/// Current Geometry Scale selected in dynamo workspace.
/// </summary>
public GeometryScaleSize ScaleSize
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
{
get
{
return scaleSize;
}
set
{
if(scaleSize != value)
{
scaleSize = value;
RaisePropertyChanged(nameof(ScaleSize));
}
}
}

internal void UpdateGeometryScale(double scaleFactor)
{
int UIScaleFactor = GeometryScalingOptions.ConvertScaleFactorToUI((int)scaleFactor);

if (Enum.IsDefined(typeof(GeometryScaleSize), UIScaleFactor))
{
ScaleSize = (GeometryScaleSize)UIScaleFactor;
}
}
}
}
14 changes: 13 additions & 1 deletion src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using DynamoUtilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ViewModels.Core;
using Function = Dynamo.Graph.Nodes.CustomNodes.Function;

namespace Dynamo.ViewModels
Expand Down Expand Up @@ -431,7 +432,15 @@ public bool CanRunNodeToCode
[JsonIgnore]
public RunSettingsViewModel RunSettingsViewModel { get; protected set; }



private GeometryScalingViewModel geoScalingViewModel;
internal GeometryScalingViewModel GeoScalingViewModel
{
get
{
return geoScalingViewModel;
}
}

#endregion

Expand Down Expand Up @@ -504,6 +513,9 @@ public WorkspaceViewModel(WorkspaceModel model, DynamoViewModel dynamoViewModel)
{
Visible = true
};

geoScalingViewModel = new GeometryScalingViewModel(this.DynamoViewModel);
geoScalingViewModel.ScaleValue = this.DynamoViewModel.ScaleFactorLog;
}
/// <summary>
/// This event is triggered from Workspace Model. Used in instrumentation
Expand Down
Loading