Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ae71ae0
initial commit
SHKnudsen Jul 8, 2021
53b4265
wip
SHKnudsen Jul 21, 2021
46ef28c
clean up
SHKnudsen Jul 21, 2021
49daddb
remove leftovers
SHKnudsen Jul 21, 2021
4695b67
UndoRedo behaviour + grouped groups cut out + general fixes
SHKnudsen Aug 2, 2021
5d4bde1
update images
SHKnudsen Aug 2, 2021
7068c7a
fix CopyPaste + few minor bugs
SHKnudsen Aug 4, 2021
3b66ffb
minor clean ups
SHKnudsen Aug 4, 2021
8dbe17d
Group improvements unit tests (#29)
SHKnudsen Aug 4, 2021
76d88c0
initial commit
SHKnudsen Jul 8, 2021
9b07a60
wip
SHKnudsen Jul 21, 2021
4c86c27
clean up
SHKnudsen Jul 21, 2021
f97586a
remove leftovers
SHKnudsen Jul 21, 2021
a55f433
UndoRedo behaviour + grouped groups cut out + general fixes
SHKnudsen Aug 2, 2021
4d1747a
update images
SHKnudsen Aug 2, 2021
fb74a8f
fix CopyPaste + few minor bugs
SHKnudsen Aug 4, 2021
4af8e04
minor clean ups
SHKnudsen Aug 4, 2021
350bb11
Merge branch 'Group-Improvements-to-the-Graph-View' of https://github…
SHKnudsen Aug 4, 2021
e269a4c
Update SerializationTests.cs
SHKnudsen Aug 5, 2021
05d0d38
Update SerializationTests.cs
SHKnudsen Aug 6, 2021
fd260de
comment updates
SHKnudsen Aug 16, 2021
3bdb1d1
comment updates
SHKnudsen Aug 20, 2021
60fcb98
fix GetOutputPorts errors
SHKnudsen Aug 20, 2021
6397472
fix serialization
SHKnudsen Aug 20, 2021
ecb21ae
Update WorkspaceModel.cs
SHKnudsen Aug 20, 2021
d9f980a
remove grid style (not needed anymore)
SHKnudsen Aug 20, 2021
244973a
Remove BelongsToGroup property from ModelBase
SHKnudsen Aug 23, 2021
f8b817d
Update AnnotationViewModel.cs
SHKnudsen Aug 23, 2021
fd5f3d6
fix setting the graph to have unsaved changes on graph open
SHKnudsen Aug 24, 2021
753f7b3
disable drag and drop on collapsed groups
SHKnudsen Aug 24, 2021
17dac94
fix spelling mistake
SHKnudsen Aug 26, 2021
9b8c7fe
Merge branch 'DynamoNodeRedesign' into Group-Improvements-to-the-Grap…
SHKnudsen Aug 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// to distinguish one build from another. AssemblyFileVersion is specified
// in AssemblyVersionInfo.cs so that it can be easily incremented by the
// automated build process.
[assembly: AssemblyVersion("2.13.0.2104")]
[assembly: AssemblyVersion("2.13.0.2374")]


// By default, the "Product version" shown in the file properties window is
Expand All @@ -64,4 +64,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("2.13.0.2104")]
[assembly: AssemblyFileVersion("2.13.0.2374")]
1 change: 1 addition & 0 deletions src/DynamoCore/DynamoCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ limitations under the License.
<Compile Include="Extensions\ExtensionData.cs" />
<Compile Include="Extensions\IExtensionStorageAccess.cs" />
<Compile Include="Extensions\LinterExtensionBase.cs" />
<Compile Include="Graph\Annotations\AnnotationModelExtensions.cs" />
<Compile Include="Graph\Connectors\ConnectorPinModel.cs" />
<Compile Include="Graph\Workspaces\PackageDependencyInfo.cs" />
<Compile Include="Graph\Nodes\NodeOutputData.cs" />
Expand Down
176 changes: 155 additions & 21 deletions src/DynamoCore/Graph/Annotations/AnnotationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,17 @@ public override double Width
}
set
{
if (width == value) return;

width = value;
RaisePropertyChanged("Width");
}
}

