示例#1
0
        private void ScribbleDrawn(object o, DrawnArgs args)
        {
            Cairo.Context cr = args.Cr;

            cr.SetSourceSurface(surface, 0, 0);
            cr.Paint();
        }
示例#2
0
        private void ImgBox_Drawn(object o, DrawnArgs args)
        {
            Color activeRect = new Color(255, 0, 0);
            Color setted     = new Color(246, 255, 2);

            var ctx = args.Cr;

            ctx.SetSource(ims);
            ctx.Rectangle(0, 0, imgBox.WidthRequest, imgBox.HeightRequest);
            ctx.Fill();


            ctx.SetSourceColor(activeRect);
            if (current != null)
            {
                ctx.Rectangle(current.box2d.x1, current.box2d.y1, current.box2d.width, current.box2d.height);
                ctx.Stroke();
            }

            ctx.SetSourceColor(setted);
            foreach (var lbl in label.labels)
            {
                ctx.Rectangle(lbl.box2d.x1, lbl.box2d.y1, lbl.box2d.width, lbl.box2d.height);
                ctx.MoveTo(lbl.box2d.x1, lbl.box2d.y1);
                ctx.SetFontSize(24);
                ctx.TextPath(lbl.category);
                ctx.Stroke();
            }
        }
示例#3
0
        private void DrawingAreaCirclesOnDrawn(object o, DrawnArgs args)
        {
            if (o is DrawingArea da)
            {
                Context cr = args.Cr;

                int width  = da.Allocation.Width;
                int height = da.Allocation.Height;

                cr.LineWidth = 5;
                cr.SetSourceRGB(0.8, 0.8, 0.8);

                cr.Rectangle(0, 0, width, height);
                cr.Fill();

                cr.SetSourceRGB(0.9, 0, 0);
                cr.Translate(width / 2d, height / 2d);
                cr.Arc(0, 0, (width < height ? width : height) / 2 - 10, 0, 2 * Math.PI);
                cr.StrokePreserve();

                cr.SetSourceRGB(0, 0.9, 0);
                cr.Fill();

                cr.GetTarget().Dispose();
                cr.Dispose();
            }
        }
