SelectFontFace() public method

public SelectFontFace ( string family, FontSlant slant, FontWeight weight ) : void
family string
slant FontSlant
weight FontWeight
return void
Beispiel #1
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);


            TextExtents te;

            Text.ShadowedText(g, "Time", X + x1, Y + y1);
            Text.ShadowedText(g, "Gil", X + x1, Y + y2);

            g.SelectFontFace("Courier New", FontSlant.Normal, FontWeight.Bold);

            long s, m, h;

            s = GameClock.Seconds;
            m = GameClock.Minutes;
            h = GameClock.Hours;

            string time = String.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s);

            te = g.TextExtents(time);
            Text.ShadowedText(g, time, X + x2 - te.Width, Y + y1);

            te = g.TextExtents(Gil);
            Text.ShadowedText(g, Gil, X + x2 - te.Width, Y + y2);
        }
Beispiel #2
0
    protected void DrawingPlace(object sender, ExposeEventArgs args)
    {
        DrawingArea area = (DrawingArea)sender;

        Cairo.Context cc = Gdk.CairoHelper.Create(area.GdkWindow);

        cc.SelectFontFace("Sans", Cairo.FontSlant.Italic, Cairo.FontWeight.Bold);
        cc.SetFontSize(25);
        cc.MoveTo(15, 20);
        cc.ShowText("Диаграмма");
        cc.MoveTo(330, 40);
        cc.SetFontSize(15);
        cc.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
        cc.ShowText("Выручка");

        cc.SetSourceRGB(0.2, 0.23, 0.9);
        cc.LineWidth = 1;

        int s      = 50;
        int s_next = 40;
        int w;
        int i = 0;
        int h = 65;

        foreach (var item in global_1)
        {
            w = Convert.ToInt32(item);
            cc.SetFontSize(15);
            cc.MoveTo(0, h);
            cc.SetSourceRGB(0, 0, 0);
            cc.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
            cc.ShowText(Convert.ToString(i + 1));
            i = i + 1;
            cc.SetSourceRGB(0.2, 0.23, 0.9);
            cc.Rectangle(10, s, w, 30);
            h = h + 40;
            s = s + s_next;
        }

        cc.LineTo(10, 50);
        cc.LineTo(10, 390);
        cc.StrokePreserve();
        cc.Fill();

        cc.LineTo(10, 50);
        cc.LineTo(390, 50);
        cc.StrokePreserve();
        cc.Fill();

        cc.MoveTo(0, 390);
        cc.SetSourceRGB(0, 0, 0);
        cc.SetFontSize(15);
        cc.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
        cc.ShowText("Период");

        ((IDisposable)cc).Dispose();
    }
Beispiel #3
0
        //intro bottom tips
        public void IntroBottom(Cairo.Context g)
        {
            PointD p1, p2, p3, p4, s1, s2, s3, s4;

            p1 = new PointD(30, 10); p2 = new PointD(420, 10); s1 = new PointD(422, 12); s2 = new PointD(422, 88);
            p3 = new PointD(420, 90); p4 = new PointD(30, 90); s3 = new PointD(28, 88); s4 = new PointD(28, 12);

            g.Color = new Color(0.3, 0.4, 0.6, 0.8);
            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath(); g.LineWidth = 1; g.Stroke();

            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath();

            Cairo.Gradient pat = new Cairo.LinearGradient(80, 20, 80, 80);
            pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0));
            pat.AddColorStop(1, new Cairo.Color(0.3, 0.4, 0.6, 0.3));
            g.Pattern = pat;
            g.FillPreserve();


            g.Color = new Color(0, 0, 0, 0.8);
            g.SelectFontFace("", FontSlant.Italic, FontWeight.Bold);
            g.SetFontSize(18);
            g.MoveTo(new PointD(88, 28));
            g.ShowText(".");
            g.MoveTo(new PointD(88, 58));
            g.ShowText(".");
            g.SelectFontFace("", FontSlant.Italic, FontWeight.Normal);
            g.SetFontSize(10);
            g.MoveTo(new PointD(98, 30));
            g.ShowText("Use the navigation on the left to choose different categories");
            g.MoveTo(new PointD(98, 42));
            g.ShowText("of your computer and system information to display.");
            g.MoveTo(new PointD(98, 60));
            g.ShowText("When you click on a category in the navigation, the dynamic");
            g.MoveTo(new PointD(98, 72));
            g.ShowText("information is automatically refreshed.");

            g.MoveTo(new PointD(38, 35));
            g.Color = new Color(0.3, 0.4, 0.6, 1);
            g.SelectFontFace("", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(18);
            g.ShowText("Tips");

            g.NewPath();

            /*
             * g.Color = new Color (0.3, 0.4, 0.6, 0.8);
             * g.Scale (34, 34);
             * g.LineWidth = 0.06;
             * g.Arc (1.0, 1.0, 0.6, 0, 360);
             * g.Stroke ();*/

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #4
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            Graphics.ShadowedText(g, "Item", X + x1, Y + (ys * 1));

            List <InventoryRecord> taken = HoardItemLeft.Instance.Taken;

            for (int i = 0; i < taken.Count; i++)
            {
                if (taken[i].ID != "")
                {
                    string count = taken[i].Count.ToString();
                    te = g.TextExtents(count);
                    Graphics.ShadowedText(g, taken[i].Item.Name, X + x2, Y + (ys * (i + 2)));
                    Graphics.ShadowedText(g, count, X + x3 - te.Width, Y + (ys * (i + 2)));
                }
            }

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #5
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            Graphics.ShadowedText(g, "Take everything", X + x1, Y + (ys * 1));

            for (int i = 0; i < _hoard.Count; i++)
            {
                if (_hoard[i].ID != "")
                {
                    string count = _hoard[i].Count.ToString();
                    te = g.TextExtents(count);
                    Graphics.ShadowedText(g, _hoard[i].Item.Name, X + x2, Y + (ys * (i + 2)));
                    Graphics.ShadowedText(g, count, X + x3 - te.Width, Y + (ys * (i + 2)));
                }
            }

            Graphics.ShadowedText(g, "Exit", X + x1, Y + (ys * 7));


            if (IsControl)
            {
                Graphics.RenderCursor(g, X + cx + x1, Y + cy + ys * (_option + 1));
            }


            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #6
0
        //system top
        public void SystemTop(Cairo.Context g, Int32 width)
        {
            PointD p1, p2, p3, p4, s1, s2, s3, s4;

            p1 = new PointD(5, 5); p2 = new PointD(width, 5); s1 = new PointD(width + 2, 7); s2 = new PointD(width + 2, 28);
            p3 = new PointD(width, 30); p4 = new PointD(5, 30); s3 = new PointD(3, 28); s4 = new PointD(3, 7);

            g.Color = new Color(0.3, 0.4, 0.6, 1);
            g.MoveTo(p1); g.LineTo(p2);  g.LineTo(s1);  g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath(); g.LineWidth = 1; g.Stroke();

            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath();

            Cairo.Gradient pat = new Cairo.LinearGradient(80, 10, 80, 60);
            pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0.6));
            pat.AddColorStop(1, new Cairo.Color(0, 0, 0, 1));
            g.Pattern = pat;
            g.FillPreserve();

            g.SetFontSize(17);
            g.SelectFontFace("", FontSlant.Normal, FontWeight.Bold);
            g.MoveTo(new PointD(12, 23));
            g.Color = new Color(1, 1, 1, 1);
            g.ShowText("General system information");

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #7
0
        //intro top Welcome
        public void IntroTop(Cairo.Context g, Int32 width)
        {
            PointD p1, p2, p3, p4, s1, s2, s3, s4;

            p1 = new PointD(10, 10); p2 = new PointD(width, 10); s1 = new PointD(width + 2, 12); s2 = new PointD(width + 2, 38);
            p3 = new PointD(width, 40); p4 = new PointD(10, 40); s3 = new PointD(8, 38); s4 = new PointD(8, 12);

            g.Color = new Color(0.3, 0.4, 0.6, 1);
            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath(); g.LineWidth = 1; g.Stroke();

            g.MoveTo(p1); g.LineTo(p2);  g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath();

            Cairo.Gradient pat = new Cairo.LinearGradient(80, 10, 80, 80);
            pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0.6));
            pat.AddColorStop(1, new Cairo.Color(0, 0, 0, 1));
            g.Pattern = pat; g.FillPreserve();

            g.SetFontSize(22);
            g.SelectFontFace("", FontSlant.Italic, FontWeight.Bold);
            g.MoveTo(new PointD(22, 33));
            g.Color = new Color(1, 1, 1, 1);
            g.ShowText("Welcome to");

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #8
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC        gc = new Gdk.GC(d);
            Cairo.Context g  = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);


            TextExtents te;

            string lvl, hp, hpm, mp, mpm;


            #region Character Status

            d.DrawPixbuf(gc, Graphics.GetProfile(Selected.Name), 0, 0,
                         X + xpic, Y + ypic,
                         Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT,
                         Gdk.RgbDither.None, 0, 0);

            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x3, Y + ya);
            g.ShowText("LV");
            g.MoveTo(X + x3, Y + yb);
            g.ShowText("HP");
            g.MoveTo(X + x3, Y + yc);
            g.ShowText("MP");
            g.Color = new Color(1, 1, 1);

            Graphics.ShadowedText(g, Selected.Name, X + x3, Y + y);

            lvl = Selected.Level.ToString();
            hp  = Selected.HP.ToString() + "/";
            hpm = Selected.MaxHP.ToString();
            mp  = Selected.MP.ToString() + "/";
            mpm = Selected.MaxMP.ToString();

            te = g.TextExtents(lvl);
            Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + ya);

            te = g.TextExtents(hp);
            Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + yb);

            te = g.TextExtents(hpm);
            Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + yb);

            te = g.TextExtents(mp);
            Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + yc);

            te = g.TextExtents(mpm);
            Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + yc);

            #endregion Status



            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #9
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            Color c;

            for (int i = 0; i <= OPTION_MAX; i++)
            {
                c = i == _option ? Colors.WHITE : Colors.GRAY_4;

                int x = X + x0 + x_spacing * (i + 1);

                char symbol;

                if (i > 9)
                {
                    symbol = '7';
                }
                else
                {
                    symbol = '0';
                }

                symbol += (char)i;

                Text.ShadowedText(g, c, symbol.ToString(), x, Y + y);
            }
        }
