예제 #1
0
            protected override bool OnDrawn(Cairo.Context cc)
            {
                if (!IsRealized)
                {
                    return(false);
                }

                int    w, h, nw, nh;
                double x = 0, y = 0;

                CairoContextEx cr = new CairoContextEx(cc.Handle);

                cr.PangoFontDescription = PangoContext.FontDescription;
                w = Window.Width;
                h = Window.Height;

                nh = nw = Math.Min(w, h);

                if (nw < w)
                {
                    x = (w - nw) / 2d;
                }

                if (nh < h)
                {
                    y = (h - nh) / 2d;
                }

                cr.Translate(x, y);
                cr.Scale(nw, nh);

                view.Draw(cr, nw, nh, Direction == Gtk.TextDirection.Rtl);

                ((IDisposable)cr).Dispose();
                return(true);
            }
예제 #2
0
            protected override bool OnExposeEvent(Gdk.EventExpose args)
            {
                if (!IsRealized)
                {
                    return(false);
                }

                int    w, h, nw, nh;
                double x = 0, y = 0;

                Cairo.Context  cc = Gdk.CairoHelper.Create(args.Window);
                CairoContextEx cr = new CairoContextEx(cc.Handle, this);

                args.Window.GetSize(out w, out h);

                nh = nw = Math.Min(w, h);

                if (nw < w)
                {
                    x = (w - nw) / 2d;
                }

                if (nh < h)
                {
                    y = (h - nh) / 2d;
                }

                cr.Translate(x, y);
                cr.Scale(nw, nh);

                view.Draw(cr, nw, nh, Direction == Gtk.TextDirection.Rtl);

                ((IDisposable)cc).Dispose();
                ((IDisposable)cr).Dispose();
                return(base.OnExposeEvent(args));
            }