Пример #1
0
            protected override bool OnDrawn(Context cr)
            {
                int w, h;

                this.GdkWindow.GetSize(out w, out h);

                // We clear the surface with a transparent color if possible
                if (supportAlpha)
                {
                    cr.SetSourceRGBA(1.0, 1.0, 1.0, 0.0);
                }
                else
                {
                    cr.SetSourceRGB(1.0, 1.0, 1.0);
                }
                cr.Operator = Operator.Source;
                cr.Paint();

                cr.LineWidth = GtkWorkarounds.GetScaleFactor(Content) > 1 ? 2 : 1;
                var bounds         = new Xwt.Rectangle(cr.LineWidth / 2, cr.LineWidth / 2, w - cr.LineWidth, h - cr.LineWidth);
                var calibratedRect = RecalibrateChildRectangle(bounds);

                // Fill it with one round rectangle
                RoundRectangle(cr, calibratedRect, radius);

                // Triangle
                // We first begin by positionning ourselves at the top-center or bottom center of the previous rectangle
                var arrowX = bounds.Center.X + arrowDelta;
                var arrowY = arrowPosition == Xwt.Popover.Position.Top ? calibratedRect.Top + cr.LineWidth : calibratedRect.Bottom;

                cr.MoveTo(arrowX, arrowY);
                // We draw the rectangle path
                DrawTriangle(cr);

                // We use it
                if (supportAlpha)
                {
                    cr.SetSourceRGBA(0.0, 0.0, 0.0, 0.2);
                }
                else
                {
                    cr.SetSourceRGB(238d / 255d, 238d / 255d, 238d / 255d);
                }
                cr.StrokePreserve();
                cr.SetSourceRGBA(BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A);
                cr.Fill();

                return(base.OnDrawn(cr));
            }
Пример #2
0
 public static double GetScaleFactor(Gtk.Widget w)
 {
     return(GtkWorkarounds.GetScaleFactor(w));
 }