Beispiel #10
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.Color = new Color(1, 1, 1);
            g.SetFontSize(24);

            int j = Math.Min(rows + _topRow, _equipment.Count);

            for (int i = _topRow; i < j; i++)
            {
                Graphics.ShadowedText(g, _equipment[i].Item.Name,
                                      X + x, Y + (i - _topRow + 1) * y);
            }

            if (IsControl)
            {
                Graphics.RenderCursor(g, X + cx, Y + cy + (_option - _topRow) * y);
            }


            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #11
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;


            if (IsControl || MateriaArrange.Instance.IsControl || MateriaPrompt.Instance.IsControl)
            {
                int j = Math.Min(rows + topRow, Materiatory.MATERIATORY_SIZE);

                for (int i = topRow; i < j; i++)
                {
                    Materia orb = Materiatory.Get(i);
                    if (orb != null)
                    {
                        Graphics.RenderCircle(g, new Color(1, 1, 1), 9, X + x1, Y + cy + (i - topRow) * y);
                        Graphics.RenderCircle(g, orb.Color, 7, X + x1, Y + cy + (i - topRow) * y);

                        Graphics.ShadowedText(g, orb.Name, X + x2, Y + (i - topRow + 1) * y);
                    }
                }
            }

            if (IsControl)
            {
                Graphics.RenderCursor(g, X + cx, Y + cy + (option - topRow) * y);
            }

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #12
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            Spell s = Game.Battle.Commanding.EnemySkillMenu.Selected;

            int row = 0;

            if (!String.IsNullOrEmpty(s.ID))
            {
                string cost = s.Cost.ToString();
                Graphics.ShadowedText(g, "MP Req", X + x1, Y + y0);

                row++;

                cost = cost + "/";
                te   = g.TextExtents(cost);
                Graphics.ShadowedText(g, cost, X + x2 - te.Width, Y + y0 + (row * ys));

                string tot = Game.Battle.Commanding.MP.ToString();
                te = g.TextExtents(tot);
                Graphics.ShadowedText(g, tot, X + x3 - te.Width, Y + y0 + (row * ys));

                row++;
            }

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #13
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            Gdk.GC gc = new Gdk.GC(d);

            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);


            for (int i = 0; i < Party.PARTY_SIZE; i++)
            {
                if (MenuState.Party[i] != null)
                {
                    DrawCharacterStatus(d, g, MenuState.Party[i], y_firstRow + i * row_height);
                }
            }


            if (IsControl)
            {
                if (option_hold != -1)
                {
                    Shapes.RenderBlinkingCursor(g, X + x_cursor, Y + y_firstRow + y_displacement_cursor + option * row_height);
                }

                if (option != option_hold)
                {
                    Shapes.RenderCursor(g, X + x_cursor, Y + y_firstRow + y_displacement_cursor + option * row_height);
                }
            }
        }
Beispiel #14
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            switch (option)
            {
            case 0:
                Graphics.RenderCursor(g, X + x0 - cx, Y + y1 - cy);
                break;

            case 1:
                Graphics.RenderCursor(g, X + x2 - cx, Y + y1 - cy);
                break;

            default: break;
            }
            Graphics.ShadowedText(g, "Are you sure?", X + x1, Y + y0);
            Graphics.ShadowedText(g, "Yes", X + x0, Y + y1);
            Graphics.ShadowedText(g, "No", X + x2, Y + y1);

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #15
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            Text.ShadowedText(g, "PHS", X + 20, Y + 25);
        }
Beispiel #16
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);


            int j = Math.Min(_visibleRows + _topRow, _totalRows);

            for (int b = _topRow; b < j; b++)
            {
                for (int a = 0; a < COLUMNS; a++)
                {
                    Graphics.ShadowedText(g, String.IsNullOrEmpty(_spells[b, a].ID) ? "" : _spells[b, a].Name,
                                          X + x1 + a * xs,
                                          Y + (b - _topRow + 1) * ys);
                }
            }


            if (IsControl)
            {
                Graphics.RenderCursor(g,
                                      X + x1 + cx + _xopt * xs,
                                      Y + cy + (_yopt - _topRow + 1) * ys);
            }

            EnemySkillMenuInfo.Instance.Draw(d);


            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #17
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);


            if (IsControl || MenuState.MateriaArrange.IsControl || MenuState.MateriaPrompt.IsControl)
            {
                int j = Math.Min(rows + topRow, Materiatory.MATERIATORY_SIZE);

                for (int i = topRow; i < j; i++)
                {
                    MateriaOrb orb = MenuState.Party.Materiatory.Get(i);
                    if (orb != null)
                    {
                        Shapes.RenderCircle(g, Colors.WHITE, 9, X + x1, Y + cy + (i - topRow) * y);
                        Shapes.RenderCircle(g, orb.Color, 7, X + x1, Y + cy + (i - topRow) * y);

                        Text.ShadowedText(g, orb.Name, X + x2, Y + (i - topRow + 1) * y);
                    }
                }
            }

            if (IsControl)
            {
                Shapes.RenderCursor(g, X + cx, Y + cy + (option - topRow) * y);
            }
        }
Beispiel #18
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            Text.ShadowedText(g, "Take everything", X + x1, Y + (ys * 1));

            for (int i = 0; i < _hoard.Count; i++)
            {
                if (_hoard[i].ID != "")
                {
                    string count = _hoard[i].Count.ToString();
                    te = g.TextExtents(count);
                    Text.ShadowedText(g, _hoard[i].Item.Name, X + x2, Y + (ys * (i + 2)));
                    Text.ShadowedText(g, count, X + x3 - te.Width, Y + (ys * (i + 2)));
                }
            }

            Text.ShadowedText(g, "Exit", X + x1, Y + (ys * 7));


            if (IsControl)
            {
                Shapes.RenderCursor(g, X + cx + x1, Y + cy + ys * (_option + 1));
            }
        }
Beispiel #19
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);


            int j = Math.Min(_visibleRows + _topRow, _totalRows);


            for (int b = _topRow; b < j; b++)
            {
                for (int a = 0; a < COLUMNS; a++)
                {
                    Spell enemySkill = _spells[b, a];

                    if (enemySkill != null)
                    {
                        Text.ShadowedText(g, enemySkill.Name,
                                          X + x1 + a * xs,
                                          Y + (b - _topRow + 1) * ys);
                    }
                }
            }


            if (IsControl)
            {
                Shapes.RenderCursor(g,
                                    X + x1 + cx + _xopt * xs,
                                    Y + cy + (_yopt - _topRow + 1) * ys);
            }


            BattleState.Screen.EnemySkillInfo.Draw(d, g, width, height, screenChanged);
        }
Beispiel #20
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(28);


            string name0 = (Game.Battle.Allies[0] == null) ? "" : Game.Battle.Allies[0].Name;
            string name1 = (Game.Battle.Allies[1] == null) ? "" : Game.Battle.Allies[1].Name;
            string name2 = (Game.Battle.Allies[2] == null) ? "" : Game.Battle.Allies[2].Name;

            if (name0.CompareTo("") != 0)
            {
                Graphics.ShadowedText(g, name0, X + x1, Y + y0);
            }
            if (name1.CompareTo("") != 0)
            {
                Graphics.ShadowedText(g, name1, X + x1, Y + y1);
            }
            if (name2.CompareTo("") != 0)
            {
                Graphics.ShadowedText(g, name2, X + x1, Y + y2);
            }


            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #21
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;


            int j = Math.Min(_visibleRows + _topRow, _totalRows);

            for (int b = _topRow; b < j; b++)
            {
                Graphics.ShadowedText(g, String.IsNullOrEmpty(_summons[b].ID) ? "" : _summons[b].Name,
                                      X + x1,
                                      Y + (b - _topRow + 1) * ys);
            }


            if (IsControl)
            {
                Graphics.RenderCursor(g,
                                      X + x1 + cx,
                                      Y + cy + (_option - _topRow + 1) * ys);
            }

            SummonMenuInfo.Instance.Draw(d);


            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #22
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            Text.ShadowedText(g, "Gained Experience points and AP.", X + xs, Y + ys);
        }
