Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
Browse files Browse the repository at this point in the history
  • Loading branch information
zeusongit committed Sep 17, 2024
2 parents bd561f0 + c567326 commit e05e6a8
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 32 deletions.
4 changes: 4 additions & 0 deletions src/DynamoCore/Graph/Connectors/ConnectorModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Xml;
using Dynamo.Configuration;
using Dynamo.Graph.Nodes;
using Dynamo.Graph.Workspaces;
using Dynamo.Utilities;
Expand Down Expand Up @@ -159,6 +160,9 @@ private ConnectorModel(
GUID = guid;
Start = start.OutPorts[startIndex];
PortModel endPort = end.InPorts[endIndex];
// Reading visibility settings from preferences and setting the visibility of the connector
// so that setting changes within the session can be relfected instantly
IsHidden = !PreferenceSettings.Instance.ShowConnector;

Debug.WriteLine("Creating a connector between ports {0}(owner:{1}) and {2}(owner:{3}).",
start.GUID, Start.Owner == null ? "null" : Start.Owner.Name, end.GUID, endPort.Owner == null ? "null" : endPort.Owner.Name);
Expand Down
21 changes: 13 additions & 8 deletions src/DynamoCore/Models/RecordableCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Runtime.Serialization;
using System.Xml;
using System.Globalization;
using Dynamo.Configuration;

namespace Dynamo.Models
{
Expand Down Expand Up @@ -1563,15 +1564,16 @@ public enum Mode
BeginCreateConnections
}

void setProperties(int portIndex, PortType portType, Mode mode)
void SetProperties(int portIndex, PortType portType, Mode mode)
{
PortIndex = portIndex;
Type = portType;
ConnectionMode = mode;
IsHidden = !PreferenceSettings.Instance.ShowConnector;
}

/// <summary>
///
/// Recordable command ConnectionCommand constructor
/// </summary>
/// <param name="nodeId"></param>
/// <param name="portIndex"></param>
Expand All @@ -1581,11 +1583,11 @@ void setProperties(int portIndex, PortType portType, Mode mode)
public MakeConnectionCommand(string nodeId, int portIndex, PortType portType, Mode mode)
: base(new[] { Guid.Parse(nodeId) })
{
setProperties(portIndex, portType, mode);
SetProperties(portIndex, portType, mode);
}

/// <summary>
///
/// Recordable command ConnectionCommand constructor
/// </summary>
/// <param name="nodeId"></param>
/// <param name="portIndex"></param>
Expand All @@ -1594,11 +1596,11 @@ public MakeConnectionCommand(string nodeId, int portIndex, PortType portType, Mo
public MakeConnectionCommand(Guid nodeId, int portIndex, PortType portType, Mode mode)
: base(new[] { nodeId })
{
setProperties(portIndex, portType, mode);
SetProperties(portIndex, portType, mode);
}

/// <summary>
///
/// Recordable command ConnectionCommand constructor
/// </summary>
/// <param name="nodeId"></param>
/// <param name="portIndex"></param>
Expand All @@ -1607,7 +1609,7 @@ public MakeConnectionCommand(Guid nodeId, int portIndex, PortType portType, Mode
public MakeConnectionCommand(IEnumerable<Guid> nodeId, int portIndex, PortType portType, Mode mode)
: base(nodeId)
{
setProperties(portIndex, portType, mode);
SetProperties(portIndex, portType, mode);
}

internal static MakeConnectionCommand DeserializeCore(XmlElement element)
Expand All @@ -1616,7 +1618,6 @@ internal static MakeConnectionCommand DeserializeCore(XmlElement element)
int portIndex = helper.ReadInteger("PortIndex");
var portType = ((PortType)helper.ReadInteger("Type"));
var mode = ((Mode)helper.ReadInteger("ConnectionMode"));

var modelGuids = DeserializeGuid(element, helper);

return new MakeConnectionCommand(modelGuids, portIndex, portType, mode);
Expand All @@ -1635,6 +1636,9 @@ internal static MakeConnectionCommand DeserializeCore(XmlElement element)
[DataMember]
public Mode ConnectionMode { get; private set; }

[DataMember]
internal bool IsHidden { get; private set; }

#endregion

#region Protected Overridable Methods
Expand All @@ -1651,6 +1655,7 @@ protected override void SerializeCore(XmlElement element)
helper.SetAttribute("PortIndex", PortIndex);
helper.SetAttribute("Type", ((int)Type));
helper.SetAttribute("ConnectionMode", ((int)ConnectionMode));
helper.SetAttribute("IsHidden", IsHidden);
}

#endregion
Expand Down
4 changes: 4 additions & 0 deletions src/DynamoCoreWpf/Controls/StartPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ private void SetSampleDatasetsPath()
{
sampleDatasetsPath = datasetsPath;
}
else
{
DynamoViewModel.Model.Logger.Log("Error, Dataset folder not found.");
}
}
}
catch (Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

<Target Name="NpmRunBuildHomePage" BeforeTargets="BeforeBuild">
<PropertyGroup>
<PackageVersion>1.0.18</PackageVersion>
<PackageVersion>1.0.19</PackageVersion>
<PackageName>DynamoHome</PackageName>
</PropertyGroup>
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command echo ($(SolutionDir)\pkgexist.ps1 $(PackageName) $(PackageVersion))" ConsoleToMSBuild="true">
Expand Down
40 changes: 22 additions & 18 deletions src/DynamoCoreWpf/ViewModels/Core/ConnectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,22 +1450,18 @@ public void Redraw(object parameter)
{
var p2 = new Point();

if (parameter is Point)
if (parameter is Point point)
{
p2 = (Point)parameter;
p2 = point;
}
else if (parameter is Point2D)
else if (parameter is Point2D d)
{
p2 = ((Point2D)parameter).AsWindowsType();
p2 = d.AsWindowsType();
}

CurvePoint3 = p2;

var offset = 0.0;
double distance = 0;

distance = Math.Sqrt(Math.Pow(CurvePoint3.X - CurvePoint0.X, 2) + Math.Pow(CurvePoint3.Y - CurvePoint0.Y, 2));
offset = .45 * distance;
double distance = Math.Sqrt(Math.Pow(CurvePoint3.X - CurvePoint0.X, 2) + Math.Pow(CurvePoint3.Y - CurvePoint0.Y, 2));
double offset = .45 * distance;

CurvePoint1 = new Point(CurvePoint0.X + offset, CurvePoint0.Y);
CurvePoint2 = new Point(p2.X - offset, p2.Y);
Expand All @@ -1485,20 +1481,28 @@ public void Redraw(object parameter)
//RaisePropertyChanged(string.Empty);


PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = CurvePoint0;
PathFigure pathFigure = new PathFigure
{
StartPoint = CurvePoint0
};

BezierSegment segment = new BezierSegment(CurvePoint1, CurvePoint2, CurvePoint3, true);
var segmentCollection = new PathSegmentCollection(1);
segmentCollection.Add(segment);
var segmentCollection = new PathSegmentCollection(1)
{
segment
};
pathFigure.Segments = segmentCollection;
PathFigureCollection pathFigureCollection = new PathFigureCollection();
pathFigureCollection.Add(pathFigure);

ComputedBezierPathGeometry = new PathGeometry();
ComputedBezierPathGeometry.Figures = pathFigureCollection;
ComputedBezierPath = new Path();
ComputedBezierPath.Data = ComputedBezierPathGeometry;
ComputedBezierPathGeometry = new PathGeometry
{
Figures = pathFigureCollection
};
ComputedBezierPath = new Path
{
Data = ComputedBezierPathGeometry
};
}

private PathFigure DrawSegmentBetweenPointPairs(Point startPt, Point endPt, ref List<Point[]> controlPointList)
Expand Down
11 changes: 6 additions & 5 deletions src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void OnDataContextChanged(object sender, DependencyPropertyChangedEventA

private void DynamoViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if(dynWebView?.CoreWebView2 != null && e.PropertyName.Equals(nameof(startPage.DynamoViewModel.ShowStartPage)))
if(e.PropertyName == nameof(startPage.DynamoViewModel.ShowStartPage) && dynWebView?.CoreWebView2 != null)
{
dynWebView.CoreWebView2.ExecuteScriptAsync(@$"window.setShowStartPageChanged('{startPage.DynamoViewModel.ShowStartPage}')");
}
Expand Down Expand Up @@ -615,8 +615,10 @@ internal void ShowSampleFilesInFolder()
return;
}

Process.Start(new ProcessStartInfo("explorer.exe", "/select,"
+ this.startPage.SampleFolderPath)
// Open the default Explorer location if the Sample folder cannot be found
string explorerArg = this.startPage.SampleFolderPath != null ? "/select," + this.startPage.SampleFolderPath : "";

Process.Start(new ProcessStartInfo("explorer.exe", explorerArg)
{ UseShellExecute = true });
Logging.Analytics.TrackEvent(Logging.Actions.Show, Logging.Categories.DynamoHomeOperations, "Sample Files");
}
Expand All @@ -630,8 +632,7 @@ internal void ShowSampleDatasetsInFolder()
return;
}

Process.Start(new ProcessStartInfo("explorer.exe", /*"/select,"*/
/*+ */this.startPage.SampleDatasetsPath)
Process.Start(new ProcessStartInfo("explorer.exe", this.startPage.SampleDatasetsPath)
{ UseShellExecute = true });
Logging.Analytics.TrackEvent(Logging.Actions.Show, Logging.Categories.DynamoHomeOperations, "Dataset Files");
}
Expand Down

0 comments on commit e05e6a8

Please sign in to comment.