/// <summary> Occurs when a connection created by mouse drag </summary> /// <param name="newConnection">New connection</param> protected virtual void OnCreateConnection(DirectConnection newConnection) { if (CreateConnection != null) { CreateConnection(this, new DirectConnectionEventArgs(newConnection)); } }
/// <summary> Render </summary> protected override void Render() { base.Render(); if (_IsDetecting) { DirectConnection.DrawConnection(this._StartControl.RenderArea.center, this._EndPreviewConnection, this.PreviewColor); } }
/// <summary> /// HandleEvent /// </summary> /// <param name="e">Event</param> public override void HandleEvent(Event e) { if (_IsDetecting && Parent != null && e != null) { this._EndPreviewConnection = e.mousePosition; Skill.Editor.UI.EditorFrame.RepaintParentEditorWindow(this); if ((e.type == EventType.MouseDown) && e.button == 0) { Frame of = OwnerFrame; if (of != null) { of.UnregisterPrecedenceEvent(this); _IsDetecting = false; Vector2 mousePosition = e.mousePosition; foreach (var c in GetConnectableControls()) { if (c.RenderArea.Contains(mousePosition) && CanConnect(_StartControl, c)) { DirectConnection newConnection = CreateNewConnection(_StartControl, c); OnCreateConnection(newConnection); Controls.Add(newConnection); break; } } } e.Use(); } else { e.Use(); } } else { base.HandleEvent(e); } }
/// <summary> /// Create a ConnectionEventArgs /// </summary> /// <param name="connection">Connection</param> public DirectConnectionEventArgs(DirectConnection connection) { this.Connection = connection; }