Beispiel #23
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            for (int i = 0; i < Party.PARTY_SIZE; i++)
            {
                if (MenuState.Party[i] != null)
                {
                    DrawCharacterStatus(d, g, MenuState.Party[i], y_firstRow + i * row_height);
                }
            }

            if (IsControl)
            {
                switch (_selectedItem.FieldTarget)
                {
                case FieldTarget.Character:
                    Shapes.RenderCursor(g, X + x_cursor, Y + y_firstRow + y_displacement_cursor + option * row_height);
                    break;

                case FieldTarget.Party:
                    for (int i = 0; i < Party.PARTY_SIZE; i++)
                    {
                        Shapes.RenderBlinkingCursor(g, X + x_cursor, Y + y_firstRow + y_displacement_cursor + i * row_height);
                    }
                    break;
                }
            }
        }
Beispiel #24
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            Ability s = BattleState.Commanding.EnemySkillMenu.Selected;

            int row = 0;

            if (s != null)
            {
                string cost = s.MPCost.ToString();
                Text.ShadowedText(g, "MP Req", X + x1, Y + y0);

                row++;

                cost = cost + "/";
                te   = g.TextExtents(cost);
                Text.ShadowedText(g, cost, X + x2 - te.Width, Y + y0 + (row * ys));

                string tot = BattleState.Commanding.MP.ToString();
                te = g.TextExtents(tot);
                Text.ShadowedText(g, tot, X + x3 - te.Width, Y + y0 + (row * ys));

                row++;
            }
        }
Beispiel #25
0
            protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
            {
                g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
                g.SetFontSize(24);

                Color cr, cg, cb;

                for (int i = 0; i < 11; i++)
                {
                    cr = i == indicies[0] ? Colors.WHITE : Colors.GRAY_4;
                    cg = i == indicies[1] ? Colors.WHITE : Colors.GRAY_4;
                    cb = i == indicies[2] ? Colors.WHITE : Colors.GRAY_4;

                    int x = X + x0 + x_spacing * (i + 1);

                    Text.ShadowedText(g, cr, i.ToString(), x, Y + yr);
                    Text.ShadowedText(g, cg, i.ToString(), x, Y + yg);
                    Text.ShadowedText(g, cb, i.ToString(), x, Y + yb);
                }

                cr = option_y == 0 ? Colors.WHITE : Colors.GRAY_4;
                cg = option_y == 1 ? Colors.WHITE : Colors.GRAY_4;
                cb = option_y == 2 ? Colors.WHITE : Colors.GRAY_4;


                Text.ShadowedText(g, cr, "R", X + x0, Y + yr);
                Text.ShadowedText(g, cg, "G", X + x0, Y + yg);
                Text.ShadowedText(g, cb, "B", X + x0, Y + yb);
            }
Beispiel #26
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;


            int j = Math.Min(_rows + _topRow, Inventory.INVENTORY_SIZE);

            for (int i = _topRow; i < j; i++)
            {
                IInventoryItem item = BattleState.Party.Inventory.GetItem(i);

                if (item != null)
                {
                    int count = BattleState.Party.Inventory.GetCount(i);
                    te = g.TextExtents(count.ToString());

                    Color textColor = item.CanUseInBattle ? Colors.WHITE : Colors.GRAY_4;

                    Text.ShadowedText(g, textColor, item.Name,
                                      X + x1, Y + (i - _topRow + 1) * y);
                    Text.ShadowedText(g, textColor, count.ToString(),
                                      X + x2 - te.Width, Y + (i - _topRow + 1) * y);
                }
            }

            if (IsControl)
            {
                Shapes.RenderCursor(g, X + cx, Y + cy + (_option - _topRow) * y);
            }
        }
Beispiel #27
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC        gc = new Gdk.GC(d);
            Cairo.Context g  = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            if (Growth != "")
            {
                g.Color = new Color(.1, .1, .2);
                g.Rectangle(X + x1, Y + ya - (yj - yi) + ysa, 8 * xs, yj - yi);
                g.Fill();

                Cairo.Color gray1 = new Color(.2, .2, .2);
                Cairo.Color gray2 = new Color(.7, .7, .8);

                int links, slots;

                slots = Slots.Length;
                links = Links;


                for (int j = 0; j < links; j++)
                {
                    Graphics.RenderLine(g, gray2, 3,
                                        X + x1 + (xs / 2) + (j * 2 * xs), Y + ya - ysb - zs,
                                        X + x1 + (xs / 2) + ((j * 2 + 1) * xs), Y + ya - ysb - zs);
                    Graphics.RenderLine(g, gray2, 3,
                                        X + x1 + (xs / 2) + (j * 2 * xs), Y + ya - ysb,
                                        X + x1 + (xs / 2) + ((j * 2 + 1) * xs), Y + ya - ysb);
                    Graphics.RenderLine(g, gray2, 3,
                                        X + x1 + (xs / 2) + (j * 2 * xs), Y + ya - ysb + zs,
                                        X + x1 + (xs / 2) + ((j * 2 + 1) * xs), Y + ya - ysb + zs);
                }
                for (int i = 0; i < slots; i++)
                {
                    Graphics.RenderCircle(g, gray2, 14,
                                          X + x1 + (i * xs) + (xs / 2), Y + yi - ysb);
                    Graphics.RenderCircle(g, gray1, 10,
                                          X + x1 + (i * xs) + (xs / 2), Y + yi - ysb);
                }

                Graphics.ShadowedText(g, new Color(.3, .8, .8), "Slot", X + x0, Y + ya);
                Graphics.ShadowedText(g, new Color(.3, .8, .8), "Growth", X + x0, Y + yb);

                string growth = Growth;

                te = g.TextExtents(growth);
                Graphics.ShadowedText(g, growth, X + x2 - (te.Width / 2), Y + yb);
            }

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Beispiel #28
0
        public void Draw(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(20);

            TextExtents te = g.TextExtents(Message);

            Text.ShadowedText(g, Color, Message, X - (te.Width / 2), Y - (te.Height / 2) + GetCurrentDisplacement());
        }
Beispiel #29
0
    public void CreatePng()
    {
        const int Width     = 480;
        const int Height    = 160;
        const int CheckSize = 10;
        const int Spacing   = 2;

        // Create an Image-based surface with data stored in ARGB32 format and a context,
        // "using" is used here to ensure that they are Disposed once we are done
        using (ImageSurface surface = new ImageSurface(Format.ARGB32, Width, Height))
            using (Context cr = new Cairo.Context(surface))
            {
                // Start drawing a checkerboard
                int i, j, xcount, ycount;
                xcount = 0;
                i      = Spacing;
                while (i < Width)
                {
                    j      = Spacing;
                    ycount = xcount % 2;             // start with even/odd depending on row
                    while (j < Height)
                    {
                        if (ycount % 2 != 0)
                        {
                            cr.SetSourceRGB(1, 0, 0);
                        }
                        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;
                }

                // Select a font to draw with
                cr.SelectFontFace("serif", FontSlant.Normal, FontWeight.Bold);
                cr.SetFontSize(64.0);

                // Select a color (blue)
                cr.SetSourceRGB(0, 0, 1);

                // Draw
                cr.MoveTo(20, 100);
                cr.ShowText("Hello, World");

                surface.WriteToPng("test.png");
            }
    }
Beispiel #30
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            te = g.TextExtents(Exp);
            Text.ShadowedText(g, "EXP", X + x1, Y + ys);
            Text.ShadowedText(g, Exp, X + x2 - te.Width, Y + ys);
        }
