From 2508e6c21e6e97ad7252a4af3ae2117e2695215b Mon Sep 17 00:00:00 2001
From: reddyashish <43763136+reddyashish@users.noreply.github.com>
Date: Fri, 18 Jul 2025 07:27:03 -0700
Subject: [PATCH] [Reverting] [DYN-8894] When groups expand, auto layout
relocates adjacent groups/nodes to avoid overlaps (#16401)
(cherry picked from commit cc8df50421506bc9f117fccb10bc005a5b2f385e)
---
src/DynamoCore/Configuration/IPreferences.cs | 15 -
.../Configuration/PreferenceSettings.cs | 48 --
.../Graph/Annotations/AnnotationModel.cs | 265 ++-----
src/DynamoCore/Graph/Notes/NoteModel.cs | 10 +-
.../Graph/Workspaces/WorkspaceModel.cs | 15 +-
src/DynamoCore/Models/DynamoModel.cs | 4 -
src/DynamoCore/PublicAPI.Unshipped.txt | 28 -
.../Properties/Resources.Designer.cs | 54 --
.../Properties/Resources.en-US.resx | 18 -
src/DynamoCoreWpf/Properties/Resources.resx | 18 -
src/DynamoCoreWpf/PublicAPI.Unshipped.txt | 22 -
src/DynamoCoreWpf/UI/Converters.cs | 39 +-
.../ViewModels/Core/AnnotationViewModel.cs | 724 +-----------------
.../Converters/SerializationConverters.cs | 8 -
.../ViewModels/Menu/PreferencesViewModel.cs | 48 --
.../Views/Core/AnnotationView.xaml.cs | 358 ++-------
.../Views/Menu/PreferencesView.xaml | 69 +-
.../AnnotationViewModelTests.cs | 8 +-
test/settings/DynamoSettings-NewSettings.xml | 3 -
19 files changed, 179 insertions(+), 1575 deletions(-)
diff --git a/src/DynamoCore/Configuration/IPreferences.cs b/src/DynamoCore/Configuration/IPreferences.cs
index 8146793a2e3..f33c84731e1 100644
--- a/src/DynamoCore/Configuration/IPreferences.cs
+++ b/src/DynamoCore/Configuration/IPreferences.cs
@@ -25,21 +25,6 @@ public interface IPreferences
///
public bool ShowDefaultGroupDescription { get; set; }
- ///
- /// Indicates if the optional input ports are hidden by default.
- ///
- public bool OptionalInPortsCollapsed { get; set; }
-
- ///
- /// Indicates if the unconnected output ports are hidden by default.
- ///
- public bool UnconnectedOutPortsCollapsed { get; set; }
-
- ///
- /// Indicates if the groups should be collapsed by default.
- ///
- public bool CollapseToMinSize { get; set; }
-
///
/// Returns height of console
///
diff --git a/src/DynamoCore/Configuration/PreferenceSettings.cs b/src/DynamoCore/Configuration/PreferenceSettings.cs
index d2313a7eecb..f5c8b0cc05f 100644
--- a/src/DynamoCore/Configuration/PreferenceSettings.cs
+++ b/src/DynamoCore/Configuration/PreferenceSettings.cs
@@ -80,9 +80,6 @@ private readonly static Lazy
private string backupLocation;
private string templateFilePath;
private bool isMLAutocompleteTOUApproved;
- private bool optionalInputsCollapsed;
- private bool unconnectedOutputsCollapsed;
- private bool collapseToMinSize;
#region Constants
///
@@ -198,48 +195,6 @@ public bool IsADPAnalyticsReportingApproved
///
public bool ShowDefaultGroupDescription { get; set; }
- ///
- /// Indicates if the optional input ports are collapsed by default.
- ///
- public bool OptionalInPortsCollapsed
- {
- get => optionalInputsCollapsed;
- set
- {
- if (optionalInputsCollapsed == value) return;
- optionalInputsCollapsed = value;
- RaisePropertyChanged(nameof(OptionalInPortsCollapsed));
- }
- }
-
- ///
- /// Indicates if the unconnected output ports are hidden by default.
- ///
- public bool UnconnectedOutPortsCollapsed
- {
- get => unconnectedOutputsCollapsed;
- set
- {
- if (unconnectedOutputsCollapsed == value) return;
- unconnectedOutputsCollapsed = value;
- RaisePropertyChanged(nameof(UnconnectedOutPortsCollapsed));
- }
- }
-
- ///
- /// Indicates if the groups should be collapsed to minimal size by default.
- ///
- public bool CollapseToMinSize
- {
- get => collapseToMinSize;
- set
- {
- if (collapseToMinSize == value) return;
- collapseToMinSize = value;
- RaisePropertyChanged(nameof(CollapseToMinSize));
- }
- }
-
///
/// Indicates if Host units should be used for graphic helpers for Dynamo Revit
///
@@ -1046,9 +1001,6 @@ public PreferenceSettings()
DefaultRunType = RunType.Automatic;
DefaultNodeAutocompleteSuggestion = NodeAutocompleteSuggestion.MLRecommendation;
ShowDefaultGroupDescription = true;
- OptionalInPortsCollapsed = true;
- UnconnectedOutPortsCollapsed = true;
- CollapseToMinSize = true;
BackupInterval = DefaultBackupInterval;
BackupFilesCount = 1;
diff --git a/src/DynamoCore/Graph/Annotations/AnnotationModel.cs b/src/DynamoCore/Graph/Annotations/AnnotationModel.cs
index 78e7a7534e9..aa34d10e1d5 100644
--- a/src/DynamoCore/Graph/Annotations/AnnotationModel.cs
+++ b/src/DynamoCore/Graph/Annotations/AnnotationModel.cs
@@ -24,6 +24,8 @@ public class AnnotationModel : ModelBase
private const double ExtendYHeight = 5.0;
private const double NoteYAdjustment = 8.0;
+ double lastExpandedWidth = 0;
+
#region Properties
///
@@ -72,7 +74,7 @@ public override double Width
if (width == value) return;
width = value;
- RaisePropertyChanged(nameof(Width));
+ RaisePropertyChanged("Width");
}
}
@@ -92,7 +94,7 @@ public override double Height
if (height == value) return;
height = value;
- RaisePropertyChanged(nameof(Height));
+ RaisePropertyChanged("Height");
}
}
@@ -103,7 +105,7 @@ public override double Height
///
public double ModelAreaHeight
{
- get => modelAreaHeight;
+ get { return modelAreaHeight; }
set
{
modelAreaHeight = value;
@@ -122,7 +124,7 @@ public string Text
set
{
text = value;
- RaisePropertyChanged(nameof(Text));
+ RaisePropertyChanged("Text");
}
}
@@ -136,7 +138,7 @@ public string AnnotationText
set
{
annotationText = value;
- RaisePropertyChanged(nameof(AnnotationText));
+ RaisePropertyChanged("AnnotationText");
}
}
@@ -165,7 +167,7 @@ public string Background
set
{
background = value;
- RaisePropertyChanged(nameof(Background));
+ RaisePropertyChanged("Background");
}
}
@@ -441,113 +443,6 @@ internal set
}
}
}
-
- private bool isOptionalInPortsCollapsed;
- ///
- /// Indicates whether optional input ports were manually expanded or collapsed when the graph was last saved.
- /// Used only for serialization.
- ///
- public bool IsOptionalInPortsCollapsed
- {
- get => isOptionalInPortsCollapsed;
- set
- {
- if (isOptionalInPortsCollapsed == value) return;
- isOptionalInPortsCollapsed = value;
- }
- }
-
- private bool isUnconnectedOutPortsCollapsed;
- ///
- /// Indicates whether unconnected output ports were manually expanded or collapsed when the graph was last saved.
- /// Used only for serialization.
- ///
- public bool IsUnconnectedOutPortsCollapsed
- {
- get => isUnconnectedOutPortsCollapsed;
- set
- {
- if (isUnconnectedOutPortsCollapsed == value) return;
- isUnconnectedOutPortsCollapsed = value;
- }
-
- }
-
- private bool hasToggledOptionalInPorts;
- ///
- /// Indicates whether the user manually toggled the visibility of optional input ports.
- /// If true, this overrides the global preference setting.
- ///
- public bool HasToggledOptionalInPorts
- {
- get => hasToggledOptionalInPorts;
- set
- {
- if (hasToggledOptionalInPorts == value) return;
- hasToggledOptionalInPorts = value;
- }
- }
-
- private bool hasToggledUnconnectedOutPorts;
- ///
- /// Indicates whether the user manually toggled the visibility of unconnected output ports.
- /// If true, this overrides the global preference setting.
- ///
- public bool HasToggledUnconnectedOutPorts
- {
- get => hasToggledUnconnectedOutPorts;
- set
- {
- if (hasToggledUnconnectedOutPorts == value) return;
- hasToggledUnconnectedOutPorts = value;
- }
- }
-
- private bool isCollapsedToMinSize;
- ///
- /// Gets or sets a value indicating whether the group was manually resized while collapsed
- ///
- public bool IsCollapsedToMinSize
- {
- get => isCollapsedToMinSize;
- set
- {
- if (isCollapsedToMinSize == value) return;
- isCollapsedToMinSize = value;
- }
- }
-
- private bool suppressBoundaryUpdate;
- ///
- /// A temporary flag used to suppress boundary updates while internal operations,
- /// such as connector redrawing, are in progress.
- /// Should be set to true only during those operations to avoid redundant or recursive updates.
- ///
- internal bool SuppressBoundaryUpdate
- {
- get => suppressBoundaryUpdate;
- set
- {
- if (value == suppressBoundaryUpdate) return;
- suppressBoundaryUpdate = value;
- }
- }
-
- private double minWidthOnCollapsed;
- ///
- /// Gets or sets the minimum width of the group when it is collapsed.
- /// This value equals the combined width of the group's proxy input and output ports.
- ///
- public double MinWidthOnCollapsed
- {
- get => minWidthOnCollapsed;
- set
- {
- if (minWidthOnCollapsed == value) return;
- minWidthOnCollapsed = value;
- }
- }
-
#endregion
///
@@ -615,10 +510,6 @@ private void ClearRemovedPins()
private void model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
- // Skip boundary updates caused by connector redraws if group is collapsed
- if (!IsExpanded && SuppressBoundaryUpdate && e.PropertyName == nameof(Position))
- return;
-
switch (e.PropertyName)
{
case nameof(Position):
@@ -683,103 +574,71 @@ internal void UpdateGroupFrozenStatus()
///
/// Updates the group boundary based on the nodes / notes selection.
- ///
+ ///
internal void UpdateBoundaryFromSelection()
- {
+ {
var selectedModelsList = nodes.ToList();
- if (!selectedModelsList.Any())
- {
- // No models in the group — set dimensions to zero
- Width = 0;
- Height = 0;
- return;
- }
-
- // Sort models left to right for consistent calculations
- var groupModels = selectedModelsList.OrderBy(x => x.X).ToList();
- // Determine left boundary (smallest X), shifted left by padding
- double regionX = groupModels.Min(x => x.X) - ExtendSize;
+ if (selectedModelsList.Any())
+ {
+ var groupModels = selectedModelsList.OrderBy(x => x.X).ToList();
- // Determine top boundary, adjusted for note offset and text block height
- double regionY = groupModels.Min(y => (y as NoteModel) == null ? y.Y : y.Y - NoteYAdjustment)
- - ExtendSize
- - (TextBlockHeight == 0.0 ? MinTextHeight : TextBlockHeight);
+ //Shifting x by 10 and y to the height of textblock
+ var regionX = groupModels.Min(x => x.X) - ExtendSize;
+ //Increase the Y value by 10. This provides the extra space between
+ // a model and textbox. Otherwise there will be some overlap
+ var regionY = groupModels.Min(y => (y as NoteModel) == null ? (y.Y) : (y.Y - NoteYAdjustment)) -
+ ExtendSize - (TextBlockHeight == 0.0 ? MinTextHeight : TextBlockHeight);
- // Compute the horizontal span of all models
- double xDistance = groupModels.Max(x => x.X + x.Width) - regionX;
+ //calculates the distance between the nodes
+ var xDistance = groupModels.Max(x => (x.X + x.Width)) - regionX;
+ var yDistance = groupModels.Max(y => (y as NoteModel) == null ? (y.Y + y.Height) : (y.Y + y.Height - NoteYAdjustment)) - regionY;
+
+ // InitialTop is to store the Y value without the Textblock height
+ this.InitialTop = groupModels.Min(y => (y as NoteModel) == null ? (y.Y) : (y.Y - NoteYAdjustment));
- // Save the actual top-most Y value (before subtracting text block height)
- this.InitialTop = groupModels.Min(y => (y as NoteModel) == null ? y.Y : y.Y - NoteYAdjustment);
- // Track whether position has changed
- bool positionChanged = regionX != X || regionY != Y;
- X = regionX;
- Y = regionY;
+ var region = new Rect2D
+ {
+ X = regionX,
+ Y = regionY,
+ Width = xDistance + ExtendSize + WidthAdjustment,
+ Height = yDistance + ExtendSize + ExtendYHeight + HeightAdjustment - TextBlockHeight
+ };
- // Use different logic for expanded vs. collapsed state
- if (IsExpanded)
- {
- UpdateExpandedLayout(groupModels, regionX, regionY, xDistance);
- }
- else
- {
- UpdateCollapsedLayout(xDistance);
- }
+ bool positionChanged = region.X != X || region.Y != Y;
- // Notify UI if position changed
- if (positionChanged)
- RaisePropertyChanged(nameof(Position));
- }
+ this.X = region.X;
+ this.Y = region.Y;
+ this.ModelAreaHeight = IsExpanded ? region.Height : ModelAreaHeight;
+ Height = this.ModelAreaHeight + TextBlockHeight;
- ///
- /// Calculates and sets the group size and bounds when the group is expanded.
- /// Includes full height of contained models and padding.
- ///
- private void UpdateExpandedLayout(List groupModels, double regionX, double regionY, double xDistance)
- {
- // Compute total vertical height of models in group
- double yDistance = groupModels.Max(y => (y as NoteModel) == null ? y.Y + y.Height : y.Y + y.Height - NoteYAdjustment)
- - regionY;
+ if (IsExpanded)
+ {
+ Width = Math.Max(region.Width, TextMaxWidth + ExtendSize);
+ lastExpandedWidth = Width;
+ }
+ else
+ {
+ //If the annotation is not expanded, then it will remain the same width of the last time it was expanded
+ Width = lastExpandedWidth;
+ }
- // Define the full rectangular area of the group (excluding text block)
- var region = new Rect2D
- {
- X = regionX,
- Y = regionY,
- Width = xDistance + ExtendSize + Math.Max(WidthAdjustment, 0),
- Height = yDistance + ExtendSize + ExtendYHeight + HeightAdjustment - TextBlockHeight
- };
-
- // Store layout size and apply dimensions
- ModelAreaHeight = region.Height;
- Height = ModelAreaHeight + TextBlockHeight;
- Width = Math.Max(region.Width, TextMaxWidth + ExtendSize);
-
- // Only store the first calculated initial height
- if (InitialHeight <= 0.0)
- InitialHeight = region.Height;
- }
+ //Initial Height is to store the Actual height of the group.
+ //that is the height should be the initial height without the textblock height.
+ if (this.InitialHeight <= 0.0)
+ this.InitialHeight = region.Height;
- ///
- /// Calculates and sets the group size when collapsed.
- /// Supports two modes: full-width collapse and minimum-size collapse.
- ///
- private void UpdateCollapsedLayout(double xDistance)
- {
- // Choose width based on collapse preference
- if (!IsCollapsedToMinSize)
- {
- // Collapse vertically, keep full width
- Width = Math.Max(xDistance + ExtendSize + WidthAdjustment, TextMaxWidth + ExtendSize);
+ if (positionChanged)
+ {
+ RaisePropertyChanged(nameof(Position));
+ }
}
else
{
- // Fully minimize the group
- Width = Math.Max(MinWidthOnCollapsed + ExtendSize, TextMaxWidth + ExtendSize);
+ this.Width = 0;
+ this.Height = 0;
}
-
- Height = TextBlockHeight + ModelAreaHeight;
}
///
@@ -897,10 +756,6 @@ void SerializeCore(XmlElement element, SaveContext context)
helper.SetAttribute("backgrouund", (this.Background == null ? "" : this.Background.ToString()));
helper.SetAttribute(nameof(IsSelected), IsSelected);
helper.SetAttribute(nameof(IsExpanded), this.IsExpanded);
- helper.SetAttribute(nameof(IsOptionalInPortsCollapsed), this.IsOptionalInPortsCollapsed);
- helper.SetAttribute(nameof(IsUnconnectedOutPortsCollapsed), this.IsUnconnectedOutPortsCollapsed);
- helper.SetAttribute(nameof(HasToggledOptionalInPorts), this.HasToggledOptionalInPorts);
- helper.SetAttribute(nameof(HasToggledUnconnectedOutPorts), this.HasToggledUnconnectedOutPorts);
//Serialize Selected models
XmlDocument xmlDoc = element.OwnerDocument;
@@ -934,10 +789,6 @@ protected override void DeserializeCore(XmlElement element, SaveContext context)
this.InitialHeight = helper.ReadDouble("InitialHeight", DoubleValue);
this.IsSelected = helper.ReadBoolean(nameof(IsSelected), false);
this.IsExpanded = helper.ReadBoolean(nameof(IsExpanded), true);
- this.IsOptionalInPortsCollapsed = helper.ReadBoolean(nameof(IsOptionalInPortsCollapsed), true);
- this.IsUnconnectedOutPortsCollapsed = helper.ReadBoolean(nameof(IsUnconnectedOutPortsCollapsed), true);
- this.HasToggledOptionalInPorts = helper.ReadBoolean(nameof(HasToggledOptionalInPorts), false);
- this.HasToggledUnconnectedOutPorts = helper.ReadBoolean(nameof(HasToggledUnconnectedOutPorts), false);
if (IsSelected)
DynamoSelection.Instance.Selection.Add(this);
@@ -983,8 +834,6 @@ protected override void DeserializeCore(XmlElement element, SaveContext context)
RaisePropertyChanged(nameof(AnnotationText));
RaisePropertyChanged(nameof(Nodes));
RaisePropertyChanged(nameof(IsExpanded));
- RaisePropertyChanged(nameof(IsOptionalInPortsCollapsed));
- RaisePropertyChanged(nameof(IsUnconnectedOutPortsCollapsed));
this.ReportPosition();
}
diff --git a/src/DynamoCore/Graph/Notes/NoteModel.cs b/src/DynamoCore/Graph/Notes/NoteModel.cs
index df482eeb4a8..7a25a818b59 100644
--- a/src/DynamoCore/Graph/Notes/NoteModel.cs
+++ b/src/DynamoCore/Graph/Notes/NoteModel.cs
@@ -146,7 +146,15 @@ protected override void DeserializeCore(XmlElement nodeElement, SaveContext cont
Text = helper.ReadString("text", "New Note");
X = helper.ReadDouble("x", 0.0);
Y = helper.ReadDouble("y", 0.0);
- PinnedNodeGuid = helper.ReadGuid("pinnedNode", Guid.Empty);
+
+ try
+ {
+ PinnedNodeGuid = helper.ReadGuid("pinnedNode");
+ }
+ catch (Exception) { }
+
+ if (pinnedNode != null && helper.ReadGuid("pinnedNode") != Guid.Empty)
+ pinnedNode.GUID = helper.ReadGuid("pinnedNode");
// Notify listeners that the position of the note has changed,
// then parent group will also redraw itself.
diff --git a/src/DynamoCore/Graph/Workspaces/WorkspaceModel.cs b/src/DynamoCore/Graph/Workspaces/WorkspaceModel.cs
index 006322d8797..ba4cd6b3f14 100644
--- a/src/DynamoCore/Graph/Workspaces/WorkspaceModel.cs
+++ b/src/DynamoCore/Graph/Workspaces/WorkspaceModel.cs
@@ -143,10 +143,6 @@ public class ExtraAnnotationViewInfo
public string PinnedNode;
public double WidthAdjustment;
public double HeightAdjustment;
- public bool IsOptionalInPortsCollapsed;
- public bool IsUnconnectedOutPortsCollapsed;
- public bool hasToggledOptionalInPorts;
- public bool HasToggledUnconnectedOutPorts;
// TODO, Determine if these are required
public double Left;
@@ -175,11 +171,7 @@ public override bool Equals(object obj)
this.GroupStyleId == other.GroupStyleId &&
this.Background == other.Background &&
this.WidthAdjustment == other.WidthAdjustment &&
- this.HeightAdjustment == other.HeightAdjustment &&
- this.IsOptionalInPortsCollapsed == other.IsOptionalInPortsCollapsed &&
- this.IsUnconnectedOutPortsCollapsed == other.IsUnconnectedOutPortsCollapsed &&
- this.hasToggledOptionalInPorts == other.hasToggledOptionalInPorts &&
- this.HasToggledUnconnectedOutPorts == other.HasToggledUnconnectedOutPorts;
+ this.HeightAdjustment == other.HeightAdjustment;
//TODO try to get rid of these if possible
//needs investigation if we are okay letting them get
@@ -2723,11 +2715,6 @@ private void LoadAnnotation(ExtraAnnotationViewInfo annotationViewInfo)
annotationModel.GUID = annotationGuidValue;
annotationModel.HeightAdjustment = annotationViewInfo.HeightAdjustment;
annotationModel.WidthAdjustment = annotationViewInfo.WidthAdjustment;
- annotationModel.IsOptionalInPortsCollapsed = annotationViewInfo.IsOptionalInPortsCollapsed;
- annotationModel.IsUnconnectedOutPortsCollapsed = annotationViewInfo.IsUnconnectedOutPortsCollapsed;
- annotationModel.HasToggledOptionalInPorts = annotationViewInfo.hasToggledOptionalInPorts;
- annotationModel.HasToggledUnconnectedOutPorts = annotationViewInfo.HasToggledUnconnectedOutPorts;
-
annotationModel.UpdateGroupFrozenStatus();
annotationModel.ModelBaseRequested += annotationModel_GetModelBase;
diff --git a/src/DynamoCore/Models/DynamoModel.cs b/src/DynamoCore/Models/DynamoModel.cs
index d8cd5ab99a6..dc8b7db210c 100644
--- a/src/DynamoCore/Models/DynamoModel.cs
+++ b/src/DynamoCore/Models/DynamoModel.cs
@@ -3329,10 +3329,6 @@ private AnnotationModel CreateAnnotationModel(
Background = model.Background,
FontSize = model.FontSize,
GroupStyleId = model.GroupStyleId,
- IsOptionalInPortsCollapsed = model.IsOptionalInPortsCollapsed,
- IsUnconnectedOutPortsCollapsed = model.IsUnconnectedOutPortsCollapsed,
- HasToggledOptionalInPorts = model.HasToggledOptionalInPorts,
- HasToggledUnconnectedOutPorts = model.HasToggledUnconnectedOutPorts,
};
modelLookup.Add(model.GUID, annotationModel);
diff --git a/src/DynamoCore/PublicAPI.Unshipped.txt b/src/DynamoCore/PublicAPI.Unshipped.txt
index dde4aecfaa6..9d2357a29c5 100644
--- a/src/DynamoCore/PublicAPI.Unshipped.txt
+++ b/src/DynamoCore/PublicAPI.Unshipped.txt
@@ -125,8 +125,6 @@ Dynamo.Configuration.PreferenceSettings.BackupInterval.get -> int
Dynamo.Configuration.PreferenceSettings.BackupInterval.set -> void
Dynamo.Configuration.PreferenceSettings.BackupLocation.get -> string
Dynamo.Configuration.PreferenceSettings.BackupLocation.set -> void
-Dynamo.Configuration.PreferenceSettings.CollapseToMinSize.get -> bool
-Dynamo.Configuration.PreferenceSettings.CollapseToMinSize.set -> void
Dynamo.Configuration.PreferenceSettings.ConnectorType.get -> Dynamo.Graph.Connectors.ConnectorType
Dynamo.Configuration.PreferenceSettings.ConnectorType.set -> void
Dynamo.Configuration.PreferenceSettings.ConsoleHeight.get -> int
@@ -219,8 +217,6 @@ Dynamo.Configuration.PreferenceSettings.NumberFormat.get -> string
Dynamo.Configuration.PreferenceSettings.NumberFormat.set -> void
Dynamo.Configuration.PreferenceSettings.OpenFileInManualExecutionMode.get -> bool
Dynamo.Configuration.PreferenceSettings.OpenFileInManualExecutionMode.set -> void
-Dynamo.Configuration.PreferenceSettings.OptionalInPortsCollapsed.get -> bool
-Dynamo.Configuration.PreferenceSettings.OptionalInPortsCollapsed.set -> void
Dynamo.Configuration.PreferenceSettings.PackageDirectoriesToUninstall.get -> System.Collections.Generic.List
Dynamo.Configuration.PreferenceSettings.PackageDirectoriesToUninstall.set -> void
Dynamo.Configuration.PreferenceSettings.PackageDownloadTouAccepted.get -> bool
@@ -264,8 +260,6 @@ Dynamo.Configuration.PreferenceSettings.StaticFields() -> System.Collections.Gen
Dynamo.Configuration.PreferenceSettings.TemplateFilePath.get -> string
Dynamo.Configuration.PreferenceSettings.TemplateFilePath.set -> void
Dynamo.Configuration.PreferenceSettings.TrustedLocations.get -> System.Collections.Generic.List
-Dynamo.Configuration.PreferenceSettings.UnconnectedOutPortsCollapsed.get -> bool
-Dynamo.Configuration.PreferenceSettings.UnconnectedOutPortsCollapsed.set -> void
Dynamo.Configuration.PreferenceSettings.UseHardwareAcceleration.get -> bool
Dynamo.Configuration.PreferenceSettings.UseHardwareAcceleration.set -> void
Dynamo.Configuration.PreferenceSettings.UseHostScaleUnits.get -> bool
@@ -708,30 +702,18 @@ Dynamo.Graph.Annotations.AnnotationModel.GroupState.get -> Dynamo.Graph.Nodes.El
Dynamo.Graph.Annotations.AnnotationModel.GroupStyleId.get -> System.Guid
Dynamo.Graph.Annotations.AnnotationModel.GroupStyleId.set -> void
Dynamo.Graph.Annotations.AnnotationModel.HasNestedGroups.get -> bool
-Dynamo.Graph.Annotations.AnnotationModel.HasToggledOptionalInPorts.get -> bool
-Dynamo.Graph.Annotations.AnnotationModel.HasToggledOptionalInPorts.set -> void
-Dynamo.Graph.Annotations.AnnotationModel.HasToggledUnconnectedOutPorts.get -> bool
-Dynamo.Graph.Annotations.AnnotationModel.HasToggledUnconnectedOutPorts.set -> void
Dynamo.Graph.Annotations.AnnotationModel.HeightAdjustment.get -> double
Dynamo.Graph.Annotations.AnnotationModel.HeightAdjustment.set -> void
Dynamo.Graph.Annotations.AnnotationModel.InitialHeight.get -> double
Dynamo.Graph.Annotations.AnnotationModel.InitialHeight.set -> void
Dynamo.Graph.Annotations.AnnotationModel.InitialTop.get -> double
Dynamo.Graph.Annotations.AnnotationModel.InitialTop.set -> void
-Dynamo.Graph.Annotations.AnnotationModel.IsCollapsedToMinSize.get -> bool
-Dynamo.Graph.Annotations.AnnotationModel.IsCollapsedToMinSize.set -> void
Dynamo.Graph.Annotations.AnnotationModel.IsExpanded.get -> bool
Dynamo.Graph.Annotations.AnnotationModel.IsExpanded.set -> void
Dynamo.Graph.Annotations.AnnotationModel.IsFrozen.get -> bool
-Dynamo.Graph.Annotations.AnnotationModel.IsOptionalInPortsCollapsed.get -> bool
-Dynamo.Graph.Annotations.AnnotationModel.IsOptionalInPortsCollapsed.set -> void
-Dynamo.Graph.Annotations.AnnotationModel.IsUnconnectedOutPortsCollapsed.get -> bool
-Dynamo.Graph.Annotations.AnnotationModel.IsUnconnectedOutPortsCollapsed.set -> void
Dynamo.Graph.Annotations.AnnotationModel.IsVisible.get -> bool
Dynamo.Graph.Annotations.AnnotationModel.loadFromXML.get -> bool
Dynamo.Graph.Annotations.AnnotationModel.loadFromXML.set -> void
-Dynamo.Graph.Annotations.AnnotationModel.MinWidthOnCollapsed.get -> double
-Dynamo.Graph.Annotations.AnnotationModel.MinWidthOnCollapsed.set -> void
Dynamo.Graph.Annotations.AnnotationModel.ModelAreaHeight.get -> double
Dynamo.Graph.Annotations.AnnotationModel.ModelAreaHeight.set -> void
Dynamo.Graph.Annotations.AnnotationModel.ModelBaseRequested -> System.Func
@@ -1302,16 +1284,12 @@ Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.ExtraAnnotationViewInfo() -> voi
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.FontSize -> double
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.GroupStyleId -> System.Guid
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.HasNestedGroups -> bool
-Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.hasToggledOptionalInPorts -> bool
-Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.HasToggledUnconnectedOutPorts -> bool
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.Height -> double
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.HeightAdjustment -> double
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.Id -> string
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.InitialHeight -> double
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.InitialTop -> double
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.IsExpanded -> bool
-Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.IsOptionalInPortsCollapsed -> bool
-Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.IsUnconnectedOutPortsCollapsed -> bool
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.Left -> double
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.Nodes -> System.Collections.Generic.IEnumerable
Dynamo.Graph.Workspaces.ExtraAnnotationViewInfo.PinnedNode -> string
@@ -1586,8 +1564,6 @@ Dynamo.Interfaces.IPreferences.BackgroundPreviews.get -> System.Collections.Gene
Dynamo.Interfaces.IPreferences.BackgroundPreviews.set -> void
Dynamo.Interfaces.IPreferences.BackupFiles.get -> System.Collections.Generic.List
Dynamo.Interfaces.IPreferences.BackupFiles.set -> void
-Dynamo.Interfaces.IPreferences.CollapseToMinSize.get -> bool
-Dynamo.Interfaces.IPreferences.CollapseToMinSize.set -> void
Dynamo.Interfaces.IPreferences.ConnectorType.get -> Dynamo.Graph.Connectors.ConnectorType
Dynamo.Interfaces.IPreferences.ConnectorType.set -> void
Dynamo.Interfaces.IPreferences.ConsoleHeight.get -> int
@@ -1611,8 +1587,6 @@ Dynamo.Interfaces.IPreferences.MaxNumRecentFiles.get -> int
Dynamo.Interfaces.IPreferences.MaxNumRecentFiles.set -> void
Dynamo.Interfaces.IPreferences.NumberFormat.get -> string
Dynamo.Interfaces.IPreferences.NumberFormat.set -> void
-Dynamo.Interfaces.IPreferences.OptionalInPortsCollapsed.get -> bool
-Dynamo.Interfaces.IPreferences.OptionalInPortsCollapsed.set -> void
Dynamo.Interfaces.IPreferences.PackageDirectoriesToUninstall.get -> System.Collections.Generic.List
Dynamo.Interfaces.IPreferences.PackageDirectoriesToUninstall.set -> void
Dynamo.Interfaces.IPreferences.PythonTemplateFilePath.get -> string
@@ -1631,8 +1605,6 @@ Dynamo.Interfaces.IPreferences.ShowPreviewBubbles.get -> bool
Dynamo.Interfaces.IPreferences.ShowPreviewBubbles.set -> void
Dynamo.Interfaces.IPreferences.TemplateFilePath.get -> string
Dynamo.Interfaces.IPreferences.TemplateFilePath.set -> void
-Dynamo.Interfaces.IPreferences.UnconnectedOutPortsCollapsed.get -> bool
-Dynamo.Interfaces.IPreferences.UnconnectedOutPortsCollapsed.set -> void
Dynamo.Interfaces.IPreferences.WindowH.get -> double
Dynamo.Interfaces.IPreferences.WindowH.set -> void
Dynamo.Interfaces.IPreferences.WindowW.get -> double
diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs
index a99c354141f..b1da786f996 100644
--- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs
+++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs
@@ -3758,15 +3758,6 @@ public static string GroupNameDefaultText {
}
}
- ///
- /// Looks up a localized string similar to Optional.
- ///
- public static string GroupOptionalInportsText {
- get {
- return ResourceManager.GetString("GroupOptionalInportsText", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to Group Style.
///
@@ -3803,15 +3794,6 @@ public static string GroupStylesSaveButtonText {
}
}
- ///
- /// Looks up a localized string similar to Unconnected.
- ///
- public static string GroupUnconnectedOutportsText {
- get {
- return ResourceManager.GetString("GroupUnconnectedOutportsText", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to Hide Classic Node Library.
///
@@ -8023,24 +8005,6 @@ public static string PreferencesViewAlreadyExistingStyleWarning {
}
}
- ///
- /// Looks up a localized string similar to Collapsed Group.
- ///
- public static string PreferencesViewCollapsedGroupHeader {
- get {
- return ResourceManager.GetString("PreferencesViewCollapsedGroupHeader", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Collapse to minimal size by default.
- ///
- public static string PreferencesViewCollapseToMinSizeDescription {
- get {
- return ResourceManager.GetString("PreferencesViewCollapseToMinSizeDescription", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to Default Python Engine.
///
@@ -8252,24 +8216,6 @@ public static string PreferencesViewGroupStylesHeader {
}
}
- ///
- /// Looks up a localized string similar to Hide optional input ports by default.
- ///
- public static string PreferencesViewHideInportsDescription {
- get {
- return ResourceManager.GetString("PreferencesViewHideInportsDescription", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Hide unconnected output ports by default.
- ///
- public static string PreferencesViewHideOutportsDescription {
- get {
- return ResourceManager.GetString("PreferencesViewHideOutportsDescription", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to When toggled on, file names of exported images include date and time of export..
///
diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx
index cb3825e4480..21873a1f2fb 100644
--- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx
+++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx
@@ -4176,22 +4176,4 @@ To make this file into a new template, save it to a different folder, then move
Node Icon Data is dumped to \"{0}\".
Debug menu | Dump all node icons
-
- Optional
-
-
- Unconnected
-
-
- Collapsed Group
-
-
- Collapse to minimal size by default
-
-
- Hide optional input ports by default
-
-
- Hide unconnected output ports by default
-
diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx
index 2f4a4436efc..61b60a37d3a 100644
--- a/src/DynamoCoreWpf/Properties/Resources.resx
+++ b/src/DynamoCoreWpf/Properties/Resources.resx
@@ -4160,22 +4160,4 @@ To make this file into a new template, save it to a different folder, then move
Node Icon Data is dumped to \"{0}\".
Debug menu | Dump all node icons
-
- Optional
-
-
- Unconnected
-
-
- Collapsed Group
-
-
- Collapse to minimal size by default
-
-
- Hide optional input ports by default
-
-
- Hide unconnected output ports by default
-
diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt
index 98aeed3512f..d9baf9c6bf2 100644
--- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt
+++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt
@@ -53,10 +53,6 @@ Dynamo.Controls.BooleanNegationConverter
Dynamo.Controls.BooleanNegationConverter.BooleanNegationConverter() -> void
Dynamo.Controls.BooleanNegationConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.BooleanNegationConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
-Dynamo.Controls.BooleanToAngleConverter
-Dynamo.Controls.BooleanToAngleConverter.BooleanToAngleConverter() -> void
-Dynamo.Controls.BooleanToAngleConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
-Dynamo.Controls.BooleanToAngleConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.BooleanToBrushConverter
Dynamo.Controls.BooleanToBrushConverter.BooleanToBrushConverter() -> void
Dynamo.Controls.BooleanToBrushConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
@@ -1779,10 +1775,6 @@ Dynamo.ViewModels.AnnotationViewModel.Height.set -> void
Dynamo.ViewModels.AnnotationViewModel.InPorts.get -> System.Collections.ObjectModel.ObservableCollection
Dynamo.ViewModels.AnnotationViewModel.IsExpanded.get -> bool
Dynamo.ViewModels.AnnotationViewModel.IsExpanded.set -> void
-Dynamo.ViewModels.AnnotationViewModel.IsOptionalInPortsCollapsed.get -> bool
-Dynamo.ViewModels.AnnotationViewModel.IsOptionalInPortsCollapsed.set -> void
-Dynamo.ViewModels.AnnotationViewModel.IsUnconnectedOutPortsCollapsed.get -> bool
-Dynamo.ViewModels.AnnotationViewModel.IsUnconnectedOutPortsCollapsed.set -> void
Dynamo.ViewModels.AnnotationViewModel.Left.get -> double
Dynamo.ViewModels.AnnotationViewModel.Left.set -> void
Dynamo.ViewModels.AnnotationViewModel.ModelAreaHeight.get -> double
@@ -1795,7 +1787,6 @@ Dynamo.ViewModels.AnnotationViewModel.NodeContentCount.get -> int
Dynamo.ViewModels.AnnotationViewModel.NodeHoveringState.get -> bool
Dynamo.ViewModels.AnnotationViewModel.NodeHoveringState.set -> void
Dynamo.ViewModels.AnnotationViewModel.Nodes.get -> System.Collections.Generic.IEnumerable
-Dynamo.ViewModels.AnnotationViewModel.OptionalInPorts.get -> System.Collections.ObjectModel.ObservableCollection
Dynamo.ViewModels.AnnotationViewModel.OutPorts.get -> System.Collections.ObjectModel.ObservableCollection
Dynamo.ViewModels.AnnotationViewModel.PreviewState.get -> Dynamo.ViewModels.PreviewState
Dynamo.ViewModels.AnnotationViewModel.RemoveGroupFromGroupCommand.get -> Dynamo.UI.Commands.DelegateCommand
@@ -1803,7 +1794,6 @@ Dynamo.ViewModels.AnnotationViewModel.ToggleIsFrozenGroupCommand.get -> Dynamo.U
Dynamo.ViewModels.AnnotationViewModel.ToggleIsVisibleGroupCommand.get -> Dynamo.UI.Commands.DelegateCommand
Dynamo.ViewModels.AnnotationViewModel.Top.get -> double
Dynamo.ViewModels.AnnotationViewModel.Top.set -> void
-Dynamo.ViewModels.AnnotationViewModel.UnconnectedOutPorts.get -> System.Collections.ObjectModel.ObservableCollection
Dynamo.ViewModels.AnnotationViewModel.Width.get -> double
Dynamo.ViewModels.AnnotationViewModel.Width.set -> void
Dynamo.ViewModels.AnnotationViewModel.ZIndex.get -> double
@@ -2834,8 +2824,6 @@ Dynamo.ViewModels.PreferencesViewModel.BackupLocation.get -> string
Dynamo.ViewModels.PreferencesViewModel.BackupLocation.set -> void
Dynamo.ViewModels.PreferencesViewModel.CanResetBackupLocation.get -> bool
Dynamo.ViewModels.PreferencesViewModel.CanResetTemplateLocation.get -> bool
-Dynamo.ViewModels.PreferencesViewModel.CollapseToMinSize.get -> bool
-Dynamo.ViewModels.PreferencesViewModel.CollapseToMinSize.set -> void
Dynamo.ViewModels.PreferencesViewModel.CopyToClipboardCommand.get -> Dynamo.UI.Commands.DelegateCommand
Dynamo.ViewModels.PreferencesViewModel.CopyToClipboardCommand.set -> void
Dynamo.ViewModels.PreferencesViewModel.CurrentWarningMessage.get -> string
@@ -2898,8 +2886,6 @@ Dynamo.ViewModels.PreferencesViewModel.NotificationCenterIsChecked.get -> bool
Dynamo.ViewModels.PreferencesViewModel.NotificationCenterIsChecked.set -> void
Dynamo.ViewModels.PreferencesViewModel.NumberFormatList.get -> System.Collections.ObjectModel.ObservableCollection
Dynamo.ViewModels.PreferencesViewModel.NumberFormatList.set -> void
-Dynamo.ViewModels.PreferencesViewModel.OptionalInputsCollapsed.get -> bool
-Dynamo.ViewModels.PreferencesViewModel.OptionalInputsCollapsed.set -> void
Dynamo.ViewModels.PreferencesViewModel.OptionsGeometryScale.get -> Dynamo.ViewModels.GeometryScalingOptions
Dynamo.ViewModels.PreferencesViewModel.OptionsGeometryScale.set -> void
Dynamo.ViewModels.PreferencesViewModel.PackagePathsForInstall.get -> System.Collections.ObjectModel.ObservableCollection
@@ -2944,8 +2930,6 @@ Dynamo.ViewModels.PreferencesViewModel.ShowDefaultGroupDescription.get -> bool
Dynamo.ViewModels.PreferencesViewModel.ShowDefaultGroupDescription.set -> void
Dynamo.ViewModels.PreferencesViewModel.ShowEdges.get -> bool
Dynamo.ViewModels.PreferencesViewModel.ShowEdges.set -> void
-Dynamo.ViewModels.PreferencesViewModel.UnconnectedOutputsCollapsed.get -> bool
-Dynamo.ViewModels.PreferencesViewModel.UnconnectedOutputsCollapsed.set -> void
Dynamo.ViewModels.PreferencesViewModel.UseRenderInstancing.get -> bool
Dynamo.ViewModels.PreferencesViewModel.UseRenderInstancing.set -> void
Dynamo.ViewModels.PreferencesViewModel.ShowPreviewBubbles.get -> bool
@@ -4948,12 +4932,10 @@ static Dynamo.Wpf.Properties.Resources.GroupContextMenuUngroup.get -> string
static Dynamo.Wpf.Properties.Resources.GroupDefaultText.get -> string
static Dynamo.Wpf.Properties.Resources.GroupFrozenButtonToolTip.get -> string
static Dynamo.Wpf.Properties.Resources.GroupNameDefaultText.get -> string
-static Dynamo.Wpf.Properties.Resources.GroupOptionalInportsText.get -> string
static Dynamo.Wpf.Properties.Resources.GroupStyleContextAnnotation.get -> string
static Dynamo.Wpf.Properties.Resources.GroupStyleFontSizeToolTip.get -> string
static Dynamo.Wpf.Properties.Resources.GroupStylesCancelButtonText.get -> string
static Dynamo.Wpf.Properties.Resources.GroupStylesSaveButtonText.get -> string
-static Dynamo.Wpf.Properties.Resources.GroupUnconnectedOutportsText.get -> string
static Dynamo.Wpf.Properties.Resources.HideClassicNodeLibrary.get -> string
static Dynamo.Wpf.Properties.Resources.HideWiresPopupMenuItem.get -> string
static Dynamo.Wpf.Properties.Resources.IDSDKErrorMessage.get -> string
@@ -5416,8 +5398,6 @@ static Dynamo.Wpf.Properties.Resources.PreferencesSettingUpdateTemplateLocationT
static Dynamo.Wpf.Properties.Resources.PreferencesUseHostScaleUnits.get -> string
static Dynamo.Wpf.Properties.Resources.PreferencesUseHostScaleUnitsToolTip.get -> string
static Dynamo.Wpf.Properties.Resources.PreferencesViewAlreadyExistingStyleWarning.get -> string
-static Dynamo.Wpf.Properties.Resources.PreferencesViewCollapsedGroupHeader.get -> string
-static Dynamo.Wpf.Properties.Resources.PreferencesViewCollapseToMinSizeDescription.get -> string
static Dynamo.Wpf.Properties.Resources.PreferencesViewDefaultPythonEngine.get -> string
static Dynamo.Wpf.Properties.Resources.PreferencesViewDefaultRunSettingsInfoTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.PreferencesViewDisableBuiltInPackages.get -> string
@@ -5439,8 +5419,6 @@ static Dynamo.Wpf.Properties.Resources.PreferencesViewGeneralSettingsRun.get ->
static Dynamo.Wpf.Properties.Resources.PreferencesViewGeneralSettingsTemplate.get -> string
static Dynamo.Wpf.Properties.Resources.PreferencesViewGeneralTab.get -> string
static Dynamo.Wpf.Properties.Resources.PreferencesViewGroupStylesHeader.get -> string
-static Dynamo.Wpf.Properties.Resources.PreferencesViewHideInportsDescription.get -> string
-static Dynamo.Wpf.Properties.Resources.PreferencesViewHideOutportsDescription.get -> string
static Dynamo.Wpf.Properties.Resources.PreferencesViewIncludeTimestampExportPathTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.PreferencesViewLanguageLabel.get -> string
static Dynamo.Wpf.Properties.Resources.PreferencesViewLanguageSwitchHelp.get -> string
diff --git a/src/DynamoCoreWpf/UI/Converters.cs b/src/DynamoCoreWpf/UI/Converters.cs
index 13c8dc946e8..8b67604d49c 100644
--- a/src/DynamoCoreWpf/UI/Converters.cs
+++ b/src/DynamoCoreWpf/UI/Converters.cs
@@ -3917,36 +3917,20 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
}
///
- /// Returns a dark or light color depending on the contrast ratio of the color with the background color
- /// Contrast ratio should be larger than 4.5:1
+ /// Returns a dark or light color depending on the contrast ration of the color with the background color
+ /// Contrast ration should be larger than 4.5:1
/// Contrast calculation algorithm from https://stackoverflow.com/questions/70187918/adapt-given-color-pairs-to-adhere-to-w3c-accessibility-standard-for-epubs/70192373#70192373
- ///
- /// Expected values for controlType:
- /// - "groupPortToggle" : applies alternate dark color for optional/unconnected port toggle controls
- /// - null : applies default dark color for annotation text and description
///
public class TextForegroundSaturationColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- var controlType = parameter as string;
-
- // Text and description colors
var lightColor = (System.Windows.Media.Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["WhiteColor"];
var darkColor = (System.Windows.Media.Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["DarkerGrey"];
- // Port toggle colors
- var lightColorToggle = (System.Windows.Media.Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["Blue350"];
- var darkColorToggle = (System.Windows.Media.Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["Blue450"];
var backgroundColor = (System.Windows.Media.Color)value;
- var contrastRatio = GetContrastRatio(darkColor, backgroundColor);
- // Custom scheme override
- if (controlType == "groupPortToggle")
- {
- lightColor = lightColorToggle;
- darkColor = darkColorToggle;
- }
+ var contrastRatio = GetContrastRatio(darkColor, backgroundColor);
return contrastRatio < 4.5 ? new SolidColorBrush(lightColor) : new SolidColorBrush(darkColor);
}
@@ -4352,21 +4336,4 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
throw new NotImplementedException();
}
}
-
- ///
- /// Converts a boolean value to an angle for rotating an arrow icon.
- /// Returns 0° when true (expanded), and 180° when false (collapsed).
- ///
- public class BooleanToAngleConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- return (value is bool isChecked && isChecked) ? 0.0 : 180.0;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- return Binding.DoNothing;
- }
- }
}
diff --git a/src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs
index 6134c1409e2..f25d458d47d 100644
--- a/src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs
+++ b/src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs
@@ -2,18 +2,13 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
-using System.ComponentModel;
using System.Linq;
-using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
-using System.Windows.Threading;
using Dynamo.Configuration;
using Dynamo.Graph;
using Dynamo.Graph.Annotations;
using Dynamo.Graph.Nodes;
-using Dynamo.Graph.Notes;
-using Dynamo.Interfaces;
using Dynamo.Logging;
using Dynamo.Models;
using Dynamo.Selection;
@@ -34,21 +29,9 @@ public class AnnotationViewModel : ViewModelBase
// vertical offset accounts for the port margins
private const int verticalOffset = 17;
private const int portVerticalMidPoint = 17;
- private const int portToggleOffset = 32;
private ObservableCollection groupStyleList;
private IEnumerable preferencesStyleItemsList;
private PreferenceSettings preferenceSettings;
- private double heightBeforeToggle;
- private double widthBeforeToggle;
-
- // Collapsed proxy ports for Code Block Nodes appear visually misaligned - 0.655px
- // taller compared to their actual ports. This is due to the fixed height - 16.345px
- // used inside CBNs for code lines, while proxy ports use 14px height + 3px top margin.
- // To compensate for this visual mismatch and keep connector alignment consistent,
- // we apply this adjusted proxy height.
- private const double CBNProxyPortVisualHeight = 17;
- private const double MinSpacing = 50;
- private const double MinChangeThreshold = 1;
public readonly WorkspaceViewModel WorkspaceViewModel;
@@ -250,21 +233,6 @@ private set
}
}
- private ObservableCollection optionalInPorts;
- ///
- /// Collection of optional input ports.
- /// These are inputs using default values or unconnected.
- ///
- [JsonIgnore]
- public ObservableCollection OptionalInPorts
- {
- get => optionalInPorts;
- private set
- {
- optionalInPorts = value;
- }
- }
-
private ObservableCollection outPorts;
///
/// Collection of all output ports on this group.
@@ -282,74 +250,6 @@ private set
}
}
- private ObservableCollection unconnectedOutPorts;
- ///
- /// Collection of unconnected output ports in the group.
- ///
- [JsonIgnore]
- public ObservableCollection UnconnectedOutPorts
- {
- get => unconnectedOutPorts;
- private set
- {
- unconnectedOutPorts = value;
- }
- }
-
- private bool isOptionalInPortsCollapsed;
- ///
- /// Controls visibility of optional input ports in the group.
- ///
- [JsonIgnore]
- public bool IsOptionalInPortsCollapsed
- {
- get => isOptionalInPortsCollapsed;
- set
- {
- if (isOptionalInPortsCollapsed == value) return;
-
- // Record for undo
- var undoRecorder = WorkspaceViewModel.Model.UndoRecorder;
- using (undoRecorder.BeginActionGroup())
- undoRecorder.RecordModificationForUndo(annotationModel);
-
- isOptionalInPortsCollapsed = value;
- annotationModel.IsOptionalInPortsCollapsed = value;
-
- RaisePropertyChanged(nameof(IsOptionalInPortsCollapsed));
- WorkspaceViewModel.HasUnsavedChanges = true;
-
- HandlePrePortToggleLayout();
- }
- }
-
- private bool isUnconnectedOutPortsCollapsed;
- ///
- /// Controls visibility of unconnected output ports in the group.
- ///
- public bool IsUnconnectedOutPortsCollapsed
- {
- get => isUnconnectedOutPortsCollapsed;
- set
- {
- if (isUnconnectedOutPortsCollapsed == value) return;
-
- // Record for undo
- var undoRecorder = WorkspaceViewModel.Model.UndoRecorder;
- using (undoRecorder.BeginActionGroup())
- undoRecorder.RecordModificationForUndo(annotationModel);
-
-
- isUnconnectedOutPortsCollapsed = value;
- annotationModel.IsUnconnectedOutPortsCollapsed = value;
-
- RaisePropertyChanged(nameof(IsUnconnectedOutPortsCollapsed));
- WorkspaceViewModel.HasUnsavedChanges = true;
-
- HandlePrePortToggleLayout();
- }
- }
-
///
/// Gets or sets the models IsExpanded property.
/// When set it will either show all of the groups node
@@ -374,7 +274,6 @@ public bool IsExpanded
// Methods to collapse or expand the group based on the new value of IsExpanded.
ManageAnnotationMVExpansionAndCollapse();
- HandlePrePortToggleLayout();
}
}
@@ -723,16 +622,6 @@ public AnnotationViewModel(WorkspaceViewModel workspaceViewModel, AnnotationMode
this.WorkspaceViewModel = workspaceViewModel;
this.preferenceSettings = WorkspaceViewModel.DynamoViewModel.PreferenceSettings;
- preferenceSettings.PropertyChanged += OnPreferenceChanged;
-
- isOptionalInPortsCollapsed = annotationModel.HasToggledOptionalInPorts
- ? annotationModel.IsOptionalInPortsCollapsed
- : preferenceSettings.OptionalInPortsCollapsed;
-
- isUnconnectedOutPortsCollapsed = annotationModel.HasToggledUnconnectedOutPorts
- ? annotationModel.IsUnconnectedOutPortsCollapsed
- : preferenceSettings.UnconnectedOutPortsCollapsed;
-
model.PropertyChanged += model_PropertyChanged;
model.RemovedFromGroup += OnModelRemovedFromGroup;
model.AddedToGroup += OnModelAddedToGroup;
@@ -753,8 +642,6 @@ public AnnotationViewModel(WorkspaceViewModel workspaceViewModel, AnnotationMode
InPorts = new ObservableCollection();
OutPorts = new ObservableCollection();
- OptionalInPorts = new ObservableCollection();
- UnconnectedOutPorts = new ObservableCollection();
ViewModelBases = this.WorkspaceViewModel.GetViewModelsInternal(annotationModel.Nodes.Select(x => x.GUID));
@@ -779,40 +666,8 @@ public AnnotationViewModel(WorkspaceViewModel workspaceViewModel, AnnotationMode
groupStyleList = new ObservableCollection();
//This will add the GroupStyles created in Preferences panel to the Group Style Context menu.
LoadGroupStylesFromPreferences(preferenceSettings.GroupStyleItemsList);
-
- // Passes the CollapseToMinSize from PreferenceSettings to the model
- if (preferenceSettings.CollapseToMinSize)
- {
- annotationModel.IsCollapsedToMinSize = true;
- }
}
- private void OnPreferenceChanged(object sender, PropertyChangedEventArgs e)
- {
- switch (e.PropertyName)
- {
- case nameof(IPreferences.OptionalInPortsCollapsed):
- if (!annotationModel.HasToggledOptionalInPorts)
- {
- IsOptionalInPortsCollapsed = preferenceSettings.OptionalInPortsCollapsed;
- }
- break;
- case nameof(IPreferences.UnconnectedOutPortsCollapsed):
- if (!annotationModel.HasToggledUnconnectedOutPorts)
- {
- IsUnconnectedOutPortsCollapsed = preferenceSettings.UnconnectedOutPortsCollapsed;
- }
- break;
- case nameof(IPreferences.CollapseToMinSize):
- annotationModel.IsCollapsedToMinSize = preferenceSettings.CollapseToMinSize;
- // Update the boundary only if the group is collapsed
- if (!IsExpanded)
- {
- annotationModel.UpdateBoundaryFromSelection();
- }
- break;
- }
- }
///
/// Creates input ports for the group based on its Nodes.
@@ -822,8 +677,7 @@ private void OnPreferenceChanged(object sender, PropertyChangedEventArgs e)
///
private void SetGroupInputPorts()
{
- List mainPortViewModels;
- List optionalPortViewModels;
+ List newPortViewModels;
// we need to store the original ports here
// as we need those later for when we
@@ -846,15 +700,11 @@ private void SetGroupInputPorts()
// visually add them to the group but they
// should still reference their NodeModel
// owner
- var newPortViewModels = CreateProxyInPorts(originalInPorts);
- mainPortViewModels = newPortViewModels.Main;
- optionalPortViewModels = newPortViewModels.Optional;
+ newPortViewModels = CreateProxyInPorts(originalInPorts);
- if (mainPortViewModels != null)
- InPorts.AddRange(mainPortViewModels);
-
- if (optionalPortViewModels != null)
- OptionalInPorts.AddRange(optionalPortViewModels);
+ if (newPortViewModels == null) return;
+ InPorts.AddRange(newPortViewModels);
+ return;
}
///
@@ -864,11 +714,10 @@ private void SetGroupInputPorts()
///
private void SetGroupOutPorts()
{
- List mainPortViewModels;
- List unconnectedPortViewModels;
+ List newPortViewModels;
// we need to store the original ports here
- // as we need those later for when we
+ // as we need thoese later for when we
// need to collapse the groups content
if (this.AnnotationModel.HasNestedGroups)
{
@@ -888,15 +737,11 @@ private void SetGroupOutPorts()
// visually add them to the group but they
// should still reference their NodeModel
// owner
- var newPortViewModels = CreateProxyOutPorts(originalOutPorts);
- mainPortViewModels = newPortViewModels.Main;
- unconnectedPortViewModels = newPortViewModels.Unconnected;
+ newPortViewModels = CreateProxyOutPorts(originalOutPorts);
- if (mainPortViewModels != null)
- OutPorts.AddRange(mainPortViewModels);
-
- if (unconnectedPortViewModels != null)
- UnconnectedOutPorts.AddRange(unconnectedPortViewModels);
+ if (newPortViewModels == null) return;
+ OutPorts.AddRange(newPortViewModels);
+ return;
}
internal IEnumerable GetGroupInPorts(IEnumerable ownerNodes = null)
@@ -971,192 +816,53 @@ private Point2D CalculatePortPosition(PortModel portModel, double verticalPositi
return new Point2D();
}
- private (List Main, List Optional) CreateProxyInPorts(IEnumerable groupPortModels)
+ private List CreateProxyInPorts(IEnumerable groupPortModels)
{
var originalPortViewModels = WorkspaceViewModel.Nodes
.SelectMany(x => x.InPorts)
.Where(x => groupPortModels.Contains(x.PortModel))
.ToList();
- var mainPortViewModels = new List();
- var optionalPortViewModels = new List();
-
+ var newPortViewModels = new List();
double verticalPosition = 0;
-
foreach (var groupPort in groupPortModels)
{
- // Track proxy connection changes while group is collapsed
- groupPort.PropertyChanged += OnPortConnectionChanged;
-
var originalPort = originalPortViewModels.FirstOrDefault(x => x.PortModel.GUID == groupPort.GUID);
if (originalPort != null)
{
var portViewModel = originalPort.CreateProxyPortViewModel(groupPort);
-
- if (!originalPort.UsingDefaultValue || groupPort.Connectors.Any())
- {
- mainPortViewModels.Add(portViewModel);
-
- // Calculate new position for the proxy inports
- groupPort.Center = CalculatePortPosition(groupPort, verticalPosition);
- verticalPosition += originalPort.Height;
- }
- else
- {
- // Defer position setting for optional (unconnected) ports
- optionalPortViewModels.Add(portViewModel);
- }
+ newPortViewModels.Add(portViewModel);
+ // calculate new position for the proxy outports
+ groupPort.Center = CalculatePortPosition(groupPort, verticalPosition);
+ verticalPosition += originalPort.Height;
}
}
- // Leave space for toggle button
- verticalPosition += portToggleOffset;
-
- // Position optional input ports
- foreach (var portViewModel in optionalPortViewModels)
- {
- var groupPort = portViewModel.PortModel;
- groupPort.Center = CalculatePortPosition(groupPort, verticalPosition);
- verticalPosition += groupPort.Height;
- }
-
- return (mainPortViewModels, optionalPortViewModels);
+ return newPortViewModels;
}
- private (List Main, List Unconnected) CreateProxyOutPorts(IEnumerable groupPortModels)
+ private List CreateProxyOutPorts(IEnumerable groupPortModels)
{
var originalPortViewModels = WorkspaceViewModel.Nodes
.SelectMany(x => x.OutPorts)
.Where(x => groupPortModels.Contains(x.PortModel))
.ToList();
- var mainPortViewModels = new List();
- var unconnectedPortViewModels = new List();
-
+ var newPortViewModels = new List();
double verticalPosition = 0;
-
- foreach (var groupPort in groupPortModels)
+ foreach (var group in groupPortModels)
{
- // Track proxy connection changes while group is collapsed
- groupPort.PropertyChanged += OnPortConnectionChanged;
-
- var originalPort = originalPortViewModels.FirstOrDefault(x => x.PortModel.GUID == groupPort.GUID);
+ var originalPort = originalPortViewModels.FirstOrDefault(x => x.PortModel.GUID == group.GUID);
if (originalPort != null)
{
- var portViewModel = originalPort.CreateProxyPortViewModel(groupPort);
-
- if (originalPort.IsConnected)
- {
- mainPortViewModels.Add(portViewModel);
-
- // Calculate new position for the proxy inports
- groupPort.Center = CalculatePortPosition(groupPort, verticalPosition);
- verticalPosition += originalPort.Height;
- }
- else
- {
- // Defer position setting for unconnected ports
- unconnectedPortViewModels.Add(portViewModel);
- }
- }
- }
- // Leave space for toggle button
- verticalPosition += portToggleOffset;
-
- // Position unconnected output ports
- foreach (var portViewModel in unconnectedPortViewModels)
- {
- var groupPort = portViewModel.PortModel;
- groupPort.Center = CalculatePortPosition(groupPort, verticalPosition);
- verticalPosition += groupPort.Height;
- }
-
- return (mainPortViewModels, unconnectedPortViewModels);
- }
-
- private void OnPortConnectionChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName != nameof(PortModel.IsConnected)) return;
- if (sender is not PortModel port) return;
-
- Application.Current.Dispatcher.BeginInvoke(() =>
- {
- var proxyPortVM = FindPortViewModel(port);
- if (proxyPortVM == null) return;
-
- bool updatedInputs = false;
- bool updatedOutputs = false;
-
- if (port.PortType == PortType.Input)
- {
- // Connected input ports should be in the InPorts collection.
- if (port.Connectors.Any() && OptionalInPorts.Contains(proxyPortVM))
- {
- OptionalInPorts.Remove(proxyPortVM);
- InPorts.Add(proxyPortVM);
- updatedInputs = true;
- }
- // Disconnected optional ports using default value go to OptionalInPorts.
- else if (!port.Connectors.Any() && port.UsingDefaultValue)
- {
- InPorts.Remove(proxyPortVM);
- OptionalInPorts.Add(proxyPortVM);
- updatedInputs = true;
- }
+ var portViewModel = originalPort.CreateProxyPortViewModel(group);
+ newPortViewModels.Add(portViewModel);
+ // calculate new position for the proxy outports
+ group.Center = CalculatePortPosition(group, verticalPosition);
+ verticalPosition += originalPort.Height;
}
-
- if (port.PortType == PortType.Output)
- {
- if (port.IsConnected && UnconnectedOutPorts.Contains(proxyPortVM))
- {
- UnconnectedOutPorts.Remove(proxyPortVM);
- OutPorts.Add(proxyPortVM);
- updatedOutputs = true;
- }
- else if (!port.IsConnected && !UnconnectedOutPorts.Contains(proxyPortVM))
- {
- OutPorts.Remove(proxyPortVM);
- UnconnectedOutPorts.Add(proxyPortVM);
- updatedOutputs = true;
- }
- }
-
- if (updatedInputs)
- {
- UpdateProxyPortsPosition();
- RaisePropertyChanged(nameof(InPorts));
- RaisePropertyChanged(nameof(OptionalInPorts));
- }
- if (updatedOutputs)
- {
-
- UpdateProxyPortsPosition();
- RaisePropertyChanged(nameof(OutPorts));
- RaisePropertyChanged(nameof(UnconnectedOutPorts));
- }
- });
- }
-
- private PortViewModel FindPortViewModel(PortModel model)
- {
- return OutPorts.Concat(UnconnectedOutPorts)
- .Concat(InPorts)
- .Concat(OptionalInPorts)
- .FirstOrDefault(pvm => pvm.PortModel == model);
- }
-
- private void UnsubscribeFromProxyPortEvents()
- {
- if (originalInPorts != null)
- {
- foreach (var port in originalInPorts)
- port.PropertyChanged -= OnPortConnectionChanged;
}
- if (originalOutPorts != null)
- {
- foreach (var port in originalOutPorts)
- port.PropertyChanged -= OnPortConnectionChanged;
- }
+ return newPortViewModels;
}
internal void UpdateProxyPortsPosition()
@@ -1180,43 +886,16 @@ internal void UpdateProxyPortsPosition()
}
verticalPosition = 0;
- // Update all input ports
- verticalPosition = PositionPorts(inPorts, verticalPosition);
- verticalPosition += portToggleOffset;
- verticalPosition = PositionPorts(optionalInPorts, verticalPosition);
-
- // Reset vertical position for output ports
- verticalPosition = 0;
-
- verticalPosition = PositionPorts(outPorts, verticalPosition);
- verticalPosition += portToggleOffset;
- PositionPorts(unconnectedOutPorts, verticalPosition);
- }
-
- private double PositionPorts(IEnumerable portViewModels, double startY)
- {
- double y = startY;
-
- foreach (var portVM in portViewModels)
+ for (int i = 0; i < outPorts.Count(); i++)
{
- var model = portVM?.PortModel;
- if (model?.IsProxyPort == true)
+ var model = outPorts[i]?.PortModel;
+ if (model != null && model.IsProxyPort)
{
- model.Center = CalculatePortPosition(model, y);
-
- bool isCondensedCBN = model.Owner is CodeBlockNodeModel &&
- !InPorts.Contains(portVM) &&
- !OptionalInPorts.Contains(portVM);
-
- double height = isCondensedCBN ?
- CBNProxyPortVisualHeight :
- model.Height;
-
- y += height;
+ // calculate new position for the proxy outports.
+ model.Center = CalculatePortPosition(model, verticalPosition);
+ verticalPosition += model.Height;
}
}
-
- return y;
}
internal void ClearSelection()
@@ -1297,15 +976,8 @@ private void CollapseConnectors()
}
}
- private void RedrawConnectors(bool isCollapsedCheck = false)
+ private void RedrawConnectors()
{
- if (isCollapsedCheck && IsExpanded)
- return;
-
- // Suppress boundary updates while redrawing connectors to avoid
- // redundant UpdateBoundaryFromSelection calls caused by connector repositioning
- annotationModel.SuppressBoundaryUpdate = true;
-
var allNodes = this.Nodes
.OfType()
.SelectMany(x => x.Nodes.OfType())
@@ -1321,9 +993,6 @@ private void RedrawConnectors(bool isCollapsedCheck = false)
connectorViewModel.Redraw();
connector.Start.Owner.ReportPosition();
}
-
- // Re-enable boundary updates once internal redraw is complete
- annotationModel.SuppressBoundaryUpdate = false;
}
///
@@ -1391,17 +1060,14 @@ private void UpdateConnectorsAndPortsOnShowContents(IEnumerable nodes
///
private void ManageAnnotationMVExpansionAndCollapse()
{
- if (InPorts.Any() || OutPorts.Any() || OptionalInPorts.Any() || UnconnectedOutPorts.Any())
+ if (InPorts.Any() || OutPorts.Any())
{
InPorts.Clear();
OutPorts.Clear();
- OptionalInPorts.Clear();
- UnconnectedOutPorts.Clear();
}
if (annotationModel.IsExpanded)
{
- UnsubscribeFromProxyPortEvents();
this.ShowGroupContents();
}
else
@@ -1418,314 +1084,6 @@ private void ManageAnnotationMVExpansionAndCollapse()
ReportNodesPosition();
}
- ///
- /// Adjusts layout by moving nearby elements to prevent overlap when the group expands.
- ///
- internal void UpdateLayoutForGroupExpansion()
- {
- var model = annotationModel;
-
- double deltaY = ModelAreaHeight - heightBeforeToggle;
- double deltaX = Width - widthBeforeToggle;
-
- // Log the current size
- heightBeforeToggle = ModelAreaHeight;
- widthBeforeToggle = Width;
-
- // Skip layout update if changes are negligible
- if (deltaX < MinChangeThreshold && deltaY < MinChangeThreshold)
- return;
-
- var alreadyMoved = new HashSet();
- var undoRecorder = WorkspaceViewModel.Model.UndoRecorder;
-
- using (undoRecorder.BeginActionGroup())
- {
- if (deltaY > MinChangeThreshold)
- ApplySpacing(model, isHorizontal: false, alreadyMoved);
-
- if (deltaX > MinChangeThreshold)
- ApplySpacing(model, isHorizontal: true, alreadyMoved);
- }
- }
-
- ///
- /// Applies spacing to reposition nearby models when a group expands, avoiding overlaps and updating boundaries.
- ///
- private void ApplySpacing(AnnotationModel expandingGroup, bool isHorizontal, HashSet alreadyMoved)
- {
- var offsets = GetAffectedModels(expandingGroup, isHorizontal, alreadyMoved);
- if (offsets.Count == 0) return;
-
- // Ensure changes to all affected models are tracked for Undo
- WorkspaceViewModel.Model.RecordModelsForModification(offsets.Keys.ToList());
-
- foreach (var (model, offset) in offsets)
- {
- // Skip moving groups directly, just update pinned notes to ensure boundaries update
- if (model is AnnotationModel) continue;
-
- if (isHorizontal)
- model.X += offset;
- else
- model.Y += offset;
-
- model.ReportPosition();
- alreadyMoved.Add(model);
- }
-
- // To ensure group boundaries are updated correctly
- foreach (var note in WorkspaceViewModel.Model.Annotations
- .SelectMany(group => group.Nodes.OfType())
- .Where(note => note.PinnedNode != null))
- {
- note.ReportPosition();
- }
- }
-
- ///
- /// Calculates all models affected by a group's expansion and the offset needed to reposition them.
- ///
- private Dictionary GetAffectedModels(
- AnnotationModel expandingGroup,
- bool isHorizontal,
- HashSet skip)
- {
- // Track already processed items from prior horizontal/vertical pass
- var visited = new HashSet(skip);
-
- // Ensure expanding group and all its content (including nested groups) are ignored
- if (!visited.Any())
- {
- visited.Add(expandingGroup);
-
- foreach (var node in expandingGroup.Nodes)
- {
- visited.Add(node);
-
- if (node is AnnotationModel nestedGroup)
- {
- foreach (var nestedNode in nestedGroup.Nodes)
- visited.Add(nestedNode);
- }
- }
- }
-
- var toProcess = new List();
- var directlyAffected = new List();
- var otherGroups = WorkspaceViewModel.Model.Annotations.Where(g => !visited.Contains(g));
- var allGroupedItems = WorkspaceViewModel.Model.Annotations.SelectMany(g => g.Nodes);
- double smallestSpacing = double.MaxValue;
-
- var expandedBounds = GetExpandingGroupBounds(expandingGroup);
- visited.Add(expandingGroup);
- foreach (var node in expandingGroup.Nodes) visited.Add(node);
-
- // Pick direction-specific helpers
- Func overlaps = isHorizontal ? IsRightAndVerticallyOverlapping : IsBelowAndHorizontallyOverlapping;
- Func getSpacing = isHorizontal ? (a, b) => b.Left - a.Right : (a, b) => b.Top - a.Bottom;
-
- // --- Step 1: Find directly affected items ---
- // Groups
- foreach (var group in otherGroups)
- {
- if (overlaps(expandedBounds, group.Rect))
- {
- var spacing = getSpacing(expandedBounds, group.Rect);
- if (spacing < MinSpacing)
- {
- smallestSpacing = Math.Min(smallestSpacing, spacing);
- directlyAffected.Add(group);
- foreach (var node in group.Nodes)
- visited.Add(node);
- }
- }
- }
-
- // Free-standing items
- var freeItems = WorkspaceViewModel.Model.Notes.Cast()
- .Concat(WorkspaceViewModel.Model.Nodes.Cast())
- .Where(item => !allGroupedItems.Contains(item))
- .ToList();
-
- foreach (var item in freeItems)
- {
- if (overlaps(expandedBounds, item.Rect))
- {
- var spacing = getSpacing(expandedBounds, item.Rect);
- if (spacing < MinSpacing)
- {
- smallestSpacing = Math.Min(smallestSpacing, spacing);
- directlyAffected.Add(item is NoteModel { PinnedNode: NodeModel pinned } ? pinned : item);
- }
- }
- }
-
- // --- Step 2: Initialize movement ---
- var moveBy = MinSpacing - smallestSpacing;
- if (moveBy <= 0) return new();
-
- var allToMove = new Dictionary();
- foreach (var model in directlyAffected)
- {
- toProcess.Add(model);
- allToMove[model] = moveBy;
-
- if (model is AnnotationModel group)
- {
- foreach (var node in group.Nodes)
- {
- if (node is not NoteModel { PinnedNode: not null })
- allToMove[node] = moveBy;
- }
- }
- }
-
- // --- Step 3: Recursively propagate movement downstream ---
- for (int i = 0; i < toProcess.Count; i++)
- {
- var current = toProcess[i];
- var offset = allToMove.GetValueOrDefault(current, moveBy);
- var currentBounds = current.Rect;
-
- // Simulate the moved position
- currentBounds = isHorizontal
- ? new Rect2D(currentBounds.X, currentBounds.Y, currentBounds.Width + offset, currentBounds.Height)
- : new Rect2D(currentBounds.X, currentBounds.Y, currentBounds.Width, currentBounds.Height + offset);
-
- // Groups
- foreach (var group in otherGroups)
- {
- if (!overlaps(currentBounds, group.Rect)) continue;
-
- var requiredOffset = MinSpacing - getSpacing(currentBounds, group.Rect);
- if (requiredOffset <= 0) continue;
-
- allToMove[group] = Math.Max(requiredOffset, allToMove.GetValueOrDefault(group, 0));
- toProcess.Add(group);
-
- foreach (var node in group.Nodes)
- {
- if (node is NoteModel note && note.PinnedNode != null) continue;
-
- allToMove[node] = Math.Max(requiredOffset, allToMove.GetValueOrDefault(node, 0));
- visited.Add(node);
- }
- }
-
- // Free-standing items
- foreach (var item in freeItems)
- {
- if (!overlaps(currentBounds, item.Rect)) continue;
-
- var requiredOffset = MinSpacing - getSpacing(currentBounds, item.Rect);
- if (requiredOffset <= 0) continue;
-
- if (item is NoteModel note && note.PinnedNode is NodeModel pinned)
- {
- if (!visited.Contains(pinned))
- {
- allToMove[pinned] = Math.Max(requiredOffset, allToMove.GetValueOrDefault(pinned, 0));
- toProcess.Add(pinned);
- }
- }
- else
- {
- allToMove[item] = Math.Max(requiredOffset, allToMove.GetValueOrDefault(item, 0));
- toProcess.Add(item);
- }
- }
- }
-
- AddExternalConnectorPinsToMove(allToMove);
- return allToMove;
- }
-
- ///
- /// Adds external connector pins to the movement list if they connect nodes from different groups.
- ///
- private void AddExternalConnectorPinsToMove(Dictionary allToMove)
- {
- // Get all moved nodes
- var movedNodes = allToMove.Keys.OfType().ToList();
-
- // Collect only moved groups
- var movedGroups = allToMove.Keys.OfType();
-
- // Map each node to its group
- var nodeToGroup = new Dictionary();
-
- foreach (var group in movedGroups)
- {
- foreach (var node in group.Nodes.OfType())
- {
- nodeToGroup[node] = group;
- }
- }
-
- foreach (var node in movedNodes)
- {
- if (!allToMove.TryGetValue(node, out var nodeOffset)) continue;
-
- foreach (var connector in node.AllConnectors)
- {
- var startNode = connector.Start.Owner;
- var endNode = connector.End.Owner;
-
- bool sameGroup =
- nodeToGroup.TryGetValue(startNode, out var groupA) &&
- nodeToGroup.TryGetValue(endNode, out var groupB) &&
- groupA == groupB;
-
- if (sameGroup) continue;
-
- // Add each pin with the largest offset from its connected node (if multiple nodes affect it)
- foreach (var pin in connector.ConnectorPinModels)
- {
- if (!allToMove.TryGetValue(pin, out var existingOffset))
- {
- allToMove[pin] = nodeOffset;
- }
- else
- {
- allToMove[pin] = Math.Max(existingOffset, nodeOffset);
- }
- }
- }
- }
- }
-
- private static Rect2D GetExpandingGroupBounds(AnnotationModel group)
- {
- var width = group.Width;
- var height = group.ModelAreaHeight + group.TextBlockHeight;
-
- return new Rect2D(group.X, group.Y, width, height);
- }
-
- private bool IsBelowAndHorizontallyOverlapping(Rect2D thisGroup, Rect2D other)
- {
- return other.Top > thisGroup.Top &&
- other.Left < thisGroup.Right &&
- other.Right > thisGroup.Left;
- }
-
- private bool IsRightAndVerticallyOverlapping(Rect2D thisGroup, Rect2D other)
- {
- return other.Left > thisGroup.Left &&
- other.Top < thisGroup.Bottom &&
- other.Bottom > thisGroup.Top;
- }
-
- private void HandlePrePortToggleLayout()
- {
- Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
- {
- UpdateLayoutForGroupExpansion();
- }),
- DispatcherPriority.ApplicationIdle);
- }
-
private void UpdateFontSize(object parameter)
{
if (parameter == null) return;
@@ -1841,7 +1199,6 @@ private void model_PropertyChanged(object sender, System.ComponentModel.Property
RaisePropertyChanged("Width");
RaisePropertyChanged(nameof(ModelAreaRect));
UpdateAllGroupedGroups();
- RedrawConnectors(false);
break;
case "Height":
RaisePropertyChanged("Height");
@@ -1882,14 +1239,7 @@ private void model_PropertyChanged(object sender, System.ComponentModel.Property
case nameof(IsExpanded):
ManageAnnotationMVExpansionAndCollapse();
break;
- case nameof(AnnotationModel.IsOptionalInPortsCollapsed):
- isOptionalInPortsCollapsed = annotationModel.IsOptionalInPortsCollapsed;
- RaisePropertyChanged(nameof(IsOptionalInPortsCollapsed));
- break;
- case nameof(AnnotationModel.IsUnconnectedOutPortsCollapsed):
- IsUnconnectedOutPortsCollapsed = annotationModel.IsUnconnectedOutPortsCollapsed;
- RaisePropertyChanged(nameof(IsUnconnectedOutPortsCollapsed));
- break;
+
}
}
diff --git a/src/DynamoCoreWpf/ViewModels/Core/Converters/SerializationConverters.cs b/src/DynamoCoreWpf/ViewModels/Core/Converters/SerializationConverters.cs
index ecfd941bd5c..0a44f399147 100644
--- a/src/DynamoCoreWpf/ViewModels/Core/Converters/SerializationConverters.cs
+++ b/src/DynamoCoreWpf/ViewModels/Core/Converters/SerializationConverters.cs
@@ -158,14 +158,6 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
writer.WriteValue(anno.InitialHeight);
writer.WritePropertyName("TextblockHeight");
writer.WriteValue(anno.TextBlockHeight);
- writer.WritePropertyName(nameof(anno.IsOptionalInPortsCollapsed));
- writer.WriteValue(anno.IsOptionalInPortsCollapsed);
- writer.WritePropertyName(nameof(anno.IsUnconnectedOutPortsCollapsed));
- writer.WriteValue(anno.IsUnconnectedOutPortsCollapsed);
- writer.WritePropertyName(nameof(anno.HasToggledOptionalInPorts));
- writer.WriteValue(anno.HasToggledOptionalInPorts);
- writer.WritePropertyName(nameof(anno.HasToggledUnconnectedOutPorts));
- writer.WriteValue(anno.HasToggledUnconnectedOutPorts);
writer.WritePropertyName("Background");
writer.WriteValue(anno.Background != null ? anno.Background : "");
if (anno.PinnedNode != null)
diff --git a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
index ff487ebdff6..6d01b442c10 100644
--- a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
+++ b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
@@ -829,45 +829,6 @@ public bool ShowDefaultGroupDescription
}
}
- ///
- /// Indicates if the optional input ports are collapsed by default.
- ///
- public bool OptionalInputsCollapsed
- {
- get => preferenceSettings.OptionalInPortsCollapsed;
- set
- {
- preferenceSettings.OptionalInPortsCollapsed = value;
- RaisePropertyChanged(nameof(OptionalInputsCollapsed));
- }
- }
-
- ///
- /// Indicates if the unconnected output ports are hidden by default.
- ///
- public bool UnconnectedOutputsCollapsed
- {
- get => preferenceSettings.UnconnectedOutPortsCollapsed;
- set
- {
- preferenceSettings.UnconnectedOutPortsCollapsed = value;
- RaisePropertyChanged(nameof(UnconnectedOutputsCollapsed));
- }
- }
-
- ///
- /// Indicates if the groups should be collapsed to minimal size by default.
- ///
- public bool CollapseToMinSize
- {
- get => preferenceSettings.CollapseToMinSize;
- set
- {
- preferenceSettings.CollapseToMinSize = value;
- RaisePropertyChanged(nameof(CollapseToMinSize));
- }
- }
-
///
/// Indicates if Host units should be used for graphic helpers for Dynamo Revit
/// Also toggles between Host and Dynamo units
@@ -1929,15 +1890,6 @@ private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e)
case nameof(ShowDefaultGroupDescription):
description = Res.ResourceManager.GetString(nameof(Res.PreferencesViewShowDefaultGroupDescription), System.Globalization.CultureInfo.InvariantCulture);
goto default;
- case nameof(OptionalInputsCollapsed):
- description = Res.ResourceManager.GetString(nameof(Res.PreferencesViewHideInportsDescription), System.Globalization.CultureInfo.InvariantCulture);
- goto default;
- case nameof(UnconnectedOutputsCollapsed):
- description = Res.ResourceManager.GetString(nameof(Res.PreferencesViewHideOutportsDescription), System.Globalization.CultureInfo.InvariantCulture);
- goto default;
- case nameof(CollapseToMinSize):
- description = Res.ResourceManager.GetString(nameof(Res.PreferencesViewCollapseToMinSizeDescription), System.Globalization.CultureInfo.InvariantCulture);
- goto default;
case nameof(ShowCodeBlockLineNumber):
description = Res.ResourceManager.GetString(nameof(Res.PreferencesViewShowCodeBlockNodeLineNumber), System.Globalization.CultureInfo.InvariantCulture);
goto default;
diff --git a/src/DynamoCoreWpf/Views/Core/AnnotationView.xaml.cs b/src/DynamoCoreWpf/Views/Core/AnnotationView.xaml.cs
index 459975357b5..782893187e4 100644
--- a/src/DynamoCoreWpf/Views/Core/AnnotationView.xaml.cs
+++ b/src/DynamoCoreWpf/Views/Core/AnnotationView.xaml.cs
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
@@ -29,6 +27,8 @@
using TextBox = System.Windows.Controls.TextBox;
using Thickness = System.Windows.Thickness;
using ModifierKeys = System.Windows.Input.ModifierKeys;
+using System.ComponentModel;
+using System.Collections.Specialized;
namespace Dynamo.Nodes
{
@@ -51,19 +51,10 @@ public partial class AnnotationView : IViewModelView
private Border collapsedAnnotationRectangle;
private Expander groupExpander;
private ItemsControl inputPortControl;
- private ItemsControl optionalInputPortControl;
- private ToggleButton inputToggleControl;
private ItemsControl outputPortControl;
- private ItemsControl unconnectedOutputPortControl;
- private ToggleButton outputToggleControl;
- private Grid inputPortsGrid;
- private Grid outputPortsGrid;
- private Grid groupContent;
- private Border nodeCountBorder;
- private InCanvasSearchControl searchBar;
-
private Thumb mainGroupThumb;
private StackPanel groupPopupPanel;
+ private InCanvasSearchControl searchBar;
private bool _isUpdatingLayout = false;
private bool isSearchFromGroupContext;
@@ -367,7 +358,7 @@ private void OnUngroupAnnotation(object sender, RoutedEventArgs e)
{
this.ViewModel.IsExpanded = true;
}
-
+
ViewModel.WorkspaceViewModel.DynamoViewModel.ExecuteCommand(
new DynCmd.SelectModelCommand(annotationGuid, Keyboard.Modifiers.AsDynamoType()));
ViewModel.WorkspaceViewModel.DynamoViewModel.DeleteCommand.Execute(null);
@@ -426,7 +417,7 @@ private void AnnotationView_OnMouseLeftButtonDown(object sender, MouseButtonEven
private void AnnotationView_OnMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
- ViewModel.SelectAll();
+ ViewModel.SelectAll();
}
///
@@ -484,6 +475,7 @@ private void GroupTextBlock_SizeChanged(object sender, SizeChangedEventArgs e)
if (ViewModel != null && (e.HeightChanged || e.WidthChanged) && !_isUpdatingLayout)
{
_isUpdatingLayout = true;
+
// Use Dispatcher.BeginInvoke to batch layout updates
Dispatcher.BeginInvoke(new Action(() =>
{
@@ -608,7 +600,6 @@ private void GroupDescriptionTextBox_TextChanged(object sender, TextChangedEvent
private void CollapsedAnnotationRectangle_SizeChanged(object sender, SizeChangedEventArgs e)
{
- GetMinWidthOnCollapsed();
SetModelAreaHeight();
}
@@ -1534,6 +1525,7 @@ private Thumb CreateResizeThumb()
var thumb = new Thumb();
thumb.Name = "ResizeThumb";
thumb.DragDelta += AnnotationRectangleThumb_DragDelta;
+
thumb.Style = _groupResizeThumbStyle;
thumb.MouseEnter += Thumb_MouseEnter;
@@ -1559,6 +1551,7 @@ private static Style CreateGroupResizeThumbStyle()
// Create the Polygon
var polygonFactory = new FrameworkElementFactory(typeof(Polygon));
+
// Set Points collection
var points = new PointCollection
{
@@ -1597,6 +1590,8 @@ private Border CreateCollapsedAnnotationRectangle()
};
// Set bindings
+ border.SetBinding(FrameworkElement.WidthProperty, new Binding("Width"));
+ border.SetBinding(FrameworkElement.HeightProperty, new Binding("ModelAreaHeight"));
border.SetBinding(UIElement.VisibilityProperty, new Binding("IsExpanded")
{
ElementName = "GroupExpander",
@@ -1635,18 +1630,53 @@ private Grid CreateCollapsedMainGrid()
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
// Add children
- inputPortsGrid = CreateInputPortsGrid();
- outputPortsGrid = CreateOutputPortsGrid();
- groupContent = CreateGroupContent();
-
- grid.Children.Add(inputPortsGrid);
- grid.Children.Add(outputPortsGrid);
+ inputPortControl = CreateInputPortControl();
+ outputPortControl = CreateOutputPortControl();
+ var groupContent = CreateGroupContent();
+ grid.Children.Add(inputPortControl);
+ grid.Children.Add(outputPortControl);
grid.Children.Add(groupContent);
return grid;
}
+ private ItemsControl CreateInputPortControl()
+ {
+ var itemsControl = new ItemsControl
+ {
+ Name = "inputPortControl",
+ HorizontalContentAlignment = HorizontalAlignment.Left,
+ Margin = new Thickness(-25, 10, -25, 10)
+ };
+
+ Panel.SetZIndex(itemsControl, 20);
+ Grid.SetColumn(itemsControl, 0);
+ Grid.SetRow(itemsControl, 0);
+
+ itemsControl.SetBinding(ItemsControl.ItemsSourceProperty, new Binding("InPorts"));
+
+ return itemsControl;
+ }
+
+ private ItemsControl CreateOutputPortControl()
+ {
+ var itemsControl = new ItemsControl
+ {
+ Name = "outputPortControl",
+ HorizontalContentAlignment = HorizontalAlignment.Right,
+ Margin = new Thickness(-25, 10, -25, 10)
+ };
+
+ Panel.SetZIndex(itemsControl, 20);
+ Grid.SetColumn(itemsControl, 2);
+ Grid.SetRow(itemsControl, 0);
+
+ itemsControl.SetBinding(ItemsControl.ItemsSourceProperty, new Binding("OutPorts"));
+
+ return itemsControl;
+ }
+
private Grid CreateGroupContent()
{
var grid = new Grid
@@ -1745,7 +1775,7 @@ private DynamoToolTip CreateNestedGroupsTooltip()
private Border CreateNodeCountBorder()
{
- nodeCountBorder = new Border
+ var border = new Border
{
Name = "NodeCount",
BorderThickness = new Thickness(1),
@@ -1759,7 +1789,7 @@ private Border CreateNodeCountBorder()
VerticalAlignment = VerticalAlignment.Bottom,
};
- Grid.SetColumn(nodeCountBorder, 1);
+ Grid.SetColumn(border, 1);
// Create and add TextBlock
var textBlock = new TextBlock
@@ -1775,9 +1805,9 @@ private Border CreateNodeCountBorder()
StringFormat = "+{0}"
});
- nodeCountBorder.Child = textBlock;
+ border.Child = textBlock;
- return nodeCountBorder;
+ return border;
}
#endregion
@@ -2747,277 +2777,25 @@ private void SetTextHeight()
this.groupDescriptionControls.DesiredSize.Height +
this.groupNameControl.DesiredSize.Height;
}
-
- private ControlTemplate CreateCollapsedPortToggleButtonTemplate()
- {
- var template = new ControlTemplate(typeof(ToggleButton));
-
- var border = new FrameworkElementFactory(typeof(Border));
- border.SetValue(Border.BackgroundProperty, Brushes.Transparent);
-
- var stackPanel = new FrameworkElementFactory(typeof(StackPanel));
- stackPanel.SetValue(StackPanel.MarginProperty, new TemplateBindingExtension(MarginProperty));
- stackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
-
- // TextBlock with MultiBinding text
- var label = new FrameworkElementFactory(typeof(TextBlock));
- label.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
- label.SetBinding(TextBlock.ForegroundProperty, new Binding("Background")
- {
- Converter = _textForegroundSaturationColorConverter,
- ConverterParameter = "groupPortToggle"
- });
-
- var multiBinding = new MultiBinding { StringFormat = "{0} {1}" };
- multiBinding.Bindings.Add(new Binding("Tag") { RelativeSource = RelativeSource.TemplatedParent });
- multiBinding.Bindings.Add(new Binding("Content") { RelativeSource = RelativeSource.TemplatedParent });
- label.SetBinding(TextBlock.TextProperty, multiBinding);
-
- // Arrow Path
- var path = new FrameworkElementFactory(typeof(Path));
- path.SetValue(FrameworkElement.WidthProperty, 8.0);
- path.SetValue(FrameworkElement.HeightProperty, 6.0);
- path.SetValue(FrameworkElement.MarginProperty, new Thickness(6, 0, 0, 0));
- path.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
- path.SetValue(Path.DataProperty, Geometry.Parse("M0,0 L0,2 L4,6 L8,2 L8,0 L4,4 z"));
- path.SetBinding(Shape.FillProperty, new Binding("Background")
- {
- Converter = _textForegroundSaturationColorConverter,
- ConverterParameter = "groupPortToggle"
- });
-
- // RotateTransform bound to IsChecked via converter
- var rotateTransform = new RotateTransform();
- var rotateBinding = new Binding("IsChecked")
- {
- RelativeSource = RelativeSource.TemplatedParent,
- Converter = new BooleanToAngleConverter()
- };
- BindingOperations.SetBinding(rotateTransform, RotateTransform.AngleProperty, rotateBinding);
- path.SetValue(Path.RenderTransformProperty, rotateTransform);
- path.SetValue(Path.RenderTransformOriginProperty, new Point(0.5, 0.5));
-
- // Compose visual tree
- stackPanel.AppendChild(label);
- stackPanel.AppendChild(path);
- border.AppendChild(stackPanel);
- template.VisualTree = border;
-
- return template;
- }
-
- private Style CreateBaseCollapsedPortToggleStyle()
- {
- var style = new Style(typeof(ToggleButton));
- style.Setters.Add(new Setter(Control.BackgroundProperty, Brushes.Transparent));
- style.Setters.Add(new Setter(Control.BorderThicknessProperty, new Thickness(0)));
- style.Setters.Add(new Setter(Control.CursorProperty, Cursors.Hand));
- style.Setters.Add(new Setter(Control.TemplateProperty, CreateCollapsedPortToggleButtonTemplate()));
- style.Setters.Add(new Setter(Control.HeightProperty, 30.0));
-
- return style;
- }
-
- private Grid CreateInputPortsGrid()
- {
- var grid = new Grid
- {
- Name = "inputPortsGrid"
- };
- Grid.SetRow(grid, 0);
- Grid.SetColumn(grid, 0);
-
- // Define rows
- grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
- grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(34) });
- grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
-
- // Main Input Ports
- inputPortControl = new ItemsControl
- {
- Name = "inputPortControl",
- HorizontalContentAlignment = HorizontalAlignment.Left,
- Margin = new Thickness(-25, 10, 0, 0)
- };
- Panel.SetZIndex(inputPortControl, 20);
- Grid.SetRow(inputPortControl, 0);
- inputPortControl.SetBinding(ItemsControl.ItemsSourceProperty, new Binding("InPorts"));
- grid.Children.Add(inputPortControl);
-
- // Toggle Button for Collapsing Optional Ports
- inputToggleControl = new ToggleButton
- {
- Name = "inputToggleControl",
- Margin = new Thickness(5, 0, -20, 0),
- HorizontalAlignment = HorizontalAlignment.Left,
- Content = Wpf.Properties.Resources.GroupOptionalInportsText
- };
- inputToggleControl.Click += OptionalPortsToggle_Click;
- inputToggleControl.SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsOptionalInPortsCollapsed") { Mode = BindingMode.TwoWay });
- inputToggleControl.SetBinding(ToggleButton.TagProperty, new Binding("OptionalInPorts.Count"));
- Grid.SetRow(inputToggleControl, 1);
-
- var toggleStyle = CreateBaseCollapsedPortToggleStyle();
-
- // Add DataTrigger to hide toggle if no optional ports exist
- var trigger = new DataTrigger
- {
- Binding = new Binding("OptionalInPorts.Count"),
- Value = 0
- };
- trigger.Setters.Add(new Setter(VisibilityProperty, Visibility.Collapsed));
- toggleStyle.Triggers.Add(trigger);
-
- inputToggleControl.Style = toggleStyle;
- grid.Children.Add(inputToggleControl);
-
- // Optional Input Ports
- optionalInputPortControl = new ItemsControl
- {
- Name = "optionalInputPortControl",
- HorizontalContentAlignment = HorizontalAlignment.Left,
- Margin = new Thickness(-25, 0, 0, 0)
- };
- Panel.SetZIndex(optionalInputPortControl, 20);
- Grid.SetRow(optionalInputPortControl, 2);
- optionalInputPortControl.SetBinding(ItemsControl.ItemsSourceProperty, new Binding("OptionalInPorts"));
-
- // Style to collapse/expand based on IsOptionalInPortsCollapsed
- var optionalStyle = new Style(typeof(ItemsControl));
- optionalStyle.Setters.Add(new Setter(VisibilityProperty, Visibility.Collapsed));
-
- var optionalTrigger = new DataTrigger
- {
- Binding = new Binding("IsOptionalInPortsCollapsed"),
- Value = false
- };
- optionalTrigger.Setters.Add(new Setter(VisibilityProperty, Visibility.Visible));
- optionalStyle.Triggers.Add(optionalTrigger);
-
- optionalInputPortControl.Style = optionalStyle;
- grid.Children.Add(optionalInputPortControl);
-
- return grid;
- }
-
- private Grid CreateOutputPortsGrid()
+
+ private (double maxWidth, double totalHeight) MeasurePortBounds(ItemsControl portControl)
{
- var grid = new Grid
- {
- Name = "outputPortsGrid"
- };
- Grid.SetRow(grid, 0);
- Grid.SetColumn(grid, 2);
-
- // Define rows
- grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
- grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
- grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
-
- // Main Output Ports
- outputPortControl = new ItemsControl
- {
- Name = "outputPortControl",
- HorizontalContentAlignment = HorizontalAlignment.Right,
- Margin = new Thickness(0, 10, -25, 0)
- };
- Panel.SetZIndex(outputPortControl, 20);
- Grid.SetRow(outputPortControl, 0);
- outputPortControl.SetBinding(ItemsControl.ItemsSourceProperty, new Binding("OutPorts"));
- grid.Children.Add(outputPortControl);
+ double maxWidth = 0;
+ double totalHeight = 0;
- // Toggle Button for Collapsing Unconnected Ports
- outputToggleControl = new ToggleButton
+ foreach (var item in portControl.Items)
{
- Name = "outputToggleControl",
- Margin = new Thickness(0, 0, 5, 0),
- HorizontalAlignment = HorizontalAlignment.Right,
- Content = Wpf.Properties.Resources.GroupUnconnectedOutportsText
- };
- outputToggleControl.Click += UnconnectedPortsToggle_Click;
- outputToggleControl.SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsUnconnectedOutPortsCollapsed") { Mode = BindingMode.TwoWay });
- outputToggleControl.SetBinding(ToggleButton.TagProperty, new Binding("UnconnectedOutPorts.Count"));
- Grid.SetRow(outputToggleControl, 1);
-
- var toggleStyle = CreateBaseCollapsedPortToggleStyle();
-
- // Add DataTrigger to hide toggle if no unconnected ports exist
- var trigger = new DataTrigger
- {
- Binding = new Binding("UnconnectedOutPorts.Count"),
- Value = 0
- };
- trigger.Setters.Add(new Setter(VisibilityProperty, Visibility.Collapsed));
- toggleStyle.Triggers.Add(trigger);
-
- outputToggleControl.Style = toggleStyle;
- grid.Children.Add(outputToggleControl);
-
- // Unconnected Output Ports
- unconnectedOutputPortControl = new ItemsControl
- {
- Name = "unconnectedOutputPortControl",
- HorizontalContentAlignment = HorizontalAlignment.Right,
- Margin = new Thickness(0, 0, -25, 0)
- };
- Panel.SetZIndex(unconnectedOutputPortControl, 20);
- Grid.SetRow(unconnectedOutputPortControl, 2);
- unconnectedOutputPortControl.SetBinding(ItemsControl.ItemsSourceProperty, new Binding("UnconnectedOutPorts"));
-
- var optionalStyle = new Style(typeof(ItemsControl));
- optionalStyle.Setters.Add(new Setter(VisibilityProperty, Visibility.Collapsed));
- var optionalTrigger = new DataTrigger
- {
- Binding = new Binding("IsUnconnectedOutPortsCollapsed"),
- Value = false
- };
- optionalTrigger.Setters.Add(new Setter(VisibilityProperty, Visibility.Visible));
- optionalStyle.Triggers.Add(optionalTrigger);
- unconnectedOutputPortControl.Style = optionalStyle;
-
- grid.Children.Add(unconnectedOutputPortControl);
-
- return grid;
- }
-
- ///
- /// Calculates the minimum width required for a collapsed group,
- /// considering input/output ports, toggles, and their visibility states.
- ///
- private void GetMinWidthOnCollapsed()
- {
- if (ViewModel != null)
- {
- ViewModel.AnnotationModel.MinWidthOnCollapsed =
- inputPortsGrid.ActualWidth +
- outputPortsGrid.ActualWidth;
- }
- }
+ if (portControl.ItemContainerGenerator.ContainerFromItem(item) is FrameworkElement container && container.IsVisible)
+ {
+ container.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
+ var size = container.DesiredSize;
- ///
- /// Handles the click event for the optional input ports toggle button.
- /// Sets a flag indicating the user has manually toggled this state.
- ///
- private void OptionalPortsToggle_Click(object sender, RoutedEventArgs e)
- {
- // Mark it as manually changed by user
- if (!ViewModel.AnnotationModel.HasToggledOptionalInPorts)
- {
- ViewModel.AnnotationModel.HasToggledOptionalInPorts = true;
+ maxWidth = Math.Max(maxWidth, size.Width);
+ totalHeight += size.Height;
+ }
}
- }
- ///
- /// Handles the click event for the unconnected output ports toggle button.
- /// Sets a flag indicating the user has manually toggled this state.
- ///
- private void UnconnectedPortsToggle_Click(object sender, RoutedEventArgs e)
- {
- // Mark it as manually changed by user
- if (!ViewModel.AnnotationModel.HasToggledUnconnectedOutPorts)
- {
- ViewModel.AnnotationModel.HasToggledUnconnectedOutPorts = true;
- }
+ return (maxWidth, totalHeight);
}
}
}
diff --git a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml
index a36f5e67689..689b930b4be 100644
--- a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml
+++ b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml
@@ -1181,10 +1181,6 @@
-
-
-
-