当前位置: 首页>>代码示例>>C#>>正文


C# CairoContextEx.Rectangle方法代码示例

本文整理汇总了C#中gbrainy.Core.Main.CairoContextEx.Rectangle方法的典型用法代码示例。如果您正苦于以下问题:C# CairoContextEx.Rectangle方法的具体用法?C# CairoContextEx.Rectangle怎么用?C# CairoContextEx.Rectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gbrainy.Core.Main.CairoContextEx的用法示例。


在下文中一共展示了CairoContextEx.Rectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX + 0.2, y = DrawAreaY + 0.2, width = 0.4, height = 0.4;

            base.Draw (gr, area_width, area_height, rtl);

            gr.Rectangle (x, y, width, height);
            gr.Stroke ();

            gr.MoveTo (x, y + 0.1);
            gr.LineTo (x + width, y + 0.1);  // First horizontal
            gr.Stroke ();

            gr.MoveTo (x, y + 0.3);
            gr.LineTo (x + width - 0.1, y + 0.3); // Second horizontal
            gr.Stroke ();

            gr.MoveTo (x + 0.1, y);
            gr.LineTo (x + 0.1, y + height);  // First vertical
            gr.Stroke ();

            gr.MoveTo (x + 0.3, y);
            gr.LineTo (x + 0.3, y + height - 0.1);  // Second vertical
            gr.Stroke ();
        }
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:25,代码来源:PuzzleSquareSheets.cs

示例2: Draw

        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double rect_w = DrawAreaWidth / rows;
            double rect_h = DrawAreaHeight / columns;

            base.Draw (gr, area_width, area_height, rtl);

            for (int column = 0; column < columns; column++) {
                for (int row = 0; row < rows; row++) {

                    gr.Color = DefaultDrawingColor;
                    gr.Rectangle (DrawAreaX + row * rect_w, DrawAreaY + column * rect_h, rect_w, rect_h);
                    gr.Stroke ();

                    gr.DrawTextCentered (DrawAreaX + (rect_w / 2) + column * rect_w, (rect_h / 2) + DrawAreaY + row * rect_h,
                        (numbers[column + (row * 4)]).ToString() );

                    if (numbers[column + (row * 4)] % divisor == 0 && good_pos != column + (row * 4)) {
                        gr.Arc (DrawAreaX + (rect_w / 2) + column * rect_w, (rect_h / 2) + DrawAreaY + row * rect_h,
                            0.05, 0, 2 * Math.PI);
                        gr.FillGradient (DrawAreaX + (rect_w / 2) + column * rect_w, (rect_h / 2) + DrawAreaY + row * rect_h,
                            0.05, 0.05);

                    }
                    gr.Stroke ();
                }
            }
        }
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:28,代码来源:PuzzleGridCircles.cs

示例3: Draw

        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            #if DESIGN_MODE
            gr.Save ();
            gr.Color = new Cairo.Color (1, 0, 0);
            gr.Rectangle (0, 0, Width, Height);
            gr.Stroke ();
            gr.Restore ();
            #endif

            if (hoover == true)
              			{
                double lw = gr.LineWidth;
                double [] dashes = {0.01,  /* ink */
                           0.01,  /* skip */ };

                gr.Save ();

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

                if (SelectedArea.Width == 0 && SelectedArea.Height == 0)
                    gr.Rectangle (-lw, -lw, Width + lw * 2, Height + lw * 2);
                else
                    gr.Rectangle (SelectedArea.X -lw, SelectedArea.Y -lw, SelectedArea.Width + lw * 2, SelectedArea.Height + lw * 2);

                gr.Stroke ();
                gr.Restore ();
            }

            if (DrawEventHandler == null)
                return;

            DrawEventHandler (this, new DrawEventArgs (gr, Width, Height, rtl, Data));
        }
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:35,代码来源:DrawableArea.cs

