- Timestamp:
- 04/26/16 15:05:28 (9 years ago)
- Location:
- branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization/3.3
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization/3.3/HeuristicLab.Networks.Views.NetworkVisualization-3.3.csproj
r13135 r13799 75 75 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 76 76 <SpecificVersion>False</SpecificVersion> 77 <Private>False</Private> 77 78 </Reference> 78 79 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 79 80 <SpecificVersion>False</SpecificVersion> 80 81 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath> 81 <Private> True</Private>82 <Private>False</Private> 82 83 </Reference> 83 84 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 84 85 <SpecificVersion>False</SpecificVersion> 85 86 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath> 87 <Private>False</Private> 88 </Reference> 89 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 90 <SpecificVersion>False</SpecificVersion> 91 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath> 86 92 <Private>False</Private> 87 93 </Reference> … … 101 107 <Reference Include="System.Core" /> 102 108 <Reference Include="System.Drawing" /> 109 <Reference Include="System.Windows.Forms" /> 103 110 </ItemGroup> 104 111 <ItemGroup> … … 109 116 <Compile Include="Orientation.cs" /> 110 117 <Compile Include="PortVisualProperties.cs" /> 118 <Compile Include="Primitives\AlgorithmNodeRectangle.cs" /> 111 119 <Compile Include="Primitives\ConnectionLine.cs" /> 112 120 <Compile Include="Plugin.cs" /> 121 <Compile Include="Primitives\MessagePortRectangle.cs" /> 113 122 <Compile Include="Primitives\NodeRectangle.cs" /> 114 123 <Compile Include="Primitives\PortRectangle.cs" /> -
branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization/3.3/INodeVisualProperties.cs
r13135 r13799 20 20 #endregion 21 21 22 using System.Drawing; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core.Networks; … … 27 28 Point2D<double> LowerLeft { get; set; } 28 29 Point2D<double> UpperRight { get; set; } 30 Color BrushColor { get; set; } 31 Color PenColor { get; set; } 29 32 } 30 33 } -
branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization/3.3/IPortVisualProperties.cs
r13135 r13799 20 20 #endregion 21 21 22 using System.Drawing; 22 23 using HeuristicLab.Core.Networks; 23 24 … … 26 27 Orientation Orientation { get; set; } 27 28 double Offset { get; set; } 29 Color BrushColor { get; set; } 30 Color PenColor { get; set; } 28 31 } 29 32 } -
branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization/3.3/NodeVisualProperties.cs
r13135 r13799 20 20 #endregion 21 21 22 using System.Drawing; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core.Networks; … … 49 50 } 50 51 52 [Storable] 53 private Color brushColor; 54 public Color BrushColor { 55 get { return brushColor; } 56 set { 57 if (brushColor == value) return; 58 brushColor = value; 59 OnChanged(); 60 } 61 } 62 63 [Storable] 64 private Color penColor; 65 public Color PenColor { 66 get { return penColor; } 67 set { 68 if (penColor == value) return; 69 penColor = value; 70 OnChanged(); 71 } 72 } 73 51 74 #region Constructors & Cloning 52 75 [StorableConstructor] … … 56 79 lowerLeft = original.lowerLeft; 57 80 upperRight = original.upperRight; 81 brushColor = original.brushColor; 82 penColor = original.penColor; 58 83 } 59 84 60 public NodeVisualProperties(Point2D<double> lowerLeft, Point2D<double> upperRight) { 61 this.lowerLeft = lowerLeft; 62 this.upperRight = upperRight; 85 public NodeVisualProperties() { 86 lowerLeft = new Point2D<double>(0.0, 0.0); 87 upperRight = new Point2D<double>(200.0, 100.0); 88 brushColor = Color.FromArgb(255, 120, 200, 240); 89 penColor = Color.Black; 63 90 } 64 91 -
branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization/3.3/PortVisualProperties.cs
r13135 r13799 20 20 #endregion 21 21 22 using System.Drawing; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core.Networks; … … 49 50 } 50 51 52 [Storable] 53 private Color brushColor; 54 public Color BrushColor { 55 get { return brushColor; } 56 set { 57 if (brushColor == value) return; 58 brushColor = value; 59 OnChanged(); 60 } 61 } 62 63 [Storable] 64 private Color penColor; 65 public Color PenColor { 66 get { return penColor; } 67 set { 68 if (penColor == value) return; 69 penColor = value; 70 OnChanged(); 71 } 72 } 73 51 74 #region Constructors & Cloning 52 75 [StorableConstructor] … … 56 79 orientation = original.orientation; 57 80 offset = original.offset; 81 brushColor = original.brushColor; 82 penColor = original.penColor; 58 83 } 59 84 60 public PortVisualProperties(Orientation orientation, double offset) { 61 this.orientation = orientation; 62 this.offset = offset; 85 public PortVisualProperties() { 86 orientation = Orientation.South; 87 offset = 0.5; 88 brushColor = Color.RosyBrown; 89 penColor = Color.Black; 63 90 } 64 91 -
branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization/3.3/Primitives/ConnectionLine.cs
r13135 r13799 81 81 double bx = -2.5 * ax - ay, by = -2.5 * ay + ax; 82 82 double cx = -2.5 * ax + ay, cy = -2.5 * ay - ax; 83 double mul = 4* Chart.WorldToPixelRatio.Width;83 double mul = 5 * Chart.WorldToPixelRatio.Width; 84 84 bx *= mul; by *= mul; 85 85 cx *= mul; cy *= mul; -
branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization/3.3/Primitives/NodeRectangle.cs
r13135 r13799 23 23 using System.Collections.Generic; 24 24 using System.Drawing; 25 using System.Drawing.Drawing2D; 26 using System.Windows.Forms; 25 27 using HeuristicLab.Common; 26 28 using HeuristicLab.Core.Networks; … … 33 35 protected readonly IGroup portRectangles; 34 36 37 protected INodeVisualProperties VisualProperties { 38 get { return (INodeVisualProperties)networkItem.VisualProperties; } 39 set { 40 if (networkItem.VisualProperties == value) return; 41 networkItem.VisualProperties = value; 42 } 43 } 35 44 protected bool IgnoreVisualPropertiesChanges { get; set; } 36 45 … … 48 57 } 49 58 59 public override Brush Brush { 60 get { return base.Brush; } 61 set { 62 if (base.Brush == value) return; 63 base.Brush = value; 64 SaveVisualProperties(); 65 } 66 } 67 68 public override Pen Pen { 69 get { return base.Pen; } 70 set { 71 if (base.Pen == value) return; 72 base.Pen = value; 73 SaveVisualProperties(); 74 } 75 } 76 50 77 public NodeRectangle(IChart chart, INode node) 51 78 : base(chart, PointD.Empty, PointD.Empty) { 79 bool adjustSize = node.VisualProperties == null; 52 80 NetworkItem = node; 53 81 … … 59 87 } 60 88 portRectangles.RedrawRequired += (sender, args) => OnRedrawRequired(); 89 90 if (adjustSize) AdjustSize(); 61 91 } 62 92 63 93 protected virtual void RegisterNetworkItemEvents() { 94 if (VisualProperties != null) { 95 VisualProperties.Changed += VisualProperties_Changed; 96 } 64 97 networkItem.NameChanged += NetworkItem_NameChanged; 65 if (networkItem.VisualProperties != null) {66 networkItem.VisualProperties.Changed += VisualProperties_Changed;67 }68 98 if (networkItem.Ports != null) { 69 99 networkItem.Ports.ItemsAdded += Ports_ItemsAdded; … … 73 103 74 104 protected virtual void DeregisterNetworkItemEvents() { 105 if (VisualProperties != null) { 106 VisualProperties.Changed -= VisualProperties_Changed; 107 } 75 108 networkItem.NameChanged -= NetworkItem_NameChanged; 76 if (networkItem.VisualProperties != null) {77 networkItem.VisualProperties.Changed -= VisualProperties_Changed;78 }79 109 if (networkItem.Ports != null) { 80 110 networkItem.Ports.ItemsAdded -= Ports_ItemsAdded; … … 90 120 91 121 public override void Draw(Graphics graphics) { 92 base.Draw(graphics); 122 int cornerRadius = (int)Math.Round(6 * Chart.WorldToPixelRatio.Width); 123 var point = Chart.TransformWorldToPixel(new PointD(LowerLeft.X, LowerLeft.Y + Size.Height)); 124 var size = Chart.TransformWorldToPixel(Size); 125 var bounds = new System.Drawing.Rectangle(point.X, point.Y, size.Width, size.Height); 126 var arc = new System.Drawing.Rectangle(point, new Size(cornerRadius * 2, cornerRadius * 2)); 127 128 using (var path = new GraphicsPath()) { 129 path.AddArc(arc, 180f, 90f); 130 arc.X = bounds.Right - cornerRadius * 2; 131 path.AddArc(arc, 270f, 90); 132 arc.Y = bounds.Bottom - cornerRadius * 2; 133 path.AddArc(arc, 0f, 90f); 134 arc.X = bounds.Left; 135 path.AddArc(arc, 90f, 90f); 136 path.CloseFigure(); 137 138 graphics.FillPath(Brush, path); 139 graphics.DrawPath(Pen, path); 140 } 93 141 94 142 var p = Chart.TransformWorldToPixel(new PointD(LowerLeft.X, LowerLeft.Y + Size.Height)); 95 143 96 144 if (networkItem != null) { 97 using (var font = new Font(FontFamily.GenericSansSerif, (float)Math.Round(8.25 * Chart.WorldToPixelRatio.Width))) { 98 graphics.DrawString(networkItem.Name, font, Brushes.Black, p.X + 5, p.Y + 5); 145 using (var headerFont = new Font(FontFamily.GenericSansSerif, (float)Math.Round(8.25 * Chart.WorldToPixelRatio.Width), FontStyle.Bold)) 146 using (var contentFont = new Font(FontFamily.GenericSansSerif, (float)Math.Round(8.25 * Chart.WorldToPixelRatio.Width))) { 147 int margin = 4, x, y, lastY; 148 149 x = p.X + (int)Math.Round(margin * Chart.WorldToPixelRatio.Width); 150 y = p.Y + (int)Math.Round(margin * Chart.WorldToPixelRatio.Height); 151 152 var imageSize = networkItem.ItemImage.Size; 153 float imageWidth = (float)Math.Round(imageSize.Width * Chart.WorldToPixelRatio.Width); 154 float imageHeight = (float)Math.Round(imageSize.Height * Chart.WorldToPixelRatio.Height); 155 graphics.DrawImage(networkItem.ItemImage, x, y, imageWidth, imageHeight); 156 lastY = y; 157 158 var textSize = graphics.MeasureString(networkItem.Name, headerFont); 159 x += (int)Math.Round((imageSize.Width + margin) * Chart.WorldToPixelRatio.Width); 160 y += (int)Math.Round((imageSize.Height - textSize.Height * Chart.PixelToWorldRatio.Height) / 2 * Chart.WorldToPixelRatio.Height); 161 graphics.DrawString(networkItem.Name, headerFont, Brushes.Black, x, y); 162 y = lastY + (int)Math.Round(imageSize.Height * Chart.WorldToPixelRatio.Height); 163 164 x = p.X; 165 y += (int)Math.Round(margin * Chart.WorldToPixelRatio.Height); 166 graphics.DrawLine(Pen, x, y, x + size.Width, y); 167 168 foreach (var port in networkItem.Ports) { 169 x = p.X + (int)Math.Round(margin * Chart.WorldToPixelRatio.Width); 170 y += (int)Math.Round(margin * Chart.WorldToPixelRatio.Height); 171 172 imageSize = port.ItemImage.Size; 173 imageWidth = (float)Math.Round(imageSize.Width * Chart.WorldToPixelRatio.Width); 174 imageHeight = (float)Math.Round(imageSize.Height * Chart.WorldToPixelRatio.Height); 175 graphics.DrawImage(port.ItemImage, x, y, imageWidth, imageHeight); 176 lastY = y; 177 178 textSize = graphics.MeasureString(port.Name, contentFont); 179 x += (int)Math.Round((imageSize.Width + margin) * Chart.WorldToPixelRatio.Width); 180 y += (int)Math.Round((imageSize.Height - textSize.Height * Chart.PixelToWorldRatio.Height) / 2 * Chart.WorldToPixelRatio.Height); 181 graphics.DrawString(port.Name, contentFont, Brushes.Black, x, y); 182 y = lastY + (int)Math.Round(imageSize.Height * Chart.WorldToPixelRatio.Height); 183 184 var parameterizedPort = port as IParameterizedPort; 185 if (parameterizedPort != null) { 186 foreach (var param in parameterizedPort.Parameters) { 187 x = p.X + (int)Math.Round(4 * margin * Chart.WorldToPixelRatio.Width); 188 y += (int)Math.Round(margin * Chart.WorldToPixelRatio.Height); 189 190 imageSize = param.ItemImage.Size; 191 imageWidth = (float)Math.Round(imageSize.Width * Chart.WorldToPixelRatio.Width); 192 imageHeight = (float)Math.Round(imageSize.Height * Chart.WorldToPixelRatio.Height); 193 graphics.DrawImage(param.ItemImage, x, y, imageWidth, imageHeight); 194 lastY = y; 195 196 textSize = graphics.MeasureString(param.Name, contentFont); 197 x += (int)Math.Round((imageSize.Width + margin) * Chart.WorldToPixelRatio.Width); 198 y += (int)Math.Round((imageSize.Height - textSize.Height * Chart.PixelToWorldRatio.Height) / 2 * Chart.WorldToPixelRatio.Height); 199 graphics.DrawString(param.Name, contentFont, Brushes.Black, x, y); 200 y = lastY + (int)Math.Round(imageSize.Height * Chart.WorldToPixelRatio.Height); 201 } 202 } 203 } 99 204 } 100 205 } … … 128 233 129 234 private void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 235 AdjustSize(); 236 130 237 foreach (var port in e.Items) { 131 238 var portRectangle = PrimitiveAttribute.CreateDefaultPrimitive(port.GetType(), Chart, port, networkItem); … … 133 240 portRectangles.Add(portRectangle); 134 241 } 135 136 OnRedrawRequired();137 242 } 138 243 139 244 private void Ports_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 245 AdjustSize(); 246 140 247 foreach (var port in e.Items) { 141 248 var portRectangle = port2primitive[port]; … … 143 250 portRectangles.Remove(portRectangle); 144 251 } 145 146 OnRedrawRequired();147 252 } 148 253 #endregion 149 254 150 255 #region Helpers 151 private INodeVisualProperties CreateDefaultVisualProperties() {152 var offset = Chart.UpperRight - Chart.LowerLeft;153 var center = new PointD(Chart.LowerLeft.X + offset.DX * 0.5, Chart.LowerLeft.Y + offset.DY * 0.5);154 var size = Chart.TransformPixelToWorld(new Size(200, 100));155 var lowerLeft = center - new Offset(size.Width * 0.5, size.Height * 0.5);156 var upperRight = center + new Offset(size.Width * 0.5, size.Height * 0.5);157 return new NodeVisualProperties(new Point2D<double>(lowerLeft.X, lowerLeft.Y), new Point2D<double>(upperRight.X, upperRight.Y));158 }159 160 256 private void LoadVisualProperties() { 161 if (networkItem.VisualProperties == null) 162 networkItem.VisualProperties = CreateDefaultVisualProperties(); 163 164 var vp = (INodeVisualProperties)networkItem.VisualProperties; 165 SetPosition(new PointD(vp.LowerLeft.X, vp.LowerLeft.Y), new PointD(vp.UpperRight.X, vp.UpperRight.Y)); 257 if (VisualProperties == null) 258 VisualProperties = new NodeVisualProperties(); 259 260 var vp = VisualProperties; 261 IgnoreVisualPropertiesChanges = true; 262 try { 263 SetPosition(new PointD(vp.LowerLeft.X, vp.LowerLeft.Y), new PointD(vp.UpperRight.X, vp.UpperRight.Y)); 264 Brush = new SolidBrush(vp.BrushColor); 265 Pen = new Pen(vp.PenColor); 266 } finally { IgnoreVisualPropertiesChanges = false; } 166 267 } 167 268 168 269 private void SaveVisualProperties() { 169 if (networkItem == null) return; 170 171 var vp = (INodeVisualProperties)networkItem.VisualProperties; 172 270 if (networkItem == null || IgnoreVisualPropertiesChanges) return; 271 272 var vp = VisualProperties; 173 273 IgnoreVisualPropertiesChanges = true; 174 274 try { 175 275 vp.LowerLeft = new Point2D<double>(LowerLeft.X, LowerLeft.Y); 176 276 vp.UpperRight = new Point2D<double>(UpperRight.X, UpperRight.Y); 277 vp.BrushColor = ((SolidBrush)Brush).Color; 278 vp.PenColor = Pen.Color; 177 279 } finally { IgnoreVisualPropertiesChanges = false; } 280 } 281 282 private void AdjustSize() { 283 if (networkItem == null) return; 284 285 var p = Chart.TransformWorldToPixel(new PointD(LowerLeft.X, LowerLeft.Y + Size.Height)); 286 int margin = 4, x = p.X, y = p.Y; 287 using (var headerFont = new Font(FontFamily.GenericSansSerif, (float)Math.Round(8.25), FontStyle.Bold)) 288 using (var contentFont = new Font(FontFamily.GenericSansSerif, (float)Math.Round(8.25))) { 289 x += 2 * margin; y += 2 * margin; 290 int headerWidth = networkItem.ItemImage.Width + margin + TextRenderer.MeasureText(networkItem.Name, headerFont).Width; 291 y += networkItem.ItemImage.Height + margin; 292 int maxPortWidth = 0, maxPortParamWidth = 0; 293 foreach (var port in networkItem.Ports) { 294 int portWidth = port.ItemImage.Width + margin + TextRenderer.MeasureText(port.Name, contentFont).Width; 295 if (portWidth > maxPortWidth) maxPortWidth = portWidth; 296 y += margin + port.ItemImage.Height; 297 var parameterizedPort = port as IParameterizedPort; 298 if (parameterizedPort != null) { 299 foreach (var param in parameterizedPort.Parameters) { 300 int portParamWidth = param.ItemImage.Width + 3 * margin + TextRenderer.MeasureText(param.Name, contentFont).Width; 301 if (portParamWidth > maxPortParamWidth) maxPortParamWidth = portParamWidth; 302 y += margin + param.ItemImage.Height; 303 } 304 } 305 } 306 307 x += Math.Max(headerWidth, Math.Max(maxPortWidth, maxPortParamWidth)); 308 var ll = Chart.TransformPixelToWorld(new Point(p.X, y)); 309 var ur = Chart.TransformPixelToWorld(new Point(x, p.Y)); 310 SetPosition(ll, ur); 311 } 178 312 } 179 313 #endregion -
branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization/3.3/Primitives/PortRectangle.cs
r13135 r13799 35 35 protected readonly INodeVisualProperties nodeVisualProperties; 36 36 37 protected IPortVisualProperties VisualProperties { 38 get { return (IPortVisualProperties)networkItem.VisualProperties; } 39 set { 40 if (networkItem.VisualProperties == value) return; 41 networkItem.VisualProperties = value; 42 } 43 } 37 44 protected bool IgnoreVisualPropertiesChanges { get; set; } 38 45 … … 57 64 } 58 65 66 public override Brush Brush { 67 get { return base.Brush; } 68 set { 69 if (base.Brush == value) return; 70 base.Brush = value; 71 SaveVisualProperties(); 72 } 73 } 74 75 public override Pen Pen { 76 get { return base.Pen; } 77 set { 78 if (base.Pen == value) return; 79 base.Pen = value; 80 SaveVisualProperties(); 81 } 82 } 83 59 84 public PortRectangle(IChart chart, IPort port, INode node) 60 : base(chart, PointD.Empty, Size.Empty , Pens.Black, Brushes.Red) {85 : base(chart, PointD.Empty, Size.Empty) { 61 86 nodeVisualProperties = (INodeVisualProperties)node.VisualProperties; 62 87 nodeVisualProperties.Changed += NodeVisualProperties_Changed; … … 65 90 66 91 protected virtual void RegisterNetworkItemEvents() { 92 if (VisualProperties != null) { 93 VisualProperties.Changed += VisualProperties_Changed; 94 } 67 95 networkItem.NameChanged += NetworkItem_NameChanged; 68 if (networkItem.VisualProperties != null) {69 networkItem.VisualProperties.Changed += VisualProperties_Changed;70 }71 96 var connectablePort = networkItem as IConnectablePort; 72 97 if (connectablePort != null) { … … 76 101 77 102 protected virtual void DeregisterNetworkItemEvents() { 103 if (VisualProperties != null) { 104 VisualProperties.Changed -= VisualProperties_Changed; 105 } 78 106 networkItem.NameChanged -= NetworkItem_NameChanged; 79 if (networkItem.VisualProperties != null) {80 networkItem.VisualProperties.Changed -= VisualProperties_Changed;81 }82 107 var connectablePort = networkItem as IConnectablePort; 83 108 if (connectablePort != null) { … … 97 122 var p = Chart.TransformWorldToPixel(Point); 98 123 99 if (networkItem != null && networkItem.VisualProperties != null) {124 if (networkItem != null && VisualProperties != null) { 100 125 using (var font = new Font(FontFamily.GenericSansSerif, (float)Math.Round(8.25 * Chart.WorldToPixelRatio.Width))) { 101 126 var textSize = graphics.MeasureString(networkItem.Name, font); 102 var vp = (IPortVisualProperties)networkItem.VisualProperties;127 var vp = VisualProperties; 103 128 switch (vp.Orientation) { 104 129 case Orientation.North: p = new Point((int)(p.X - textSize.Width / 2), (int)(p.Y - Size.Height - textSize.Height)); break; … … 179 204 180 205 #region Helpers 181 182 private IPortVisualProperties CreateDefaultVisualProperties() {183 return new PortVisualProperties(Orientation.South, 0.5);184 }185 186 206 private void LoadVisualProperties() { 187 if (networkItem.VisualProperties == null) 188 networkItem.VisualProperties = CreateDefaultVisualProperties(); 189 190 var vp = (IPortVisualProperties)networkItem.VisualProperties; 191 var p = PointD.Empty; 192 double nodeWidth = nodeVisualProperties.UpperRight.X - nodeVisualProperties.LowerLeft.X; 193 double nodeHeight = nodeVisualProperties.UpperRight.Y - nodeVisualProperties.LowerLeft.Y; 194 195 switch (vp.Orientation) { 196 case Orientation.North: 197 p.X = nodeVisualProperties.LowerLeft.X + vp.Offset * nodeWidth; 198 p.Y = nodeVisualProperties.UpperRight.Y; 199 break; 200 case Orientation.East: 201 p.X = nodeVisualProperties.UpperRight.X; 202 p.Y = nodeVisualProperties.UpperRight.Y - vp.Offset * nodeHeight; 203 break; 204 case Orientation.South: 205 p.X = nodeVisualProperties.UpperRight.X - vp.Offset * nodeWidth; 206 p.Y = nodeVisualProperties.LowerLeft.Y; 207 break; 208 case Orientation.West: 209 p.X = nodeVisualProperties.LowerLeft.X; 210 p.Y = nodeVisualProperties.LowerLeft.Y + vp.Offset * nodeHeight; 211 break; 212 } 213 214 SetPosition(p); 207 if (VisualProperties == null) 208 VisualProperties = new PortVisualProperties(); 209 210 var vp = VisualProperties; 211 IgnoreVisualPropertiesChanges = true; 212 try { 213 var p = PointD.Empty; 214 double nodeWidth = nodeVisualProperties.UpperRight.X - nodeVisualProperties.LowerLeft.X; 215 double nodeHeight = nodeVisualProperties.UpperRight.Y - nodeVisualProperties.LowerLeft.Y; 216 217 switch (vp.Orientation) { 218 case Orientation.North: 219 p.X = nodeVisualProperties.LowerLeft.X + vp.Offset * nodeWidth; 220 p.Y = nodeVisualProperties.UpperRight.Y; 221 break; 222 case Orientation.East: 223 p.X = nodeVisualProperties.UpperRight.X; 224 p.Y = nodeVisualProperties.UpperRight.Y - vp.Offset * nodeHeight; 225 break; 226 case Orientation.South: 227 p.X = nodeVisualProperties.UpperRight.X - vp.Offset * nodeWidth; 228 p.Y = nodeVisualProperties.LowerLeft.Y; 229 break; 230 case Orientation.West: 231 p.X = nodeVisualProperties.LowerLeft.X; 232 p.Y = nodeVisualProperties.LowerLeft.Y + vp.Offset * nodeHeight; 233 break; 234 } 235 236 SetPosition(p); 237 Brush = new SolidBrush(vp.BrushColor); 238 Pen = new Pen(vp.PenColor); 239 } finally { IgnoreVisualPropertiesChanges = false; } 215 240 } 216 241 217 242 private void SaveVisualProperties() { 218 if (networkItem == null) return; 219 220 var vp = (IPortVisualProperties)networkItem.VisualProperties; 221 243 if (networkItem == null || IgnoreVisualPropertiesChanges) return; 244 245 var vp = VisualProperties; 222 246 IgnoreVisualPropertiesChanges = true; 223 247 try { … … 245 269 } 246 270 } 247 } finally { 248 IgnoreVisualPropertiesChanges = false; 249 } 271 272 vp.BrushColor = ((SolidBrush)Brush).Color; 273 vp.PenColor = Pen.Color; 274 } finally { IgnoreVisualPropertiesChanges = false; } 250 275 } 251 276
Note: See TracChangeset
for help on using the changeset viewer.