public OnNodeEvent(EventType type, Node node, Vector2 localMousePos, ConnectionPoint conPoint) { this.eventType = type; this.eventSourceNode = node; this.eventSourceConnectionPoint = conPoint; this.globalMousePosition = new Vector2(localMousePos.x + node.GetX(), localMousePos.y + node.GetY()); }
private void GetClosestConnectionPoints(out ConnectionPoint fromPoint, out ConnectionPoint toPoint) { float shortestDist = float.MaxValue; float dist = shortestDist; fromPoint = ConnectionPoint.Center; toPoint = ConnectionPoint.Center; for (int i = 0; i < 4; ++i) { PointF posF = GetConnectionPointPosition(from, (ConnectionPoint)i); for (int j = 0; j < 4; ++j) { PointF posT = GetConnectionPointPosition(to, (ConnectionPoint)j); float dx = posF.X - posT.X; float dy = posF.Y - posT.Y; dist = (dx*dx) + (dy*dy); if (dist < shortestDist) { shortestDist = dist; fromPoint = (ConnectionPoint)i; toPoint = (ConnectionPoint)j; } } } }
private static PointF GetConnectionPointPosition (IRectangle rect, ConnectionPoint point) { switch (point) { case ConnectionPoint.North: return new PointF(rect.X + rect.ActualWidth / 2, rect.Y); case ConnectionPoint.East: return new PointF(rect.X + rect.ActualWidth, rect.Y + rect.ActualHeight / 2); case ConnectionPoint.South: return new PointF(rect.X + rect.ActualWidth / 2, rect.Y + rect.ActualHeight); case ConnectionPoint.West: return new PointF(rect.X, rect.Y + rect.ActualHeight / 2); } return new PointF(rect.X + rect.ActualWidth / 2, rect.Y + rect.ActualHeight / 2); }
public static Connection LoadConnection(string label, string connectionId, string startNodeId, ConnectionPoint output, string endNodeId, ConnectionPoint input) { return new Connection( label, connectionId, startNodeId, output, endNodeId, input ); }
public static Connection NewConnection(string label, string startNodeId, ConnectionPoint output, string endNodeId, ConnectionPoint input) { return new Connection( label, Guid.NewGuid().ToString(), startNodeId, output, endNodeId, input ); }
public void ConnectRoom( ConnectionPoint cp, Connector connector, Room connectedRoom ) { if ( cp.isConnected ) Debug.LogError( "Already room connected at " + cp ); if ( !connections.Contains( cp ) ) Debug.LogError( this + " doesn't contain connection " + cp ); cp.connectedTo = connectedRoom; cp.connector = connector; }
private Connection(string label, string connectionId, string startNodeId, ConnectionPoint output, string endNodeId, ConnectionPoint input) { conInsp = ScriptableObject.CreateInstance<ConnectionInspector>(); conInsp.hideFlags = HideFlags.DontSave; this.label = label; this.connectionId = connectionId; this.startNodeId = startNodeId; this.outputPoint = output; this.endNodeId = endNodeId; this.inputPoint = input; connectionButtonStyle = "sv_label_0"; }
protected virtual void Load() { string savePath = OpenFileDialogue(); if (savePath == "") { return; } Graph <NodeType, ConnectionType> graphDeserialized = XMLSerializerHelper.Deserialize <Graph <NodeType, ConnectionType> >(savePath); m_Graph.m_Nodes = new List <NodeType>(); m_Graph.m_Connections = new List <ConnectionType>(); foreach (var nodeDeserialized in graphDeserialized.m_Nodes) { m_Graph.m_Nodes.Add(GetAsFinalType().DeserializeNode(nodeDeserialized)); } foreach (var connectionDeserialized in graphDeserialized.m_Connections) { ConnectionPoint outPoint = null; foreach (Node n in m_Graph.m_Nodes) { outPoint = n.GetConnectionPoint(connectionDeserialized.m_OutPoint.m_Id); if (outPoint != null) { break; } } ConnectionPoint inPoint = null; foreach (Node n in m_Graph.m_Nodes) { inPoint = n.GetConnectionPoint(connectionDeserialized.m_InPoint.m_Id); if (inPoint != null) { break; } } Connection connectionBase = new Connection(inPoint, outPoint, OnClickRemoveConnection); ConnectionType connection = GetAsFinalType().CreateConnection(connectionBase); m_Graph.m_Connections.Add(connection); inPoint.OnConnectionMade(connection); outPoint.OnConnectionMade(connection); outPoint.GetNode().OnConnectionMade(connection); inPoint.GetNode().OnConnectionMade(connection); } }
public GUIDialogueNode(DialogueEditor parentEditor, DialogueNode data) { this.nodeData = data; this.speakerUID = parentEditor.speakerUID; this.editor = parentEditor; this.replies = new List <GUIDialogueReply>(); if (nodeData.replies.Count == 0) { nodeData.replies.Add(new DialogueReply()); } for (int i = 0; i < data.replies.Count; i++) { DialogueReply replyData = data.replies[i]; this.replies.Add(new GUIDialogueReply(replyData, this, i, i)); } repliesToRemove = new List <GUIDialogueReply>(); isInitialLine = (parentEditor.initialLineID == this.lineID); nameLabelRect = new Rect( data.position.x + padding, data.position.y + padding, textWidth, nameHeight ); nameRect = new Rect( data.position.x + padding, data.position.y + padding + nameHeight, textWidth, nameHeight ); initialLineToggleRect = new Rect( data.position.x + padding, data.position.y + padding + nameHeight * 2.0f, textWidth, nameHeight ); textLabelRect = new Rect( data.position.x + padding, data.position.y + padding + nameHeight * 3.0f, textWidth, textHeight ); textRect = new Rect( data.position.x + padding, data.position.y + padding * 2.0f + nameHeight * 4.0f, textWidth, textHeight ); rect = new Rect( data.position.x, data.position.y, textWidth + padding * 2.0f, mainBlockHeight + (textHeight + padding) * replies.Count ); style = defaultNodeStyle; inPoint = new ConnectionPoint(this, ConnectionPointType.In); }
private void CreateControlLayout() { Headlabel.Text = $"Timer"; Output = new ConnectionPoint(typeof(IOIDAction)); Output.Location = new Point(this.Width - Output.Width, Headlabel.Bottom); Output.OnConnectionStateChange += (_, e) => { base.RaiseFeebackEvent(new FeebackEventArgs(e)); }; Output.SetColor(COLORACTION); InputA = new ConnectionPoint(new Type[] { typeof(OIDRegister) }); InputA.Location = new Point(0, Headlabel.Bottom); InputA.OnConnectionStateChange += (_, e) => { base.RaiseFeebackEvent(new FeebackEventArgs(e)); }; InputA.SetColor(COLORREGISTER); HeadLabel l2 = new HeadLabel(); l2.Text = $"Register Only"; l2.Location = InputA.RightFrom().AddY(2); InputB = new ConnectionPoint(new Type[] { typeof(ushort) }); InputB.Location = new Point(0, InputA.Bottom); InputB.OnConnectionStateChange += (_, e) => { base.RaiseFeebackEvent(new FeebackEventArgs(e)); }; InputB.SetColor(COLORVALUE); HeadLabel l3 = new HeadLabel(); l3.Text = $"Register, Value"; l3.Location = InputB.RightFrom().AddY(3); this.Height = InputB.Bottom; this.Controls.Add(l2); this.Controls.Add(l3); this.Controls.Add(Output); this.Controls.Add(InputA); this.Controls.Add(InputB); this.DoubleClick += (_, __) => { var no = NodeObject(true); if (no != null && no is IOIDAction oID) { RaiseMessageEvent(new MessageEventArgs($"{oID.GetActionString}")); } }; }
public void OnClickInPoint(ConnectionPoint inPoint) { selectedInPoint = inPoint; if (selectedOutPoint != null) { if (selectedOutPoint.parent != selectedInPoint.parent) { CreateConnection(); ClearConnectionSelection(); } else { ClearConnectionSelection(); } } }
public AsyncRequestManager(OpcDaGroup opcDaGroup) { var opcDataCallback = new OpcDataCallback { CancelComplete = OnCancelComplete, DataChange = OnDataChange, ReadComplete = OnReadComplete, WriteComplete = OnWriteComplete }; _connectionPoint = new ConnectionPoint <IOPCDataCallback>(opcDataCallback); _slots = new Slots <IAsyncRequest>(OpcConfiguration.MaxSimultaneousRequests); _opcDaGroup = opcDaGroup; TryConnect(opcDaGroup.ComObject); }
protected void OnClickConnectionPoint(ConnectionPoint point) { //if (selectedToNode == null) //{ // selectedToNode = point; //} //else //{ // selectedFromNode = point; // if (selectedFromNode.node != selectedToNode.node) // { // CreateConnection(); // ClearConnectionSelection(); // } //} }
private void connectionsSearchButton_Click(object sender, RoutedEventArgs e) { bool isResultFound = false; try { connectionsListBox.Items.Clear(); string selectedDate = ""; if ((connectionsDatePicker.SelectedDate != null) && (connectionsTimeComboBox.SelectedItem != null)) { string str = connectionsDatePicker.SelectedDate.ToString().Replace("00:00:00", ""); selectedDate = str + connectionsTimeComboBox.SelectedItem.ToString() + ":00"; } if (connectionsStartComboBox.Text == "" || connectionsEndComboBox.Text == "") { throw new Exception(); } List <Connection> connections = transport.GetConnections(connectionsStartComboBox.Text, connectionsEndComboBox.Text).ConnectionList; foreach (Connection connection in connections) { ConnectionPoint connectionPointFrom = connection.From; if (isAfterSelectedDate(selectedDate, connectionPointFrom)) { string listBoxOutput = ""; listBoxOutput += "Von: " + connectionsStartComboBox.Text; listBoxOutput += " ----> "; listBoxOutput += "Nach: " + connectionsEndComboBox.Text; listBoxOutput += " Zeit: " + connectionPointFrom.Departure; connectionsListBox.Items.Add(listBoxOutput); isResultFound = true; } } } catch (WebException) { navigation.showError("Sie haben keine Internetverbindung, verbinden Sie sich mit dem Internet."); } catch (FormatException) { navigation.showError("Geben Sie Datum und Zeit ein."); } catch (Exception) { navigation.showError("Geben Sie erst zwei gültige Stationen in die Eingabefelder ein, bevor Sie die Suche starten."); } if (!isResultFound) { connectionsListBox.Items.Add("Es wurden keine Suchergebnisse gefunden."); } }
public Vector4Node(int id, Vector2 position, GUIStyle nodeStyle, GUIStyle selectedStyle, GUIStyle inPointStyle, GUIStyle outPointStyle) : base(id, position, nodeStyle, selectedStyle, inPointStyle, outPointStyle) { title = "Vector4"; ShowTitle = false; rect.width = 260; xPoint = AddInPoint <DigitConnectPoint>("X"); yPoint = AddInPoint <DigitConnectPoint>("Y"); zPoint = AddInPoint <DigitConnectPoint>("Z"); wPoint = AddInPoint <DigitConnectPoint>("W"); AddOutPoint <Vector3ConnectPoint>("V", GetV); AddOutPoint <FloatConnectPoint>("X", GetX); AddOutPoint <FloatConnectPoint>("Y", GetY); AddOutPoint <FloatConnectPoint>("Z", GetW); AddOutPoint <FloatConnectPoint>("W", GetW); InPointAlignment = EConnectPointAlignment.Upper; OutPointAlignment = EConnectPointAlignment.Upper; }
private void OnClickOutPoint(ConnectionPoint outPoint) { selectedOutPoint = outPoint; if (selectedInPoint != null) { if (selectedOutPoint.node != selectedInPoint.node) { CreateConnection(); ClearConnectionSelection(); } else { ClearConnectionSelection(); } } }
protected void OnClickOutPoint(ConnectionPoint _outPoint) { m_outSelectionPoint = _outPoint; if (m_inSelectedPoint != null) { if (m_inSelectedPoint.Node != m_outSelectionPoint.Node) { CreateConnection(); ClearConnectionSelection(); } else { ClearConnectionSelection(); } } }
public AsyncRequestManager(OpcDaGroup opcDaGroup) { var opcDataCallback = new OpcDataCallback { CancelComplete = OnCancelComplete, DataChange = OnDataChange, ReadComplete = OnReadComplete, WriteComplete = OnWriteComplete }; _connectionPoint = new ConnectionPoint<IOPCDataCallback>(opcDataCallback); _slots = new Slots<IAsyncRequest>(OpcConfiguration.MaxSimultaneousRequests); _opcDaGroup = opcDaGroup; TryConnect(opcDaGroup.ComObject); }
/// <summary> /// Init the node /// </summary> /// <param name="_position"></param> /// <param name="_width"></param> /// <param name="_height"></param> /// <param name="_nodeStyle"></param> /// <param name="_selectedNodeStyle"></param> /// <param name="_inPointStyle"></param> /// <param name="_outPointStyle"></param> /// <param name="_onClickInPoint"></param> /// <param name="_onClickOutPoint"></param> /// <param name="_onRemoveNodeAction"></param> public Node(Vector2 _position, float _width, float _height, GUIStyle _nodeStyle, GUIStyle _selectedNodeStyle, GUIStyle _inPointStyle, GUIStyle _outPointStyle, Action <ConnectionPoint> _onClickInPoint, Action <ConnectionPoint> _onClickOutPoint, Action <Node> _onRemoveNodeAction) { NodeRect = new Rect(_position.x, _position.y, _width, _height); m_defaultNodeStyle = _nodeStyle; m_selectedNodeStyle = _selectedNodeStyle; m_nodeStyle = m_defaultNodeStyle; InPoint = new ConnectionPoint(this, ConnectionPointType.In, _inPointStyle, _onClickInPoint); if (OutPoints == null) { OutPoints = new List <ConnectionPoint>(); } m_onClickOutPoint = _onClickOutPoint; m_outPointStyle = _outPointStyle; OutPoints.Add(new ConnectionPoint(this, ConnectionPointType.Out, m_outPointStyle, m_onClickOutPoint)); m_onRemoveNode = _onRemoveNodeAction; }
public void isMouseOverWindow(Vector2 mousePos) { for (int i = 0; i < NodeManager.Instance.getLength(); i++) { //Get the Selected Node if (NodeManager.Instance.getNode(i).windowRect.Contains(mousePos)) { //Fill column with node data ActiveNode = NodeManager.Instance.getNode(i); //If mouse is over a point if (ActiveNode.isOverPoint(mousePos)) { //Clicked on the connection point start to draw Handle if (!IsDrawingHandle) { handlePoint = ActiveNode.getConPoint(mousePos); IsDrawingHandle = true; return; } //Already Drawing a curve, point been selected now a second one is else { ConnectionPoint fromPoint = ActiveNode.getConPoint(mousePos); //Opposite type and not of of the current node if ((fromPoint.type != handlePoint.type) && !ActiveNode.containsPoint(handlePoint)) { //Remove Connections if (ConnectionManager.Instance.isOutConnected(fromPoint, handlePoint)) { ConnectionManager.Instance.remove(fromPoint, handlePoint); } fromPoint.connectedTo = handlePoint; handlePoint.connectedTo = fromPoint; ConnectionManager.Instance.addConnection(fromPoint, handlePoint, OnClickRemoveConnection); } } } } } //Clicked but not over a window handlePoint = null; IsDrawingHandle = false; return; }
private void OnClickInPoint(ConnectionPoint inPoint) { _selectedInPoint = inPoint; if (_selectedOutPoint != null) { if (_selectedOutPoint.node != _selectedInPoint.node) { CreateConnection(); ClearConnectionSelection(); } else { ClearConnectionSelection(); } } }
public void OnEndDrag(PointerEventData eventData) { ConnectionPoint target = FindConnectionPoint(); if (target == null) { anchor.currentWireBuilder = null; Destroy(this.gameObject); return; } bool valid = true; if (target.connectionType == anchor.connectionType) { valid = false; } if (valid) { Debug.Log("Good connection"); var source = anchor.connectionType == ConnectionPoint.ConnectionType.Output ? anchor : target; var dest = target.connectionType == ConnectionPoint.ConnectionType.Input ? target : anchor; Debug.Assert(source != dest); CircuitDisplay cd = GetComponentInParent <CircuitDisplay>(); if (cd.CanMakeConnection(source, dest)) { cd.MakeConnection(source, dest); } else { Debug.Log("CircuitDisplay says connection illegal"); } } else { Debug.Log("Cancelling, invalid connection"); } anchor.currentWireBuilder = null; Destroy(this.gameObject); }
public int GetSharedPlaces(ConnectionPoint other, List <Place> output) { output.Clear(); foreach (var mp in places) { foreach (var op in other.places) { if (mp == op) { output.Add(mp); } } } return(output.Count); }
protected virtual void OnClickInPoint(ConnectionPoint inPoint) { selectedInPoint = inPoint; if (selectedOutPoint != null) { if (selectedInPoint.node != selectedOutPoint.node) { CreateConnection(); ClearConnectionSelection(); } else { ClearConnectionSelection(); } } }
public RAM64KB(string name) { V = new ConnectionPoint($"{name}-ram64.v"); Write = new ConnectionPoint($"{name}-ram64.clk"); A0 = new ConnectionPoint($"{name}-ram64.a0"); A1 = new ConnectionPoint($"{name}-ram64.a1"); A2 = new ConnectionPoint($"{name}-ram64.a2"); A3 = new ConnectionPoint($"{name}-ram64.a3"); A4 = new ConnectionPoint($"{name}-ram64.a4"); A5 = new ConnectionPoint($"{name}-ram64.a5"); A6 = new ConnectionPoint($"{name}-ram64.a6"); A7 = new ConnectionPoint($"{name}-ram64.a7"); A8 = new ConnectionPoint($"{name}-ram64.a8"); A9 = new ConnectionPoint($"{name}-ram64.a9"); A10 = new ConnectionPoint($"{name}-ram64.a10"); A11 = new ConnectionPoint($"{name}-ram64.a11"); A12 = new ConnectionPoint($"{name}-ram64.a12"); A13 = new ConnectionPoint($"{name}-ram64.a13"); A14 = new ConnectionPoint($"{name}-ram64.a14"); A15 = new ConnectionPoint($"{name}-ram64.a15"); Din0 = new ConnectionPoint($"{name}-ram64.din0"); Din1 = new ConnectionPoint($"{name}-ram64.din1"); Din2 = new ConnectionPoint($"{name}-ram64.din2"); Din3 = new ConnectionPoint($"{name}-ram64.din3"); Din4 = new ConnectionPoint($"{name}-ram64.din4"); Din5 = new ConnectionPoint($"{name}-ram64.din5"); Din6 = new ConnectionPoint($"{name}-ram64.din6"); Din7 = new ConnectionPoint($"{name}-ram64.din7"); Dout0 = new ConnectionPoint($"{name}-ram64.dout0"); Dout1 = new ConnectionPoint($"{name}-ram64.dout1"); Dout2 = new ConnectionPoint($"{name}-ram64.dout2"); Dout3 = new ConnectionPoint($"{name}-ram64.dout3"); Dout4 = new ConnectionPoint($"{name}-ram64.dout4"); Dout5 = new ConnectionPoint($"{name}-ram64.dout5"); Dout6 = new ConnectionPoint($"{name}-ram64.dout6"); Dout7 = new ConnectionPoint($"{name}-ram64.dout7"); DoWireUp(); Reset(); Components.Record(nameof(RAM64KB)); }
/// <summary> /// Connect the ParentNode's Port and ChildNode's Port /// </summary> /// <param name="parentNode">ParentNode's Port</param> /// <param name="childNode">ChildNode's Port</param> /// <param name="decoratorShape">DecoratorShape of the connector</param> /// <param name="labelText">Set the text to the label</param> /// <param name="OffsetX">Set the OffsetX to the label</param> /// <param name="OffsetY">Set the OffsetY to the label</param> /// <param name="DrawImage">Determines whether image should draw with label or not</param> /// <param name="classType">Classtype</param> private ConnectorBase ConnectNodes(ConnectionPoint parentNode, ConnectionPoint childNode, DecoratorShape decoratorShape, string labelText, float OffsetX, float OffsetY, bool DrawImage, int classType) { if (parentNode != null && childNode != null) { OrthogonalConnector lConnector = new OrthogonalConnector(System.Drawing.PointF.Empty, new System.Drawing.PointF(0, 1)); lConnector.LineRoutingEnabled = true; lConnector.LineRoutingEnabled = true; lConnector.HeadDecorator.DecoratorShape = decoratorShape; lConnector.LineStyle.LineColor = Color.Goldenrod; lConnector.LineStyle.LineWidth = 1; lConnector.CentralPort.ConnectionsLimit = 10000; ImageLabel imageLabel = new ImageLabel(lConnector, labelText); imageLabel.OffsetX = OffsetX; imageLabel.OffsetY = OffsetY; imageLabel.ImageOffsetX = OffsetX - 25; imageLabel.ImageOffsetY = OffsetY - 5; imageLabel.DrawImage = DrawImage; if (classType == 1) { imageLabel.TextImage = System.Drawing.Image.FromFile(@"..\..\..\..\..\..\..\Common\Images\Diagram\class diagram\6.png"); } else { imageLabel.TextImage = System.Drawing.Image.FromFile(@"..\..\..\..\..\..\..\Common\Images\Diagram\class diagram\7.png"); } lConnector.Labels.Add(imageLabel); lConnector.HeadDecorator.Size = new System.Drawing.SizeF(12, 12); if (decoratorShape == DecoratorShape.Filled45Arrow) { lConnector.HeadDecorator.FillStyle.Color = Color.White; } lConnector.HeadDecorator.LineStyle.LineColor = Color.Goldenrod; lConnector.LineRoutingEnabled = true; parentNode.TryConnect(lConnector.TailEndPoint); childNode.TryConnect(lConnector.HeadEndPoint); this.diagram1.Model.AppendChild(lConnector); this.diagram1.Model.SendToBack(lConnector); return(lConnector); } else { return(null); } }
protected void OnClickInPoint(ConnectionPoint inPoint) { selectedInPoint = inPoint; if (selectedOutPoint != null) { //is not on same node, and nodes are free to connect if (selectedOutPoint.node != selectedInPoint.node && CanMakeConnection()) { CreateConnection(); ClearConnectionSelection(); } else { ClearConnectionSelection(); } } }
private void OnClickInPoint(ConnectionPoint inPoint) { selectedInPoint = inPoint; if (selectedOutPoint != null) { if (selectedOutPoint.node != selectedInPoint.node) { CreateConnection(); ClearConnectionSelection(); } else { Debug.Log("New Node?"); ClearConnectionSelection(); } } }
public void RefreshConnectionPoint(ConnectionPoint connectionPoint) { refreshConnections.Add(connectionPoint); if (connectionPoints.ContainsKey(connectionPoint.GUID)) { foreach (var conn in connectionPoints[connectionPoint.GUID].connectedTo) { refreshConnections.Add(conn); conn.ReplaceOld(connectionPoint); } connectionPoints[connectionPoint.GUID] = connectionPoint; } else { connectionPoints.Add(connectionPoint.GUID, connectionPoint); } }
private void OnClickOutPoint(ConnectionPoint outPoint) { selectedOutPoint = outPoint; if (selectedInPoint != null) { if (selectedOutPoint.node != selectedInPoint.node) { CreateConnection(); Debug.Log("I clicked an outPoint on " + outPoint.node.title); ClearConnectionSelection(); } else { ClearConnectionSelection(); } } }
public ComboNode(Vector2 position, float width, float height, GUIStyle nodeStyle, GUIStyle in_style, GUIStyle out_style, Action <ConnectionPoint> OnClickInPoint, Action <ConnectionPoint> OnClickOutPoint, Action <ComboNode> OnclickdeRemoveNode, AttackObject attack) { rect = new Rect(position.x, position.y, width, height); style = nodeStyle; in_point = new ConnectionPoint(this, ConnectionPointType.In, in_style, OnClickInPoint); out_point = new ConnectionPoint(this, ConnectionPointType.Out, out_style, OnClickOutPoint); OnRemoveNode = OnclickdeRemoveNode; attack_object = attack; }
private void OnClickInPoint(ConnectionPoint inPoint) { selectedInPoint = inPoint; if (selectedOutPoint == null) { return; } if (selectedOutPoint.node != selectedInPoint.node) { CreateConnection(); ClearConnectionSelection(); } else { ClearConnectionSelection(); } }
static ConnectionPoint GetSrcConnectionPointForSharedTrigger(UIElement sourceDesigner, ModelItem connectorModelItem) { ConnectionPoint sourceConnectionPoint = null; List <Connector> connectors = StateContainerEditor.GetOutgoingConnectors(sourceDesigner); foreach (Connector connector in connectors) { ModelItem modelItem = StateContainerEditor.GetConnectorModelItem(connector); if (modelItem != null && modelItem.ItemType == typeof(Transition)) { if (modelItem.Properties[TransitionDesigner.TriggerPropertyName].Value == connectorModelItem.Properties[TransitionDesigner.TriggerPropertyName].Value) { sourceConnectionPoint = FreeFormPanel.GetSourceConnectionPoint(connector); } } } return(sourceConnectionPoint); }
private void CreateIDEAOpenModelConnection() { ConnectionPoint connection = new ConnectionPoint(); connection.Node = new ReferenceElement(openStructModel.Point3D.First(n => n.Id == 3)); connection.Id = 1; connection.Name = "Con " + "N3"; ConnectedMember conMb1 = AddConnectedMember(1, 1, 1, 3, 5); ConnectedMember conMb2 = AddConnectedMember(2, 1, 2, 3); ConnectedMember conMb3 = AddConnectedMember(3, 1, 3, 4); connection.ConnectedMembers.Add(conMb1); connection.ConnectedMembers.Add(conMb2); connection.ConnectedMembers.Add(conMb3); openStructModel.AddObject(connection); }
private void onClickOutPoint(ConnectionPoint outPoint) { selectedOutPoint = outPoint; if (selectedInPoint != null) { // if connect node isn't the same node if (!selectedOutPoint.HasSameNode(selectedInPoint)) { CreateConnection(); ClearConnectionSelection(); } else { ClearConnectionSelection(); } } }
public DFlipFlopEdgeWithPresetAndClear(string name) { _not = new NOT($"{name}-flop.clk"); _nor3Clr = new NOR3($"{name}-flop.clr"); _nor3Pre = new NOR3($"{name}-flop.pre"); _nor3Clk = new NOR3($"{name}-flop.clk"); _nor3D = new NOR3($"{name}-flop.d"); _nor3Q = new NOR3($"{name}-flop.q"); _nor3Qnot = new NOR3($"{name}-flop.qnot"); V = new ConnectionPoint($"{name}-flop.v"); Clr = new ConnectionPoint($"{name}-flop.clr"); Pre = new ConnectionPoint($"{name}-flop.pre"); DoWireUp(); Components.Record(nameof(DFlipFlopEdgeWithPresetAndClear)); }
private IEnumerator GenerateMap() { //Add starting room's connection points AddConnectionPoints(startingRoom.GetComponentsInChildren <ConnectionPoint>()); yield return(null); //While we haven't exceed the room limit, //let's try to generate the room for each connection point, //starting from the center while (ConnectionPoints.Count > 0 && roomPool.Count > 0) { ConnectionPoint currentPoint = ConnectionPoints.Dequeue(); yield return(null); yield return(StartCoroutine(currentPoint.GenerateRoom(roomPool[0]))); } isGeneratingRooms = false; yield return(new WaitForSeconds(0.03f)); //Let us build the navmesh now for the AI isBuildingNavMesh = true; parent.GetComponent <NavMeshSurface>().BuildNavMesh(); yield return(new WaitForSeconds(0.03f)); //reactivate Deco foreach (GameObject room in generatedRooms) { room.transform.Find("Environment").Find("Deco").gameObject.SetActive(true); } isBuildingNavMesh = false; isGenerated = true; //For all the connection points left, let us generate the deadend //isGeneratingDeadends = true; foreach (ConnectionPoint currentPoint in ConnectionPoints) { yield return(null); yield return(StartCoroutine(currentPoint.GenerateRoom(deadend, true))); } //isGeneratingDeadends = false; }
private void Awake() { position = transform.position; rotation = transform.rotation; rb = GetComponent <Rigidbody2D>(); connectionPoints = new List <ConnectionPoint>(); for (int i = 0; i < transform.childCount; i++) { ConnectionPoint point = transform.GetChild(i).GetComponent <ConnectionPoint>(); if (point) { point.physicsObject = this; connectionPoints.Add(point); } } }
Connector GetConnectorForConnectionType( ConnectionPoint.ConnectionType connectionType ) { connectorPrefabs.Shuffle(); foreach ( var connector in connectorPrefabs ) { if ( connectionType == ConnectionPoint.ConnectionType.ANY ) return connector; if ( connectionType == ConnectionPoint.ConnectionType.DOOR && ( connector.end1 == null != connector.end2 == null ) || connectionType == ConnectionPoint.ConnectionType.HALLWAY && connector.end1 != null && connector.end2 != null ) return connector; } Debug.LogWarning( "No connector found to fit connection type " + connectionType ); return null; }
public void ReadXml(System.Xml.XmlReader reader) { // read the position of the connexion (for file version under 4) if (Map.DataVersionOfTheFileLoaded <= 3) mPositionInStudWorldCoord = XmlReadWrite.readPointF(reader); else reader.ReadToDescendant("LinkedTo"); // check if we have a link if (reader.IsEmptyElement) { mConnectionLink = null; reader.Read(); } else { var linkString = reader.ReadElementContentAsString(); // remove character 'c' preceding the link id int hashCodeOfTheLink = int.Parse(linkString.Substring(1)); // look in the hastable if this connexion alread exists, else create it mConnectionLink = ConnectionPoint.sHashtableForLinkRebuilding[hashCodeOfTheLink] as ConnectionPoint; if (mConnectionLink == null) { // instanciate a ConnectionPoint, and add it in the hash table mConnectionLink = new ConnectionPoint(); ConnectionPoint.sHashtableForLinkRebuilding.Add(hashCodeOfTheLink, mConnectionLink); } } }
public void AddConnectionPoint(ConnectionPoint adding) { connectionPoints.Add(adding); UpdateNodeRect(); }
Room GetRoomToConnectWith(ConnectionPoint.ConnectionType connectionType) { roomPrefabs.Shuffle(); for(int j = 0; j < roomPrefabs.Length; j++) { var bit = roomPrefabs[j]; if ( connectionType == ConnectionPoint.ConnectionType.ANY ) return bit; var connectors = bit.GetConnections(); // look in the level bit and see if it has a valid connection point foreach( var cp in connectors ) { Debug.Log("connects to: "+cp.connectionType); if ( cp.connectionType == ConnectionPoint.ConnectionType.ANY || cp.connectionType == connectionType ){ return bit; } } } return null; }
private Rect OutputRect(ConnectionPoint outputPoint) { return new Rect( baseRect.x + baseRect.width - 8f, baseRect.y + outputPoint.buttonRect.y + 1f, AssetBundleGraphGUISettings.CONNECTION_POINT_MARK_SIZE, AssetBundleGraphGUISettings.CONNECTION_POINT_MARK_SIZE ); }
public Vector2 GlobalConnectionPointPosition(ConnectionPoint p) { var x = 0f; var y = 0f; if (p.isInput) { x = baseRect.x; y = baseRect.y + p.buttonRect.y + (p.buttonRect.height / 2f) - 1f; } if (p.isOutput) { x = baseRect.x + baseRect.width; y = baseRect.y + p.buttonRect.y + (p.buttonRect.height / 2f) - 1f; } return new Vector2(x, y); }
public bool IsSameDetail(Node start, ConnectionPoint output, Node end, ConnectionPoint input) { if ( startNodeId == start.nodeId && outputPoint == output && endNodeId == end.nodeId && inputPoint == input ) { return true; } return false; }
public bool IsEndAtConnectionPoint(ConnectionPoint p) { return inputPoint == p; }
/// <summary> /// Creates a new instance of class "ComponentDrawn". /// </summary> /// <param name="cName">component name</param> /// <param name="cTop">component top coordinate</param> /// <param name="cBottom">component bottom coordinate</param> /// <param name="cCapacity">component capacity</param> /// <returns>True if successfully created, false otherwise.</returns> public virtual bool CreateComponentDrawn(string cName, ConnectionPoint cTop, ConnectionPoint cBottom, int cCapacity) { throw new System.NotImplementedException(); }
public override void ReadXml(System.Xml.XmlReader reader) { // read the id of the brick, then add this brick in the hashtable if (Map.DataVersionOfTheFileLoaded >= 7) { int brickId = int.Parse(reader.GetAttribute(0)); Id = brickId.ToString(); Map.sHashtableForRulerAttachementRebuilding.Add(brickId, this); } // read the base class base.ReadXml(reader); // avoid using the accessor to reduce the number of call of updateBitmap mPartNumber = BrickLibrary.Instance.getActualPartNumber(reader.ReadElementContentAsString().ToUpperInvariant()); // but then update its electric list mElectricCircuitIndexList = BrickLibrary.Instance.getElectricCircuitList(mPartNumber); mOrientation = reader.ReadElementContentAsFloat(); mActiveConnectionPointIndex = reader.ReadElementContentAsInt(); // the altitude if (Map.DataVersionOfTheFileLoaded >= 3) mAltitude = reader.ReadElementContentAsFloat(); // update the bitmap updateImage(); updateSnapMargin(); // read the connexion points if any reader.ReadAttributeValue(); int count = int.Parse(reader.GetAttribute(0)); // check the number of connection is the same in the Brick library and in the loading file. // They can be different if the file was saved with an old part library and then one part // was updated to add or remove connection. So there is 3 different cases: // - if they are the same: no problems. // - if there is more connections in the part lib than in the file: we reserve enough space in the list, // based on the library value, and then we will add empty connections instances to fullfill the list // after finishing reading the connection tag. // - if there is more parts in the file than in the list, we need to discard some connection, // so we add a check in the parsing to create the last connections as default one (of type brick). // This will ensure that the link will be broken (because all connections or type BRICK are // broken after the loading of the file is finished) and then the GC will destroy these connections. // And of course the list is reserved based on the library value. // So first, we ask the number of connection to the part lib then allocate // the list of connection based on the number set in the library and not the number // read in the file, because finally the number of connection must be like the part lib says int connectionCountInBrickLibrary = BrickLibrary.Instance.getConnectionCount(mPartNumber); if (connectionCountInBrickLibrary > 0) mConnectionPoints = new List<ConnectionPoint>(connectionCountInBrickLibrary); // now check if we need to parse some connection in the file if (count > 0) { // declare a counter for the connections int connexionIndex = 0; bool connexionFound = reader.ReadToDescendant("Connexion"); while (connexionFound) { // a boolean saying if the current connection is valid or will be destroyed later // because it is over the number indicated by the part library // be careful mConnectionPoints can be null, so use the int var instead bool isConnectionValid = (connexionIndex < connectionCountInBrickLibrary); // read the id (hashcode key) of the connexion reader.ReadAttributeValue(); String id = reader.GetAttribute(0); int hashCode = int.Parse(id.Substring(1)); // look in the hastable if this connexion alread exists, else create it ConnectionPoint connexion = ConnectionPoint.sHashtableForLinkRebuilding[hashCode] as ConnectionPoint; if (connexion == null) { // instanciate a ConnectionPoint, and add it in the hash table if (isConnectionValid) connexion = new ConnectionPoint(this, connexionIndex); else connexion = new ConnectionPoint(); ConnectionPoint.sHashtableForLinkRebuilding.Add(hashCode, connexion); } else { // set the connexion type, if not set during the above creation if (isConnectionValid) connexion.Type = BrickLibrary.Instance.getConnexionType(this.PartNumber, connexionIndex); } //read the connexion data and add it in the Connection list connexion.mMyBrick = this; connexion.ReadXml(reader); // during the reading of the connection list in the file, we check if // we didn't reached the limit of the part library. If there is more connection // in the file than in the part lib, we continue to read the connections, // but we don't add them in the connection list. if (isConnectionValid) mConnectionPoints.Add(connexion); // increment the connexion index connexionIndex++; // read the next brick connexionFound = reader.ReadToNextSibling("Connexion"); } reader.ReadEndElement(); // check if we read all the connections in the file, if not we have to instanciate // empty connection to fullfill the list if (mConnectionPoints != null) for (int i = mConnectionPoints.Count; i < mConnectionPoints.Capacity; ++i) { ConnectionPoint connexion = new ConnectionPoint(this, i); mConnectionPoints.Add(connexion); // we don't need to add this connection in the hastable since we know this // connection doesn't exist in the file, so there is no link attached to it } // update the connexion position which is not stored in the bbm file // in file version before 3 it was stored, but I removed it because the connexion // point can move in different part libraries updateConnectionPosition(); } else { reader.Read(); } // read the end element of the brick reader.ReadEndElement(); }
private bool IsConnectablePointFromTo(ConnectionPoint sourcePoint, ConnectionPoint destPoint) { if (sourcePoint.isOutput != destPoint.isOutput && sourcePoint.isInput != destPoint.isInput) { return true; } return false; }
public static bool ContainsConnection(this List<Connection> connections, Node start, ConnectionPoint output, Node end, ConnectionPoint input) { foreach (var con in connections) { if (con.IsSameDetail(start, output, end, input)) return true; } return false; }
public bool IsStartAtConnectionPoint(ConnectionPoint p) { return outputPoint == p; }
// Returns the ConnectionPoints of a prefab in random order. If no ConnectionPoints exist, returns null. private ConnectionPoint[] GetConnections(GameObject aPrefab) { //Debug.Log("Connection"); ConnectionPoint[] ReturnArray = null; ConnectionPoint[] Connections = aPrefab.GetComponentsInChildren<ConnectionPoint>(); if(Connections.Length > 0) { ReturnArray = new ConnectionPoint[Connections.Length]; int RandomAdd = Random.Range(0, Connections.Length); for(int i = 0; i < ReturnArray.Length; i++) { ReturnArray[i] = Connections[(i + RandomAdd) % Connections.Length]; } } return ReturnArray; }
public void Connect(Shape shapeFrom, ConnectionPoint shapeFromConnectionPoint, Shape shapeTo, ConnectionPoint shapeToConnectionPoint) { VisioHelper.Connect(shapeFrom, shapeFromConnectionPoint == ConnectionPoint.Center ? null : (short?)shapeFromConnectionPoint, shapeTo, shapeToConnectionPoint == ConnectionPoint.Center ? null : (short?)shapeToConnectionPoint); }
/** create new connection if same relationship is not exist yet. */ private void AddConnection(string label, Node startNode, ConnectionPoint startPoint, Node endNode, ConnectionPoint endPoint) { Undo.RecordObject(this, "Add Connection"); var connectionsFromThisNode = connections .Where(con => con.startNodeId == startNode.nodeId) .Where(con => con.outputPoint == startPoint) .ToList(); if (connectionsFromThisNode.Any()) { var alreadyExistConnection = connectionsFromThisNode[0]; DeleteConnectionById(alreadyExistConnection.connectionId); } if (!connections.ContainsConnection(startNode, startPoint, endNode, endPoint)) { connections.Add(Connection.NewConnection(label, startNode.nodeId, startPoint, endNode.nodeId, endPoint)); } }
private void readConnexionListTag(ref System.Xml.XmlReader xmlReader, Dictionary<string, int> connectionRemapingDictionary) { if (!xmlReader.IsEmptyElement) { // the connexion bool connexionFound = xmlReader.ReadToDescendant("connexion"); if (connexionFound) { mConnectionPoints = new List<ConnectionPoint>(); mConnectionPositionList = new List<PointF>(); } while (connexionFound) { // instanciate a connection point for the current connexion ConnectionPoint connectionPoint = new ConnectionPoint(); // read the first child node of the connexion xmlReader.Read(); bool continueToReadConnexion = true; while (continueToReadConnexion) { if (xmlReader.Name.Equals("type")) connectionPoint.mType = readConnectionType(ref xmlReader, connectionRemapingDictionary); else if (xmlReader.Name.Equals("position")) connectionPoint.mPosition = readPointTag(ref xmlReader, "position"); else if (xmlReader.Name.Equals("angle")) connectionPoint.mAngle = xmlReader.ReadElementContentAsFloat(); else if (xmlReader.Name.Equals("angleToPrev")) connectionPoint.mAngleToPrev = xmlReader.ReadElementContentAsFloat(); else if (xmlReader.Name.Equals("angleToNext")) connectionPoint.mAngleToNext = xmlReader.ReadElementContentAsFloat(); else if (xmlReader.Name.Equals("nextConnexionPreference")) connectionPoint.mNextPreferedIndex = xmlReader.ReadElementContentAsInt(); else if (xmlReader.Name.Equals("electricPlug")) connectionPoint.mElectricPlug = xmlReader.ReadElementContentAsInt(); else xmlReader.Read(); // check if we reach the end of the connexion continueToReadConnexion = !xmlReader.Name.Equals("connexion") && !xmlReader.EOF; } // add the current connexion in the list mConnectionPoints.Add(connectionPoint); mConnectionPositionList.Add(connectionPoint.mPosition); // go to next connexion connexionFound = !xmlReader.EOF && xmlReader.ReadToNextSibling("connexion"); } // finish the connexion if (!xmlReader.EOF) xmlReader.ReadEndElement(); // build the electric circuit if these connections are electrical // to know if there's a circuit between two connections, we must find pairs like // 1/-1 or 2/-2 or 3/-3, etc... if (mConnectionPoints != null) { int nbPossibleCircuits = mConnectionPoints.Count - 1; for (int i = 0; i < nbPossibleCircuits; ++i) for (int j = i + 1; j < mConnectionPoints.Count; ++j) if ((mConnectionPoints[i].mElectricPlug != 0) && (mConnectionPoints[i].mElectricPlug == -mConnectionPoints[j].mElectricPlug)) { // we found a circuit, so create the list if not already done if (this.mElectricCircuitList == null) this.mElectricCircuitList = new List<ElectricCircuit>(); // compute the distance between the two connection (length of the circuit) PointF distance = new PointF( mConnectionPoints[i].mPosition.X - mConnectionPoints[j].mPosition.X, mConnectionPoints[i].mPosition.Y - mConnectionPoints[j].mPosition.Y); float length = (float)Math.Sqrt((distance.X * distance.X) + (distance.Y * distance.Y)); // add the new circuit in the list this.mElectricCircuitList.Add(new ElectricCircuit(i, j, length)); } } } else { xmlReader.Read(); } }