示例#4
0
        static void DrawContent(object sender, DrawnArgs args)
        {
            var cr = args.Cr;

            double x, y;

            x = y = 1.0;
            double width        = args.Width - 2.0;
            double height       = args.Height - 2.0;
            double aspect       = 1.0;
            double cornerRadius = args.Height / 20.0;

            double radius  = cornerRadius / aspect;
            double degrees = Math.PI / 180.0;

            cr.Save();
            cr.Operator = Operator.Clear;
            cr.Paint();
            cr.Restore();

            cr.NewSubPath();
            cr.Arc(x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
            cr.Arc(x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);
            cr.Arc(x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees);
            cr.Arc(x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
            cr.ClosePath();

            cr.SetSourceRGB(0.5, 0.5, 1);
            cr.Fill();

            args.RetVal = true;
        }
        private void DrawingArea_OnDraw(object o, DrawnArgs args)
        {
            Widget widget = o as Widget;

            Cairo.Context cr = args.Cr;
            cr.SetSourceRGB(0.9, 0.9, 0.9);
            cr.Rectangle(0, 0, widget.Allocation.Width, widget.Allocation.Height);

            cr.Fill();

            cr.SetSourceRGB(1.0, 1.0, 1.0);
            cr.Rectangle(5, 5, widget.Allocation.Width - 10, widget.Allocation.Height - 10);

            cr.Fill();

            if (this.player != null)
            {
                if (this.player.IsLoop)
                {
                    cr.SetSourceRGB(0.21, 0.517, 0.894);
                    cr.Rectangle((int)((widget.Allocation.Width - 10) * ((double)this.player.LoopStart / player.TotalSamples)) + 5, 5, (int)((widget.Allocation.Width - 10) * ((double)(this.player.LoopEnd - this.player.LoopStart) / player.TotalSamples)), widget.Allocation.Height - 10);
                    cr.Fill();
                }
                cr.SetSourceRGB(0, 0, 0);
                cr.Rectangle(((widget.Allocation.Width - 10) * ((double)player.SamplePosition / player.TotalSamples)), 0, 10, widget.Allocation.Height);
                cr.Fill();

                cr.SetSourceRGB(1.0, 1.0, 1.0);
                cr.Rectangle(((widget.Allocation.Width - 10) * ((double)player.SamplePosition / player.TotalSamples)) + 1, 1, 8, widget.Allocation.Height - 2);
                cr.Fill();
            }
        }
示例#6
0
 private void Da_Drawn(object o, DrawnArgs args)
 {
     if (attentionHandler.Image != null)
     {
         var         scaleX      = (attentionHandler.Width / pictureBox.WidthRequest);
         var         scaleY      = (attentionHandler.Height / pictureBox.HeightRequest);
         var         winSizeXImg = scaleX * windowSize;
         var         winSizeYImg = scaleY * windowSize;
         DrawingArea da          = (DrawingArea)o;
         var         ctx         = args.Cr;
         ctx.SetSourceRGB(0, 0, 0);
         ctx.Rectangle(0, 0, windowSize, windowSize);
         ctx.Fill();
         if (model.IsNotRunning)
         {
             var          SubImage = attentionHandler.Image[new Rectangle((int)(dispBeginX * scaleX), (int)(dispBeginY * scaleY), (int)(windowSize * scaleX), (int)(windowSize * scaleY))].ToImage <BGRA>();
             var          img      = SubImage.Rescale(windowSize, windowSize, ScalingMode.AverageInterpolate);
             ImageSurface ims      = new ImageSurface(img.DataPointer, Format.Argb32, img.Width, img.Height, img.Width * 4);
             ctx.SetSource(ims);
             ctx.Arc(windowSize / 2, windowSize / 2, windowSize / 2, 0, 2 * Math.PI);
             ctx.Fill();
             img.Dispose();
             SubImage.Dispose();
             ims.Dispose();
         }
     }
 }
示例#7
0
        // Expose callback for the drawing area
        void DrawnCallback(object o, DrawnArgs args)
        {
            Cairo.Context cr = args.Cr;

            Gdk.CairoHelper.SetSourcePixbuf(cr, frame, 0, 0);
            cr.Paint();

            args.RetVal = true;
        }
示例#8
0
        /* Event members */

        private void OnWidgetDrawn(object o, DrawnArgs args)
        {
            TextView textView = o as TextView;

            if (textView.State != StateType.Insensitive)
            {
                DrawMargin(textView, args.Cr);
            }
        }
示例#9
0
        private void Black_Drawn(object o, DrawnArgs args)
        {
            var da = (DrawingArea)o;

            var ctx = args.Cr;

            ctx.SetSourceRGB(0, 0, 0);
            ctx.Rectangle(0, 0, da.AllocatedWidth, da.AllocatedHeight);
            ctx.Fill();
        }
示例#10
0
        /// <summary>
        /// Performs actions whenever the scope drawing area has been drawn.
        /// </summary>
        private void ScopeDrawingArea_DrawnEventHandler(object o, DrawnArgs args)
        {
            _scopeGraphics.Draw(scopeDrawingArea.Window);

            if (_captureContinuously)
            {
                RefreshData();
                RefreshGraphics();
            }
        }
示例#11
0
        private void OnDrawn(object o, DrawnArgs args)
        {
            // NOTE: This is a little insane, but it allows packing of EventBox based widgets
            // into a GtkMenuItem without breaking the theme (leaving an unstyled void in the item).
            // This method is called before the EventBox child does its drawing and the background
            // is filled in with the proper style.

            int    x, y, width, height;
            Widget widget = (Widget)o;

            if (IsSelected)
            {
                x      = Allocation.X - widget.Allocation.X;
                y      = Allocation.Y - widget.Allocation.Y;
                width  = Allocation.Width;
                height = Allocation.Height;

                StyleContext.Save();
                StyleContext.AddClass("menuitem");
                StyleContext.State |= StateFlags.Prelight | StateFlags.Selected;
                StyleContext.RenderFrame(args.Cr, x, y, width, height);
                StyleContext.RenderBackground(args.Cr, x, y, width, height);
                StyleContext.Restore();
            }
            else
            {
                args.Cr.Save();

                var color = Parent.StyleContext.GetBackgroundColor(StateFlags.Normal);
                // Fill only the visible area in solid color, to be most efficient
                args.Cr.SetSourceRGB(color.Red, color.Green, color.Blue);
                args.Cr.Rectangle(0, 0, widget.Allocation.Width, widget.Allocation.Height);
                args.Cr.Fill();

                args.Cr.Restore();

                // FIXME: The above should not be necessary, but Clearlooks-based themes apparently
                // don't provide any style for the menu background so we have to fill it first with
                // the correct theme color. Weak.
                //
                // Do a complete style paint based on the size of the entire menu to be compatible with
                // themes that provide a real style for "menu"
                x      = Parent.Allocation.X - widget.Allocation.X;
                y      = Parent.Allocation.Y - widget.Allocation.Y;
                width  = Parent.Allocation.Width;
                height = Parent.Allocation.Height;

                StyleContext.Save();
                StyleContext.AddClass("menuitem");
                StyleContext.State |= StateFlags.Normal;
                StyleContext.RenderFrame(args.Cr, x, y, width, height);
                StyleContext.RenderBackground(args.Cr, x, y, width, height);
                StyleContext.Restore();
            }
        }
示例#12
0
 /// <summary>
 /// Invoked when the chart is rendered. Handles drawing of the
 /// lines of the triangle.
 /// </summary>
 /// <param name="o">Sender object.</param>
 /// <param name="args">Event arguments.</param>
 private void OnDrawChart(object o, DrawnArgs args)
 {
     try
     {
         Refresh(true);
     }
     catch (Exception err)
     {
         ShowError(err);
     }
 }
示例#13
0
        /// <summary>
        /// Traps the Exposed event for the image. This event fires after
        /// size/space allocation has occurred but before it is actually
        /// drawn on the screen. Because the size-allocated signal is emitted
        /// several times, we don't want to refresh the map each time.
        /// Therefore, we refresh the map once, during the expose event.
        ///
        /// We also disconnect the event handler after refreshing the map so
        /// that we don't refresh it multiple times unnecessarily.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="args">Event data.</param>
        private void OnImageExposed(object sender, DrawnArgs args)
        {
            try
            {
                RefreshMap();

                image.Drawn -= OnImageExposed;
            }
            catch (Exception err)
            {
                ShowError(err);
            }
        }
示例#14
0
        private void OnCubanoToolbarExposeEvent(object o, DrawnArgs args)
        {
            Toolbar toolbar = (Toolbar)o;

            // This forces the toolbar to look like it's just a regular part
            // of the window since the stock toolbar look makes Banshee look ugly.
            RenderBackground(args.Cr);

            // Manually expose all the toolbar's children
            foreach (Widget child in toolbar.Children)
            {
                toolbar.PropagateDraw(child, args.Cr);
            }
        }
示例#15
0
        private void CheckerboardDrawn(object o, DrawnArgs args)
        {
            const int CheckSize = 10;
            const int Spacing   = 2;

            Widget widget = o as Widget;

            Cairo.Context cr = args.Cr;

            int i, j, xcount, ycount;

            // At the start of a draw handler, a clip region has been set on
            // the Cairo context, and the contents have been cleared to the
            // widget's background color.

            Rectangle alloc = widget.Allocation;

            // Start redrawing the Checkerboard
            xcount = 0;
            i      = Spacing;
            while (i < alloc.Width)
            {
                j      = Spacing;
                ycount = xcount % 2;                 // start with even/odd depending on row
                while (j < alloc.Height)
                {
                    if (ycount % 2 != 0)
                    {
                        cr.SetSourceRGB(0.45777, 0, 0.45777);
                    }
                    else
                    {
                        cr.SetSourceRGB(1, 1, 1);
                    }
                    // If we're outside the clip, this will do nothing.
                    cr.Rectangle(i, j, CheckSize, CheckSize);
                    cr.Fill();

                    j += CheckSize + Spacing;
                    ++ycount;
                }
                i += CheckSize + Spacing;
                ++xcount;
            }

            // return true because we've handled this event, so no
            // further processing is required.
            args.RetVal = true;
        }
示例#16
0
        private void Img_Drawn(object o, DrawnArgs args)
        {
            Console.WriteLine("Img_Drawn");
            if (image != null)
            {
                Console.WriteLine("image!=null");
                var allox = img.Allocation;
                if (!IsRunning && (ims == null || allox.Width != img_bgra.Width || allox.Height != img_bgra.Height))
                {
                    Console.WriteLine("ims==null");
                    IsRunning = true;
                    var ims_tmp = img;
                    ims = null;
                    ims_tmp?.Dispose();
                    img_tmp?.Dispose();
                    img_bgra?.Dispose();


                    

                    Task.Run(() =>
                     {
                         Console.WriteLine("Task begin");
                         img_tmp = image.Resize(allox.Width, allox.Height, ScalingMode.AverageInterpolate);
                         img_bgra = img_tmp.ConvertBufferTo<BGRA>();
                         IsRunning = false;
                         Console.WriteLine("Task end");
                     });
                   
                }
                if (ims == null && !IsRunning)
                {
                    Console.WriteLine("Create ims");
                
                    ims = new ImageSurface(img_bgra.DataPointer, Format.Argb32, img_bgra.Width, img_bgra.Height, img_bgra.Width * 4);
                }
                Console.WriteLine("middle draw");
                if (ims != null)
                {
                    Console.WriteLine("draw image");
                    var ctx = args.Cr;
                    ctx.SetSource(ims);
                    ctx.Rectangle(0, 0, allox.Width, allox.Height);
                    ctx.Fill();
                }
            }
        }
示例#17
0
        private static void DrawClock(object sender, DrawnArgs args)
        {
            Cairo.Context cr     = args.Cr;
            int           width  = args.Width;
            int           height = args.Height;

            DateTime now = DateTime.Now;
            double   hours, minutes, seconds;

            Clutter.Color color;

            seconds = now.Second * Math.PI / 30;
            minutes = now.Minute * Math.PI / 30;
            hours   = now.Hour * Math.PI / 6;

            cr.Save();
            cr.Operator = Operator.Clear;
            cr.Paint();
            cr.Restore();
            cr.Operator = Operator.Over;
            cr.Scale(width, height);
            cr.LineCap   = LineCap.Round;
            cr.LineWidth = 0.1;

            Global.CairoSetSourceColor(cr, Clutter.Color.New(0, 0, 0, 255));
            cr.Translate(0.5, 0.5);
            cr.Arc(0, 0, 0.4, 0, Math.PI * 2);
            cr.Stroke();

            color = Clutter.Color.New(255, 255, 255, 128);
            Global.CairoSetSourceColor(cr, color);
            cr.MoveTo(0, 0);
            cr.Arc(Math.Sin(seconds) * 0.4, -Math.Cos(seconds) * 0.4, 0.05, 0, Math.PI * 2);
            cr.Fill();

            color = Clutter.Color.New(78, 154, 6, 196);
            Global.CairoSetSourceColor(cr, color);
            cr.MoveTo(0, 0);
            cr.LineTo(Math.Sin(minutes) * 0.4, -Math.Cos(minutes) * 0.4);
            cr.Stroke();

            cr.MoveTo(0, 0);
            cr.LineTo(Math.Sin(hours) * 0.2, -Math.Cos(hours) * 0.2);
            cr.Stroke();

            args.RetVal = true;
        }
示例#18
0
        private void DrawingAreaTextOnDrawn(object o, DrawnArgs args)
        {
            if (o is DrawingArea da)
            {
                Context cr = args.Cr;

                int width  = da.Allocation.Width;
                int height = da.Allocation.Height;

                int rectangle_width  = width;
                int rectangle_height = height / 2;

                // Draw a black rectangle
                cr.SetSourceRGB(0, 0, 0);
                cr.Rectangle(0, 0, rectangle_width, rectangle_height);
                cr.Fill();

                // and some white text
                cr.SetSourceRGB(1.0, 1.0, 1.0);
                draw_text(cr, rectangle_width, rectangle_height, "Hi there!");

                // flip the image vertically
                // see http://www.cairographics.org/documentation/cairomm/reference/classCairo_1_1Matrix.html
                // the -1 corresponds to the yy part (the flipping part)
                // the height part is a translation (we could have just called cr->translate(0, height) instead)
                // it's height and not height / 2, since we want this to be on the second part of our drawing
                // (otherwise, it would draw over the previous part)
                Cairo.Matrix matrix = new Matrix(1.0, 0.0, 0.0, -1.0, 0.0, height);

                // apply the matrix
                cr.Transform(matrix);

                // white rectangle
                cr.SetSourceRGB(1.0, 1.0, 1.0);
                cr.Rectangle(0, 0, rectangle_width, rectangle_height);
                cr.Fill();

                // black text
                cr.SetSourceRGB(0, 0, 0);
                draw_text(cr, rectangle_width, rectangle_height, "Hi there!");

                cr.GetTarget().Dispose();
                cr.Dispose();
            }
        }
示例#19
0
        private static void GameWindow_Drawn(object o, DrawnArgs args)
        {
            Window w  = (Window)o;
            var    cr = args.Cr;
            var    t  = cr.Operator;

            cr.Operator = op1;
            cr.Operator = Cairo.Operator.Source;
            var alloc = w.Allocation;

            cr.Rectangle(new Cairo.Rectangle(0, 0, alloc.Width, alloc.Height));
            cr.SetSourceColor(back);
            cr.Fill();
            cr.Translate(w.Child.Allocation.X, 0);
            cr.Operator = op2;
            cr.Operator = t;
            w.Child.Draw(cr);
        }
示例#20
0
        protected void Redraw(object o, DrawnArgs args)
        {
            var cr = args.Cr;

            cr.SetSourceSurface(surface, 0, 0);
            cr.Paint();
            var ct = args.Cr;

            w            = AllocatedWidth;
            h            = AllocatedHeight;
            layout       = Pango.CairoHelper.CreateLayout(ct);
            ct.LineWidth = 1;

            DrawAxes(ct);
            DrawGrid(ct);
            DrawGraph(ct);
            args.RetVal = true;
        }
        /// <summary>
        /// This function is called everytime the video window needs to be redrawn (due to damage/exposure,
        /// rescaling, etc). GStreamer takes care of this in the PAUSED and PLAYING states, otherwise,
        /// we simply draw a black rectangle to avoid garbage showing up.
        /// </summary>
        static void HandleDrawn(object o, DrawnArgs args)
        {
            var widget = o as Widget;

            Playbin.GetState(out State state, out State pending, 100);

            if (state != State.Paused && state != State.Playing)
            {
                var window     = widget.Window;
                var allocation = widget.Allocation;

                var cr = Gdk.CairoHelper.Create(window);
                cr.SetSourceRGB(0, 0, 0);
                cr.Rectangle(0, 0, allocation.Width, allocation.Height);
                cr.Fill();
                cr.Dispose();
            }
            args.RetVal = false;
        }
示例#22
0
        void HandleHeaderDrawn(object o, DrawnArgs args)
        {
            Cairo.Context cr = args.Cr;
            cr.Save();

            int wd = Allocation.Width - 48;

            Cairo.Color c1 = new Gdk.Color(65, 65, 65).ToCairoColor();
            Cairo.Color c2 = new Gdk.Color(255, 255, 255).ToCairoColor();

            Cairo.Gradient linpat = new LinearGradient(0, 0, wd, Allocation.Height);
            linpat.AddColorStop(0.00, c1);
            linpat.AddColorStop(1.00, c2);

            cr.Rectangle(0, 0, wd, Allocation.Height);
            cr.Source = linpat;
            //cr.PaintWithAlpha(0.5);
            cr.Fill();

            cr.Color = new Color(1, 1, 1);
            cr.SelectFontFace("Arial", FontSlant.Normal, FontWeight.Bold);
            cr.SetFontSize(15.2);

            String txt = String.Empty;

            if (CurrentWidget != null)
            {
                if (CurrentWidget is  DockableWidget)
                {
                    txt = (CurrentWidget as DockableWidget).Title;
                }
            }

            //TextExtents te = cr.TextExtents(txt);


            cr.MoveTo(4, 20);
            cr.ShowText(txt);

            cr.Restore();

            cr = null;
        }
示例#23
0
        /// <summary>The drawing canvas is being exposed to user.</summary>
        private void OnDrawingAreaExpose(object sender, DrawnArgs args)
        {
            try
            {
                DrawingArea area = (DrawingArea)sender;


                Cairo.Context context = args.Cr;

                CairoContext drawingContext = new CairoContext(context, MainWidget);
                DirectedGraphRenderer.Draw(drawingContext, arcs, nodes);

                ((IDisposable)context.GetTarget()).Dispose();
                ((IDisposable)context).Dispose();
            }
            catch (Exception err)
            {
                ShowError(err);
            }
        }
示例#24
0
        void OnDrawnEvent(object obj, DrawnArgs args)
        {
            if (Disposed)
            {
                return;
            }
            try
            {
                if (args.Cr == null)
                {
                    return;
                }

                Context cr = args.Cr;

                if (obj is Widget w)
                {
                    Paint(cr, w.AllocatedWidth, w.AllocatedHeight);
                }

                args.RetVal = true;
            }
            catch
            {
            }
            finally
            {
                if (args.Cr != null)
                {
                    Context cr = args.Cr;

                    Surface cs = cr.GetTarget();
                    cs?.Dispose();

                    cr.Dispose();
                }
            }
        }
示例#25
0
        /// <summary>The drawing canvas is being exposed to user.</summary>
        private void OnDrawingAreaExpose(object sender, DrawnArgs args)
        {
            try
            {
                DrawingArea area = (DrawingArea)sender;

                Cairo.Context context = args.Cr;

                DGObject.DefaultOutlineColour = area.StyleContext.GetColor(StateFlags.Normal).ToColour();
#pragma warning disable 0612
                DGObject.DefaultBackgroundColour = area.StyleContext.GetBackgroundColor(StateFlags.Normal).ToColour();
#pragma warning restore 0612

                CairoContext drawingContext = new CairoContext(context, MainWidget);
                DirectedGraphRenderer.Draw(drawingContext, arcs, nodes);

                ((IDisposable)context.GetTarget()).Dispose();
                ((IDisposable)context).Dispose();
            }
            catch (Exception err)
            {
                ShowError(err);
            }
        }
        private void Graph_Drawn(object sender, DrawnArgs args)
        {
            var context = args.Cr;

            DrawingUtilsForSamples.DrawFromGraph(new Cairo.Rectangle(0, 0, width, height), graph, args.Cr);
        }
示例#27
0
 private static void NewMethod(object o, DrawnArgs e)
 {
 }
示例#28
0
 private void CircuitEditor_Drawn(object o, DrawnArgs args)
 {
     DoDraw(args.Cr);
 }
示例#29
0
 public void SetGtkContext(DrawnArgs args)
 {
     _gtkContext = args.Cr;
 }
示例#30
0
        private void DareaOnDrawn(object o, DrawnArgs args, ObjectDef trg)
        {
            var da = o as DrawingArea;

            using var cr     = args.Cr;
            using var target = cr.GetTarget();


            var width  = da.Allocation.Width;
            var height = da.Allocation.Height;

            var ViewScaleDefault = 5;
            var iowidth          = 5.41;


            cr.SetSourceColor(to(Color.Black));
            foreach (var p in trg.Texts)
            {
                var x = p.Gui[0] * 5;
                var y = p.Gui[1] * 5;
                draw_text(cr, x, y, p.Text);
            }

            foreach (var t in trg.Net)
            {
                if (t.Gui.Count > 1)
                {
                    for (int i = 0; i < t.Gui.Count; i++)
                    {
                        var p = t.Gui[i];

                        var x = p[0] * 5;
                        var y = p[1] * 5;

                        cr.SetSourceColor(to(Color.Blue));
                        cr.LineWidth = 3;

                        if (i == 0)
                        {
                            cr.MoveTo(x, y);
                        }
                        else
                        {
                            cr.LineTo(x, y);
                        }

                        cr.StrokePreserve();
                    }
                }
            }

            foreach (var p in trg.Behavior)
            {
                try {
                    var x = p.Gui[0] * 5;
                    var y = p.Gui[1] * 5;

                    if (p.Name.StartsWith("Junction"))
                    {
                        cr.SetSourceColor(to(Color.Red));
                        cr.LineWidth = 3;
                        cr.MoveTo(x - 4, y);
                        cr.RelLineTo(8, 0);

                        cr.StrokePreserve();
                        cr.MoveTo(x, y - 4);
                        cr.RelLineTo(0, 8);
                        cr.StrokePreserve();
                        continue;
                    }

                    if (p.Name.StartsWith("Input"))
                    {
                        cr.MoveTo(x, y);
                        cr.RelLineTo(0, -4);
                        cr.RelLineTo(4, 4);
                        cr.RelLineTo(-4, 4);
                        cr.LineTo(x, y);
                        cr.StrokePreserve();

                        var name = p.Outputs[0][1];

                        var l = MakeLayout(name, bold: true);
                        int ph;
                        int pw;
                        l.GetPixelSize(out pw, out ph);

                        cr.MoveTo(x - pw - 9, y - ph / 2);

                        cr.SetSourceColor(to(Color.Black));
                        Pango.CairoHelper.ShowLayout(cr, l);

                        continue;
                    }

                    if (p.Name.StartsWith("Output"))
                    {
                        cr.MoveTo(x, y);
                        cr.RelLineTo(4, -4);
                        cr.RelLineTo(0, 9);
                        cr.RelLineTo(-4, -4);
                        cr.LineTo(x, y);
                        cr.StrokePreserve();



                        var name = p.Inputs[0][1];

                        var l = MakeLayout(name, bold: true);
                        int ph;
                        int pw;
                        l.GetPixelSize(out pw, out ph);

                        cr.MoveTo(x + 9, y - ph / 2);

                        cr.SetSourceColor(to(Color.Black));
                        Pango.CairoHelper.ShowLayout(cr, l);

                        continue;

                        continue;
                    }


                    cr.LineWidth = 2;

                    cr.SetSourceColor(to(Color.Blue));

                    var ios = Math.Max(p.Inputs.Count, p.Outputs.Count);

                    var layout = MakeLayout(p.Name);
                    int tw, th;

                    layout.GetPixelSize(out tw, out th);

                    var box_width = Math.Max(tw + 5, 45);

                    cr.Rectangle(x, y, box_width, 15 * ios + 10);
                    cr.StrokePreserve();

                    cr.SetSourceColor(to(Color.White));
                    cr.Fill();
                    cr.SetSourceColor(to(Color.Red));
                    cr.MoveTo(p.Gui[0] * 5 + 2, p.Gui[1] * 5 - th);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                }
                catch {
                    throw new Exception($"Problem with {p}");
                }
            }
        }