private double height;
/// <summary>
/// Returns height of the group
/// Returns the full height of the group.
/// That means ModelAreaHeight + TextBlockHeight
/// </summary>
public override double Height
{
Expand All @@ -83,11 +86,29 @@ public override double Height
}
set
{
if (height == value) return;

height = value;
RaisePropertyChanged("Height");
}
}

private double modelAreaHeight;
/// <summary>
/// Returns the height of the area that all
/// model belonging to this group is encapsulated in.
/// </summary>
public double ModelAreaHeight
{
get { return modelAreaHeight; }
set
{
if (modelAreaHeight == value) return;
modelAreaHeight = value;
RaisePropertyChanged(nameof(ModelAreaHeight));
}
}

private string text;

/// <summary>
Expand Down Expand Up @@ -118,6 +139,20 @@ public string AnnotationText

}

private string annotationDescriptionText;
/// <summary>
/// Group description text
/// </summary>
public string AnnotationDescriptionText
{
get => annotationDescriptionText;
set
{
annotationDescriptionText = value;
RaisePropertyChanged(nameof(AnnotationDescriptionText));
}
}

private string background;
/// <summary>
/// Returns background of the group
Expand All @@ -132,7 +167,7 @@ public string Background
}
}

private IEnumerable<ModelBase> nodes;
private HashSet<ModelBase> nodes;
/// <summary>
/// Returns collection of models (nodes and notes) which the group contains
/// </summary>
Expand All @@ -141,15 +176,17 @@ public IEnumerable<ModelBase> Nodes
get { return nodes; }
set
{
nodes = value.ToList(); ;
nodes = value.ToHashSet<ModelBase>();
if (nodes != null && nodes.Any())
{
foreach (var model in nodes)
{
model.PropertyChanged +=model_PropertyChanged;
model.Disposed+=model_Disposed;
model.PropertyChanged += model_PropertyChanged;
model.Disposed += model_Disposed;
}
}
UpdateBoundaryFromSelection();
RaisePropertyChanged(nameof(Nodes));
}
}

Expand Down Expand Up @@ -243,33 +280,102 @@ public NodeModel PinnedNode
}
}

private double widthAdjustment;
/// <summary>
/// Adjustment margin to be added to the width of the
/// group. When set the width of the group will always
/// be set to Width + widthAdjustment
/// </summary>
public double WidthAdjustment
{
get { return widthAdjustment; }
set
{
if (value == widthAdjustment) return;
widthAdjustment = value;
UpdateBoundaryFromSelection();
}
}

private double heightAdjustment;
/// <summary>
/// Adjustment margin to be added to the height of the
/// group. When set the height of the group will always
/// be set to Height + heightAdjustment
/// </summary>
public double HeightAdjustment
{
get { return heightAdjustment; }
set
{
if (value == heightAdjustment) return;
heightAdjustment = value;
UpdateBoundaryFromSelection();
}
}

private bool isExpanded = true;
/// <summary>
/// Returns whether or not the group is expanded.
/// </summary>
public bool IsExpanded
{
get { return isExpanded; }
set
{
isExpanded = value;
UpdateBoundaryFromSelection();
}
}

/// <summary>
/// Checks if this group contains any nested groups.
/// </summary>
public bool HasNestedGroups => nodes.OfType<AnnotationModel>().Any();

#endregion

/// <summary>
/// Initializes a new instance of the <see cref="AnnotationModel"/> class.
/// </summary>
/// <param name="nodes">The nodes.</param>
/// <param name="notes">The notes.</param>
public AnnotationModel(IEnumerable<NodeModel> nodes, IEnumerable<NoteModel> notes)
public AnnotationModel(IEnumerable<NodeModel> nodes, IEnumerable<NoteModel> notes) : this(nodes, notes, new List<AnnotationModel>()) { }