Beispiel #31
0
	public void CreatePng ()
	{
		const int Width = 480;
		const int Height = 160;
		const int CheckSize = 10;
		const int Spacing = 2;

		// Create an Image-based surface with data stored in ARGB32 format and a context,
		// "using" is used here to ensure that they are Disposed once we are done
		using (ImageSurface surface = new ImageSurface (Format.ARGB32, Width, Height))
		using (Context cr = new Cairo.Context (surface))
		{
			// Start drawing a checkerboard
			int i, j, xcount, ycount;
			xcount = 0;
			i = Spacing;
			while (i < Width) {
				j = Spacing;
				ycount = xcount % 2; // start with even/odd depending on row
				while (j < Height) {
					if (ycount % 2 != 0)
						cr.SetSourceRGB (1, 0, 0);
					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;
			}

			// Select a font to draw with
			cr.SelectFontFace ("serif", FontSlant.Normal, FontWeight.Bold);
			cr.SetFontSize (64.0);

			// Select a color (blue)
			cr.SetSourceRGB (0, 0, 1);

			// Draw
			cr.MoveTo (20, 100);
			cr.ShowText ("Hello, World");

			surface.WriteToPng ("test.png");
		}
	}
Beispiel #32
0
 protected override bool OnExposed(Context cr, Rectangle area)
 {
     cr.Save();
     if(!base.OnExposed(cr, area))
     {
         cr.Color = new Color(1.0, 0.0, 0.0);
         cr.SetFontSize(100.0);
         cr.SelectFontFace("Librarian", FontSlant.Normal, FontWeight.Bold);
         cr.ShowText(role.ToString());
         cr.Restore();
         return true;
     }
     cr.Restore();
     return true;
 }
Beispiel #33
0
 public static void SetFontFacePieceName(Context ctx)
 {
     ctx.SelectFontFace("Arial",FontSlant.Italic,FontWeight.Bold);
     ctx.SetFontSize(14.0d);
 }
Beispiel #34
0
        /*
        [XmlIgnore]
        public FontFamily font;
        */
        public void InternalRegenerateCloud()
        {
            r = new Random();
            int id = 0;
            double minSize = Entries.Min(e => e.SizeValue);
            double maxSize = Entries.Max(e => e.SizeValue);
            double range = Math.Max(0.00001, maxSize - minSize);

            _source = new ImageSurface(Format.Argb32,ActualWidth,ActualHeight);
            pixelss = _source.Data;
            g = new Context(_source);
            g.Color = new Color(1.0,1.0,1.0);
            //g.Rectangle(0.0,0.0,ActualWidth,ActualHeight);
            g.Paint();

            g.SelectFontFace(fontname,FontSlant.Normal,FontWeight.Bold);
            g.SetFontSize(100.0);
            TextExtents te = g.TextExtents("x");
            double areaPerLetter = te.Width;

            strides = _source.Stride;
            int arraySize = (int)((ActualWidth / 4) + 2) * (int)((ActualHeight / 4) + 2);
            _mapping = new int[arraySize];
            for (int i = 0; i < arraySize; i++) _mapping[i] = -1;

            if(svgfn != null) {
                svgs = new SvgSurface(svgfn,ActualWidth,ActualHeight);
                svg = new Context(svgs);
                svg.SelectFontFace(fontname,FontSlant.Normal,FontWeight.Bold);
            }
            if(pdffn != null) {
                pdfs = new PdfSurface(pdffn,ActualWidth,ActualHeight);
                pdf = new Context(pdfs);
                pdf.SelectFontFace(fontname,FontSlant.Normal,FontWeight.Bold);
            }

            double fontMultiplier;

            if(CoverRatio > 0.0) {
                double totalsize = 0.0;
                MinFontSize = 24.0; // use big fonts for testing
                if(FontMaxRatio < 1.0 || FontMaxRatio > 500.0) FontMaxRatio = 6.0;
                MaxFontSize = FontMaxRatio*MinFontSize;
                fontMultiplier = (MaxFontSize - MinFontSize) / range;
                foreach(WordCloudEntry e in Entries) {
                    float fontsize = (float)(((e.SizeValue - minSize) * fontMultiplier) + MinFontSize);
                    g.SetFontSize(fontsize);
                    TextExtents te1 = g.TextExtents(e.Word);
                    totalsize += te1.Width*te1.Height;
                }
                double actualsize = ActualHeight*ActualWidth;
                double ratio1 = totalsize / actualsize; //this should be == CoverRatio
                //we assume that totalsize ~ MinFontSize^2 in this case
                MinFontSize = MinFontSize*Math.Sqrt(CoverRatio / ratio1);
                MaxFontSize = FontMaxRatio*MinFontSize;
                fontMultiplier = (MaxFontSize - MinFontSize) / range;
                LargestSizeWidthProportion = 0.9;
            }

            double targetWidth = Math.Max(ActualWidth, ActualHeight) * LargestSizeWidthProportion;
            WordCloudEntry od = Entries.OrderByDescending(e => (e.SizeValue - minSize) * e.Word.Length).First();
            double maxFontSize;
            if(MaxFontSize > 0.0 && CoverRatio <= 0.0) {
                maxFontSize = MaxFontSize;
                if(maxFontSize < MinFontSize) maxFontSize = MinFontSize*2.7;
            }
            else {
                g.SetFontSize(100.0);
                TextExtents te2 = g.TextExtents(od.Word);
                maxFontSize = 97.0*targetWidth / te2.Width;
                //maxFontSize = Math.Max(MinFontSize * 2.7, 100.0 / ((od.Word.Length * areaPerLetter) / targetWidth));
                if(maxFontSize > MinFontSize + 100) maxFontSize = MinFontSize + 100;
            }
            if(CoverRatio > 0.0) {
                if(maxFontSize < MaxFontSize) MaxFontSize = maxFontSize;
                fontMultiplier = (maxFontSize - MinFontSize) / range;
            }
            else fontMultiplier = (maxFontSize - MinFontSize) / range;

            var points = new[]
                             {
                                 new Point((int) (ActualWidth/2), (int) (ActualHeight/2)),
                                 new Point((int) (ActualWidth/4), (int) (ActualHeight/4)),
                                 new Point((int) (ActualWidth/4), (int) (3*ActualHeight/2)),
                                 new Point((int) (3*ActualWidth/4), (int) (ActualHeight/2)),
                                 new Point((int) (3*ActualWidth/4), (int) (3*ActualHeight/4))
                             };

            int currentPoint = 0;
            foreach (WordCloudEntry e in Entries.OrderByDescending(e => e.SizeValue))
            {
            again:
                double position = 0.0;
                Point centre = points[currentPoint];

                double angle = 0.0;
                if(vratio > 0.0)
                {
                    if(r.NextDouble() < vratio) angle = 90.0;
                }
                float fontsize = (float)(((e.SizeValue - minSize) * fontMultiplier) + MinFontSize);
                ImageSurface bm;
            imgretry:
                bm = CreateImage(e.Word,fontsize,e.Color,angle);
                // test if it fits
                if(angle == 90.0) {
                    if(bm.Height > ActualHeight) {
                        if(ActualWidth > ActualHeight) {
                            angle = 0.0;
                            bm.Destroy();
                            bm = null;
                            goto imgretry;
                        }
                        // crop the end
                        ImageSurface bm2 = new ImageSurface(Format.Argb32,bm.Width,(int)(ActualHeight*0.95));
                        Context g2 = new Context(bm2);
                        g2.SetSource(bm,0,ActualHeight-bm.Height);
                        g2.Paint();
                        ((IDisposable)g2).Dispose();
                        bm.Destroy();
                        bm = bm2;
                    }
                }
                else {
                    if(bm.Width > ActualWidth) {
                        if(ActualHeight > ActualWidth) {
                            angle = 90.0;
                            bm.Destroy();
                            bm = null;
                            goto imgretry;
                        }
                        // crop the end
                        ImageSurface bm2 = new ImageSurface(Format.Argb32,(int)(ActualWidth*0.95),bm.Height);
                        Context g2 = new Context(bm2);
                        g2.SetSource(bm,0,0);
                        g2.Paint();
                        ((IDisposable)g2).Dispose();
                        bm.Destroy();
                        bm = bm2;
                    }
                }
                //WordBitmap bm2 = new WordBitmap(bm);
                Dictionary<Point, List<Point>> lst = CreateCollisionList(bm);
                bool collided = true;
                do
                {
                    Point spiralPoint = GetSpiralPoint(position);
                    int offsetX = (bm.Width / 2);
                    int offsetY = (bm.Height / 2);
                    var testPoint = new Point((int)(spiralPoint.X + centre.X - offsetX), (int)(spiralPoint.Y + centre.Y - offsetY));
                    if (position > (2 * Math.PI) * 580)
                    {
                        //bm2.Dispose();
                        if (++currentPoint >= points.Length)
                            goto done;
              					goto again;
                    }
                    int cols = CountCollisions(testPoint, lst);
                    if (cols == 0)
                    {
                    tryagain:
                        double oldY = testPoint.Y;
                        if (Math.Abs(testPoint.X + offsetX - centre.X) > 10)
                        {
                            if (testPoint.X + offsetX < centre.X)
                            {
                                do
                                {
                                    testPoint.X += 2;
                                } while (testPoint.X + offsetX < centre.X && CountCollisions(testPoint, lst) == 0);
                                testPoint.X -= 2;
                            }
                            else
                            {
                                do
                                {
                                    testPoint.X -= 2;
                                } while (testPoint.X + offsetX > centre.X && CountCollisions(testPoint, lst) == 0);
                                testPoint.X += 2;
                            }
                        }
                        if (Math.Abs(testPoint.Y + offsetY - centre.Y) > 10)
                        {
                            if (testPoint.Y + offsetY < centre.Y)
                            {
                                do
                                {
                                    testPoint.Y += 2;
                                } while (testPoint.Y + offsetY < centre.Y && CountCollisions(testPoint, lst) == 0);
                                testPoint.Y -= 2;
                            }
                            else
                            {
                                do
                                {
                                    testPoint.Y -= 2;
                                } while (testPoint.Y + offsetY > centre.Y && CountCollisions(testPoint, lst) == 0);
                                testPoint.Y += 2;
                            }
                            if (testPoint.Y != oldY)
                                goto tryagain;
                        }

                        collided = false;
                        CopyBits(testPoint, bm, lst, Entries.IndexOf(e));
                        Console.Error.WriteLine("id: {0}, word: {1}, score: {7}, fontsize: {8}," +
                            "x: {2}, y: {3}, w: {4}, h: {5}, angle: {6}",id,e.Word,testPoint.X,testPoint.Y,
                                             bm.Width,bm.Height,angle,e.SizeValue,fontsize);
                        id++;
                        bm.Destroy();
                        if(svg != null) {
                            svg.SetFontSize(fontsize);
                            TextExtents te2 = svg.TextExtents(e.Word);
                            svg.Save();

                            if(angle == 90.0) {
                                svg.MoveTo(testPoint.X-te2.YBearing,testPoint.Y+te2.Width+te2.XBearing);
                                svg.Rotate(-0.5*Math.PI);
                            }
                            else {
                                svg.MoveTo(testPoint.X-te2.XBearing,testPoint.Y-te2.YBearing);
                            }
                            svg.Color = e.Color;
                            svg.ShowText(e.Word);
                            svg.Restore();
                        }
                        if(pdf != null) {
                            pdf.SetFontSize(fontsize);
                            TextExtents te2 = pdf.TextExtents(e.Word);
                            pdf.Save();

                            if(angle == 90.0) {
                                pdf.MoveTo(testPoint.X-te2.YBearing,testPoint.Y+te2.Width+te2.XBearing);
                                pdf.Rotate(-0.5*Math.PI);
                            }
                            else {
                                pdf.MoveTo(testPoint.X-te2.XBearing,testPoint.Y-te2.YBearing);
                            }
                            pdf.Color = e.Color;
                            pdf.ShowText(e.Word);
                            pdf.Restore();
                        }
                    }
                    else
                    {
                        if (cols <= 2)
                        {
                            position += (2 * Math.PI) / 100;
                        }
                        else

                            position += (2 * Math.PI) / 40;
                    }
                } while (collided);
            }
            done:
            ((IDisposable)g).Dispose();
            if(svgfn != null) ((IDisposable)svg).Dispose();
            if(pdffn != null) ((IDisposable)pdf).Dispose();
            Console.Error.WriteLine("# {0} words placed",id);
        }
Beispiel #35
0
        protected override void onDraw(Context gr)
        {
            base.onDraw (gr);

            gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
            gr.SetFontSize (Font.Size);
            gr.FontOptions = Interface.FontRenderingOptions;
            gr.Antialias = Interface.Antialias;

            rText = new Rectangle (new Size (
                measureRawSize (LayoutingType.Width), measureRawSize (LayoutingType.Height)));
            rText.Width -= 2 * Margin;
            rText.Height -= 2 * Margin;

            widthRatio = 1f;
            heightRatio = 1f;

            Rectangle cb = ClientRectangle;

            //ignore text alignment if size to content = true
            //or if text size is larger than client bounds
            if (Width < 0 || Height < 0 || rText.Width > cb.Width) {
                rText.X = cb.X;
                rText.Y = cb.Y;
            } else {
                if (horizontalStretch) {
                    widthRatio = (float)cb.Width / rText.Width;
                    if (!verticalStretch)
                        heightRatio = widthRatio;
                }
                if (verticalStretch) {
                    heightRatio = (float)cb.Height / rText.Height;
                    if (!horizontalStretch)
                        widthRatio = heightRatio;
                }

                rText.Width = (int)(widthRatio * cb.Width);
                rText.Height = (int)(heightRatio * cb.Height);

                switch (TextAlignment) {
                case Alignment.TopLeft:     //ok
                    rText.X = cb.X;
                    rText.Y = cb.Y;
                    break;
                case Alignment.Top:   //ok
                    rText.Y = cb.Y;
                    rText.X = cb.X + cb.Width / 2 - rText.Width / 2;
                    break;
                case Alignment.TopRight:    //ok
                    rText.Y = cb.Y;
                    rText.X = cb.Right - rText.Width;
                    break;
                case Alignment.Left://ok
                    rText.X = cb.X;
                    rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
                    break;
                case Alignment.Right://ok
                    rText.X = cb.X + cb.Width - rText.Width;
                    rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
                    break;
                case Alignment.Bottom://ok
                    rText.X = cb.Width / 2 - rText.Width / 2;
                    rText.Y = cb.Height - rText.Height;
                    break;
                case Alignment.BottomLeft://ok
                    rText.X = cb.X;
                    rText.Y = cb.Bottom - rText.Height;
                    break;
                case Alignment.BottomRight://ok
                    rText.Y = cb.Bottom - rText.Height;
                    rText.X = cb.Right - rText.Width;
                    break;
                case Alignment.Center://ok
                    rText.X = cb.X + cb.Width / 2 - rText.Width / 2;
                    rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
                    break;
                }
            }

            gr.FontMatrix = new Matrix (widthRatio * Font.Size, 0, 0, heightRatio * Font.Size, 0, 0);

            int curLineCount = 0;
            for (int i = 0; i < lines.Count; i++) {
                string l = lines [i].Replace ("\t", new String (' ', Interface.TabSize));
                List<string> wl = new List<string> ();
                int lineLength = (int)gr.TextExtents (l).XAdvance;

                if (wordWrap && lineLength > cb.Width) {
                    string tmpLine = "";
                    int curChar = 0;
                    while (curChar < l.Length) {
                        tmpLine += l [curChar];
                        if ((int)gr.TextExtents (tmpLine).XAdvance > cb.Width) {
                            tmpLine = tmpLine.Remove (tmpLine.Length - 1);
                            wl.Add (tmpLine);
                            tmpLine = "";
                            continue;
                        }
                        curChar++;
                    }
                    wl.Add (tmpLine);
                } else
                    wl.Add (l);

                foreach (string ll in wl) {
                    lineLength = (int)gr.TextExtents (ll).XAdvance;

                    if (string.IsNullOrWhiteSpace (ll)) {
                        curLineCount++;
                        continue;
                    }

                    Foreground.SetAsSource (gr);
                    gr.MoveTo (rText.X, rText.Y + fe.Ascent + fe.Height * curLineCount);

                    gr.ShowText (ll);
                    gr.Fill ();

                    curLineCount++;
                }
            }
        }
        protected override bool OnExposed(Context cr, Rectangle area)
        {
            cr.Save();
            if(!base.OnExposed(cr, area))
            {
                cr.Color = new Color(1.0, 0.0, 0.0);
                cr.SetFontSize(100.0);
                cr.SelectFontFace("Librarian", FontSlant.Normal, FontWeight.Bold);
                cr.ShowText(type.ToString());
                cr.Restore();
                return true;
            }
            cr.Restore();

            if(type != CardType.Unknown)
            {
                ApplyConstriction(cr);
                double ratio = Allocation.Height / Card.DefaultHeight;
                cr.Scale(ratio, ratio);
                cr.Translate(RankOffsetX, RankOffsetY);
                Pango.CairoHelper.ShowLayout(cr, layout);
                cr.LineWidth = 2.0;
                cr.Color = new Color(1, 1, 1);
                cr.LineCap = LineCap.Butt;
                cr.LineJoin = LineJoin.Round;
                Pango.CairoHelper.LayoutPath(cr, layout);
                cr.Stroke();
            }
            return true;
        }
Beispiel #37
0
		public static void Draw (Context grw, TextElement text)
		{
			double dY = 0;

			if (text.Foregraund != null) {
				grw.SetSourceRGB (
					text.Foregraund.Red, 
					text.Foregraund.Green, 
					text.Foregraund.Blue);
			}

			grw.SelectFontFace (
				text.FontFamily, 
				FontSlant.Normal, 
				(FontWeight)text.Weight);

			grw.SetFontSize (text.ScaledFontSize);
			var te = grw.TextExtents (text.Text);

			double dX = 0;
			if (text.Align != null) {
				switch (text.Align.ToLowerInvariant()) {
				case AlignType.Center:
					dX = 0.5 * te.Width;

					break;
				case AlignType.Right:
					dX = te.Width;

					break;
				case AlignType.Left:
					dX = 0;
					break;
				default:					
					return;
				}
			}

			if (text.VAlign != null) {
				switch (text.VAlign.ToLowerInvariant ()) {
				case VAlignType.Top:
					dY = te.YBearing;
					break;
				case VAlignType.Center:
					dY = 0.5 * te.YBearing;
					break;
				case VAlignType.Bottom:
					dY = 0;
					break;
				default:					
					return;
				}
			}

			grw.MoveTo (
				text.Start.GeometryX - dX, 
				text.Start.GeometryY - dY);

			grw.ShowText (text.FormattedText);

			grw.Stroke ();
		}
        static void SetupContext(Context g, string fontName, FontSlant fontSlant, FontWeight fontWeight, double fontSize)
        {
            FontOptions fo = new FontOptions();

            fo.Antialias = Antialias.Gray;
            fo.HintStyle = HintStyle.Full;

            g.FontOptions = fo;
            g.SelectFontFace(fontName, fontSlant, fontWeight);
            g.SetFontSize(fontSize);
            g.Color = new Color(1.0, 1.0, 1.0);
        }
 protected override bool OnExposed(Context cr, Rectangle area)
 {
     cr.Save();
     if(!base.OnExposed(cr, area))
     {
         cr.Color = new Color(1.0, 0.0, 1.0);
         cr.Rectangle(new Rectangle(2.0, 2.0, Allocation.Width - 4.0, Allocation.Height - 4.0));
         cr.LineWidth = 4.0;
         cr.LineJoin = LineJoin.Round;
         cr.Stroke();
         cr.SetFontSize(20.0);
         cr.SelectFontFace("Librarian", FontSlant.Normal, FontWeight.Bold);
         cr.Translate(0.0, Allocation.Height / 2);
         cr.ShowText(type.ToString());
         cr.Restore();
         return true;
     }
     cr.Restore();
     return true;
 }
Beispiel #40
0
 protected void UseStandardLineDrawing(Context g)
 {
     g.Antialias = Antialias.Subpixel;
     g.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Normal); //Draw backround reference lines.
     g.SetFontSize (12);
     g.SetSourceRGB (referenceLineColor, referenceLineColor, referenceLineColor);
     g.LineWidth = 2;
 }
 public void Text(Context context,  string txt, HorizontalTextAlignment horizontal = HorizontalTextAlignment.Center, VerticalTextAlignment vertical = VerticalTextAlignment.Middle)
 {
     context.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Normal);
     //context.SetFontSize (_surface.Height / 10);
     context.SetFontSize (14);
     var extends = context.TextExtents (txt);
     double x, y;
     x = -(((double)horizontal) / 2 * extends.Width + extends.XBearing);
     y = -(((double)vertical) / 2 * extends.Height + extends.YBearing);
     context.RelMoveTo (x, y);
     context.ShowText (txt);
 }
