Skip to content

Commit

Permalink
[DYN-3657] Save changes label (#11671)
Browse files Browse the repository at this point in the history
* Removal of unused code

* Revert "Removal of unused code"

This reverts commit c78dfe9.

* Added Obsolete Tag

* Message change

* Tests1

* Tests changes

* WorkspaceModel Tests

* Fix merge issue

* GitHub Action For Issue Content

* Refactor

* Update checkIssueInfo.yaml

* Add github action

* Template/Issue parser and comparator improvements

* Update infromation analyzer

* Delete checkIssueInfo.yaml

* ux changes

* Disable preferences in debug mode

* fix

* visibility change

* UX fixes

* Update DynamoView.xaml

* Change save button into a label that will show when changes where saved
  • Loading branch information
Astul-Betizagasti authored May 11, 2021
1 parent 62b131f commit 677d647
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 28 deletions.
18 changes: 18 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

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

6 changes: 6 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2382,4 +2382,10 @@ Uninstall the following packages: {0}?</value>
<value>Italicized locations are disabled.</value>
<comment>Italic locations are disabled. This can currently only be the standard library.</comment>
</data>
<data name="PreferencesViewSavedChangesLabel" xml:space="preserve">
<value>All changes saved automatically</value>
</data>
<data name="PreferencesViewSavedChangesTooltip" xml:space="preserve">
<value>Last saved: </value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2382,4 +2382,10 @@ Uninstall the following packages: {0}?</value>
<value>Italicized locations are disabled.</value>
<comment>Italic locations are disabled. This can currently only be the standard library.</comment>
</data>
<data name="PreferencesViewSavedChangesLabel" xml:space="preserve">
<value>All changes saved automatically</value>
</data>
<data name="PreferencesViewSavedChangesTooltip" xml:space="preserve">
<value>Last saved:</value>
</data>
</root>
83 changes: 72 additions & 11 deletions src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Reflection;
using Res = Dynamo.Wpf.Properties.Resources;
Expand All @@ -25,6 +26,8 @@ public enum GeometryScaleSize
public class PreferencesViewModel : ViewModelBase
{
#region Private Properties
private string savedChangesLabel;
private string savedChangesTooltip;
private ObservableCollection<string> languagesList;
private ObservableCollection<string> fontSizeList;
private ObservableCollection<string> numberFormatList;
Expand Down Expand Up @@ -72,6 +75,38 @@ public Tuple<string, string, string> ScaleRange
{GeometryScaleSize.ExtraLarge, new Tuple<string, string, string>("extra large", "1", "100,000,000")}
};

/// <summary>
/// Controls what the SavedChanges label will display
/// </summary>
public string SavedChangesLabel
{
get
{
return savedChangesLabel;
}
set
{
savedChangesLabel = value;
RaisePropertyChanged(nameof(SavedChangesLabel));
}
}

/// <summary>
/// Controls what SavedChanges label's tooltip will display
/// </summary>
public string SavedChangesTooltip
{
get
{
return savedChangesTooltip;
}
set
{
savedChangesTooltip = value;
RaisePropertyChanged(nameof(SavedChangesTooltip));

}
}
//This includes all the properties that can be set on the General tab
#region General Properties
/// <summary>
Expand All @@ -87,6 +122,7 @@ public string SelectedLanguage
{
selectedLanguage = value;
RaisePropertyChanged(nameof(SelectedLanguage));
UpdateSavedChangesLabel();
}
}

Expand All @@ -103,6 +139,7 @@ public string SelectedFontSize
{
selectedFontSize = value;
RaisePropertyChanged(nameof(SelectedFontSize));
UpdateSavedChangesLabel();
}
}

Expand All @@ -120,6 +157,7 @@ public string SelectedNumberFormat
selectedNumberFormat = value;
preferenceSettings.NumberFormat = value;
RaisePropertyChanged(nameof(SelectedNumberFormat));
UpdateSavedChangesLabel();
}
}

