// Remove the last connected board space public void RemoveLastConnected() { ConnectionLine line = connectionLines.GetLast(); line.Remove(); connectedSpaces.RemoveAt(connectedSpaces.Count - 1); }
void Start() { currentDotLink = new CurrentDotLink(); dragInput.OnSwipe += OnSwipe; dragInput.OnTouchEnd += OnTouchEnd; touchLine = GameObject.Instantiate(connectionLinePrefab).GetComponent <ConnectionLine>(); }
public void StyleLineShouldSetThickness() { ConsumeAssociation target = AssociationTestData.ConsumeAssociationFullModel(this.factory, typeof(string), new List<string>(), 5); var line = new ConnectionLine(); target.StyleLine(line); Assert.IsTrue(line.Thickness > 1); }
/// <summary> /// Merges two connection objects into one /// </summary> /// <param name="fromConnection">the remaining connection</param> /// <param name="toConnection">the connection that gets merged</param> private void MergeConnections(GraphicConnection fromConnection, PointF fromPoint, GraphicConnection toConnection, PointF toPoint) { if (fromConnection.Equals(toConnection)) { return; } if (MessageBox.Show(String.Format("Sollen die Verbindungen \"{0}\" und \"{1}\" miteinander verbunden werden?", fromConnection.Name, toConnection.Name), "Frage", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { //derive all Terminals and ConnectionItems (lines, nodes) fromConnection.Merge(toConnection); IConnectionItem item1 = fromConnection.GetItemAt(fromPoint); IConnectionItem item2 = fromConnection.GetItemAt(toPoint); if (item1 is ConnectionLine) { item1 = SplitConnectionLine(item1 as ConnectionLine, fromPoint); } if (item2 is ConnectionLine) { item2 = SplitConnectionLine(item2 as ConnectionLine, fromPoint); } ConnectionLine line = new ConnectionLine(item1 as ConnectionNode, item2 as ConnectionNode); fromConnection.AddChild(line); m_Editor.RemoveElement(toConnection); m_Editor.UpdateDrawing(); m_Editor.RaiseChangedEvent(); } }
public static List <ConnectionLine> find(UIElementCollection entities, UIEntity entity) { List <ConnectionLine> result = new List <ConnectionLine>(); foreach (UIEntity e in entities) { if (e is ConnectionLine) { ConnectionLine conenctor = e as ConnectionLine; BindingExpression srcExp = conenctor.GetBindingExpression(ConnectionLine.SourceProperty); BindingExpression dstExp = conenctor.GetBindingExpression(ConnectionLine.DestinationProperty); if (srcExp != null && dstExp != null) { Port src = srcExp.DataItem as Port; Port dst = dstExp.DataItem as Port; //if (entity.Equals(src.Owner) || entity.Equals(dst.Owner)) if (entity.Equals(entity, src.Owner) || entity.Equals(entity, dst.Owner)) { result.Add(conenctor); } } } } return(result); }
private ConnectionItemData[] ConvertConnectionItems(Connection connection) { GraphicConnection graphicConnection = connection.LinkedObject as GraphicConnection; List <ConnectionItemData> itemdatalist = new List <ConnectionItemData>(graphicConnection.Children.Count); foreach (IConnectionItem item in graphicConnection.Children) { if (item is ConnectionLine) { ConnectionLine line = item as ConnectionLine; LineItemData linedata = new LineItemData(line.Nodes[0].Name, line.Nodes[1].Name); itemdatalist.Add(linedata); } if (item is ConnectionNode) { ConnectionNode node = item as ConnectionNode; //if (node.Parent is GraphicTerminal) //impossible //{ // NodeItemData nodedata = new NodeItemData(node.Name); // nodedata.IsTerminalNode = true; //not needed // itemdatalist.Add(nodedata); //} else if (node.Parent is GraphicConnection) { NodeItemData nodedata = new NodeItemData(node.Name); //nodedata.IsTerminalNode = false; //not needed nodedata.X = node.Location.X; nodedata.Y = node.Location.Y; itemdatalist.Add(nodedata); } } } return(itemdatalist.ToArray()); }
private void MouseOverNode(DNANode node) { if (editMode == EditMode.CreateDNA) { return; } if (!isClicking) { return; } if (firstConNode == null) { firstConNode = node; if (ConnectionLine == null) { ConnectionLine = Instantiate(ConnectionLinePrefub); } return; } if (secondConNode == null && firstConNode != node) { secondConNode = node; } }
public void CompareToObjectShouldReturnNegative() { var target = new ConnectionLine { Distance = 3.4 }; object compareTo = new ConnectionLine { Distance = 10.1 }; var result = target.CompareTo(compareTo); Assert.IsTrue(result < 0); }
public void CompareToShouldReturnPositive() { var target = new ConnectionLine { Distance = 20.1 }; var compareTo = new ConnectionLine { Distance = 10.1 }; var result = target.CompareTo(compareTo); Assert.IsTrue(result > 0); }
public void CompareToShouldReturnZero() { var target = new ConnectionLine { Distance = 3.4 }; var compareTo = new ConnectionLine { Distance = 3.4 }; var result = target.CompareTo(compareTo); Assert.IsTrue(result == 0); }
public void StyleLineShouldSetThickness() { ParentAssociation target = AssociationTestData.ParentAssociationIsolated(this.mockModelBuilder, this.mockType); var line = new ConnectionLine(); target.StyleLine(line); line.Thickness.Should().BeGreaterThan(0); }
private UserCard CreateUserCard(UserVo user, int level) { var userCard = new UserCard { User = user }; double left = Math.Round(HorizontalCenter - (userCard.Width * _itemsLevels[level].Count / 2)); userCard.Top = VerticalGap * (level + 1) + userCard.Height * level; userCard.Left = left + userCard.Width * _itemsLevels[level].Proccesed + HorizontalGap * (_itemsLevels[level].Proccesed + 1); userCard.SetValue(FrameworkElement.NameProperty, "UserCard" + _userCardNumber++); Canvas.SetZIndex(userCard, 2); userCard.MouseLeftButtonDown += _mouseLeftButtonDownHandler; _whitespace.Children.Add(userCard); _itemsLevels[level].Proccesed++; foreach (UserVo childUser in user.Users) { UserCard childUserCard = CreateUserCard(childUser, level + 1); var line = new ConnectionLine { ParentUserCard = userCard, ChildUserCard = childUserCard }; Canvas.SetZIndex(line, 1); _whitespace.Children.Add(line); } return(userCard); }
// Connect this board space with another, creating a line between them public void Connect(BoardSpace space) { Vector3 lineStart = GetScreenPosition(); Vector3 lineEnd = space.GetScreenPosition(); ConnectionLine line = connectionLines.GetUnusedLine(); line.SetPoints(lineStart, lineEnd); connectedSpaces.Add(space); }
//Remove connection private void OnClickRemoveConnection(ConnectionLine connection) { //Save for undoing Undo.RecordObject(branchingTreeObj, "Remove connection"); int tempIn = -1; int tempOut = -1; //Remove the connections between the nodes for (int i = 0; i < nodes.Count; i++) { if (connection.inNode == nodes[i]) { tempIn = i; } else if (connection.outNode == nodes[i]) { tempOut = i; } } NodeConnectionCouple tempNCC = new NodeConnectionCouple(); //foreach inNode connection on the inNode, check to see if it's connected to the outNode //If so, remove that connection for (int i = 0; i < nodes[tempIn].inNodes.Count; i++) { if (nodes[tempIn].inNodes[i].n == connection.outNode) { tempNCC = nodes[tempIn].inNodes[i]; break; } } nodes[tempIn].RemoveInNode(tempNCC); //foreach inNode connection on the inNode, check to see if it's connected to the outNode //If so, remove that connection for (int i = 0; i < nodes[tempOut].outNodes.Count; i++) { if (nodes[tempOut].outNodes[i].n == connection.inNode) { tempNCC = nodes[tempOut].outNodes[i]; break; } } nodes[tempOut].RemoveOutNode(tempNCC); connections.Remove(connection); //connectionCount = connections.Count; //Save for undoing SaveTree(); }
void Start() { connectionLines = new List <ConnectionLine>(); for (int i = 0; i < connectionLinesPerSpace; i++) { GameObject newConnectionLine = GameObject.Instantiate(linePrefab); ConnectionLine connectionLine = newConnectionLine.GetComponent <ConnectionLine>(); connectionLines.Add(connectionLine); } }
public ConnectionLine ToConnectionLine() { var connectionLine = new ConnectionLine { Name = this.Name, Start = this.Start, End = this.End }; return(connectionLine); }
private void addLinkForRealEntities(ConnectionLine c, Entity realSrc, Entity realDest) { if (c.SourcePort.PortType == PortType.OUTPUT && c.DestinationPort.PortType == PortType.INPUT) { realSrc.addOutput(realDest); realDest.addInput(realSrc); } else if (c.SourcePort.PortType == PortType.INPUT && c.DestinationPort.PortType == PortType.OUTPUT) { realSrc.addInput(realDest); realDest.addOutput(realSrc); } }
void startLine() { if (standingOver != null) { connectionOrigin = standingOver; inConnectMode = true; GameObject l = Instantiate(connectionLine, transform.position, Quaternion.identity); GetComponentInChildren <SpriteRenderer>().color = connectingColor; currentConnectionLine = l; ConnectionLine c = l.GetComponent <ConnectionLine>(); c.origin = transform.position; c.end = transform; } }
private void OnMouseDown(Vector2 touchPos, Transform hitTransform) { if (!ProcessUserInput || remainingLineCount <= 0) { return; } if (hitTransform && hitTransform.tag == "Node" && hitTransform.GetComponent <Node>().GraphId == graph.Id) { touchStartNode = hitTransform.GetComponent <Node>(); currentLine = Instantiate(ConnectionLinePrefab, new Vector2(0, 0), Quaternion.identity, transform); currentLine.Scale = Scale; currentLine.GraphId = graph.Id; currentLine.SetPositions(touchStartNode.transform.position, touchPos, StaticValues.ColorByIndex[touchStartNode.ColorId - 1], StaticValues.ColorByIndex[touchStartNode.ColorId - 1]); } }
private void processConnectionLine(ConnectionLine c, bool skipSubprocess) { UIEntity src = c.SourcePort.Owner; UIEntity dest = c.DestinationPort.Owner; if (skipSubprocess && (src is SubDiagram || dest is SubDiagram)) { return; } if (map.ContainsKey(src) && map.ContainsKey(dest)) { addLinkForRealEntities(c, map[src] as Entity, map[dest] as Entity); } }
/// <summary> /// Splits the connection line at the given point and places a node there /// </summary> /// <param name="line">the line to split</param> /// <param name="atPoint">the point to place a node</param> /// <returns>the placed node</returns> private ConnectionNode SplitConnectionLine(ConnectionLine line, PointF atPoint) { GraphicConnection connection = line.Parent as GraphicConnection; ConnectionNode node = new ConnectionNode(line.NearestPointOnLine(m_Editor.AlignToGrid(atPoint))); ConnectionLine line1 = new ConnectionLine(line.Nodes[0], node); ConnectionLine line2 = new ConnectionLine(line.Nodes[1], node); connection.RemoveChild(line); connection.AddChild(node); connection.AddChild(line1); connection.AddChild(line2); return(node); }
internal override void StyleLine(ConnectionLine line) { if (line == null) { throw new ArgumentNullResourceException("line", Resources.General_Given_Parameter_Cannot_Be_Null); } double thickness = 1.25 + (this.UsageCount * 0.75); if (thickness > 15) { thickness = 15; } line.Thickness = thickness; line.Style = this.IsTrivialAssociation() ? "ConsumptionLineTrivial" : "ConsumptionLineStrong"; }
private void CreateConnectionLines(Circuit circuit, GraphicConnection graphicConnection, ConnectionData connectionData) { if (connectionData.Items == null || connectionData.Items.Length == 0) { //downward compatibility - no detailed information available: Connection connection = graphicConnection.LinkedObject as Connection; GraphicTerminal previous = null; //displays straight lines from one terminal to another foreach (Terminal terminal in connection.Terminals) { GraphicTerminal graphicTerminal = terminal.LinkedObject as GraphicTerminal; if (previous != null) { graphicConnection.AddChild(new ConnectionLine(previous.ConnectionNode, graphicTerminal.ConnectionNode)); } previous = graphicTerminal; } return; } //create nodes foreach (ConnectionItemData itemData in connectionData.Items) { if (itemData is NodeItemData) { NodeItemData nodeData = itemData as NodeItemData; ConnectionNode node = new ConnectionNode(nodeData.X, nodeData.Y); graphicConnection.AddChild(node); } } //create lines foreach (ConnectionItemData itemData in connectionData.Items) { if (itemData is LineItemData) { LineItemData lineData = itemData as LineItemData; ConnectionNode node1 = SearchNode(lineData.Node1, circuit, graphicConnection); ConnectionNode node2 = SearchNode(lineData.Node2, circuit, graphicConnection); if (node1 != null && node2 != null) { ConnectionLine line = new ConnectionLine(node1, node2); graphicConnection.AddChild(line); } } } }
private void OnMouseUp(Vector2 touchPos, Transform hitTransform) { if (!ProcessUserInput) { return; } if (hitTransform) { if (hitTransform.tag == "Line" && !touchStartNode) { var line = hitTransform.GetComponent <ConnectionLine>(); if (line.GraphId == graph.Id) { Graph.RemoveConnectionMatrix(graph, line.Node1Index, line.Node2Index); connectionLines.Remove(line); nodes[line.Node1Index].lines.Remove(line); nodes[line.Node2Index].lines.Remove(line); Destroy(line.gameObject); } } else if (hitTransform.tag == "Node" && hitTransform.GetComponent <Node>().GraphId == graph.Id) { var node2 = hitTransform.GetComponent <Node>(); if (touchStartNode && touchStartNode.Id != node2.Id && !Graph.IsNodesConnectedMatrix(graph, touchStartNode.Index, node2.Index)) { var node1 = touchStartNode; currentLine.SetConnectedNodes(node1.Index, node1.transform.position, node2.Index, node2.transform.position, StaticValues.ColorByIndex[node1.ColorId - 1], StaticValues.ColorByIndex[node2.ColorId - 1]); connectionLines.Add(currentLine); node1.lines.Add(currentLine); node2.lines.Add(currentLine); currentLine = null; Graph.AddConnectionMatrix(graph, node1.Index, node2.Index); --remainingLineCount; if (TxtRemainingLineCount) { TxtRemainingLineCount.text = remainingLineCount.ToString(); } } } } touchStartNode = null; if (currentLine) { Destroy(currentLine.gameObject); //TODO: instead, hide it to use later } }
/// <summary> /// Connect to a Connection /// </summary> /// <param name="connection"></param> private void TryConnectToConnection(GraphicConnection connection, PointF location) { if (m_FromElement is GraphicTerminal) { Terminal fromTerminal = m_FromElement.LinkedObject as Terminal; if (fromTerminal.Connection != null) { MergeConnections(fromTerminal.Connection.LinkedObject as GraphicConnection, m_LastMouseLocation, connection, location); } else { IConnectionItem connectionItem = connection.GetItemAt(location); if (connectionItem is ConnectionNode) { //user clicked near a node - connect to this ConnectionLine line = new ConnectionLine((m_FromElement as GraphicTerminal).ConnectionNode, connectionItem as ConnectionNode); connection.AddChild(line); } else if (connectionItem is ConnectionLine) { //user clicked near a line ConnectionLine prevLine = connectionItem as ConnectionLine; //place a connection node at location - split connection line ConnectionNode node = SplitConnectionLine(prevLine, location); ConnectionLine line = new ConnectionLine(node, (m_FromElement as GraphicTerminal).ConnectionNode); connection.AddChild(line); } connection.ConnectTerminal(m_FromElement as GraphicTerminal); m_Editor.UpdateDrawing(); m_Editor.RaiseChangedEvent(); } } else if (m_FromElement is GraphicConnection) { MergeConnections(m_FromElement as GraphicConnection, m_LastMouseLocation, connection, location); } else if (m_FromElement is ConnectionNode) { MergeConnections(m_FromElement.Parent as GraphicConnection, m_LastMouseLocation, connection, location); //GraphicConnection fromConnection = m_FromElement.Parent as GraphicConnection; } m_FromElement = null; m_Editor.Invalidate(); }
private void NodeOnSlotConnected(Slot slot) { Dispatcher.Invoke(() => { ConnectionLine line; if (_lines.TryGetValue(slot, out line)) { line.Dispose(); } if (slot.Mode == InOut.In) { if (slot.Output != null) { line = new ConnectionLine(Canvas, slot, slot.Output); _lines[slot] = line; } } }); }
public JsonSchemaConnectionLine(ConnectionLine connectionLine) { if (connectionLine == null) { return; } this.Type = CreativeMode.Line; this.Name = connectionLine.Name; // this.PathGeometry = connectionLine.PathGeometry; this.Start = connectionLine.Start; this.End = connectionLine.End; this.Element1Name = connectionLine.Element1?.Name; this.Element2Name = connectionLine.Element2?.Name; // this.Element1 = connectionLine.Element1 is Module ? new JsonSchemaModule(connectionLine.Element1 as Module): null; // this.Element2 = connectionLine.Element2 is Module ? new JsonSchemaModule(connectionLine.Element2 as Module) : null; }
private void MouseButtonUp() { if (editMode == EditMode.CreateDNA) { return; } if (firstConNode != null && secondConNode != null) { ConnectionLine = null; connectionsCount++; updateVirusMetaInfo(); } else { if (ConnectionLine != null) { Destroy(ConnectionLine.gameObject); ConnectionLine = null; } } firstConNode = null; secondConNode = null; }
public ViewModelComponentLine(PointPin point0, PointPin point1, Canvas _surface, int id = -1) { BaseComponentUI componentUi; if (id == -1) { componentUi = new ComponentUIConnectionLine(BaseElement.IdCounter); element = new ConnectionLine(BaseElement.IdCounter); } else { componentUi = new ComponentUIConnectionLine(id); element = new ConnectionLine(id); } Panel.SetZIndex(componentUi, -1000000); ((ConnectionLine)element).OnPropertyChangedModel += PropertyChanged; componentUi.DataContext = this; FirstPin = point0; LastPin = point1; BuildLine(point0, point1); componentUi.OnDeleteElement += OnDelete; _surface.Children.Add(componentUi); }
private void restoreConnectionLines(MainWindow mw) { List <ConnectionLine> connections = ConnectorFinder.find(owner.canvas.Children, owner); foreach (ConnectionLine cl in connections) { // can use ==, because it's same object instance UIEntity connectedTo = cl.SourcePort.Owner != owner ? cl.SourcePort.Owner : cl.DestinationPort.Owner; PortType srcPortType = cl.SourcePort.Owner != owner ? cl.SourcePort.PortType : cl.DestinationPort.PortType; PortType dstPortType = cl.SourcePort.Owner != owner ? cl.DestinationPort.PortType : cl.SourcePort.PortType; if (!(ParameterProccesor.newResource.GetType() == typeof(MaterialResource) && PortType.BOTTOM_RESOURCE.Equals(dstPortType))) { ConnectionLine newCl = new ConnectionLine(owner.canvas); newCl.SetBinding(ConnectionLine.SourceProperty, new Binding() { Source = connectedTo.findPort(srcPortType), Path = new PropertyPath(Port.AnchorPointProperty) }); newCl.SetBinding(ConnectionLine.DestinationProperty, new Binding() { Source = ParameterProccesor.newResource.findPort(dstPortType), Path = new PropertyPath(Port.AnchorPointProperty) }); newCl.MouseLeftButtonDown += mw.Shape_MouseLeftButtonDown; newCl.MouseLeftButtonUp += mw.Shape_MouseLeftButtonUp; ZIndexUtil.setCorrectZIndex(newCl.canvas, newCl); owner.canvas.Children.Add(newCl); } } }
internal override void StyleLine(ConnectionLine line) { if (!this.IsInitialised) { CannotUseWithoutInitializationFirst(); } if (line == null) { throw new ArgumentNullResourceException("line", Resources.General_Given_Parameter_Cannot_Be_Null); } line.Style = this.AssociatedTo.Modifiers.Kind == TypeKind.Interface ? "ImplementsLine" : "InheritanceLine"; }
public void StyleLineShouldSetThicknessTo16WhenUsageIsHigh() { FieldAssociation target = AssociationTestData.FieldAssociationFullModel(this.factory, typeof(string), new List<string> { "one", "two" }, 20); var line = new ConnectionLine(); target.StyleLine(line); Assert.AreEqual(16, line.Thickness); }
internal override void StyleLine(ConnectionLine line) { throw new NotImplementedException(); }
/// <summary> /// Connect to a Terminal (resp. its connection) /// </summary> /// <param name="graphicTerminal"></param> private void TryConnectToTerminal(GraphicTerminal graphicTerminal, PointF location) { Terminal toTerminal = graphicTerminal.LinkedObject as Terminal; if (toTerminal.Connection != null) { //merging connections not supported by clicking terminals return; } if (m_FromElement is GraphicTerminal) { Terminal fromTerminal = m_FromElement.LinkedObject as Terminal; //if (fromTerminal.Connection != null && toTerminal.Connection != null) //{ // MergeConnections(fromTerminal.Connection.LinkedObject as GraphicConnection, m_LastMouseLocation, // toTerminal.Connection.LinkedObject as GraphicConnection, location); //} //else if (fromTerminal.Connection != null) //{ // //IDEE: suche über allen linien die kürzeste entfernung vom ziel zur verbindung // GraphicConnection graphicConnection = fromTerminal.Connection.LinkedObject as GraphicConnection; // ConnectionLine line = new ConnectionLine((m_FromElement as GraphicTerminal).ConnectionNode, graphicTerminal.ConnectionNode); // graphicConnection.AddChild(line); // graphicConnection.ConnectTerminal(graphicTerminal); // m_Editor.UpdateDrawing(); // m_Editor.RaiseChangedEvent(); //} //else if (toTerminal.Connection != null) //{ // GraphicConnection graphicConnection = toTerminal.Connection.LinkedObject as GraphicConnection; // graphicConnection.ConnectTerminal(m_FromElement as GraphicTerminal); // m_Editor.UpdateDrawing(); // m_Editor.RaiseChangedEvent(); //} //else if (fromTerminal.Connection == null && toTerminal.Connection == null) { GraphicTerminal fromGraphicTerminal = m_FromElement as GraphicTerminal; if (IsOrthogonal(fromGraphicTerminal.ConnectionNode.Location, graphicTerminal.ConnectionNode.Location) == false) { return; } GraphicConnection graphicConnection = GraphicObjectFactory.CreateInstance(typeof(Connection), new Connection()) as GraphicConnection; graphicConnection.Name = UniqueName.GetUniqueName(m_Editor.Circuit, typeof(Connection)); graphicConnection.ConnectTerminal(fromGraphicTerminal); graphicConnection.ConnectTerminal(graphicTerminal); ConnectionLine line = new ConnectionLine(fromGraphicTerminal.ConnectionNode, graphicTerminal.ConnectionNode); graphicConnection.AddChild(line); m_Editor.AddElement(graphicConnection); m_Editor.UpdateDrawing(); m_Editor.RaiseChangedEvent(); } } if (m_FromElement is GraphicConnection) { GraphicConnection fromConnection = m_FromElement as GraphicConnection; IConnectionItem connectionItem = fromConnection.GetItemAt(m_LastMouseLocation); if (connectionItem is ConnectionNode) { ConnectionLine line = new ConnectionLine(connectionItem as ConnectionNode, graphicTerminal.ConnectionNode); fromConnection.AddChild(line); } else if (connectionItem is ConnectionLine) { ConnectionLine prevLine = connectionItem as ConnectionLine; ConnectionNode node = new ConnectionNode(prevLine.NearestPointOnLine(m_LastMouseLocation)); ConnectionLine line1 = new ConnectionLine(prevLine.Nodes[0], node); ConnectionLine line2 = new ConnectionLine(prevLine.Nodes[1], node); fromConnection.RemoveChild(prevLine); fromConnection.AddChild(node); fromConnection.AddChild(line1); fromConnection.AddChild(line2); ConnectionLine line = new ConnectionLine(node, graphicTerminal.ConnectionNode); fromConnection.AddChild(line); } fromConnection.ConnectTerminal(graphicTerminal); m_Editor.UpdateDrawing(); m_Editor.RaiseChangedEvent(); } if (m_FromElement is ConnectionNode) { m_FromElement.Location = ForceOrthogonality(graphicTerminal.ConnectionNode.Location, m_FromElement.Location); ConnectionLine line = new ConnectionLine(m_FromElement as ConnectionNode, graphicTerminal.ConnectionNode); m_FromElement.Parent.AddChild(line); (m_FromElement.Parent as GraphicConnection).ConnectTerminal(graphicTerminal); m_Editor.UpdateDrawing(); m_Editor.RaiseChangedEvent(); } m_FromElement = null; m_Editor.Invalidate(); }
public BoardInput(Board board, ConnectionLine connectionLine) { this.board = board; this.connectionLine = connectionLine; SelectedElements = new List <BoardElement>();; }
/// <summary> /// Create a floating connnection, i.e. not completely connected everywhere /// </summary> /// <param name="location"></param> private void FloatingConnection(PointF location) { if (m_FromElement is GraphicConnection) { GraphicConnection graphicConnection = m_FromElement as GraphicConnection; IConnectionItem connectionItem = graphicConnection.GetItemAt(m_LastMouseLocation); if (connectionItem is ConnectionNode) { //user clicked near a node at fist, connect to this ConnectionNode prevNode = connectionItem as ConnectionNode; location = ForceOrthogonality(prevNode.Location, m_Editor.AlignToGrid(location)); bool skip = false; //check whether the new line would just lenghten the previous line if (prevNode.Lines.Length == 1) { ConnectionLine prevLine = prevNode.Lines[0]; if (prevLine.LineStyle == ConnectionLine.DetermineLineStyle(prevNode.Location, location)) { //place the node at the new location in this case prevNode.Location = location; skip = true; } } if (skip == false) { //place a new line ConnectionNode node = new ConnectionNode(location); ConnectionLine line = new ConnectionLine(prevNode, node); m_FromElement.AddChild(node); m_FromElement.AddChild(line); m_FromElement = node; } } else if (connectionItem is ConnectionLine) { //user clicked near a line at first ConnectionLine prevLine = connectionItem as ConnectionLine; //place a connection node at location - split connection line ConnectionNode node = SplitConnectionLine(prevLine, m_LastMouseLocation); //the new node/line location = ForceOrthogonality(node.Location, m_Editor.AlignToGrid(location)); ConnectionNode fnode = new ConnectionNode(location); ConnectionLine line = new ConnectionLine(node, fnode); m_FromElement.AddChild(fnode); m_FromElement.AddChild(line); m_FromElement = fnode; } } else if (m_FromElement is GraphicTerminal) { //floating connection from a terminal GraphicTerminal graphicTerminal = m_FromElement as GraphicTerminal; location = ForceOrthogonality(graphicTerminal.ConnectionNode.Location, m_Editor.AlignToGrid(location)); ConnectionNode node = new ConnectionNode(location); ConnectionLine line = new ConnectionLine(node, graphicTerminal.ConnectionNode); GraphicConnection graphicConnection = GraphicObjectFactory.CreateInstance(typeof(Connection), new Connection()) as GraphicConnection; graphicConnection.Name = UniqueName.GetUniqueName(m_Editor.Circuit, typeof(Connection)); graphicConnection.AddChild(node); graphicConnection.AddChild(line); graphicConnection.ConnectTerminal(graphicTerminal); m_Editor.AddElement(graphicConnection); //proceed connecting with this node m_FromElement = node; } else if (m_FromElement is ConnectionNode) { //special case -> could be covered by "is GraphicConnection" //sequential floating lines ConnectionNode prevNode = m_FromElement as ConnectionNode; location = ForceOrthogonality(prevNode.Location, m_Editor.AlignToGrid(location)); bool skip = false; //check whether the new line would just lenghten the previous line if (prevNode.Lines.Length == 1) { ConnectionLine prevLine = prevNode.Lines[0]; if (prevLine.LineStyle == ConnectionLine.DetermineLineStyle(prevNode.Location, location)) { //place the node at the new location in this case prevNode.Location = location; skip = true; } } if (skip == false) { //place a new line ConnectionNode node = new ConnectionNode(location); ConnectionLine line = new ConnectionLine(prevNode, node); GraphicConnection graphicConnection = prevNode.Parent as GraphicConnection; graphicConnection.AddChild(node); graphicConnection.AddChild(line); m_FromElement = node; } } m_Editor.UpdateDrawing(); m_Editor.RaiseChangedEvent(); m_Editor.Invalidate(); }
/// <summary> /// The style line. /// </summary> /// <param name="line"> /// The line. /// </param> internal override void StyleLine(ConnectionLine line) { if (!this.IsInitialised) { CannotUseWithoutInitializationFirst(); } StyleLineForNonParentAssociation(line, this.UsageCount, this.AssociatedTo, this.IsTrivialAssociation()); }
public abstract (bool success, string validationError) VisitConnectionLine(ConnectionLine connectionLine);
internal abstract void StyleLine(ConnectionLine line);
public ConnectionRouteEventArgs(ConnectionLine route) { this.Line = route; }
public void CompareToShouldThrowWhenGivenNull() { var target = new ConnectionLine(); var result = target.CompareTo(null); }
internal static void StyleLineForNonParentAssociation(ConnectionLine line, int usageCount, IVisualisableType associatedTo, bool isTrivial) { if (line == null) { throw new ArgumentNullResourceException("line", Resources.General_Given_Parameter_Cannot_Be_Null); } double thickness = 2.25 + (usageCount * 0.75); if (thickness > 15) { thickness = 15; } if (associatedTo.Modifiers.Kind == TypeKind.Interface) { line.Style = "AssociationLineInterface"; line.Thickness = thickness; } else if (isTrivial) { line.Style = "AssociationLineTrivial"; line.Thickness = thickness; } else { line.Style = "AssociationLineStrong"; line.Thickness = thickness + 1; } }
internal override void StyleLine(ConnectionLine line) { // A subject association may still be asked to style a line if a secondary relationship points back to the subject. FieldAssociation.StyleLineForNonParentAssociation(line, 1, this.AssociatedTo, this.IsTrivialAssociation()); }
/// <summary> /// Erstellt eine Linie zu der angegebenen EpicControl /// </summary> /// <param name="ec"></param> private void CreateLine(EpicControl ec) { ec.IsHiddenChanged += ec_IsHiddenChanged; Line = new ConnectionLine(this, ec); }