Beispiel #42
0
    private void DrawGraphGrid()
    {
        using (Context GridGraphCtx = new Context(ScaleGraph))
        {
            GridGraphCtx.Antialias = Antialias.Subpixel;
            GridGraphCtx.Color = new Cairo.Color(0, 0, 0);
            GridGraphCtx.LineWidth = 0.6;
            GridGraphCtx.SelectFontFace("Purisa", FontSlant.Normal, FontWeight.Normal);
            GridGraphCtx.SetFontSize(10);

            ClearGraph(GridGraphCtx);

            GCurves.GCurve tmp;
            AllCurves.Curves.TryGetValue(CurveSelectBox.ActiveText, out tmp);

            if (tmp != null)
            {
                double min = tmp.min;
                double max = tmp.max;
                int width = GraphArea.Allocation.Width;
                int height = GraphArea.Allocation.Height;

                if (AllFiles.Count > 1)
                {
                    double Xp = GetGraphXY(new PointF(AllFiles.Count - 1, 0)).X;
                    double Xm = GetGraphXY(new PointF(0, 0)).X;

                    //drawing the X scale lines
                    double f = (Xp - Xm) / 10;

                    for (int i = 0; i <= 10; i++)
                    {
                        GridGraphCtx.MoveTo((int)(GrBorLeft + (f * i)) + 0.5, (int)(height - GrBor + 8) + 0.5);
                        GridGraphCtx.LineTo((int)(GrBorLeft + (f * i)) + 0.5, GrBor + 0.5);
                    }

                    //X-axis label
                    GridGraphCtx.MoveTo(GrBor + 12, height - 5);
                    GridGraphCtx.ShowText("1");
                    if (AllFiles.Count >= 10) { GridGraphCtx.MoveTo(Xp - 10, height - 5); }
                    else if (AllFiles.Count >= 100) { GridGraphCtx.MoveTo(Xp - 25, height - 5); }
                    else if (AllFiles.Count >= 1000) { GridGraphCtx.MoveTo(Xp - 40, height - 5); }
                    else if (AllFiles.Count >= 10000) { GridGraphCtx.MoveTo(Xp - 55, height - 5); }
                    else { GridGraphCtx.MoveTo(Xp - 5, height - 5); }
                    GridGraphCtx.ShowText(AllFiles.Count.ToString());

                    //drawing the Y scale lines
                    for (int i = 0; i <= 10; i++)
                    {
                        GridGraphCtx.MoveTo((int)(GrBorLeft - 8) + 0.5, (int)(height - GrBor - (((height - (2 * GrBor)) / 10) * i)) + 0.5);
                        GridGraphCtx.LineTo((int)Xp + 0.5, (int)(height - GrBor - (((height - (2 * GrBor)) / 10) * i)) + 0.5);
                    }

                    //Y-axis label
                    GridGraphCtx.MoveTo(3, height - GrBor);
                    GridGraphCtx.ShowText(min.ToString("N2"));
                    GridGraphCtx.MoveTo(3, GrBor);
                    GridGraphCtx.ShowText(max.ToString("N2"));
                    GridGraphCtx.Stroke();
                }
            }
        }
    }
