protected override void OnDraw(Xwt.Drawing.Context ctx) { base.OnDraw (ctx); ctx.SetLineDash (15, 10, 10, 5, 5); ctx.Rectangle (100, 100, 100, 100); ctx.Stroke (); ctx.SetLineDash (0); ImageBuilder ib = new ImageBuilder (30, 30, ImageFormat.ARGB32); ib.Context.Arc (15, 15, 15, 0, 360); ib.Context.SetColor (new Color (1, 0, 1)); ib.Context.Rectangle (0, 0, 5, 5); ib.Context.Fill (); var img = ib.ToImage (); ctx.DrawImage (img, 90, 90); ctx.DrawImage (img, 90, 140, 50, 10); ctx.Arc (190, 190, 15, 0, 360); ctx.SetColor (new Color (1, 0, 1, 0.4)); ctx.Fill (); ctx.Save (); ctx.Translate (90, 220); ctx.Pattern = new ImagePattern (img); ctx.Rectangle (0, 0, 100, 70); ctx.Fill (); ctx.Restore (); ctx.Translate (30, 30); double end = 270; for (double n = 0; n<=end; n += 5) { ctx.Save (); ctx.Rotate (n); ctx.MoveTo (0, 0); ctx.RelLineTo (30, 0); double c = n / end; ctx.SetColor (new Color (c, c, c)); ctx.Stroke (); ctx.Restore (); } }
private void DrawImageSized(PageImage pi, Xwt.Drawing.Image im, Xwt.Drawing.Context g, Xwt.Rectangle r) { double height, width; // some work variables StyleInfo si = pi.SI; Xwt.Rectangle r2 = new Xwt.Rectangle(r.X + PixelsX(si.PaddingLeft), r.Y + PixelsY(si.PaddingTop), r.Width - PixelsX(si.PaddingLeft + si.PaddingRight), r.Height - PixelsY(si.PaddingTop + si.PaddingBottom)); Xwt.Rectangle ir; // int work rectangle switch (pi.Sizing) { case ImageSizingEnum.AutoSize: float imwidth = PixelsX( (float)im.Size.Width); float imheight = PixelsX( (float)im.Size.Height); ir = new Xwt.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y), imwidth, imheight); im.Scale((int)r2.Width, (int)r2.Height); g.DrawImage(im, ir); break; case ImageSizingEnum.Clip: g.Save(); g.Rectangle(r2); g.Clip(); ir = new Xwt.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y), im.Size.Width, im.Size.Height); g.DrawImage(im, ir); g.Restore(); break; case ImageSizingEnum.FitProportional: double ratioIm = (float)im.Size.Height / (float)im.Size.Width; double ratioR = r2.Height / r2.Width; height = r2.Height; width = r2.Width; if (ratioIm > ratioR) { // this means the rectangle width must be corrected width = height * (1 / ratioIm); } else if (ratioIm < ratioR) { // this means the ractangle height must be corrected height = width * ratioIm; } r2 = new Xwt.Rectangle(r2.X, r2.Y, width, height); g.DrawImage(im, r2); break; case ImageSizingEnum.Fit: default: g.DrawImage(im, r2); break; } }
protected override void OnDraw (Xwt.Drawing.Context ctx, Xwt.Rectangle dirtyRect) { base.OnDraw (ctx, dirtyRect); if (image != null) { ctx.DrawImage (image, 0, 0); if (filler != null) { int fillCount = (int)Math.Ceiling ((Bounds.Width - image.Width) / filler.Width); double x = image.Width; while ((fillCount--) > 0) { ctx.DrawImage (filler, x, 0); x += filler.Width; } } } }
protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect) { if (!Sensitive) { ctx.GlobalAlpha = .5d; } if (image == null) { ctx.SetColor(bg); ctx.Rectangle(dirtyRect); ctx.Fill(); } else ctx.DrawImage(image, new Rectangle(0, 0, WidthRequest, HeightRequest)); if (mOver && Sensitive) { ctx.SetColor(mOverColor); ctx.Rectangle(dirtyRect); ctx.Fill(); } if (mDown) { ctx.SetColor(mOverColor); ctx.Rectangle(dirtyRect); ctx.Fill(); } //ctx.SetColor(Colors.Red); //ctx.Rectangle(0, 0, WidthRequest, HeightRequest); //ctx.Stroke(); }
protected override void OnDraw(Xwt.Drawing.Context ctx, Xwt.Rectangle dirtyRect) { int width = (int)this.Size.Width, height = (int)this.Size.Height; ctx.DrawImage(Build(width, height), new Xwt.Point(0, 0), this.ParentWindow.Screen.ScaleFactor); }
protected override void OnDraw(Xwt.Drawing.Context ctx) { base.OnDraw (ctx); // Simple rectangles ctx.SetLineWidth (1); ctx.Rectangle (100, 5, 10, 10); ctx.SetColor (Color.Black); ctx.Fill (); ctx.Rectangle (115, 5, 10, 10); ctx.SetColor (Color.Black); ctx.Stroke (); // ctx.SetLineWidth (3); ctx.Rectangle (100, 20, 10, 10); ctx.SetColor (Color.Black); ctx.Fill (); ctx.Rectangle (115, 20, 10, 10); ctx.SetColor (Color.Black); ctx.Stroke (); // Rectangle with hole ctx.Rectangle (10, 100, 40, 40); ctx.MoveTo (45, 135); ctx.RelLineTo (0, -20); ctx.RelLineTo (-20, 0); ctx.RelLineTo (0, 20); ctx.ClosePath (); ctx.SetColor (Color.Black); ctx.Fill (); // Dashed lines ctx.SetLineDash (15, 10, 10, 5, 5); ctx.Rectangle (100, 100, 100, 100); ctx.Stroke (); ctx.SetLineDash (0); ImageBuilder ib = new ImageBuilder (30, 30, ImageFormat.ARGB32); ib.Context.Arc (15, 15, 15, 0, 360); ib.Context.SetColor (new Color (1, 0, 1)); ib.Context.Rectangle (0, 0, 5, 5); ib.Context.Fill (); var img = ib.ToImage (); ctx.DrawImage (img, 90, 90); ctx.DrawImage (img, 90, 140, 50, 10); ctx.Arc (190, 190, 15, 0, 360); ctx.SetColor (new Color (1, 0, 1, 0.4)); ctx.Fill (); ctx.Save (); ctx.Translate (90, 220); ctx.Pattern = new ImagePattern (img); ctx.Rectangle (0, 0, 100, 70); ctx.Fill (); ctx.Restore (); ctx.Translate (30, 30); double end = 270; for (double n = 0; n<=end; n += 5) { ctx.Save (); ctx.Rotate (n); ctx.MoveTo (0, 0); ctx.RelLineTo (30, 0); double c = n / end; ctx.SetColor (new Color (c, c, c)); ctx.Stroke (); ctx.Restore (); } ctx.ResetTransform (); }
protected override void OnDraw(Xwt.Drawing.Context ctx, Xwt.Rectangle dirtyRect) { if (ParentWindow.Visible) { System.Drawing.Bitmap B = new System.Drawing.Bitmap((int)(dirtyRect.Width * this.ParentWindow.Screen.ScaleFactor), (int)(dirtyRect.Height * this.ParentWindow.Screen.ScaleFactor)); System.Drawing.Graphics G = System.Drawing.Graphics.FromImage(B); G.FillRectangle( new System.Drawing.SolidBrush(System.Drawing.Color.White), new System.Drawing.Rectangle(0, 0, B.Width - 1, B.Height - 1) ); List<GradientButton> S = this.Buttons.OrderBy(X => X.CurrentMode).ToList(); S.ForEach(X => { X.DrawDescription = (X.Size.Width != this.ButtonSize); X.DrawImg = true; X.Draw(G, new System.Drawing.PointF((float)X.Position.X, (float)X.Position.Y), this.ParentWindow.Screen.ScaleFactor); }); ctx.DrawImage(B, new Point(0, 0), this.ParentWindow.Screen.ScaleFactor); } }
protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect) { if (Bounds.IsEmpty) return; // Copy plotCache to on-screen display ctx.DrawImage (plotImage, dirtyRect); // draw some overlay over this DrawFocus (ctx, cursorX, cursorY); }