Skip to content

Commit

Permalink
Dyn 4552 pick group styles (#12667)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertGlobant20 authored Mar 11, 2022
1 parent d5f98ce commit 46e3fd3
Show file tree
Hide file tree
Showing 23 changed files with 720 additions and 72 deletions.
14 changes: 14 additions & 0 deletions src/DynamoCore/Configuration/GroupStyleItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,19 @@ namespace Dynamo.Configuration
{
public class GroupStyleItem: StyleItem
{
private bool isChecked = false;

/// <summary>
/// This property will say it we should display the checkmark in the MenuItem (appearing in the GroupStyles context menu)
/// </summary>
public bool IsChecked
{
get { return isChecked; }
set
{
isChecked = value;
RaisePropertyChanged(nameof(IsChecked));
}
}
}
}
11 changes: 11 additions & 0 deletions src/DynamoCore/Configuration/GroupStyleSeparator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Dynamo.Configuration;

namespace Dynamo.Graph.Annotations
{
/// <summary>
/// This class will represent a separator item that once inserted in the list the Style selector will take the MenuItem separator style
/// </summary>
internal class GroupStyleSeparator : StyleItem
{
}
}
22 changes: 21 additions & 1 deletion src/DynamoCore/Configuration/PreferenceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Dynamo.Graph.Connectors;
using Dynamo.Interfaces;
using Dynamo.Models;
using Dynamo.Properties;

namespace Dynamo.Configuration
{
Expand Down Expand Up @@ -533,6 +534,9 @@ public PreferenceSettings()
DefaultPythonEngine = string.Empty;
ViewExtensionSettings = new List<ViewExtensionSettings>();
GroupStyleItemsList = new List<GroupStyleItem>();

//Add the default group styles
AddDefaultStyles();
}

/// <summary>
Expand Down Expand Up @@ -606,11 +610,27 @@ public static PreferenceSettings Load(string filePath)
}
catch (Exception) { }
settings.CustomPackageFolders = settings.CustomPackageFolders.Distinct().ToList();
settings.GroupStyleItemsList = settings.GroupStyleItemsList.GroupBy(entry => entry.Name).Select(result => result.First()).ToList();
MigrateStdLibTokenToBuiltInToken(settings);

return settings;
}

/// <summary>
/// This method will add the Defaul GroupStyles that are shown in the Preferences panel
/// </summary>
public void AddDefaultStyles()
{
var defaultGroupStylesList = GroupStyleItemsList.Where(style => style.IsDefault == true);
//Just in case the Default profiles have not been added then are added.
if (defaultGroupStylesList != null && defaultGroupStylesList.Count() == 0)
{
GroupStyleItemsList.Add(new GroupStyleItem() { Name = Resources.GroupStyleDefaultActions, HexColorString = Resources.GroupStyleDefaultActionsColor, IsDefault = true });
GroupStyleItemsList.Add(new GroupStyleItem() { Name = Resources.GroupStyleDefaultInputs, HexColorString = Resources.GroupStyleDefaultInputsColor, IsDefault = true });
GroupStyleItemsList.Add(new GroupStyleItem() { Name = Resources.GroupStyleDefaultOutputs, HexColorString = Resources.GroupStyleDefaultOutputsColor, IsDefault = true });
GroupStyleItemsList.Add(new GroupStyleItem() { Name = Resources.GroupStyleDefaultReview, HexColorString = Resources.GroupStyleDefaultReviewColor, IsDefault = true });
}
}

/// <summary>
/// Returns the static Python template file path.
/// When the file exists and is not empty, its contents are used to populate new Python Script nodes added to the Dynamo workspace.
Expand Down
46 changes: 38 additions & 8 deletions src/DynamoCore/Configuration/StyleItem.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dynamo.Core;