Beispiel #43
0
        protected override void onDraw(Context gr)
        {
            base.onDraw (gr);

            gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
            gr.SetFontSize (Font.Size);
            gr.FontOptions = Interface.FontRenderingOptions;
            gr.Antialias = Interface.Antialias;

            rText = new Rectangle(new Size(
                measureRawSize(LayoutingType.Width), measureRawSize(LayoutingType.Height)));
            rText.Width -= 2 * Margin;
            rText.Height -= 2 * Margin;

            widthRatio = 1f;
            heightRatio = 1f;

            Rectangle cb = ClientRectangle;

            rText.X = cb.X;
            rText.Y = cb.Y;

            if (horizontalStretch) {
                widthRatio = (float)cb.Width / (float)rText.Width;
                if (!verticalStretch)
                    heightRatio = widthRatio;
            }

            if (verticalStretch) {
                heightRatio = (float)cb.Height / (float)rText.Height;
                if (!horizontalStretch)
                    widthRatio = heightRatio;
            }

            rText.Width = (int)(widthRatio * (float)rText.Width);
            rText.Height = (int)(heightRatio * (float)rText.Height);

            switch (TextAlignment)
            {
            case Alignment.TopLeft:     //ok
                rText.X = cb.X;
                rText.Y = cb.Y;
                break;
            case Alignment.Top:   //ok
                rText.Y = cb.Y;
                rText.X = cb.X + cb.Width / 2 - rText.Width / 2;
                break;
            case Alignment.TopRight:    //ok
                rText.Y = cb.Y;
                rText.X = cb.Right - rText.Width;
                break;
            case Alignment.Left://ok
                rText.X = cb.X;
                rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
                break;
            case Alignment.Right://ok
                rText.X = cb.X + cb.Width - rText.Width;
                rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
                break;
            case Alignment.Bottom://ok
                rText.X = cb.Width / 2 - rText.Width / 2;
                rText.Y = cb.Height - rText.Height;
                break;
            case Alignment.BottomLeft://ok
                rText.X = cb.X;
                rText.Y = cb.Bottom - rText.Height;
                break;
            case Alignment.BottomRight://ok
                rText.Y = cb.Bottom - rText.Height;
                rText.X = cb.Right - rText.Width;
                break;
            case Alignment.Center://ok
                rText.X = cb.X + cb.Width / 2 - rText.Width / 2;
                rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
                break;
            }

            gr.FontMatrix = new Matrix(widthRatio * (float)Font.Size, 0, 0, heightRatio * (float)Font.Size, 0, 0);
            fe = gr.FontExtents;

            #region draw text cursor
            if (HasFocus && Selectable)
            {
                if (mouseLocalPos >= 0)
                {
                    computeTextCursor(gr);

                    if (SelectionInProgress)
                    {
                        if (SelBegin < 0){
                            SelBegin = new Point(CurrentColumn, CurrentLine);
                            SelStartCursorPos = textCursorPos;
                            SelRelease = -1;
                        }else{
                            SelRelease = new Point(CurrentColumn, CurrentLine);
                            if (SelRelease == SelBegin)
                                SelRelease = -1;
                            else
                                SelEndCursorPos = textCursorPos;
                        }
                    }
                }else
                    computeTextCursorPosition(gr);

                Foreground.SetAsSource (gr);
                gr.LineWidth = 1.0;
                gr.MoveTo (0.5 + textCursorPos + rText.X, rText.Y + CurrentLine * fe.Height);
                gr.LineTo (0.5 + textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * fe.Height);
                gr.Stroke();
            }
            #endregion

            //****** debug selection *************
            //			if (SelRelease >= 0) {
            //				gr.Color = Color.Green;
            //				Rectangle R = new Rectangle (
            //					             rText.X + (int)SelEndCursorPos - 2,
            //					             rText.Y + (int)(SelRelease.Y * fe.Height),
            //					             4,
            //					             (int)fe.Height);
            //				gr.Rectangle (R);
            //				gr.Fill ();
            //			}
            //			if (SelBegin >= 0) {
            //				gr.Color = Color.UnmellowYellow;
            //				Rectangle R = new Rectangle (
            //					rText.X + (int)SelStartCursorPos - 2,
            //					rText.Y + (int)(SelBegin.Y * fe.Height),
            //					4,
            //					(int)fe.Height);
            //				gr.Rectangle (R);
            //				gr.Fill ();
            //			}
            //*******************

            for (int i = 0; i < lines.Count; i++) {
                string l = lines [i].Replace ("\t", new String (' ', Interface.TabSize));
                int lineLength = (int)gr.TextExtents (l).XAdvance;
                Rectangle lineRect = new Rectangle (
                    rText.X,
                    rText.Y + (int)Math.Ceiling(i * fe.Height),
                    lineLength,
                    (int)Math.Ceiling(fe.Height));

            //				if (TextAlignment == Alignment.Center ||
            //					TextAlignment == Alignment.Top ||
            //					TextAlignment == Alignment.Bottom)
            //					lineRect.X += (rText.Width - lineLength) / 2;
            //				else if (TextAlignment == Alignment.Right ||
            //					TextAlignment == Alignment.TopRight ||
            //					TextAlignment == Alignment.BottomRight)
            //					lineRect.X += (rText.Width - lineLength);
                if (Selectable) {
                    if (SelRelease >= 0 && i >= selectionStart.Y && i <= selectionEnd.Y) {
                        gr.SetSourceColor (selBackground);

                        Rectangle selRect = lineRect;

                        int cpStart = (int)SelStartCursorPos,
                        cpEnd = (int)SelEndCursorPos;

                        if (SelBegin.Y > SelRelease.Y) {
                            cpStart = cpEnd;
                            cpEnd = (int)SelStartCursorPos;
                        }

                        if (i == selectionStart.Y) {
                            selRect.Width -= cpStart;
                            selRect.Left += cpStart;
                        }
                        if (i == selectionEnd.Y)
                            selRect.Width -= (lineLength - cpEnd);

                        gr.Rectangle (selRect);
                        gr.Fill ();
                    }
                }

                if (string.IsNullOrWhiteSpace (l))
                    continue;

                Foreground.SetAsSource (gr);
                gr.MoveTo (lineRect.X, rText.Y + fe.Ascent + fe.Height * i);
                gr.ShowText (l);
                gr.Fill ();
            }
        }
