private void NodeSocketConnectEventHandler(object sender, NodeSocketConnectionEventArgs args) { NodeViewConnection con = new NodeViewConnection { Source = args.Source, Sink = args.Sink, }; _connections.Add(con); QueueDraw(); }
private void DrawSocketConnection(Cairo.Context cr, NodeViewConnection c) { Cairo.LinearGradient pat; RGBA colSrc, colSink; Rectangle allocation; Rectangle allocParent; int x0, x1, y0, y1; allocParent = c.Source.Parent.Allocation; allocation = c.Source.Allocation; x0 = allocation.X + allocation.Width / 2 + allocParent.X; y0 = allocation.Y + allocation.Height / 2 + allocParent.Y; allocParent = c.Sink.Parent.Allocation; allocation = c.Sink.Allocation; x1 = allocation.X + allocation.Width / 2 + allocParent.X; y1 = allocation.Y + allocation.Height / 2 + allocParent.Y; pat = new Cairo.LinearGradient(x0, y0, x1, y1); colSrc = c.Source.RGBA; colSink = c.Sink.RGBA; pat.AddColorStop ( 0, new Cairo.Color(colSrc.Red, colSrc.Green, colSrc.Blue, colSrc.Alpha) ); pat.AddColorStop ( 1, new Cairo.Color(colSink.Red, colSink.Green, colSink.Blue, colSink.Alpha) ); cr.Save(); NodeConnectingCurve(cr, x0, y0, x1, y1); cr.SetSource(pat); cr.Stroke(); pat.Dispose(); cr.Restore(); }