Changeset 13799 for branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization.Views/3.3/ChartModes
- Timestamp:
- 04/26/16 15:05:28 (9 years ago)
- Location:
- branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization.Views/3.3/ChartModes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization.Views/3.3/ChartModes/AddNodesChartMode.cs
r13135 r13799 79 79 var lowerLeft = center - new Offset(size); 80 80 var upperRight = center + new Offset(size); 81 node.VisualProperties = new NodeVisualProperties(new Point2D<double>(lowerLeft.X, lowerLeft.Y), 82 new Point2D<double>(upperRight.X, upperRight.Y)); 81 node.VisualProperties = new NodeVisualProperties { 82 LowerLeft = new Point2D<double>(lowerLeft.X, lowerLeft.Y), 83 UpperRight = new Point2D<double>(upperRight.X, upperRight.Y) 84 }; 83 85 network.Nodes.Add(node); 84 86 break; -
branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization.Views/3.3/ChartModes/SelectChartMode.cs
r13135 r13799 49 49 } 50 50 51 public override void HandleOnKeyDown(object sender, KeyEventArgs e) {52 try {53 if (!(chartControl.Tag is IUserDefinedNetwork)) return;54 55 switch (e.KeyCode) {56 case Keys.Delete:57 chartControl.SuspendRendering();58 59 var connectionLines = chartControl.Chart.Group.Primitives.OfType<ConnectionLine>().ToList();60 var nodeRectangles = chartControl.Chart.Group.Primitives.OfType<NodeRectangle>().ToList();61 var portRectangles = nodeRectangles.SelectMany(x => x.NetworkItem.Ports.Select(x.GetPortPrimitive)).OfType<PortRectangle>().ToList();62 63 var deletedNodes = new HashSet<INode>();64 var deletedPorts = new HashSet<IMessagePort>();65 66 foreach (var nodeRectangle in nodeRectangles) {67 if (nodeRectangle.Selected) {68 var node = nodeRectangle.NetworkItem;69 if (node == null) continue;70 deletedNodes.Add(node);71 foreach (var port in node.Ports.OfType<IMessagePort>())72 deletedPorts.Add(port);73 }74 }75 76 foreach (var portRectangle in portRectangles) {77 if (portRectangle.Selected) {78 var port = portRectangle.NetworkItem as IMessagePort;79 if (port == null) continue;80 port.Parent.Ports.Remove(port);81 deletedPorts.Add(port);82 }83 }84 85 selectedPortRectangle = null;86 87 foreach (var connectionLine in connectionLines) {88 var startPortRectangle = connectionLine.StartPortRectangle;89 var endPortRectangle = connectionLine.EndPortRectangle;90 if (startPortRectangle == null || endPortRectangle == null) continue;91 92 var startPort = startPortRectangle.NetworkItem as IMessagePort;93 var endPort = endPortRectangle.NetworkItem as IMessagePort;94 if (startPort == null || endPort == null) continue;95 96 if (connectionLine.Selected || deletedPorts.Contains(startPort) || deletedPorts.Contains(endPort))97 startPort.ConnectedPort = null;98 }99 100 foreach (var node in deletedNodes)101 node.Parent.Nodes.Remove(node);102 break;103 }104 } finally {105 chartControl.ResumeRendering();106 }107 }108 109 51 public override void HandleOnMouseDown(object sender, MouseEventArgs e) { 110 52 try { … … 129 71 selectedPortRectangle = portRectangle; 130 72 constrainingNodeRectangle = nodeRectangle; 73 break; 131 74 } 132 75 } … … 134 77 135 78 if (selectedPortRectangle != null) 136 foreach (var sp in chartControl.Chart.Group.SelectedPrimitives) 79 foreach (var sp in chartControl.Chart.Group.SelectedPrimitives) { 137 80 sp.Selected = false; 138 else139 base.HandleOnMouseDown(sender, e);81 OnSelectedPrimitivesChanged(); 82 } else base.HandleOnMouseDown(sender, e); 140 83 break; 141 84 } … … 196 139 } 197 140 } 141 142 protected override void DeleteSelectedPrimitives() { 143 if (!(chartControl.Tag is IUserDefinedNetwork)) return; 144 145 try { 146 chartControl.SuspendRendering(); 147 148 var connectionLines = chartControl.Chart.Group.Primitives.OfType<ConnectionLine>().ToList(); 149 var nodeRectangles = chartControl.Chart.Group.Primitives.OfType<NodeRectangle>().ToList(); 150 var portRectangles = nodeRectangles.SelectMany(x => x.NetworkItem.Ports.Select(x.GetPortPrimitive)).OfType<PortRectangle>().ToList(); 151 152 var deletedNodes = new HashSet<INode>(); 153 var deletedPorts = new HashSet<IMessagePort>(); 154 155 foreach (var nodeRectangle in nodeRectangles) { 156 if (nodeRectangle.Selected) { 157 var node = nodeRectangle.NetworkItem; 158 if (node == null) continue; 159 deletedNodes.Add(node); 160 foreach (var port in node.Ports.OfType<IMessagePort>()) 161 deletedPorts.Add(port); 162 } 163 } 164 165 foreach (var portRectangle in portRectangles) { 166 if (portRectangle.Selected) { 167 var port = portRectangle.NetworkItem as IMessagePort; 168 if (port == null) continue; 169 port.Parent.Ports.Remove(port); 170 deletedPorts.Add(port); 171 } 172 } 173 174 selectedPortRectangle = null; 175 176 foreach (var connectionLine in connectionLines) { 177 var startPortRectangle = connectionLine.StartPortRectangle; 178 var endPortRectangle = connectionLine.EndPortRectangle; 179 if (startPortRectangle == null || endPortRectangle == null) continue; 180 181 var startPort = startPortRectangle.NetworkItem as IMessagePort; 182 var endPort = endPortRectangle.NetworkItem as IMessagePort; 183 if (startPort == null || endPort == null) continue; 184 185 if (connectionLine.Selected || deletedPorts.Contains(startPort) || deletedPorts.Contains(endPort)) 186 startPort.ConnectedPort = null; 187 } 188 189 foreach (var node in deletedNodes) 190 node.Parent.Nodes.Remove(node); 191 } finally { chartControl.ResumeRendering(); } 192 } 198 193 } 199 194 }
Note: See TracChangeset
for help on using the changeset viewer.