DrawBackground() public method

public DrawBackground ( ) : void
return void
Exemplo n.º 1
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            if (!IsRealized)
                return false;

            int w, h, total_w, total_h;

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

            args.Window.GetSize (out total_w, out total_h);

            h = total_h - question_high;
            if (UseSolutionArea)
                h -= solution_high;

            w = total_w;

            // We want a square drawing area for the puzzles then the figures are shown as designed.
            // For example, squares are squares. This also makes sure that proportions are kept when resizing
            DrawingSquare = Math.Min (w, h);

            if (DrawingSquare < w)
                OffsetX = (w - DrawingSquare) / 2d;
            else
                OffsetX = 0;

            if (DrawingSquare < h)
                OffsetY = (h - DrawingSquare) / 2d;
            else
                OffsetY = 0;

            OffsetY += question_high;

            // Draw a background taking all the window area
            cr.Save ();
            cr.Scale (total_w, total_h);
            cr.DrawBackground ();

            if (Paused == false) {
                DrawQuestionAndAnswer (cr, total_h);
            } else {
                cr.SetPangoFontSize (0.08);
                cr.DrawTextCentered (0.5, 0.5, Catalog.GetString ("Paused"));
                cr.Stroke ();
            }
            cr.Restore ();

            if (Paused == false) {
                // Draw the game area
                cr.Translate (OffsetX, OffsetY);
                cr.SetPangoNormalFontSize ();
                cr.Color = new Color (1, 1, 1, 0.5);
                Drawable.Draw (cr, DrawingSquare, DrawingSquare, Direction == Gtk.TextDirection.Rtl);
                cr.Stroke ();
            }

            ((IDisposable)cc).Dispose();
            ((IDisposable)cr).Dispose();
            return true;
        }