Beispiel #44
0
        protected override int measureRawSize(LayoutingType lt)
        {
            if (lines == null)
                lines = getLines;

            using (ImageSurface img = new ImageSurface (Format.Argb32, 10, 10)) {
                using (Context gr = new Context (img)) {
                    //Cairo.FontFace cf = gr.GetContextFontFace ();

                    gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
                    gr.SetFontSize (Font.Size);

                    fe = gr.FontExtents;
                    te = new TextExtents();

                    if (lt == LayoutingType.Height){
                        int lc = lines.Count;
                        //ensure minimal height = text line height
                        if (lc == 0)
                            lc = 1;

                        return (int)Math.Ceiling(fe.Height * lc) + Margin * 2;
                    }

                    foreach (string s in lines) {
                        string l = s.Replace("\t", new String (' ', Interface.TabSize));

                        TextExtents tmp = gr.TextExtents (l);

                        if (tmp.XAdvance > te.XAdvance)
                            te = tmp;
                    }
                    return (int)Math.Ceiling (te.XAdvance) + Margin * 2;
                }
            }
        }
Beispiel #45
0
		public void text_extents(Context cr, int width, int height)
		{
			double x=0.1;
			double y=0.6;
			string utf8 = "cairo";
			Normalize (cr, width, height);

			cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Normal);

			cr.SetFontSize(0.4);
			TextExtents extents = cr.TextExtents(utf8);

			cr.MoveTo(x,y);
			cr.ShowText(utf8);

			// draw helping lines
			cr.Color = new Color (1, 0.2, 0.2, 0.6);
			cr.Arc(x, y, 0.05, 0, 2*Math.PI);
			cr.Fill();
			cr.MoveTo(x,y);
			cr.RelLineTo(0, -extents.Height);
			cr.RelLineTo(extents.Width, 0);
			cr.RelLineTo(extents.XBearing, -extents.YBearing);
			cr.Stroke();
		}
Beispiel #46
0
		public void text_align_center(Context cr, int width, int height)
		{
			Normalize (cr, width, height);

			cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Normal);
			cr.SetFontSize(0.2);
			TextExtents extents = cr.TextExtents("cairo");
			double x = 0.5 -((extents.Width/2.0) + extents.XBearing);
			double y = 0.5 -((extents.Height/2.0) + extents.YBearing);

			cr.MoveTo(x, y);
			cr.ShowText("cairo");

			// draw helping lines
			cr.Color = new Color (1, 0.2, 0.2, 0.6);
			cr.Arc(x, y, 0.05, 0, 2*Math.PI);
			cr.Fill();
			cr.MoveTo(0.5, 0);
			cr.RelLineTo(0, 1);
			cr.MoveTo(0, 0.5);
			cr.RelLineTo(1, 0);
			cr.Stroke();
		}
Beispiel #47
0
 public static void SetFontFaceNormal(Context ctx)
 {
     ctx.SelectFontFace("Arial",FontSlant.Normal,FontWeight.Normal);
     ctx.SetFontSize(12.0d);
 }
Beispiel #48
0
        private void DrawOnHandPieces(Context cr, Position pos, bool BlackPlayer)
        {
            cr.Save();
            cr.Rectangle(0, 0, ON_HAND_AREA_WIDTH, 9 * FIELD_SIZE + 2 * FIELD_NAMING_SIZE);
            cr.Color = BorderColor;
            cr.FillPreserve();
            cr.Color = new Color(0.6, 0.5, 0.55);
            cr.LineWidth = 3;
            cr.Stroke();

            if (BlackPlayer)
            {
                cr.Translate(0, 8 * FIELD_SIZE + 2 * FIELD_NAMING_SIZE);
            }

            for (int i = 0; i < (int)PieceType.PIECE_TYPES_COUNT; i++)
            {
                int player_nr = BlackPlayer ? 0 : 1;
                if (pos.OnHandPieces[player_nr, i] != 0)
                {
                    //highlight selected piece
                    if (gi != null && gi.localPlayerMoveState != LocalPlayerMoveState.Wait
                        && gi.localPlayerMoveState != LocalPlayerMoveState.PickSource
                        && gi.GetLocalPlayerMove().OnHandPiece != PieceType.NONE
                        && gi.GetLocalPlayerMove().OnHandPiece == (PieceType)i
                        && !((gi.CurPlayer == gi.BlackPlayer) ^ BlackPlayer))
                    {
                        cr.Rectangle(0, 0, FIELD_SIZE, FIELD_SIZE);
                        cr.Color = new Color(0.8, 0.835, 0.4);
                        cr.Fill();
                    }

                    //draw piece
                    cr.Save();
                    if (!BlackPlayer)
                    {
                        cr.Rotate(180 * Math.PI / 180);
                        cr.Translate(-FIELD_SIZE, -FIELD_SIZE);
                    }
                    cr.Scale(FIELD_SIZE / PieceGraphics[i].Dimensions.Width, FIELD_SIZE / PieceGraphics[i].Dimensions.Width);
                    PieceGraphics[i].RenderCairo(cr);
                    cr.Restore();

                    //draw amount
                    cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Normal);
                    cr.SetFontSize(FIELD_SIZE / 3 * 0.9);
                    cr.Color = new Color(0, 0, 0);

                    String amount_str = "x " + pos.OnHandPieces[player_nr, i].ToString();
                    TextExtents extents = cr.TextExtents(amount_str);
                    double x = (FIELD_SIZE);
                    // - (extents.Width/2 + extents.XBearing);
                    double y = (FIELD_SIZE / 2) - (extents.Height / 2 + extents.YBearing);

                    cr.MoveTo(x, y);
                    cr.ShowText(amount_str);

                    double offset = BlackPlayer ? -FIELD_SIZE - PADDING : FIELD_SIZE + PADDING;
                    cr.Translate(0, offset);
                }
            }
            cr.Restore();
        }
Beispiel #49
0
        private Pixbuf PixbufText(string text, int size, bool transparent)
        {
            int x=0, y=36;

            surface = new Cairo.ImageSurface(Cairo.Format.Argb32,  800, 600);
            cr = new Cairo.Context(surface);

            if (!transparent) {
                cr.SetSourceRGBA (0.0, 0.0, 0.0, 1.0);
                cr.Rectangle (new Cairo.Rectangle (0, 0, 800, 600));
                cr.Fill ();
            }

            //cr.MoveTo(x, y);
            string font = "sans";
            if (Util.IsWindows ()) {
                font = "MS Gothic";
            }
            if (Util.IsLinux ()) {
                font = "TakaoGothic";
            }
            if (Util.IsMac ()) {
                font = "Hiragino Kaku Gothic ProN";
            }

            cr.SelectFontFace(font, Cairo.FontSlant.Normal, Cairo.FontWeight.Bold);
            cr.SetFontSize(size);

            Cairo.TextExtents extents = cr.TextExtents(text);
            string[] lines = text.Split ('\n');
            int min = size;
            for (int i = 0; i < lines.Length; i++) {
                string line = lines[i];
                for (int j = size; j > 8; j-=4) {
                    extents = cr.TextExtents(line);
                    if(extents.Width+extents.XBearing<800){
                        if(j<min) min = j;
                        break;
                    }
                    cr.SetFontSize(j);
                }
            }
            cr.SetFontSize(min);

            //string[] lines = text.Split ('\n');
            for (int i = 0; i < lines.Length; i++) {
                DrawText (cr, lines[i], x, y);
                y += (int)extents.Height;
                if (i > 5)
                    break;
            }

            Pixbuf buf = new Gdk.Pixbuf (surface.Data, true, 8, surface.Width, surface.Height, surface.Stride);
            return buf;

            //buf.Save ("aaa.png", "png");
            //surface.WriteToPng (file);
        }
        private void RenderSkillCell(Context context, Gdk.Rectangle pix_rect, bool isSelected)
        {
            int osOffset = 0;
            int startX = pix_rect.Right - 64;

            if(ECM.Helper.CurrentPlatform == ECM.Helper.Platform.Windows)
                osOffset = 1;

            // Render Text
            context.Save();

            Color col = White;

            //if (!isSelected)
            //    col = Black;

            string s = string.Format("{0} ({1}x)", Text, SkillRank);
            TextExtents te = context.TextExtents(s);
            RenderText(context, s, pix_rect.X + 32, pix_rect.Y + 2, col);

            s = string.Format("Level {0}", SkillLevel);
            te = context.TextExtents(s);
            RenderText(context, s, startX - (te.Width + 6), pix_rect.Y + 2, col);

            s = ECM.Helper.GetDurationInWordsShort(TimeSpan.FromMinutes(SkillMinsToNext));
            te = context.TextExtents(s);
            RenderText(context, s, startX - (te.Width + 6), pix_rect.Y + te.Height + 6, col);

            s = string.Format("SP {0:0,0}/{1:0,0}", SkillCurrSP, SkillNextSP);
            context.SelectFontFace(m_FontDesc.Family, FontSlant.Normal, FontWeight.Bold);
            te = context.TextExtents(s);

            RenderText(context, s, pix_rect.X + 32, pix_rect.Y + te.Height + 6, col);

            context.Restore();

            // Render Progress bars
            context.Save();

            context.Color = Gray;
            context.Antialias = Antialias.None;
            context.LineWidth = 1;

            for (int i = 0; i < SkillLevel; i++)
            {
                context.Rectangle(startX + 2 + i * 9, pix_rect.Y + 3 + osOffset, 8, 6);
            }

            // Time Bar
            double fullWidth = 44;
            double dist = SkillNextSP - SkillLevlSP;
            double trav = SkillCurrSP - SkillLevlSP;
            double perc = 1;

            if(dist > 0)
                perc = Math.Max(0, trav / dist);

            context.Rectangle(startX + 2, pix_rect.Y + 17 + osOffset, fullWidth * perc, 2);

            context.Fill();

            context.Rectangle(startX, pix_rect.Y + 2, 47, 9);

            context.Rectangle(startX, pix_rect.Y + 16, 47, 5);

            context.Stroke();

            context.Restore();

            // Render Skillbook Icon
            context.Save();
            Gdk.CairoHelper.SetSourcePixbuf(context, new Gdk.Pixbuf(ECM.Core.SkillbookPNG), pix_rect.X, pix_rect.Y);

            context.Paint();
            context.Restore();
        }
