Example #1
0
 public override void DrawPreview(CairoContextEx gr, int width, int height, bool rtl)
 {
     gr.Scale(width, height);
     gr.Color     = new Cairo.Color(0, 0, 0);
     gr.LineWidth = LineWidth;
     DrawObjectToMemorize(gr, width, height, rtl);
 }
Example #2
0
 protected void InitDraw(CairoContextEx gr, int width, int height, bool rtl)
 {
     gr.Scale(width, height);
     gr.SetSourceColor(default_color);
     gr.LineWidth = LineWidth;
     // Not all Cairo surfaces have a default font size (like PDF)
     gr.SetPangoNormalFontSize();
 }
Example #3
0
        public void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            gr.Scale (area_width, area_height);

            gr.LineWidth = 0.01;
            gr.Color = new Cairo.Color (0, 0, 0, 1);

            gr.SetPangoLargeFontSize ();
            gr.DrawTextCentered (0.5, 0.1, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Get ready to memorize the next objects..."));
            gr.Stroke ();

            gr.SetPangoFontSize (0.35);
            gr.DrawTextCentered (0.5, 0.5, countdown_time.ToString ());
            gr.Stroke ();

            gr.Arc (0.5, 0.5, 0.25, 0, 2 * Math.PI);
            gr.Stroke ();
            gr.Arc (0.5, 0.5, 0.28, 0, 2 * Math.PI);
            gr.Stroke ();
        }
Example #4
0
        public void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double y = 0.04, x = 0.05;
            const double space_small = 0.02;
            List <PlayerPersonalRecord> records;
            string s, tip, played;
            double width, height;

            gr.Scale (area_width, area_height);
            gr.Color = new Cairo.Color (0, 0, 0, 1);

            gr.MoveTo (x, y);
            gr.ShowPangoText (Translations.GetString ("Score"), false, -1, 0);
            DrawBand (gr, 0.03, y - 0.01);

            y += 0.08;
            gr.MoveTo (x, y);

            s = session.History.GetResult (Translations);

            // Translator: This will be part of the sentence "Games won: 10 (6 played)"
            played = String.Format (Translations.GetPluralString ("{0} played", "{0} played", session.History.GamesPlayed),
                session.History.GamesPlayed);

            if (s == string.Empty) {
                gr.ShowPangoText (String.Format (Translations.GetPluralString ("Games won: {0} ({1})",
                    "Games won: {0} ({1})", session.History.GamesWon), session.History.GamesWon, played));
            }
            else {
                gr.ShowPangoText (String.Format (Translations.GetPluralString ("{0}. Games won: {1} ({2})",
                    "{0}. Games won: {1} ({2})", session.History.GamesWon),	s, session.History.GamesWon, played));
            }

            y += 0.06;
            gr.MoveTo (x, y);
            gr.ShowPangoText (String.Format (Translations.GetString ("Time played {0} (average per game {1})"), session.GameTime, session.TimePerGame));

            y += 0.09;
            DrawColumnBarGraphic (gr, x, y);

            y += 0.36;
            gr.MoveTo (x, y);
            gr.SetPangoFontSize (smaller_font);
            // Translators: translated string should not be longer that the English original (space restriction on the UI)
            gr.ShowPangoText (Translations.GetString ("For details on how gbrainy's scoring works refer to the help."));

            y += 0.07;
            gr.SetPangoNormalFontSize ();
            records	= session.PlayerHistory.GetLastGameRecords ();
            gr.MoveTo (x, y);

            if (records.Count == 0) {
                bool caching = cached_sessionid != session.ID;

                gr.ShowPangoText (Translations.GetString ("Tips for your next games"), false, -1, 0);
                DrawBand (gr, 0.03, y - 0.01);

                y += 0.08;

                if (caching)
                    tips.Clear ();

                for (int i = 0; i < tips_shown; i++)
                {
                    if (caching)
                        tips.Add (game_tips.Tip);

                    tip = "- " + tips [i];

                    gr.MeasureString (tip, 1.0 - x, true, out width, out height);

                    if (y + height > 0.98)
                        break;

                    gr.DrawStringWithWrapping (x, y, tip , 1.0 - x);
                    y += height + space_small;
                }

                if (caching)
                    cached_sessionid = session.ID;
            }
            else  {
                gr.ShowPangoText (Translations.GetString ("Congratulations! New personal record"), false, -1, 0);
                DrawBand (gr, 0.03, y - 0.01);

                y += 0.08;

                for (int i = 0; i < records.Count; i++)
                {
                    switch (records[i].GameType) {
                    case GameTypes.LogicPuzzle:
                        s = String.Format (Translations.
                            GetString ("By scoring {0} in logic puzzle games you have established a new personal record. Your previous record was {1}."),
                            records[i].NewScore,
                            records[i].PreviousScore);
                        break;
                    case GameTypes.Calculation:
                        s = String.Format (Translations.
                            GetString ("By scoring {0} in calculation games you have established a new personal record. Your previous record was {1}."),
                            records[i].NewScore,
                            records[i].PreviousScore);
                        break;
                    case GameTypes.Memory:
                        s = String.Format (Translations.
                            GetString ("By scoring {0} in memory games you have established a new personal record. Your previous record was {1}."),
                            records[i].NewScore,
                            records[i].PreviousScore);
                        break;
                    case GameTypes.VerbalAnalogy:
                        s = String.Format (Translations.
                            GetString ("By scoring {0} in verbal analogies you have established a new personal record. Your previous record was {1}."),
                            records[i].NewScore,
                            records[i].PreviousScore);
                        break;
                    default:
                        break;
                    }

                    tip = "- " + s;

                    gr.MeasureString (tip, 1.0 - x, true, out width, out height);

                    if (y + height > 0.98)
                        break;

                    gr.DrawStringWithWrapping (x, y, tip , 1.0 - x);
                    y += height + space_small;
                }
            }

            gr.Stroke ();
        }
Example #5
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;
            }
Example #6
0
 public override void DrawPreview(CairoContextEx gr, int width, int height, bool rtl)
 {
     gr.Scale (width, height);
     gr.Color = new Cairo.Color (0, 0, 0);
     gr.LineWidth = LineWidth;
     DrawObjectToMemorize (gr, width, height, rtl);
 }
            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);
            }
        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;
        }
Example #9
0
        public void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double y = 0.03;

            gr.Scale (area_width, area_height);
            gr.LineWidth = 0.005;

            gr.Color = new Cairo.Color (0, 0, 0, 1);

            gr.MoveTo (0.05, y);
            // Translators: {0} is the version number of the program
            gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Welcome to gbrainy {0}"), Defines.VERSION), true, -1, 0);
            gr.Stroke ();

            gr.DrawStringWithWrapping (0.05, y + 0.07,
                ServiceLocator.Instance.GetService <ITranslations> ().GetString ("gbrainy is a brain teaser game and trainer to have fun and to keep your brain trained. It includes:"),
                1 - 0.05);

            y = 0.22 + space * 3;
            gr.DrawStringWithWrapping (0.05, y + 0.17,  ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Use the Settings to adjust the difficulty level of the game."),
                1 - 0.05);
            gr.Stroke ();

            foreach (Toolkit.Container container in containers)
                container.Draw (gr, area_width, area_height, rtl);
        }