/// <summary>
/// Initializes a new instance of the <see cref="AnnotationModel"/> class.
/// </summary>
/// <param name="nodes">The nodes that belongs to this group.</param>
/// <param name="notes">The notes that belongs to this group.</param>
/// <param name="groups">The groups that belongs to this group</param>
public AnnotationModel(IEnumerable<NodeModel> nodes, IEnumerable<NoteModel> notes, IEnumerable<AnnotationModel> groups)
{
var nodeModels = nodes as NodeModel[] ?? nodes.ToArray();
var noteModels = notes as NoteModel[] ?? notes.ToArray();
var groupModels = groups as AnnotationModel[] ?? groups.ToArray();
DeletedModelBases = new List<ModelBase>();
this.Nodes = nodeModels.Concat(noteModels.Cast<ModelBase>()).ToList();
this.Nodes = nodeModels
.Concat(noteModels.Cast<ModelBase>())
.Concat(groupModels.Cast<ModelBase>())
.ToList();

UpdateBoundaryFromSelection();
}


private void model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case "Position":
UpdateBoundaryFromSelection();
{
case "Position":
UpdateBoundaryFromSelection();
break;
case "Text":
UpdateBoundaryFromSelection();
break;
break;
case nameof(ModelBase.Height):
case nameof(ModelBase.Width):
UpdateBoundaryFromSelection();
break;
}
}

Expand Down Expand Up @@ -304,7 +410,8 @@ internal void UpdateBoundaryFromSelection()
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.Y) - ExtendSize - (TextBlockHeight == 0.0 ? MinTextHeight : TextBlockHeight);
var regionY = groupModels.Min(y => y.Y) -
ExtendSize - (TextBlockHeight == 0.0 ? MinTextHeight : TextBlockHeight);

//calculates the distance between the nodes
var xDistance = groupModels.Max(x => (x.X + x.Width)) - regionX;
Expand All @@ -318,14 +425,15 @@ internal void UpdateBoundaryFromSelection()
{
X = regionX,
Y = regionY,
Width = xDistance + ExtendSize,
Height = yDistance + ExtendSize + ExtendYHeight
Width = xDistance + ExtendSize + WidthAdjustment,
Height = yDistance + ExtendSize + ExtendYHeight + HeightAdjustment - TextBlockHeight
};

this.X = region.X;
this.Y = region.Y;
this.Width = Math.Max(region.Width, TextMaxWidth + ExtendSize);
this.Height = region.Height;
this.ModelAreaHeight = IsExpanded ? region.Height : ModelAreaHeight;
this.Height = this.ModelAreaHeight + TextBlockHeight;

//Initial Height is to store the Actual height of the group.
//that is the height should be the initial height without the textblock height.
Expand Down Expand Up @@ -362,6 +470,9 @@ protected override bool UpdateValueCore(UpdateValueParams updateValueParams)
case "TextBlockText":
AnnotationText = value;
break;
case "GroupNameTextBlockText":
AnnotationDescriptionText = value;
break;
}