Expand All @@ -145,17 +183,7 @@ public bool RunSettingsIsChecked
runSettingsIsChecked = RunType.Automatic;
}
RaisePropertyChanged(nameof(RunSettingsIsChecked));
}
}

/// <summary>
/// Controls the IsChecked property in the Show Run Preview toogle button
/// </summary>
public bool RunPreviewEnabled
{
get
{
return runPreviewEnabled;
UpdateSavedChangesLabel();
}
}

Expand All @@ -172,6 +200,7 @@ public bool RunPreviewIsChecked
{
dynamoViewModel.ShowRunPreview = value;
RaisePropertyChanged(nameof(RunPreviewIsChecked));
UpdateSavedChangesLabel();
}
}

Expand Down Expand Up @@ -224,6 +253,7 @@ public ObservableCollection<string> NumberFormatList
}
#endregion

//This includes all the properties that can be set on the Visual Settings tab
#region VisualSettings Properties
/// <summary>
/// This will contain a list of all the Styles created by the user in the Styles list ( Visual Settings -> Group Styles section)
Expand All @@ -238,6 +268,17 @@ public ObservableCollection<StyleItem> StyleItemsList
}
}

/// <summary>
/// Used to add styles to the StyleItemsListe while also update the saved changes label
/// </summary>
/// <param name="style"></param>
public void AddStyle(StyleItem style)
{
StyleItemsList.Add(style);
RaisePropertyChanged(nameof(StyleItemsList));
UpdateSavedChangesLabel();
}

/// <summary>
/// This flag will be in true when the Style that user is trying to add already exists (otherwise will be false - Default)
/// </summary>
Expand Down Expand Up @@ -284,6 +325,7 @@ public GeometryScalingOptions OptionsGeometryScal
{
optionsGeometryScal = value;
RaisePropertyChanged(nameof(OptionsGeometryScal));
UpdateSavedChangesLabel();
}
}

Expand All @@ -300,6 +342,7 @@ public bool ShowEdges
{
showEdges = value;
RaisePropertyChanged(nameof(ShowEdges));
UpdateSavedChangesLabel();
}
}

Expand All @@ -316,6 +359,7 @@ public bool IsolateSelectedGeometry
{
isolateSelectedGeometry = value;
RaisePropertyChanged(nameof(IsolateSelectedGeometry));
UpdateSavedChangesLabel();
}
}

Expand All @@ -332,6 +376,7 @@ public int TessellationDivisions
{
dynamoViewModel.RenderPackageFactoryViewModel.MaxTessellationDivisions = value;
RaisePropertyChanged(nameof(TessellationDivisions));
UpdateSavedChangesLabel();
}
}
#endregion
Expand Down Expand Up @@ -370,6 +415,7 @@ public string SelectedPythonEngine
selectedPythonEngine = value;
preferenceSettings.DefaultPythonEngine = value;
RaisePropertyChanged(nameof(SelectedPythonEngine));
UpdateSavedChangesLabel();
}
}
}
Expand All @@ -388,6 +434,7 @@ public bool HideIronPythonAlertsIsChecked
hideIronPAlerts = value;
preferenceSettings.IsIronPythonDialogDisabled = value;
RaisePropertyChanged(nameof(HideIronPythonAlertsIsChecked));
UpdateSavedChangesLabel();
}
}

Expand All @@ -406,6 +453,7 @@ public bool ShowWhitespaceIsChecked
preferenceSettings.ShowTabsAndSpacesInScriptEditor = value;
showWhitespace = value;
RaisePropertyChanged(nameof(ShowWhitespaceIsChecked));
UpdateSavedChangesLabel();
}
}

Expand All @@ -423,6 +471,7 @@ public bool NodeAutocompleteIsChecked
preferenceSettings.EnableNodeAutoComplete = value;
nodeAutocomplete = value;
RaisePropertyChanged(nameof(NodeAutocompleteIsChecked));
UpdateSavedChangesLabel();
}
}

