diff --git a/src/DynamoCore/Configuration/GroupStyleItem.cs b/src/DynamoCore/Configuration/GroupStyleItem.cs index 3cd0098ceec..c179d8bfdb9 100644 --- a/src/DynamoCore/Configuration/GroupStyleItem.cs +++ b/src/DynamoCore/Configuration/GroupStyleItem.cs @@ -8,5 +8,19 @@ namespace Dynamo.Configuration { public class GroupStyleItem: StyleItem { + private bool isChecked = false; + + /// + /// This property will say it we should display the checkmark in the MenuItem (appearing in the GroupStyles context menu) + /// + public bool IsChecked + { + get { return isChecked; } + set + { + isChecked = value; + RaisePropertyChanged(nameof(IsChecked)); + } + } } } diff --git a/src/DynamoCore/Configuration/GroupStyleSeparator.cs b/src/DynamoCore/Configuration/GroupStyleSeparator.cs new file mode 100644 index 00000000000..17dc2c0455b --- /dev/null +++ b/src/DynamoCore/Configuration/GroupStyleSeparator.cs @@ -0,0 +1,11 @@ +using Dynamo.Configuration; + +namespace Dynamo.Graph.Annotations +{ + /// + /// This class will represent a separator item that once inserted in the list the Style selector will take the MenuItem separator style + /// + internal class GroupStyleSeparator : StyleItem + { + } +} diff --git a/src/DynamoCore/Configuration/PreferenceSettings.cs b/src/DynamoCore/Configuration/PreferenceSettings.cs index b55507218d9..c7e30310f5b 100644 --- a/src/DynamoCore/Configuration/PreferenceSettings.cs +++ b/src/DynamoCore/Configuration/PreferenceSettings.cs @@ -7,6 +7,7 @@ using Dynamo.Graph.Connectors; using Dynamo.Interfaces; using Dynamo.Models; +using Dynamo.Properties; namespace Dynamo.Configuration { @@ -533,6 +534,9 @@ public PreferenceSettings() DefaultPythonEngine = string.Empty; ViewExtensionSettings = new List(); GroupStyleItemsList = new List(); + + //Add the default group styles + AddDefaultStyles(); } /// @@ -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; } + /// + /// This method will add the Defaul GroupStyles that are shown in the Preferences panel + /// + 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 }); + } + } + /// /// 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. diff --git a/src/DynamoCore/Configuration/StyleItem.cs b/src/DynamoCore/Configuration/StyleItem.cs index 6ab78c3cd13..0dd681d03f1 100644 --- a/src/DynamoCore/Configuration/StyleItem.cs +++ b/src/DynamoCore/Configuration/StyleItem.cs @@ -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 { /// /// This class stores the group styles added by the user /// - 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)); + } + } + + /// + /// This property will describe if the current GroupStyle added is a default one or a custom one. + /// + public bool IsDefault + { + get { return isDefault; } + set + { + isDefault = value; + RaisePropertyChanged(nameof(IsDefault)); + } + } } } diff --git a/src/DynamoCore/Models/DynamoModel.cs b/src/DynamoCore/Models/DynamoModel.cs index 0d42a195ede..b3be53d1492 100644 --- a/src/DynamoCore/Models/DynamoModel.cs +++ b/src/DynamoCore/Models/DynamoModel.cs @@ -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) diff --git a/src/DynamoCore/Properties/Resources.Designer.cs b/src/DynamoCore/Properties/Resources.Designer.cs index 538c1afc52a..e84aca21d97 100644 --- a/src/DynamoCore/Properties/Resources.Designer.cs +++ b/src/DynamoCore/Properties/Resources.Designer.cs @@ -740,6 +740,78 @@ public static string GroupNameDefaultText { } } + /// + /// Looks up a localized string similar to Actions. + /// + public static string GroupStyleDefaultActions { + get { + return ResourceManager.GetString("GroupStyleDefaultActions", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to B9F9E1. + /// + public static string GroupStyleDefaultActionsColor { + get { + return ResourceManager.GetString("GroupStyleDefaultActionsColor", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Inputs. + /// + public static string GroupStyleDefaultInputs { + get { + return ResourceManager.GetString("GroupStyleDefaultInputs", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to FFB8D8. + /// + public static string GroupStyleDefaultInputsColor { + get { + return ResourceManager.GetString("GroupStyleDefaultInputsColor", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Outputs. + /// + public static string GroupStyleDefaultOutputs { + get { + return ResourceManager.GetString("GroupStyleDefaultOutputs", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to FFC999. + /// + public static string GroupStyleDefaultOutputsColor { + get { + return ResourceManager.GetString("GroupStyleDefaultOutputsColor", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Review. + /// + public static string GroupStyleDefaultReview { + get { + return ResourceManager.GetString("GroupStyleDefaultReview", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A4E1FF. + /// + public static string GroupStyleDefaultReviewColor { + get { + return ResourceManager.GetString("GroupStyleDefaultReviewColor", resourceCulture); + } + } + /// /// Looks up a localized string similar to ACTIONS. /// diff --git a/src/DynamoCore/Properties/Resources.en-US.resx b/src/DynamoCore/Properties/Resources.en-US.resx index d6762630d52..5722ef291ae 100644 --- a/src/DynamoCore/Properties/Resources.en-US.resx +++ b/src/DynamoCore/Properties/Resources.en-US.resx @@ -831,4 +831,28 @@ This package likely contains an assembly that is blocked. You will need to load Library load failure + + Actions + + + B9F9E1 + + + Inputs + + + FFB8D8 + + + Outputs + + + FFC999 + + + Review + + + A4E1FF + \ No newline at end of file diff --git a/src/DynamoCore/Properties/Resources.resx b/src/DynamoCore/Properties/Resources.resx index 267464080a2..2635648b02d 100644 --- a/src/DynamoCore/Properties/Resources.resx +++ b/src/DynamoCore/Properties/Resources.resx @@ -834,4 +834,28 @@ This package likely contains an assembly that is blocked. You will need to load Library load failure + + Actions + + + B9F9E1 + + + Inputs + + + FFB8D8 + + + Outputs + + + FFC999 + + + Review + + + A4E1FF + \ No newline at end of file diff --git a/src/DynamoCoreWpf/DynamoCoreWpf.csproj b/src/DynamoCoreWpf/DynamoCoreWpf.csproj index d6737b10043..95e1266815d 100644 --- a/src/DynamoCoreWpf/DynamoCoreWpf.csproj +++ b/src/DynamoCoreWpf/DynamoCoreWpf.csproj @@ -165,6 +165,7 @@ + diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index f751b755346..5d28b140d34 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -2992,6 +2992,15 @@ public static string GroupNameDefaultText { } } + /// + /// Looks up a localized string similar to Group Style. + /// + public static string GroupStyleContextAnnotation { + get { + return ResourceManager.GetString("GroupStyleContextAnnotation", resourceCulture); + } + } + /// /// Looks up a localized string similar to Hide Classic Node Library. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index bf326f0d68a..4c371d0d28c 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -3040,4 +3040,7 @@ To install the latest version of a package, click Install. \n Group Name + + Group Style + \ No newline at end of file diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index d21e2a6942d..da4b8fe7338 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -3027,4 +3027,7 @@ To install the latest version of a package, click Install. \n Group Name + + Group Style + \ No newline at end of file diff --git a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml index e9d732c9eb0..8b44842179f 100644 --- a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml +++ b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml @@ -4219,4 +4219,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/DynamoCoreWpf/Utilities/GroupStyleItemSelector.cs b/src/DynamoCoreWpf/Utilities/GroupStyleItemSelector.cs new file mode 100644 index 00000000000..584df0c0505 --- /dev/null +++ b/src/DynamoCoreWpf/Utilities/GroupStyleItemSelector.cs @@ -0,0 +1,26 @@ +using System.Windows; +using System.Windows.Controls; +using Dynamo.Configuration; +using Dynamo.Graph.Annotations; + +namespace Dynamo.Wpf.Utilities +{ + /// + /// This class will be used for select a specific Style depending if the list item is a Separator or MenuItem + /// + public class GroupStyleItemSelector : StyleSelector + { + public override Style SelectStyle(object item, DependencyObject container) + { + if (item is GroupStyleSeparator) + { + return (Style)((FrameworkElement)container).FindResource("GroupStyleSeparatorStyle"); + } + if (item is GroupStyleItem) + { + return (Style)((FrameworkElement)container).FindResource("GroupStyleItemStyle"); + } + return null; + } + } +} diff --git a/src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs index 7acaca67486..702c04866ec 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Windows.Input; using System.Windows.Media; +using Dynamo.Configuration; using Dynamo.Graph; using Dynamo.Graph.Annotations; using Dynamo.Graph.Nodes; @@ -27,7 +28,10 @@ public class AnnotationViewModel : ViewModelBase // vertical offset accounts for the port margins private const int verticalOffset = 20; private const int portVerticalMidPoint = 17; - + private ObservableCollection groupStyleList; + private IEnumerable preferencesStyleItemsList; + private PreferenceSettings preferenceSettings; + public readonly WorkspaceViewModel WorkspaceViewModel; #region Properties @@ -170,6 +174,9 @@ public Double FontSize } } + [JsonIgnore] + internal GroupStyleItem CurrentGroupStyleSelected { get; set; } + [JsonIgnore] public IEnumerable Nodes { @@ -330,6 +337,22 @@ public GeometryCollection NestedGroupsGeometryCollection get => new GeometryCollection(GroupIdToCutGeometry.Values.Select(x => x)); } + /// + /// This property will be used to populate the GroupStyle context menu (the one shown when clicking right over a Group) + /// + [JsonIgnore] + public ObservableCollection GroupStyleList + { + get + { + return groupStyleList; + } + set + { + groupStyleList = value; + RaisePropertyChanged(nameof(GroupStyleList)); + } + } #endregion #region Commands @@ -507,6 +530,7 @@ public AnnotationViewModel(WorkspaceViewModel workspaceViewModel, AnnotationMode { annotationModel = model; this.WorkspaceViewModel = workspaceViewModel; + this.preferenceSettings = WorkspaceViewModel.DynamoViewModel.PreferenceSettings; model.PropertyChanged += model_PropertyChanged; model.RemovedFromGroup += OnModelRemovedFromGroup; model.AddedToGroup += OnModelAddedToGroup; @@ -542,6 +566,9 @@ public AnnotationViewModel(WorkspaceViewModel workspaceViewModel, AnnotationMode SetGroupOutPorts(); CollapseGroupContents(true); } + groupStyleList = new ObservableCollection(); + //This will add the GroupStyles created in Preferences panel to the Group Style Context menu. + LoadGroupStylesFromPreferences(preferenceSettings.GroupStyleItemsList); } /// @@ -943,6 +970,69 @@ private void UpdateFontSize(object parameter) WorkspaceViewModel.DynamoViewModel.RaiseCanExecuteUndoRedo(); } + /// + /// This method will be called by the ChangeGroupStyleCommand when a GroupStyle is selected from the ContextMenu + /// + /// GroupStyle item selected + internal void UpdateGroupStyle(GroupStyleItem itemEntryParameter) + { + if (itemEntryParameter == null) return; + + var groupStyleItems = GroupStyleList.OfType(); + groupStyleItems.Where(c => !c.Name.Equals(itemEntryParameter.Name)).ToList().ForEach(cc => + { + cc.IsChecked = false; + }); + + itemEntryParameter.IsChecked = true; + CurrentGroupStyleSelected = itemEntryParameter; + Background = (Color)ColorConverter.ConvertFromString("#"+itemEntryParameter.HexColorString); + + WorkspaceViewModel.HasUnsavedChanges = true; + } + + /// + /// This method loads the group styles defined by the user and stored in the xml file + /// + /// + /// + private void LoadGroupStylesFromPreferences(IEnumerable styleItemsList) + { + preferencesStyleItemsList = styleItemsList; + + var defaultGroupStylesList = styleItemsList.Where(style => style.IsDefault == true); + var customGroupStylesList = styleItemsList.Where(style => style.IsDefault == false); + + //Adds to the list the Default Group Styles created by Dynamo + groupStyleList.AddRange(defaultGroupStylesList); + + //Adds the separator between the Default Group Styles and the Custom Group Styles + groupStyleList.Add(new GroupStyleSeparator()); + + //Adds to the list the Custom Group Styles created by the user + groupStyleList.AddRange(customGroupStylesList); + } + + /// + /// This method will be executed when the MenuIte.SubmenuOpened event is executed + /// The purpose is adding to the GroupStyles ContextMenu the Styles added in the Preferences panel. + /// + internal void ReloadGroupStyles() + { + if (preferencesStyleItemsList == null) return; + var currentSelectedGroupStyle = groupStyleList.OfType().Where(style => style.IsChecked == true).FirstOrDefault(); + groupStyleList.Clear(); + + LoadGroupStylesFromPreferences(preferencesStyleItemsList); + if (currentSelectedGroupStyle == null) return; + + var currentCustomGroupStyles = groupStyleList.OfType(); + var selectedGroupStyle = currentCustomGroupStyles.Where(style => style.Name.Equals(currentSelectedGroupStyle.Name)).FirstOrDefault(); + + if (selectedGroupStyle == null) return; + selectedGroupStyle.IsChecked = true; + } + /// /// Selects this group and models within it. /// diff --git a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs index 13094fce7cb..089e00f8f10 100644 --- a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs @@ -424,10 +424,12 @@ public ObservableCollection StyleItemsList public void AddStyle(StyleItem style) { StyleItemsList.Add(style); - preferenceSettings.GroupStyleItemsList.Add(new GroupStyleItem { HexColorString = style.HexColorString, Name = style.GroupName }); + preferenceSettings.GroupStyleItemsList.Add(new GroupStyleItem { HexColorString = style.HexColorString, Name = style.Name, IsDefault = style.IsDefault }); RaisePropertyChanged(nameof(StyleItemsList)); } + + /// /// This flag will be in true when the Style that user is trying to add already exists (otherwise will be false - Default) /// @@ -769,7 +771,7 @@ public PreferencesViewModel(DynamoViewModel dynamoViewModel) StyleItemsList = LoadStyles(preferenceSettings.GroupStyleItemsList); //When pressing the "Add Style" button some controls will be shown with some values by default so later they can be populated by the user - AddStyleControl = new StyleItem() { GroupName = "", HexColorString = "#" + GetRandomHexStringColor() }; + AddStyleControl = new StyleItem() { Name = string.Empty, HexColorString = GetRandomHexStringColor() }; //This piece of code will populate all the description text for the RadioButtons in the Geometry Scaling section. optionsGeometryScale = new GeometryScalingOptions(); @@ -807,6 +809,7 @@ public PreferencesViewModel(DynamoViewModel dynamoViewModel) WorkspaceEvents.WorkspaceSettingsChanged += PreferencesViewModel_WorkspaceSettingsChanged; PropertyChanged += Model_PropertyChanged; + } /// @@ -819,7 +822,7 @@ private ObservableCollection LoadStyles(IEnumerable styles = new ObservableCollection(); foreach (var style in styleItemsList) { - styles.Add(new StyleItem { GroupName = style.Name, HexColorString = style.HexColorString }); + styles.Add(new StyleItem { Name = style.Name, HexColorString = style.HexColorString, IsDefault = style.IsDefault }); } return styles; } @@ -1024,7 +1027,7 @@ internal void UpdateSavedChangesLabel() /// internal void RemoveStyleEntry(string groupName) { - StyleItem itemToRemove = (from item in StyleItemsList where item.GroupName.Equals(groupName) select item).FirstOrDefault(); + StyleItem itemToRemove = (from item in StyleItemsList where item.Name.Equals(groupName) select item).FirstOrDefault(); StyleItemsList.Remove(itemToRemove); GroupStyleItem itemToRemovePreferences = preferenceSettings.GroupStyleItemsList.FirstOrDefault(x => x.Name.Equals(groupName)); @@ -1040,7 +1043,7 @@ internal void RemoveStyleEntry(string groupName) /// internal bool ValidateExistingStyle(StyleItem item1) { - return StyleItemsList.Where(x => x.GroupName.Equals(item1.GroupName)).Any(); + return StyleItemsList.Where(x => x.Name.Equals(item1.Name)).Any(); } /// @@ -1048,8 +1051,8 @@ internal bool ValidateExistingStyle(StyleItem item1) /// internal void ResetAddStyleControl() { - AddStyleControl.GroupName = String.Empty; - AddStyleControl.HexColorString = "#" + GetRandomHexStringColor(); + AddStyleControl.Name = String.Empty; + AddStyleControl.HexColorString = GetRandomHexStringColor(); IsWarningEnabled = false; } @@ -1073,41 +1076,6 @@ private void PythonEnginesChanged(object sender, NotifyCollectionChangedEventArg } } - /// - /// This Class will act as a container for each of the StyleItems in the Styles list located in in the Visual Settings -> Group Styles section - /// - public class StyleItem : ViewModelBase - { - private string groupName; - private string hexColorString; - - /// - /// This property will containt the Group Name thas was added by the user when creating a new Style - /// - public string GroupName - { - get { return groupName; } - set - { - groupName = value; - RaisePropertyChanged(nameof(GroupName)); - } - } - - /// - /// This property represents a color in a hexadecimal representation (with the # character at the beginning of the string) - /// - public string HexColorString - { - get { return hexColorString; } - set - { - hexColorString = value; - RaisePropertyChanged(nameof(HexColorString)); - } - } - } - /// /// This class will contain the Enum value and the corresponding description for each radio button in the Visual Settings -> Geometry Scaling section /// diff --git a/src/DynamoCoreWpf/Views/Core/AnnotationView.xaml b/src/DynamoCoreWpf/Views/Core/AnnotationView.xaml index ddf19368081..7f9794753b7 100644 --- a/src/DynamoCoreWpf/Views/Core/AnnotationView.xaml +++ b/src/DynamoCoreWpf/Views/Core/AnnotationView.xaml @@ -12,6 +12,7 @@ xmlns:dynui="clr-namespace:Dynamo.UI.Controls" xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:nodes="clr-namespace:Dynamo.Graph.Nodes;assembly=DynamoCore" + xmlns:utilities="clr-namespace:Dynamo.Wpf.Utilities" mc:Ignorable="d" Height="Auto" Width="Auto" @@ -25,6 +26,8 @@ d:DataContext="{d:DesignInstance Type=viewModels:AnnotationViewModel}"> + + @@ -262,6 +265,66 @@ + + + + + + - + @@ -288,6 +353,13 @@ + + + /// According to the current GroupStyle selected (or not selected) in the ContextMenu several actions can be executed. + /// + /// + /// + private void GroupStyleCheckmark_Click(object sender, RoutedEventArgs e) + { + var menuItemSelected = sender as MenuItem; + if (menuItemSelected == null) return; + + var groupStyleItemSelected = menuItemSelected.DataContext as GroupStyleItem; + if (groupStyleItemSelected == null) return; + + //Means that no GroupStyle (Default, Custom) has been selected then the clicked one will be selected + if (ViewModel.CurrentGroupStyleSelected == null) + { + ViewModel.UpdateGroupStyle(groupStyleItemSelected); + return; + } + + //Means that the user clicked over a MenuItem that is already selected, when we need uncheck it if is not a Default Style + if (groupStyleItemSelected != ViewModel.CurrentGroupStyleSelected && groupStyleItemSelected.IsChecked == false) + { + ViewModel.UpdateGroupStyle(groupStyleItemSelected); + return; + } + + //Means that the GroupStyle selected is not a Default Style and is already checked + if (ViewModel.CurrentGroupStyleSelected.IsChecked == true && !groupStyleItemSelected.IsDefault) + { + var groupStyleItems = ViewModel.GroupStyleList.OfType(); + var firstDefaultGroupStyle = groupStyleItems.Where(item => item.IsDefault == true).FirstOrDefault(); + ViewModel.UpdateGroupStyle(firstDefaultGroupStyle); + return; + } + } + + private void GroupStyleCheckmark_Checked(object sender, RoutedEventArgs e) + { + var menuItemSelected = sender as MenuItem; + if (menuItemSelected == null) return; + + var groupStyleItemSelected = menuItemSelected.DataContext as GroupStyleItem; + if (groupStyleItemSelected == null) return; + + ViewModel.CurrentGroupStyleSelected = groupStyleItemSelected; + } + + /// + /// When the GroupStyle Submenu is opened then we need to re-load the GroupStyles in the ContextMenu (in case more Styles were added in Preferences panel). + /// + /// + /// + private void GroupStyleAnnotation_SubmenuOpened(object sender, RoutedEventArgs e) + { + ViewModel.ReloadGroupStyles(); + } } } diff --git a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml index fc31c0c5581..0b96fe7e9f1 100644 --- a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml +++ b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml @@ -55,7 +55,7 @@