return base.UpdateValueCore(updateValueParams);
Expand All @@ -373,6 +484,7 @@ void SerializeCore(XmlElement element, SaveContext context)
XmlElementHelper helper = new XmlElementHelper(element);
helper.SetAttribute("guid", this.GUID);
helper.SetAttribute("annotationText", this.AnnotationText);
helper.SetAttribute(nameof(AnnotationDescriptionText), this.AnnotationDescriptionText);
helper.SetAttribute("left", this.X);
helper.SetAttribute("top", this.Y);
helper.SetAttribute("width", this.Width);
Expand All @@ -381,7 +493,7 @@ void SerializeCore(XmlElement element, SaveContext context)
helper.SetAttribute("InitialTop", this.InitialTop);
helper.SetAttribute("InitialHeight", this.InitialHeight);
helper.SetAttribute("TextblockHeight", this.TextBlockHeight);
helper.SetAttribute("backgrouund", (this.Background == null ? "" : this.Background.ToString()));
helper.SetAttribute("background", (this.Background == null ? "" : this.Background.ToString()));
//Serialize Selected models
XmlDocument xmlDoc = element.OwnerDocument;
foreach (var guids in this.Nodes.Select(x => x.GUID))
Expand All @@ -400,12 +512,13 @@ protected override void DeserializeCore(XmlElement element, SaveContext context)
{
XmlElementHelper helper = new XmlElementHelper(element);
this.GUID = helper.ReadGuid("guid", this.GUID);
this.annotationText = helper.ReadString("annotationText", Resources.GroupDefaultText);
this.annotationText = helper.ReadString("annotationText", Resources.GroupNameDefaultText);
this.AnnotationDescriptionText = helper.ReadString(nameof(AnnotationDescriptionText), Resources.GroupDefaultText);
this.X = helper.ReadDouble("left", DoubleValue);
this.Y = helper.ReadDouble("top", DoubleValue);
this.width = helper.ReadDouble("width", DoubleValue);
this.height = helper.ReadDouble("height", DoubleValue);
this.background = helper.ReadString("backgrouund", "");
this.background = helper.ReadString("background", "");
this.fontSize = helper.ReadDouble("fontSize", fontSize);
this.textBlockHeight = helper.ReadDouble("TextblockHeight", DoubleValue);
this.InitialTop = helper.ReadDouble("InitialTop", DoubleValue);
Expand Down Expand Up @@ -450,10 +563,13 @@ protected override void DeserializeCore(XmlElement element, SaveContext context)
/// <param name="checkOverlap"> checkoverlap determines whether the selected model is
/// completely inside that group</param>
internal void AddToSelectedModels(ModelBase model, bool checkOverlap = false)
{
{
//if (model.BelongsToGroup) return;

var list = this.Nodes.ToList();
if (model.GUID == this.GUID) return;
if (list.Where(x => x.GUID == model.GUID).Any()) return;
if (!CheckModelIsInsideGroup(model, checkOverlap)) return;
if (!CheckModelIsInsideGroup(model, checkOverlap)) return;
list.Add(model);
this.Nodes = list;
this.UpdateBoundaryFromSelection();
Expand Down Expand Up @@ -481,6 +597,11 @@ public override void Select()
{
foreach (var models in Nodes)
{
if (models is AnnotationModel annotationModel)
{
annotationModel.Select();
continue;
}
models.IsSelected = true;
}

Expand All @@ -502,6 +623,19 @@ public override void Deselect()
base.Deselect();
}

/// <summary>
/// Checks if the provided modelbase belongs
/// to this group.
/// </summary>
/// <param name="modelBase">modelbase to check if belongs to this group</param>
/// <returns></returns>
public bool ContainsModel(ModelBase modelBase)
{
if (modelBase is null) return false;

return nodes.Contains(modelBase);
}

/// <summary>
/// Implementation of Dispose method
/// </summary>
Expand Down
23 changes: 23 additions & 0 deletions src/DynamoCore/Graph/Annotations/AnnotationModelExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dynamo.Graph.Annotations
{
internal static class AnnotationModelExtensions
{
/// <summary>
/// Checks if any of the provided groups contains the provided
/// ModelBase.
/// </summary>
/// <param name="groups"></param>
/// <param name="modelBase"></param>
/// <returns></returns>
internal static bool ContainsModel(this IEnumerable<AnnotationModel> groups, ModelBase modelBase)
{
return groups.Any(g => g.ContainsModel(modelBase));
}
}
}
1 change: 1 addition & 0 deletions src/DynamoCore/Graph/ModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public abstract class ModelBase : NotificationObject, ISelectable, ILocatable, I

private Guid guid;
private bool isSelected;
private bool belongsToGroup;
private double x;
private double y;
private double height = 100;
Expand Down
Loading