Expand All @@ -441,6 +490,7 @@ public bool EnableTSplineIsChecked
enableTSpline = value;
HideUnhideNamespace(!value, "ProtoGeometry.dll", "Autodesk.DesignScript.Geometry.TSpline");
RaisePropertyChanged(nameof(EnableTSplineIsChecked));
UpdateSavedChangesLabel();
}
}

Expand Down Expand Up @@ -580,6 +630,16 @@ public PreferencesViewModel(DynamoViewModel dynamoViewModel)
scaleRanges[GeometryScaleSize.Large].Item3));
optionsGeometryScal.DescriptionScaleRange.Add(string.Format(Res.ChangeScaleFactorPromptDescriptionContent, scaleRanges[GeometryScaleSize.ExtraLarge].Item2,
scaleRanges[GeometryScaleSize.ExtraLarge].Item3));

SavedChangesLabel = string.Empty;
SavedChangesTooltip = string.Empty;
}

internal void UpdateSavedChangesLabel()
{
SavedChangesLabel = Res.PreferencesViewSavedChangesLabel;
//Sets the last saved time in the en-US format
SavedChangesTooltip = Res.PreferencesViewSavedChangesTooltip + DateTime.Now.ToString(@"hh:mm tt", new CultureInfo("en-US"));
}

/// <summary>
Expand All @@ -590,6 +650,7 @@ internal void RemoveStyleEntry(string groupName)
{
StyleItem itemToRemove = (from item in StyleItemsList where item.GroupName.Equals(groupName) select item).FirstOrDefault();
StyleItemsList.Remove(itemToRemove);
UpdateSavedChangesLabel();
}

/// <summary>
Expand Down
20 changes: 9 additions & 11 deletions src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@
<!--This Grid row contains the Python section-->
<Grid Grid.Row="0">
<Expander x:Name="PythonExpander"
IsExpanded="True"
Style="{StaticResource MenuExpanderStyle}"
Header="{x:Static p:Resources.PreferencesViewPython}">
<StackPanel Orientation="Vertical" Margin="0,6,0,0">
Expand Down Expand Up @@ -659,18 +660,15 @@
Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<Button Name="SaveChanges"
Grid.Row="2"
Style="{StaticResource NormalButtonStyle}"
HorizontalAlignment="Right"
Margin="0,0,14,0"
Width="112"
Height="36"
Click="SaveChanges_Click">
Save Changes
</Button>
<Label Name="SavedChanges"
Grid.Row="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground ="{StaticResource PreferencesWindowFontColor}"
Margin="0,0,14,0"
Content="{Binding SavedChangesLabel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ToolTip="{Binding SavedChangesTooltip, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</Grid>
</Window>
8 changes: 2 additions & 6 deletions src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ private void InitRadioButtonsDescription()
RadioExtraLargeDesc.Inlines.Add(viewModel.OptionsGeometryScal.DescriptionScaleRange[2]);
}

private void SaveChanges_Click(object sender, RoutedEventArgs e)
{

}

private void CloseButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
Expand Down Expand Up @@ -98,7 +93,7 @@ private void AddStyle_SaveButton_Click(object sender, RoutedEventArgs e)
//if the validation returns false it means that the new style that will be added doesn't exists
if (viewModel.ValidateExistingStyle(newItem) == false)
{
viewModel.StyleItemsList.Add(newItem);
viewModel.AddStyle(newItem);
viewModel.ResetAddStyleControl();
AddStyleBorder.Visibility = Visibility.Collapsed;
AddStyleButton.IsEnabled = true;
Expand Down Expand Up @@ -199,6 +194,7 @@ private void Geometry_Scaling_Checked(object sender, RoutedEventArgs e)

var allNodes = dynViewModel.HomeSpace.Nodes;
dynViewModel.HomeSpace.MarkNodesAsModifiedAndRequestRun(allNodes, forceExecute: true);
viewModel.UpdateSavedChangesLabel();
}
}

Expand Down

0 comments on commit 677d647

Please sign in to comment.