/// <summary> /// Konstruktor, erstell einen neuen LineNode an der Position position. /// </summary> /// <param name="Position">absolute Position</param> /// <param name="inSlope">eingehender Richtungsvektor</param> /// <param name="outSlope">ausgehender Richtungsvektor</param> /// <param name="nl">Network layer of this LineNode</param> /// <param name="stopSign">Flag whether this LineNode models a stop sign</param> public LineNode(Vector2 Position, Vector2 inSlope, Vector2 outSlope, NetworkLayer nl, bool stopSign) { this.position = Position; this.inSlope = inSlope; this.outSlope = outSlope; _networkLayer = nl; _stopSign = stopSign; // Hashcode vergeben hashcode = hashcodeIndex++; InitStopSignEdgeOffsets(); }
/// <summary> /// Konstruktor, erstell einen neuen LineNode an der Position position. /// in-/outSlope werden mit (0,0) initialisiert. /// </summary> /// <param name="position">absolute Position</param> /// <param name="nl">Network layer of this LineNode</param> /// <param name="stopSign">Flag whether this LineNode models a stop sign</param> public LineNode(Vector2 position, NetworkLayer nl, bool stopSign) { this.position = position; this.inSlope = new Vector2(0, 0); this.outSlope = new Vector2(0, 0); _networkLayer = nl; _stopSign = stopSign; // Hashcode vergeben hashcode = hashcodeIndex++; InitStopSignEdgeOffsets(); }
/// <summary> /// Tries to remove the given NetworkLayer. Succeeds only, if <paramref name="nl"/> isn't assigned to any managed LineNode. /// </summary> /// <param name="nl">NetworkLayer to remove</param> /// <returns>True if nl was successfully deleted. False if nl is still assigned to at least one LineNode in _nodes.</returns> public bool RemoveNetworkLayer(NetworkLayer nl) { if (_networkLayers.Count <= 1) return false; foreach (LineNode ln in _nodes) { if (ln.networkLayer == nl) return false; } _networkLayers.Remove(nl); nl.VisibleChanged -= nl_VisibleChanged; nl.TitleChanged -= nl_TitleChanged; InvokeNetworkLayersChanged(new NetworkLayersChangedEventArgs(NetworkLayersChangedEventArgs.InvalidationLevel.COLLECTION_CHANGED)); return true; }
/// <summary> /// Adds a render network layer with the given title. /// </summary> /// <param name="title">Title of the new render network layer</param> /// <param name="visible">Visible flag of the new network layer</param> public void AddNetworkLayer(string title, bool visible) { NetworkLayer nl = new NetworkLayer(title, visible); nl.TitleChanged += new NetworkLayer.TitleChangedEventHandler(nl_TitleChanged); nl.VisibleChanged += new NetworkLayer.VisibleChangedEventHandler(nl_VisibleChanged); _networkLayers.Add(nl); InvokeNetworkLayersChanged(new NetworkLayersChangedEventArgs(NetworkLayersChangedEventArgs.InvalidationLevel.COLLECTION_CHANGED)); }
void nl_VisibleChanged(object sender, NetworkLayer.VisibleChangedEventArgs e) { InvokeNetworkLayersChanged(new NetworkLayersChangedEventArgs(NetworkLayersChangedEventArgs.InvalidationLevel.ONLY_VISIBILITY_CHANGED)); }
void nl_TitleChanged(object sender, NetworkLayer.TitleChangedEventArgs e) { InvokeNetworkLayersChanged(new NetworkLayersChangedEventArgs(NetworkLayersChangedEventArgs.InvalidationLevel.ONLY_TITLES_CHANGED)); }
/// <summary> /// Constructor: Creates the necessary GUI elements for the given NetworkLayer /// </summary> /// <param name="ns">Reference to the NodeSteuerung controlling the network layers</param> /// <param name="nl">Reference to base NetworkLayer to create GUI elements for</param> public NetworkLayerGUI(NodeSteuerung ns, NetworkLayer nl) { _nodeController = ns; _networkLayer = nl; _editTitle = new System.Windows.Forms.TextBox(); _btnRemove = new System.Windows.Forms.Button(); _cbVisible = new System.Windows.Forms.CheckBox(); _editTitle.Text = nl.title; _editTitle.Dock = DockStyle.Fill; _editTitle.Leave += new EventHandler(_editTitle_Leave); _btnRemove.Text = "Remove"; _btnRemove.Click += new EventHandler(_btnRemove_Click); _cbVisible.Text = "Visible"; _cbVisible.Checked = nl.visible; _cbVisible.CheckedChanged += new EventHandler(_cbVisible_CheckedChanged); }