示例4: Draw

        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = X, y = Y;

            this.rtl = rtl;

            #if DESIGN_MODE
            gr.Save ();
            gr.Color = new Cairo.Color (0, 0, 1);
            gr.Rectangle (X, Y, Width, Height);
            gr.Stroke ();
            gr.Restore ();

            double width = 0;

            foreach (Widget child in children)
            {
                width += child.Width;

                if (Height < child.Height)
                    throw new InvalidOperationException (String.Format ("Container height too small {0} < {1}", Height, child.Height));
            }

            if (Width < width)
                throw new InvalidOperationException (String.Format ("Container witdh too small {0} < {1}", Width, width));
            #endif
            //
            // Coordinates are stored right to left
            //
            if (rtl == false) {
                for (int i = 0; i < children.Count; i++)
                {
                    gr.Save ();
                    gr.Translate (x, y);

                    children[i].Draw (gr, area_width, area_height, rtl);
                    gr.Restore ();
                    x += children[i].Width;
                }
            } else {
                x += Width;
                for (int i = 0; i < children.Count; i++)
                {
                    x -= children[i].Width;
                    gr.Save ();
                    gr.Translate (x, y);
                    children[i].Draw (gr, area_width, area_height, rtl);
                    gr.Restore ();
                }
            }
        }
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:51,代码来源:HorizontalContainer.cs

示例5: Draw

        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double rect_w = DrawAreaWidth / rows;
            double rect_h = DrawAreaHeight / columns;

            base.Draw (gr, area_width, area_height, rtl);

            for (int column = 0; column < columns; column++) {
                for (int row = 0; row < rows; row++) {
                    gr.Rectangle (DrawAreaX + row * rect_w, DrawAreaY + column * rect_h, rect_w, rect_h);
                }
            }

            gr.Stroke ();
        }
开发者ID:GNOME,项目名称:gbrainy,代码行数:15,代码来源:PuzzleSquares.cs

示例6: Draw

        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = 0.25, y = 0.25;

            base.Draw (gr, area_width, area_height, rtl);

            gr.Rectangle (x, y, width, height);
            gr.Stroke ();

            gr.MoveTo (x, y + height / 2);
            gr.LineTo (x + width, y + height / 2);
            gr.Stroke ();

            gr.MoveTo (x + width / 2, y);
            gr.LineTo (x + width / 2, y + height);
            gr.Stroke ();

            if (cover_zone1)
                CoverZone (gr, x, y);

            if (cover_zone2)
                CoverZone (gr, x + width / 2, y);

            if (cover_zone3)
                CoverZone (gr, x, y + height / 2);

            if (cover_zone4)
                CoverZone (gr, x + width / 2, y + height / 2);

            switch (partial_zone) {
                case 1:
                    break;
                case 2:
                    x += width / 2;
                    break;
                case 3:
                    y += height / 2;
                    break;
                case 4:
                    y += height / 2;
                    x += width / 2;
                    break;
            }

            DrawSection (gr, x, y);
        }
开发者ID:GNOME,项目名称:gbrainy,代码行数:46,代码来源:PuzzleCoverPercentage.cs

示例7: Draw

        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = X, y = Y;

            this.rtl = rtl;

            #if DESIGN_MODE
            gr.Save ();
            gr.Color = new Cairo.Color (0, 0, 1);
            gr.Rectangle (X, Y, Width, Height);
            gr.Stroke ();
            gr.Restore ();

            ValidateDimensions ();
            #endif

            //
            // Coordinates are stored right to left
            //
            if (rtl == false) {
                for (int i = 0; i < children.Count; i++)
                {
                    gr.Save ();
                    gr.Translate (x, y);

                    children[i].Draw (gr, area_width, area_height, rtl);
                    gr.Restore ();
                    x += children[i].Width;
                }
            } else {
                x += Width;
                for (int i = 0; i < children.Count; i++)
                {
                    x -= children[i].Width;
                    gr.Save ();
                    gr.Translate (x, y);
                    children[i].Draw (gr, area_width, area_height, rtl);
                    gr.Restore ();
                }
            }
        }
开发者ID:GNOME,项目名称:gbrainy,代码行数:41,代码来源:HorizontalContainer.cs

示例8: Draw

        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            int rows = 7, columns = 9;
            double rect_w = DrawAreaWidth / columns;
            double rect_h = DrawAreaHeight / rows;
            int first_column;
            string text;

            base.Draw (gr, area_width, area_height, rtl);
            gr.SetPangoLargeFontSize ();

            for (int row = 0; row < rows; row++)
            {
                for (int column = 0; column < columns; column++)
                {
                    gr.Rectangle (DrawAreaX + column * rect_w, DrawAreaY + row * rect_h, rect_w, rect_h);
                    gr.Stroke ();

                    if (row >= lines.Length)
                        continue;

                    first_column = (columns - lines[row].TotalNumbers) / 2;

                    if (column < first_column || column - first_column >= lines [row].TotalNumbers)
                        continue;

                    if (row + 1 == lines.Length && lines [row].IsMiddle (column - first_column))
                        text = "?";
                    else
                        text = lines [row].GetNumber (column - first_column).ToString ();

                    gr.DrawTextCentered (DrawAreaX + (column * rect_w) + rect_w / 2,
                            DrawAreaY + (row * rect_h) + rect_h / 2,
                            text.ToString());
                }
            }
        }
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:37,代码来源:PuzzleRelatedNumbers.cs

