Ejemplo n.º 1
0
		public static void Draw(Graphics graphics)
		{
			var generator = graphics.Generator;
			var image = TestIcons.TestImage(generator);
			// lines
			var whitePen = Pens.White(generator);
			graphics.DrawLine(whitePen, 1, 1, 99, 99);
			graphics.DrawLine(whitePen, 50, 1, 50, 99);
			graphics.DrawLine(whitePen, 1, 51, 99, 51);

			graphics.DrawRectangle(Pens.White(generator), 101, 1, 100, 100);
			graphics.DrawRectangle(Pens.White(generator), 101, 1, 10, 10);

			graphics.DrawEllipse(Pens.Green(generator), 101, 1, 100, 100);

			graphics.DrawPolygon(Pens.White(generator), new PointF(203, 1), new PointF(253, 51), new Point(203, 101), new PointF(203, 1), new PointF(253, 1), new PointF(253, 101), new PointF(203, 101));

			var rect = new RectangleF(255, 1, 100, 100);
			graphics.DrawArc(Pens.LightGreen(generator), rect, 180, 90);
			graphics.DrawArc(Pens.SkyBlue(generator), rect, 0, 90);
			rect.Inflate(-15, 0);
			graphics.DrawArc(Pens.FloralWhite(generator), rect, -45, 90);
			rect.Inflate(-5, -20);
			graphics.DrawArc(Pens.SlateGray(generator), rect, -45, 270);
			rect.Inflate(-10, -10);
			graphics.DrawArc(Pens.SteelBlue(generator), rect, 180 + 45, 270);

			graphics.DrawImage(image, 100, 1, 100, 100);

			graphics.DrawText(Fonts.Sans(12 * graphics.PointsPerPixel, generator: generator), Colors.White, 0, 104, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");

			// filled
			graphics.FillRectangle(Brushes.White(generator), 101, 120, 100, 100);
			graphics.FillRectangle(Brushes.Gray(generator), 101, 120, 10, 10);

			graphics.FillEllipse(Brushes.Green(generator), 101, 120, 100, 100);

			graphics.FillPolygon(Brushes.White(generator), new PointF(202, 120), new PointF(252, 170), new Point(202, 220), new PointF(202, 120));

			rect = new RectangleF(255, 120, 100, 100);
			graphics.FillPie(Brushes.LightGreen(generator), rect, 180, 90);
			graphics.FillPie(Brushes.SkyBlue(generator), rect, 0, 90);
			rect.Inflate(-15, 0);
			graphics.FillPie(Brushes.FloralWhite(generator), rect, -45, 90);
			rect.Inflate(-5, -20);
			graphics.FillPie(Brushes.SlateGray(generator), rect, -45, 270);
			rect.Inflate(-10, -10);
			graphics.FillPie(Brushes.SteelBlue(generator), rect, 180 + 45, 270);


			graphics.DrawImage(image, 101, 120, 100, 100);
		}
Ejemplo n.º 2
0
		void DrawSample(Graphics graphics)
		{
			graphics.FillRectangle(Brushes.Green(), 0, 0, 200, 200);
			if (UseGraphicsPathClip)
			{
				var path = GraphicsPath.GetRoundRect(new RectangleF(10, 10, 180, 180), 20);
				graphics.SetClip(path);
			}
			else
				graphics.SetClip(new RectangleF(10, 10, 180, 180));

			if (UseClearColor)
				graphics.Clear(new SolidBrush(new Color(Colors.Red, 0.5f)));
			else
				graphics.Clear();
			graphics.FillEllipse(Brushes.Blue(), 25, 25, 150, 150);
		}
Ejemplo n.º 3
0
		void DrawSample(Graphics graphics)
		{
			using (graphics.Platform.Context)
			{
				graphics.FillRectangle(Brushes.Green, 0, 0, 200, 200);
				switch (clipMode)
				{
					case ClearClipMode.GraphicsPath:
						var path = GraphicsPath.GetRoundRect(new RectangleF(10, 10, 180, 180), 20);
						graphics.SetClip(path);
						break;
					case ClearClipMode.Rectangle:
						graphics.SetClip(new RectangleF(10, 10, 180, 180));
						break;
				}

				if (UseClearColor)
					graphics.Clear(new SolidBrush(new Color(Colors.Red, 0.5f)));
				else
					graphics.Clear();
				graphics.FillEllipse(Brushes.Blue, 25, 25, 150, 150);
			}
		}
Ejemplo n.º 4
0
		void Draw(Graphics g)
		{
			if (brush == null)
				return;
			var rect = new RectangleF(0, 0, 200, 100);
			/**/
			//g.FillRectangle(brush, rect);
			g.FillEllipse(brush, rect);
			g.DrawEllipse(Colors.Black, rect);
			/**/
			rect = new RectangleF(0, 110, 200, 80);
			g.FillRectangle(brush, rect);
			g.DrawRectangle(Colors.Black, rect);
			/**/
			rect = new RectangleF(0, 200, 200, 80);
			g.FillPie(brush, rect, 100, 240);
			g.DrawArc(Colors.Black, rect, 100, 240);
			/**/
			var points = new[] { new PointF(300, 0), new PointF(350, 20), new PointF(400, 80), new PointF(320, 90) };
			g.FillPolygon(brush, points);
			g.DrawPolygon(Colors.Black, points);
			/**/
		}
Ejemplo n.º 5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="gfx"></param>
 /// <param name="container"></param>
 private void DrawBackgroundInternal(Graphics gfx, Container container)
 {
     Brush brush = ToSolidBrush(container.Background);
     var rect = Rect2.Create(0, 0, container.Width, container.Height);
     gfx.FillRectangle(
         brush,
         _scaleToPage(rect.X),
         _scaleToPage(rect.Y),
         _scaleToPage(rect.Width),
         _scaleToPage(rect.Height));
     brush.Dispose();
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="brush"></param>
        /// <param name="pen"></param>
        /// <param name="isStroked"></param>
        /// <param name="isFilled"></param>
        /// <param name="rect"></param>
        private static void DrawRectangleInternal(
            Graphics gfx,
            Brush brush,
            Pen pen,
            bool isStroked,
            bool isFilled,
            ref Rect2 rect)
        {
            if (isFilled)
            {
                gfx.FillRectangle(
                    brush,
                    (float)rect.X,
                    (float)rect.Y,
                    (float)rect.Width,
                    (float)rect.Height);
            }

            if (isStroked)
            {
                gfx.DrawRectangle(
                    pen,
                    (float)rect.X,
                    (float)rect.Y,
                    (float)rect.Width,
                    (float)rect.Height);
            }
        }
Ejemplo n.º 7
0
		void DrawShapes(Brush brush, PointF location, Size size, Graphics g)
		{
			g.SaveTransform();
			g.TranslateTransform(location);
			g.RotateTransform(20);

			// rectangle
			g.FillRectangle(brush, new RectangleF(size));

			// ellipse
			g.TranslateTransform(0, size.Height + 20);
			g.FillEllipse(brush, new RectangleF(size));

			// pie
			g.TranslateTransform(0, size.Height + 20);
			g.FillPie(brush, new RectangleF(new SizeF(size.Width * 2, size.Height)), 0, 360);

			// polygon
			g.TranslateTransform(0, size.Height + 20);
			var polygon = GetPolygon();
			g.FillPolygon(brush, polygon);

			g.RestoreTransform();
		}
Ejemplo n.º 8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="g"></param>
 /// <param name="c"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 private void DrawBackground(Graphics g, Test2d.ArgbColor c, double width, double height)
 {
     var color = Color.FromArgb(c.R, c.G, c.B, c.A);
     var brush = new SolidBrush(color);
     var rect = Test2d.Rect2.Create(0, 0, width, height);
     g.FillRectangle(
         brush,
         (float)rect.X,
         (float)rect.Y,
         (float)rect.Width,
         (float)rect.Height);
     brush.Dispose();
 }
Ejemplo n.º 9
0
		public static void Draw(Graphics graphics)
		{
			var image = TestIcons.TestImage;
			// lines
			var whitePen = new Pen(Colors.White, 1);
			graphics.DrawLine(whitePen, 1, 1, 99, 99);
			graphics.DrawLine(whitePen, 50, 1, 50, 99);
			graphics.DrawLine(whitePen, 1, 51, 99, 51);

			graphics.DrawRectangle(whitePen, 101, 1, 100, 100);
			graphics.DrawRectangle(whitePen, 101, 1, 10, 10);

			graphics.DrawEllipse(Pens.Green, 101, 1, 100, 100);

			graphics.DrawPolygon(whitePen, new PointF(203, 1), new PointF(253, 51), new Point(203, 101), new PointF(203, 1), new PointF(253, 1), new PointF(253, 101), new PointF(203, 101));

			var rect = new RectangleF(255, 1, 100, 100);
			graphics.DrawArc(Pens.LightGreen, rect, 180, 90);
			graphics.DrawArc(Pens.SkyBlue, rect, 0, 90);
			rect.Inflate(-15, 0);
			graphics.DrawArc(Pens.FloralWhite, rect, -45, 90);
			rect.Inflate(-5, -20);
			graphics.DrawArc(Pens.SlateGray, rect, -45, 270);
			rect.Inflate(-10, -10);
			graphics.DrawArc(Pens.SteelBlue, rect, 180 + 45, 270);

			graphics.DrawImage(image, 100, 1, 100, 100);

			graphics.DrawText(Fonts.Sans(12 * graphics.PointsPerPixel), Colors.White, 0, 104, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");

			// filled
			graphics.FillRectangle(Brushes.White, 101, 120, 100, 100);
			graphics.FillRectangle(Brushes.Gray, 101, 120, 10, 10);

			graphics.FillEllipse(Brushes.Green, 101, 120, 100, 100);

			graphics.FillPolygon(Brushes.White, new PointF(202, 120), new PointF(252, 170), new Point(202, 220), new PointF(202, 120));

			rect = new RectangleF(255, 120, 100, 100);
			graphics.FillPie(Brushes.LightGreen, rect, 180, 90);
			graphics.FillPie(Brushes.SkyBlue, rect, 0, 90);
			rect.Inflate(-15, 0);
			graphics.FillPie(Brushes.FloralWhite, rect, -45, 90);
			rect.Inflate(-5, -20);
			graphics.FillPie(Brushes.SlateGray, rect, -45, 270);
			rect.Inflate(-10, -10);
			graphics.FillPie(Brushes.SteelBlue, rect, 180 + 45, 270);


			graphics.DrawImage(image, 101, 120, 100, 100);

			const int offset = 440;
			var xoffset = offset;
			var yoffset = 112;
			for (int i = 1; i < 14; i++)
			{
				var pen = new Pen(Colors.White, i);
				pen.LineCap = PenLineCap.Butt;
				graphics.DrawLine(pen, xoffset, 1, xoffset, 110);

				graphics.DrawLine(pen, offset, yoffset, offset + 100, yoffset);

				xoffset += i + 2;
				yoffset += i + 2;
			}

		}
Ejemplo n.º 10
0
		public void DrawFrame(Graphics graphics, Size canvasSize)
		{
			if (graphics == null)
				return;
			lock (Boxes)
			{
				if (Boxes.Count == 0 && canvasSize.Width > 1 && canvasSize.Height > 1)
					InitializeBoxes(canvasSize);

				var fps = TotalFrames / Watch.Elapsed.TotalSeconds;
				// The frames per second as determined by the last frame. Measuring a single frame
				// must include EndDraw, since that is when the pipeline is flushed to the device.
				var lastFrameFps = Stopwatch.Frequency / (Watch.ElapsedTicks - PreviousFrameStartTicks);
				PreviousFrameStartTicks = Watch.ElapsedTicks;
				var fpsText = string.Format("Frames per second since start: {0:0.00}, last: {1:0.00}", fps, lastFrameFps);
				var start = Watch.ElapsedTicks;
				if (EraseBoxes)
					graphics.FillRectangle(Colors.Black, new RectangleF(graphics.MeasureString(font, fpsText)));
				graphics.DrawText(font, textBrush, 0, 0, fpsText);

				var bounds = canvasSize;
				graphics.AntiAlias = false;
				foreach (var box in Boxes)
				{
					if (EraseBoxes)
						box.Erase(graphics);
					box.Move(bounds);
					box.Draw(graphics);
				}
				TotalFrames++;
			}
		}
Ejemplo n.º 11
0
		void Draw(Graphics g)
		{
			var matrix = Matrix.Create();
			matrix.Translate(OffsetX, OffsetY);
			matrix.Scale(Math.Max(ScaleX / 100f, 0.1f), Math.Max(ScaleY / 100f, 0.1f));
			matrix.Rotate(Rotation);
			var tb = brush as ITransformBrush;
			if (tb != null)
			{
				tb.Transform = matrix;
			}
			var gb = brush as LinearGradientBrush;
			if (gb != null)
			{
				gb.Wrap = GradientWrap;
			}

			var rect = new RectangleF(0, 0, 200, 100);
			g.FillEllipse(brush, rect);
			g.DrawEllipse(Colors.Black, rect);
			
			rect = new RectangleF(0, 110, 200, 80);
			g.FillRectangle(brush, rect);
			g.DrawRectangle(Colors.Black, rect);
		}