Beispiel #51
0
        private void DrawBoard(Context cr, Position pos)
        {
            Console.WriteLine("ShogibanSVG.DrawBoard");
            #region board border
            //Top
            cr.Rectangle(0, 0, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE, FIELD_NAMING_SIZE);
            //Left
            cr.Rectangle(0, 0, FIELD_NAMING_SIZE, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE);
            //Bottom
            cr.Rectangle(0, Game.BOARD_SIZE * FIELD_SIZE + FIELD_NAMING_SIZE, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE, FIELD_NAMING_SIZE);
            //Right
            cr.Rectangle(9*FIELD_SIZE + FIELD_NAMING_SIZE, 0, FIELD_NAMING_SIZE, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE);
            cr.Color = BorderColor;
            cr.Fill();
            #endregion

            #region field namings
            cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Normal);
            cr.SetFontSize(FIELD_NAMING_SIZE * 0.9);
            cr.Color = new Color(0, 0, 0);

            for (int i = 0; i < VerticalNamings.Length; i++)
            {
                TextExtents extents = cr.TextExtents(VerticalNamings[i].ToString());
                double x = (FIELD_NAMING_SIZE/2) - (extents.Width/2 + extents.XBearing);
                double y = (FIELD_NAMING_SIZE + i*FIELD_SIZE + FIELD_SIZE/2) - (extents.Height/2 + extents.YBearing);

                cr.MoveTo(x, y);
                cr.ShowText(VerticalNamings[i].ToString());
                cr.MoveTo(x + 9*FIELD_SIZE + FIELD_NAMING_SIZE, y);
                cr.ShowText(VerticalNamings[i].ToString());
            }
            for (int i = 0; i < HorizontalNamings.Length; i++)
            {
                TextExtents extents = cr.TextExtents(HorizontalNamings[i].ToString());
                double x = (FIELD_NAMING_SIZE + i*FIELD_SIZE + FIELD_SIZE/2) - (extents.Width/2 + extents.XBearing);
                double y = (FIELD_NAMING_SIZE/2) - (extents.Height/2 + extents.YBearing);

                cr.MoveTo(x, y);
                cr.ShowText(HorizontalNamings[Game.BOARD_SIZE-i-1].ToString());
                cr.MoveTo(x, y + 9*FIELD_SIZE + FIELD_NAMING_SIZE);
                cr.ShowText(HorizontalNamings[Game.BOARD_SIZE-i-1].ToString());
            }
            #endregion

            #region board playfield
            //background
            cr.Translate(FIELD_NAMING_SIZE, FIELD_NAMING_SIZE);
            cr.Rectangle(0, 0, Game.BOARD_SIZE * FIELD_SIZE, Game.BOARD_SIZE * FIELD_SIZE);
            cr.Color = BoardColor;
            cr.Fill();

            if (gi != null)
            {
                //highlight selected piece field
                if (gi.localPlayerMoveState != LocalPlayerMoveState.Wait
                    && gi.localPlayerMoveState != LocalPlayerMoveState.PickSource
                    && CurMoveNr < 0)
                {
                    if (gi.GetLocalPlayerMove().OnHandPiece == PieceType.NONE)
                    {
                        cr.Rectangle((Game.BOARD_SIZE - gi.GetLocalPlayerMove().From.x - 1) * FIELD_SIZE, gi.GetLocalPlayerMove().From.y * FIELD_SIZE, FIELD_SIZE, FIELD_SIZE);
                        cr.Color = SelectedFieldColor;
                        cr.Fill();
                    }
                }

                //highlight last move
                if (gi.Moves.Count > 0 && CurMoveNr != 0)
                {
                    Move move;
                    if (CurMoveNr < 0)
                        move = gi.Moves[gi.Moves.Count-1].move;
                    else
                        move = gi.Moves[CurMoveNr - 1].move;

                    if (move.OnHandPiece == PieceType.NONE)
                    {
                        cr.Rectangle((Game.BOARD_SIZE - move.From.x - 1) * FIELD_SIZE, move.From.y * FIELD_SIZE, FIELD_SIZE, FIELD_SIZE);
                    }
                    cr.Rectangle((Game.BOARD_SIZE - move.To.x - 1) * FIELD_SIZE, move.To.y * FIELD_SIZE, FIELD_SIZE, FIELD_SIZE);
                    cr.Color = LastMoveFieldColor;
                    cr.Fill();
                }

                //highlight possible moves
                if (gi.localPlayerMoveState == LocalPlayerMoveState.PickDestination && CurMoveNr < 0)
                {
                    ValidMoves Moves;
                    Move LocalPlayerMove = gi.GetLocalPlayerMove();
                    if (LocalPlayerMove.OnHandPiece == PieceType.NONE)
                    {
                        Moves = pos.GetValidBoardMoves(LocalPlayerMove.From);
                    }
                    else
                    {
                        Moves = pos.GetValidOnHandMoves(LocalPlayerMove.OnHandPiece, gi.CurPlayer == gi.BlackPlayer);
                    }

                    foreach (BoardField Field in Moves)
                    {
                        cr.Rectangle((Game.BOARD_SIZE - Field.x - 1) * FIELD_SIZE, Field.y * FIELD_SIZE, FIELD_SIZE, FIELD_SIZE);
                        cr.Color = PossibleMoveColor;
                        cr.Fill();
                    }
                }
            }

            //dividing lines
            for (int i = 0; i <= Game.BOARD_SIZE; i++)
            {
                cr.MoveTo(0, i * FIELD_SIZE);
                cr.LineTo(Game.BOARD_SIZE * FIELD_SIZE, i * FIELD_SIZE);
            }
            for (int i = 0; i <= Game.BOARD_SIZE; i++)
            {
                cr.MoveTo(i * FIELD_SIZE, 0);
                cr.LineTo(i * FIELD_SIZE, Game.BOARD_SIZE * FIELD_SIZE);
            }
            cr.Color = new Color(0, 0, 0);
            cr.LineWidth = 2.5;
            cr.LineCap = LineCap.Round;
            cr.Stroke();
            #endregion

            DrawPieces(cr, pos);

            //draw promotion choice area
            if (gi != null && gi.localPlayerMoveState == LocalPlayerMoveState.PickPromotion && CurMoveNr < 0)
            {
                double PromotionChoiceAreaStartX = (Game.BOARD_SIZE - gi.GetLocalPlayerMove().To.x - 1) * FIELD_SIZE - FIELD_SIZE / 2;
                double PromotionChoiceAreaStartY = gi.GetLocalPlayerMove().To.y * FIELD_SIZE;

                cr.Save();
                //draw boarder
                cr.Translate(PromotionChoiceAreaStartX - PADDING,
                    PromotionChoiceAreaStartY - PADDING);
                cr.Rectangle(0, 0, 2 * FIELD_SIZE + 2 * PADDING, FIELD_SIZE + 2 * PADDING);
                cr.Color = new Color(0, 0, 0);
                cr.Fill();

                cr.Translate(PADDING, PADDING);
                cr.Rectangle(0, 0, 2 * FIELD_SIZE, FIELD_SIZE);
                cr.Color = BoardColor;
                cr.Fill();

                Move LocalPlayerMove = gi.GetLocalPlayerMove();
                FieldInfo From = pos.Board[LocalPlayerMove.From.x, LocalPlayerMove.From.y];
                DrawPiece(cr, From.Piece, From.Direction, 0, 0);
                DrawPiece(cr, From.Piece.GetPromotedPiece(), From.Direction, FIELD_SIZE, 0);

                cr.Restore();
            }
        }
Beispiel #52
0
 protected void DrawTitle(Context g, String name)
 {
     g.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold); //Draw the title and line names/colors.
     g.SetFontSize (14);
     g.SetSourceRGBA (0, 0, 0, 0.5f);
     g.MoveTo (NumberSpacingXLeft+15, NumberSpacingYUp+7);
     g.ShowText (name);
 }
Beispiel #53
0
		public void text(Context cr, int width, int height)
		{
			Normalize (cr, width, height);
			cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Bold);
			cr.SetFontSize(0.35);

			cr.MoveTo(0.04, 0.53);
			cr.ShowText("Hello");

			cr.MoveTo(0.27, 0.65);
			cr.TextPath("void");
			cr.Save();
			cr.Color = new Color (0.5,0.5,1);
			cr.Fill();
			cr.Restore();
			cr.LineWidth = 0.01;
			cr.Stroke();

			// draw helping lines
			cr.Color = new Color (1.0, 0.2, 0.2, 0.6);
			cr.Arc(0.04, 0.53, 0.02, 0, 2*Math.PI);
			cr.Arc(0.27, 0.65, 0.02, 0, 2*Math.PI);
			cr.Fill();
		}