namespace Dynamo.Configuration
{
/// <summary>
/// This class stores the group styles added by the user
/// </summary>
public class StyleItem
public class StyleItem : NotificationObject
{
private string hexColorString;
private string name;
private bool isDefault = false;

/// This property will contain the Group Name of the stored style
public string Name { get; set; }
public string Name
{
get { return name; }
set
{
name = value;
RaisePropertyChanged(nameof(Name));
}
}

/// This property will contain the color in hexadecimal
public string HexColorString { get; set; }
public string HexColorString
{
get { return hexColorString; }
set
{
hexColorString = value;
RaisePropertyChanged(nameof(HexColorString));
}
}

/// <summary>
/// This property will describe if the current GroupStyle added is a default one or a custom one.
/// </summary>
public bool IsDefault
{
get { return isDefault; }
set
{
isDefault = value;
RaisePropertyChanged(nameof(IsDefault));
}
}
}
}
2 changes: 1 addition & 1 deletion src/DynamoCore/Models/DynamoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ protected DynamoModel(IStartConfiguration config)
if (preferences is PreferenceSettings settings)
{
PreferenceSettings = settings;
PreferenceSettings.PropertyChanged += PreferenceSettings_PropertyChanged;
PreferenceSettings.PropertyChanged += PreferenceSettings_PropertyChanged;
}

if (config is DefaultStartConfiguration defaultStartConfiguration)
Expand Down
72 changes: 72 additions & 0 deletions src/DynamoCore/Properties/Resources.Designer.cs

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

24 changes: 24 additions & 0 deletions src/DynamoCore/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -831,4 +831,28 @@ This package likely contains an assembly that is blocked. You will need to load
<data name="LibraryLoadFailureMessageBoxTitle" xml:space="preserve">
<value>Library load failure</value>
</data>
<data name="GroupStyleDefaultActions" xml:space="preserve">
<value>Actions</value>
</data>
<data name="GroupStyleDefaultActionsColor" xml:space="preserve">
<value>B9F9E1</value>
</data>
<data name="GroupStyleDefaultInputs" xml:space="preserve">
<value>Inputs</value>
</data>
<data name="GroupStyleDefaultInputsColor" xml:space="preserve">
<value>FFB8D8</value>
</data>
<data name="GroupStyleDefaultOutputs" xml:space="preserve">
<value>Outputs</value>
</data>
<data name="GroupStyleDefaultOutputsColor" xml:space="preserve">
<value>FFC999</value>
</data>
<data name="GroupStyleDefaultReview" xml:space="preserve">
<value>Review</value>
</data>
<data name="GroupStyleDefaultReviewColor" xml:space="preserve">
<value>A4E1FF</value>
</data>
</root>
24 changes: 24 additions & 0 deletions src/DynamoCore/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -834,4 +834,28 @@ This package likely contains an assembly that is blocked. You will need to load
<data name="LibraryLoadFailureMessageBoxTitle" xml:space="preserve">
<value>Library load failure</value>
</data>
<data name="GroupStyleDefaultActions" xml:space="preserve">
<value>Actions</value>
</data>
<data name="GroupStyleDefaultActionsColor" xml:space="preserve">
<value>B9F9E1</value>
</data>
<data name="GroupStyleDefaultInputs" xml:space="preserve">
<value>Inputs</value>
</data>
<data name="GroupStyleDefaultInputsColor" xml:space="preserve">
<value>FFB8D8</value>
</data>
<data name="GroupStyleDefaultOutputs" xml:space="preserve">
<value>Outputs</value>
</data>
<data name="GroupStyleDefaultOutputsColor" xml:space="preserve">
<value>FFC999</value>
</data>
<data name="GroupStyleDefaultReview" xml:space="preserve">
<value>Review</value>
</data>
<data name="GroupStyleDefaultReviewColor" xml:space="preserve">
<value>A4E1FF</value>
</data>
</root>
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
</Compile>
<Compile Include="UI\VisualConfigurations.cs" />
<Compile Include="Utilities\CrashUtilities.cs" />
<Compile Include="Utilities\GroupStyleItemSelector.cs" />
<Compile Include="Utilities\LibraryDragAndDrop.cs" />
<Compile Include="Utilities\MessageBoxUtilities.cs" />
<Compile Include="Utilities\NodeContextMenuBuilder.cs" />
Expand Down
9 changes: 9 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.

3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3040,4 +3040,7 @@ To install the latest version of a package, click Install. \n
<data name="PreferencesViewVisualSettingsGroupStyleInput" xml:space="preserve">
<value>Group Name</value>
</data>
<data name="GroupStyleContextAnnotation" xml:space="preserve">
<value>Group Style</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3027,4 +3027,7 @@ To install the latest version of a package, click Install. \n
<data name="PreferencesViewVisualSettingsGroupStyleInput" xml:space="preserve">
<value>Group Name</value>
</data>
<data name="GroupStyleContextAnnotation" xml:space="preserve">
<value>Group Style</value>
</data>
</root>
Loading

0 comments on commit 46e3fd3

Please sign in to comment.