示例9: Draw

        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double first_x = DrawAreaX + 0.05;
            double first_y = DrawAreaY + 0.1;
            const double space_fromrect = 0.02, space_fromcircle = 0.01;
            int circles = 8;
            const double unit = 0.0625;

            base.Draw (gr, area_width, area_height, rtl);

            gr.Rectangle (first_x, first_y, unit * 8, unit * 8);
            gr.Stroke ();

            // |-------|
            gr.MoveTo (first_x, first_y - 0.04 - space_fromrect);
            gr.LineTo (first_x, first_y - space_fromrect);
            gr.Stroke ();
            gr.MoveTo (first_x, first_y - 0.02 - space_fromrect);
            gr.LineTo (first_x + 0.5, first_y - 0.02 - space_fromrect);
            gr.Stroke ();
            gr.MoveTo (first_x + 0.5, first_y - 0.04 - space_fromrect);
            gr.LineTo (first_x + 0.5, first_y - space_fromrect);
            gr.Stroke ();

            gr.MoveTo (first_x + 0.2, first_y - 0.06 - space_fromrect);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("8 units"));
            gr.Stroke ();

            //  ---
            //	 |
            //	 |
            //	 |
            //  ---
            gr.MoveTo (first_x  - space_fromrect, first_y);
            gr.LineTo (first_x  - space_fromrect - 0.04, first_y);
            gr.Stroke ();
            gr.MoveTo (first_x - space_fromrect - 0.02, first_y);
            gr.LineTo (first_x - space_fromrect - 0.02, first_y + 0.5);
            gr.Stroke ();
            gr.MoveTo (first_x - space_fromrect, first_y + 0.5);
            gr.LineTo (first_x - space_fromrect - 0.04, first_y + 0.5);
            gr.Stroke ();

            gr.MoveTo (first_x - space_fromrect - 0.07, first_y + 0.3);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("8 units"), false, -1, 270 * Math.PI/180);
            gr.Stroke ();

            // Sample circle
            gr.Arc (first_x + 0.7, first_y + 0.1, unit / 2, 0, 2 * Math.PI);
            gr.Stroke ();

            // |-------|
            gr.MoveTo (first_x + 0.65, first_y + 0.05 - 0.04 - space_fromcircle);
            gr.LineTo (first_x + 0.65, first_y + 0.05 - space_fromcircle);
            gr.Stroke ();
            gr.MoveTo (first_x + 0.65, first_y + 0.05 - 0.02 - space_fromcircle);
            gr.LineTo (first_x + 0.65 + 0.1, first_y + 0.05 - 0.02 - space_fromcircle);
            gr.Stroke ();
            gr.MoveTo (first_x + 0.65 + 0.1, first_y + 0.05 - 0.04 - space_fromcircle);
            gr.LineTo (first_x + 0.65 + 0.1, first_y + 0.05 - space_fromcircle);
            gr.Stroke ();

            gr.MoveTo (first_x + 0.65, first_y - 0.04 - space_fromcircle);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("1 unit"));
            gr.Stroke ();

            //  ---
            //	 |
            //	 |
            //	 |
            //  ---
            gr.MoveTo (first_x + 0.65  - space_fromcircle, first_y + 0.05);
            gr.LineTo (first_x + 0.65  - space_fromcircle - 0.04, first_y + 0.05);
            gr.Stroke ();
            gr.MoveTo (first_x + 0.65 - space_fromcircle - 0.02, first_y + 0.05);
            gr.LineTo (first_x + 0.65 - space_fromcircle - 0.02, first_y  + 0.05 + 0.1);
            gr.Stroke ();
            gr.MoveTo (first_x + 0.65 - space_fromcircle, first_y + 0.1 + 0.05);
            gr.LineTo (first_x + 0.65 - space_fromcircle - 0.04, first_y + 0.1 + 0.05);
            gr.Stroke ();

            gr.MoveTo (first_x + 0.65 - space_fromcircle - 0.08, first_y + 0.15);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("1 unit"), false, -1, 270 * Math.PI/180);
            gr.Stroke ();

            if (Answer.Draw == false)
                return;

            double x;
            for (int line = 0; line < 9; line++)
            {
                for (int circle = 0; circle < circles; circle++)
                {
                    x = first_x + (unit / 2) + (circle * unit);

                    if (circles == 7)
                        x+= unit / 2;

                    gr.Arc (x, (unit / 2) + first_y + (unit * line) - (unit / 8) * line,
                            (unit / 2), 0, 2 * Math.PI);
//.........这里部分代码省略.........
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:101,代码来源:PuzzleCirclesSquare.cs

示例10: DrawQuestion

        void DrawQuestion(CairoContextEx gr, double x, double y)
        {
            gr.Rectangle (x, y, width, height);
            gr.Stroke ();

            gr.MoveTo (x, y + 0.1);
            gr.LineTo (x + width, y + 0.1);  // Container square
            gr.Stroke ();

            gr.MoveTo (x, y + 0.3);
            gr.LineTo (x + width - 0.1, y + 0.3); // Second horizontal
            gr.Stroke ();

            gr.MoveTo (x + 0.1, y);
            gr.LineTo (x + 0.1, y + height);  // First vertical
            gr.Stroke ();

            gr.MoveTo (x + 0.3, y);
            gr.LineTo (x + 0.3, y + height - 0.1);  // Second vertical
            gr.Stroke ();
        }
开发者ID:GNOME,项目名称:gbrainy,代码行数:21,代码来源:PuzzleSquareSheets.cs

示例11: DrawAnswer

        void DrawAnswer(CairoContextEx gr, double x, double y)
        {
            ColorPalette palette = new ColorPalette (Translations);
            gr.Save ();

            // A full sized square of paper
            gr.Color = palette.Cairo (ColorPalette.Id.Yellow);
            gr.Rectangle (x, y, width, height);
            gr.Fill ();
            gr.Stroke ();

            // 3/4 of the whole size square of paper in the bottom right corner
            gr.Color = palette.Cairo (ColorPalette.Id.Blue);
            double w = 3d/4d * width;
            double h = 3d/4d * height;
            gr.Rectangle (x + (width - w), y + (height - h), w, h);
            gr.Fill ();
            gr.Stroke ();

            // 3/4 square of paper in the top left corner
            gr.Color = palette.Cairo (ColorPalette.Id.Green);
            gr.Rectangle (x, y, 3d/4d * width, 3d/4d * height);
            gr.Fill ();
            gr.Stroke ();

            // 1/4 square of paper in the top left corner
            gr.Color = palette.Cairo (ColorPalette.Id.Red);
            gr.Rectangle (x, y, 1d/4d * width, 1d/4d * height);
            gr.Fill ();
            gr.Stroke ();

            gr.Restore ();
        }
开发者ID:GNOME,项目名称:gbrainy,代码行数:33,代码来源:PuzzleSquareSheets.cs

示例12: Draw

 public override void Draw(CairoContextEx gr, double x, double y, double size)
 {
     gr.Rectangle ((size - width) / 2, (size - heigth) / 2, width, heigth);
     gr.Stroke ();
 }
开发者ID:GNOME,项目名称:gbrainy,代码行数:5,代码来源:PuzzleLargestArea.cs

示例13: DrawFigure

 private static void DrawFigure(CairoContextEx gr, double x, double y, Figures figure)
 {
     switch (figure) {
     case Figures.TriangleA:
         gr.DrawEquilateralTriangle (x, y, figure_size);
         break;
     case Figures.TriangleB:
         gr.MoveTo (x, y);
         gr.LineTo (x, y + figure_size);
         gr.LineTo (x + figure_size, y);
         gr.LineTo (x, y);
         gr.Stroke ();
         break;
     case Figures.TriangleC:
         gr.MoveTo (x, y);
         gr.LineTo (x, y + figure_size);
         gr.LineTo (x + figure_size, y + figure_size);
         gr.LineTo (x, y);
         gr.Stroke ();
         break;
     case Figures.Square:
         gr.Rectangle (x, y, figure_size, figure_size);
         gr.Stroke ();
         break;
     case Figures.LongRectangle:
         gr.Rectangle (x, y + figure_size / 2, figure_size, figure_size / 2);
         gr.Stroke ();
         break;
     case Figures.LongRectangleUp:
         gr.Rectangle (x, y, figure_size, figure_size / 2);
         gr.Stroke ();
         break;
     case Figures.Diamon:
         gr.DrawDiamond (x, y, figure_size);
         break;
     case Figures.TriangleD:
         gr.MoveTo (x, y);
         gr.LineTo (x, y + figure_size * 0.7);
         gr.LineTo (x + figure_size * 0.7, y + figure_size * 0.7);
         gr.LineTo (x, y);
         gr.Stroke ();
         break;
     }
 }
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:44,代码来源:PuzzleBuildTriangle.cs

示例14: DrawFigure

        static void DrawFigure(CairoContextEx gr, double x, double y, Figures figure)
        {
            switch (figure) {
            case Figures.FigureA:
                double x105, y105;

                x105 = figure_size * Math.Cos (105 * Math.PI / 180);
                y105 = figure_size * Math.Sin (105 * Math.PI / 180);
                gr.MoveTo (x, y);
                gr.LineTo (x + x105, y + y105);
                gr.LineTo (x + x105 + figure_size, y + y105);
                gr.Stroke ();
                gr.MoveTo (x + figure_size, y);
                gr.LineTo (x + figure_size + x105, y + y105);
                gr.Stroke ();
                gr.MoveTo (x, y);
                gr.LineTo (x + figure_size, y);
                break;

            case Figures.FigureB:
                gr.Rectangle (x, y, figure_size * 0.8, figure_size * 1.2);
                break;

            case Figures.FigureC:
                gr.MoveTo (x, y);
                gr.LineTo (x + figure_size * 1.3, y);
                gr.LineTo (x + figure_size * 1.3, y + figure_size);
                gr.LineTo (x , y + figure_size);
                gr.LineTo (x, y);
                break;

            case Figures.FigureD:
                gr.MoveTo (x + 0.03, y);
                gr.LineTo (x + figure_size - 0.03, y);
                gr.LineTo (x + figure_size, y + figure_size);
                gr.LineTo (x , y + figure_size);
                gr.LineTo (x + 0.03, y);
                break;

            case Figures.FigureE:
                gr.MoveTo (x + 0.03, y);
                gr.LineTo (x + figure_size - 0.04, y);
                gr.LineTo (x + figure_size - 0.04, y + figure_size * 1.2);
                gr.LineTo (x , y + figure_size  * 1.2);
                gr.LineTo (x + 0.03, y);
                break;

            case Figures.FigureF:
                gr.MoveTo (x, y);
                gr.LineTo (x, y + figure_size);
                gr.LineTo (x + figure_size, y + figure_size);
                gr.LineTo (x + figure_size - 0.02, y);
                gr.LineTo (x, y);
                break;
            }

            gr.Stroke ();
        }
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:58,代码来源:PuzzleQuadrilaterals.cs

示例15: GenerateQuestions

        static void GenerateQuestions(CairoContextEx cr, Game [] games, int columns, int rows)
        {
            int x, y, page;
            Game puzzle;
            string str;

            x = y = page = 0;
            for (int i = 0; i < games.Length; i++)
            {
                puzzle = games [i];
                puzzle.Begin ();
                page++;

                cr.Save ();
                cr.Translate (x, y);
                cr.Rectangle (0, 0, width, height + question_height);
                cr.Clip ();

                // Translators: {0} is the game number and {1} the game question or answer
                // The number is used as reference when looking for the game solution in the PDF
                str = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Game #{0}. {1}"), i + 1, puzzle.Question);

                // Draw question
                cr.SetPangoFontSize (12);
                cr.UseMarkup = true;
                cr.DrawStringWithWrapping (margin, 10, str, width - margin);
                cr.Stroke ();
                cr.UseMarkup = false;

                // Draw from question_height up height since from 0 to question_height is the question
                // Translate adds always to previous matrix's transformation
                cr.Translate (0, question_height);
                puzzle.DrawPreview (cr, width, height, false);
                if (i == 0) {
                    cr.Save ();
                    cr.SetPangoFontSize (0.02);
                    cr.MoveTo (0.05, 0.95);
                    cr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Created by gbrainy {0}"), Defines.VERSION));
                    cr.Stroke ();
                    cr.Restore ();
                }

                x += width + margin;
                if (x > width + margin) {
                    x = 0;
                    y += height + margin + question_height;
                }
                cr.Restore ();
                cr.Stroke ();

                if (page >= columns * rows) {
                    cr.ShowPage ();
                    page = x = y = 0;
                }
            }

            if (y > 0)
                cr.ShowPage ();
        }
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:59,代码来源:PdfExporter.cs


注:本文中的gbrainy.Core.Main.CairoContextEx.Rectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。