Example #1
0
        void Draw(IGraphics g, DrawingMode mode)
        {
            g.SmoothingMode = checkBoxAntialiasing.Checked ? SmoothingMode.HighQuality : SmoothingMode.None;
            g.Clear(Color.White);

            DrawMillimeterGridInPixels(g, tabControl1.SelectedTab.Controls[0].ClientRectangle);

            g.PageUnit = GraphicsUnit.Millimeter;

            var points = _noisePoints;

            DrawLines(g, points, mode);

            g.ResetTransform();

            var path = CreateRoundedRectanglePath(new RectangleF(10, 10, 100, 40), 10);

            g.FillPath(new SolidBrush(Color.FromArgb(120, Color.LightSlateGray)), path);
            g.DrawPath(new Pen(Color.LightSlateGray, 0.0f), path);

            g.FillPie(new SolidBrush(Color.FromArgb(120, Color.CadetBlue)), new Rectangle(30, 20, 100, 100), 45.0f, 90.0f);
            g.DrawPie(new Pen(Color.CadetBlue, 0.0f), new Rectangle(30, 20, 100, 100), 45.0f, 90.0f);

            //GLGraphics gl = g as GLGraphics;
            //if (gl != null)
            //    gl.FillTextBackground = gl.FillTextBackground_glReadPixels;

            g.PageUnit = GraphicsUnit.Pixel;
            RectangleF rect = new RectangleF(30.0f, 15.0f, _testImage.Width, _testImage.Height);
            g.DrawImage(_testImage, rect);
            g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);

            g.PageUnit = GraphicsUnit.Millimeter;

            g.HintTextBackgroundAction((gdi, textLocation, textRect) =>
            {
                _millimeterGridBrush.ResetTransform();
                _millimeterGridBrush.TranslateTransform(-textLocation.X, -textLocation.Y);
                gdi.FillRectangle(_millimeterGridBrush, textRect);
            });

            g.DrawString("Testovací řetězec pro odzkoušení správné implementace IGraphics - metody DrawString.",
                new Font("Arial", 12.0f), Brushes.Black, new PointF(100.0f, 58.0f));
        }
Example #2
0
        void Draw(IGraphics g)
        {
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            g.SmoothingMode = SmoothingMode.HighQuality;

            //g.SetClip(new Rectangle(50, 50, 200, 400));

            if (gridBrush == null)
            {
                gridBrush = new TextureBrush(Images.Grid_37px);
            }

            //gridBrush.ResetTransform();
            //gridBrush.TranslateTransform(100, 100);

            g.CompositingMode = CompositingMode.SourceCopy;
            gridBrush.ResetTransform();
            g.FillRectangle(gridBrush, glView1.ClientRectangle);
            g.CompositingMode = CompositingMode.SourceOver;

            g.HintTextBackgroundAction(HintBackground);

            //g.PageUnit = GraphicsUnit.Millimeter;
            //g.SmoothingMode = SmoothingMode.AntiAlias;
            string text = "12.5% 2/5 (1) + ms test...";

            g.DrawString(g.DpiX.ToString(), font1, Brushes.Black, new PointF(2, 2));

            StringFormat sf = new StringFormat();
            Rectangle rect = new Rectangle(100, 50, 400, 150);

            g.DrawRectangle(Pens.Black, rect);

            g.DrawString(text, font2, Brushes.Red, rect, sf);

            sf.Alignment = StringAlignment.Center;

            g.FillRectangle(Brushes.Black, new Rectangle(230, 50, 140, 40));
            g.DrawString(text, font1, Brushes.Yellow, rect, sf);

            sf.Alignment = StringAlignment.Far;

            g.DrawString(text, font2, Brushes.Green, rect, sf);

            sf.Alignment = StringAlignment.Near;
            sf.LineAlignment = StringAlignment.Center;

            g.DrawString(text, font1, Brushes.Blue, rect, sf);

            sf = new StringFormat();
            sf.Alignment = StringAlignment.Far;
            sf.LineAlignment = StringAlignment.Far;

            g.DrawString("Far, Far, PointF", font2, Brushes.Green, new PointF(100.0f, 150.0f), sf);

            sf = new StringFormat();
            sf.LineAlignment = StringAlignment.Far;

            g.DrawString(text, font1, Brushes.DarkCyan, rect, sf);

            List<PointF> points = new List<PointF>();

            for (float x = 0.0f; x < (float)Math.PI * 6.0f; x += 0.01f)
            {
                points.Add(new PointF(x * (float)Math.Cos(x), x * (float)Math.Sin(x)));
            }

            Matrix m = new Matrix();

            for (int y = 0; y < 5; y++)
            {
                for (int x = 0; x < 5; x++)
                {
                    m.Reset();
                    m.Translate(x * 50.0f + 200.0f, y * 50.0f + 300.0f);
                    g.Transform = m;
                    g.DrawLines(new Pen(Color.Blue, 0.0f), points.ToArray());
                }
            }

            g.ResetTransform();

            g.DrawRectangle(new Pen(Color.Red, 0), new Rectangle(50, 150, 24, 24));
            g.DrawImage(Images.NavigateDown_48px, new Rectangle(50, 150, 24, 24));

            if (transparentBitmap == null)
            {
                ColorMatrix matrix = new ColorMatrix();
                matrix.Matrix33 = 0.4f; //opacity 0 = completely transparent, 1 = completely opaque
                transparentBitmap = GraphicsHelpers.BitmapFromImageAndColorMatrix(Images.NavigateDown_48px, matrix);
            }

            g.DrawRectangle(new Pen(Color.Red, 0), new Rectangle(100, 150, 24, 24));
            g.DrawImage(transparentBitmap, new Rectangle(100, 150, 24, 24));

            using (HatchBrush hatchBrush = new HatchBrush(HatchStyle.LightUpwardDiagonal, Color.Black, Color.Transparent))
            {
                g.FillRectangle(hatchBrush, new Rectangle(10, 10, 100, 20));
            }

            using (HatchBrush hatchBrush = new HatchBrush(HatchStyle.LightDownwardDiagonal, Color.Black, Color.Transparent))
            {
                g.FillRectangle(hatchBrush, new Rectangle(110, 10, 200, 20));
            }

            g.SmoothingMode = SmoothingMode.None;

            g.FillRectangle(Brushes.White, new Rectangle(0, 210, 510, 50));

            Rectangle rc = new Rectangle(520, 250, 300, 200);
            g.FillRectangle(Brushes.White, rc);

            g.HintTextBackgroundColor(Color.White);
            g.DrawString("OpenGL 3D Stuff", font1, Brushes.Black, 600.0f, 250.0f);

            if (g is GLGraphics)
                Draw3dStuff(g as GLGraphics, rc);

            Pen pen = new Pen(Color.Black, 0);
            pen.DashStyle = DashStyle.Dot;
            g.DrawLine(pen, new Point(10, 220), new Point(500, 220));
            pen.DashStyle = DashStyle.Dash;
            g.DrawLine(pen, new Point(10, 230), new Point(500, 230));
            pen.DashStyle = DashStyle.DashDot;
            g.DrawLine(pen, new Point(10, 240), new Point(500, 240));
            pen.DashStyle = DashStyle.DashDotDot;
            g.DrawLine(pen, new Point(10, 250), new Point(500, 250));

            //g.ResetClip();
        }