public void Restrict(Rectangle rectangle) { if (x < rectangle.Left) x = rectangle.Left; if (x > rectangle.Right) x = rectangle.Right; if (y < rectangle.Top) y = rectangle.Top; if (y > rectangle.Bottom) y = rectangle.Bottom; }
public void Restrict(Rectangle rectangle) { if (Left < rectangle.Left) Left = rectangle.Left; if (Top < rectangle.Top) Top = rectangle.Top; if (Right > rectangle.Right) Right = rectangle.Right; if (Bottom > rectangle.Bottom) Bottom = rectangle.Bottom; }
public void TestClone8BitIndexedRectangle(int x, int y, int width, int height) { var image = TestIcons.TexturesIndexed; var rect = new Rectangle(x, y, width, height); var clone = image.Clone(rect); ValidateImages(image, clone, rect); }
public override void Update(Eto.Drawing.Rectangle rect) { if (graphics == null) { return; } graphicsHandler.PerformDrawing(null, () => { Widget.OnPaint(new PaintEventArgs(graphics, rect)); }); }
public static Eto.Drawing.RectangleF ScreenToLogical(this Eto.Drawing.Rectangle rect, swf.Screen screen) { screen = screen ?? swf.Screen.FromPoint(rect.Location.ToSD()); var location = screen.GetLogicalLocation(); var pixelSize = screen.GetLogicalPixelSize(); var screenBounds = screen.GetBounds(); return(new Eto.Drawing.RectangleF( location.X + (rect.X - screenBounds.X) / pixelSize, location.Y + (rect.Y - screenBounds.Y) / pixelSize, rect.Width / pixelSize, rect.Height / pixelSize )); }
static void ValidateImages(Bitmap image, Bitmap clone, Rectangle? rect = null) { var testRect = rect ?? new Rectangle(image.Size); using (var imageData = image.Lock()) using (var cloneData = clone.Lock()) { if (imageData.BytesPerPixel == 1) { unsafe { // test pixels directly byte* imageptr = (byte*)imageData.Data; imageptr += testRect.Top * imageData.ScanWidth + testRect.Left; byte* cloneptr = (byte*)cloneData.Data; for (int y = 0; y < testRect.Height; y++) { byte* imagerow = imageptr; byte* clonerow = cloneptr; for (int x = 0; x < testRect.Width; x++) { var imagePixel = *(imagerow++); var clonePixel = *(clonerow++); if (imagePixel != clonePixel) { Assert.Fail("Image pixels are not the same at position {0},{1} (source: {2}, clone: {3})", x, y, imagePixel, clonePixel); } } imageptr += imageData.ScanWidth; cloneptr += cloneData.ScanWidth; } } } else for (int x = 0; x < testRect.Width; x++) for (int y = 0; y < testRect.Height; y++) { var imagePixel = imageData.GetPixel(x + testRect.Left, y + testRect.Top); var clonePixel = cloneData.GetPixel(x, y); if (imagePixel != clonePixel) Assert.Fail("Image pixels are not the same at position {0},{1} (source: {2}, clone: {3})", x, y, imagePixel, clonePixel); } } }
public void DrawInsetRectangle(Color topLeftColor, Color bottomRightColor, Rectangle rectangle) { DrawLine (topLeftColor, rectangle.TopLeft, rectangle.TopRight); DrawLine (topLeftColor, rectangle.TopLeft, rectangle.BottomLeft); DrawLine (bottomRightColor, rectangle.BottomLeft, rectangle.BottomRight); DrawLine (bottomRightColor, rectangle.TopRight, rectangle.BottomRight); }
public Bitmap Clone(Rectangle? rectangle = null) { throw new NotImplementedException(); }
PrintDocument GetPrintDocument() { var document = new PrintDocument(); document.PrintSettings = settings; var font = Fonts.Serif(16); var printTime = DateTime.Now; document.PrintPage += (sender, e) => { Size pageSize = Size.Round(e.PageSize); // draw a border around the printable area var rect = new Rectangle(pageSize); rect.Inflate(-1, -1); e.Graphics.DrawRectangle(Pens.Silver, rect); // draw title e.Graphics.DrawText(font, Colors.Black, new Point(50, 20), document.Name); // draw page number var text = string.Format("page {0} of {1}", e.CurrentPage + 1, document.PageCount); var textSize = Size.Round(e.Graphics.MeasureString(font, text)); e.Graphics.DrawText(font, Colors.Black, new Point(pageSize.Width - textSize.Width - 50, 20), text); // draw date text = string.Format("Printed on {0:f}", printTime); textSize = Size.Round(e.Graphics.MeasureString(font, text)); e.Graphics.DrawText(font, Colors.Black, new Point(pageSize.Width - textSize.Width - 50, pageSize.Height - textSize.Height - 20), text); // draw some rectangles switch (e.CurrentPage) { case 0: e.Graphics.DrawRectangle(Pens.Blue, new Rectangle(50, 50, 100, 100)); e.Graphics.DrawRectangle(Pens.Green, new Rectangle(new Point(pageSize) - new Size(150, 150), new Size(100, 100))); break; case 1: e.Graphics.DrawRectangle(Pens.Blue, new Rectangle(pageSize.Width - 150, 50, 100, 100)); e.Graphics.DrawRectangle(Pens.Green, new Rectangle(50, pageSize.Height - 150, 100, 100)); break; } }; document.Name = "Name Of Document"; document.PageCount = 2; return document; }
void HandleDocumentLoaded(object sender, WebViewLoadedEventArgs e) { var newIsLocal = string.IsNullOrEmpty(e.Uri.AbsolutePath) || e.Uri.IsLoopback; if (isLocal != newIsLocal) { isLocal = newIsLocal; var newSize = isLocal ? defaultSize : expandedSize; var location = this.Location; var rect = new Rectangle(location, this.ClientSize); rect.Inflate((newSize.Width - rect.Width) / 2, (newSize.Height - rect.Height) / 2); if (Generator.IsMac) rect.Y = location.Y; this.Location = rect.Location; this.ClientSize = rect.Size; } }
public bool Intersects(Rectangle rect) { return rect.X < this.X + this.Width && this.X < rect.X + rect.Width && rect.Y < this.Y + this.Height && this.Y < rect.Y + rect.Height; }
/// <summary> /// Excludes the specified <paramref name="rectangle"/> from the region /// </summary> /// <param name="rectangle">Rectangle to exclude</param> public void Exclude (Rectangle rectangle) { Handler.Exclude (rectangle); }
/// <summary> /// Draws an ellipse outline with the specified <paramref name="color"/> /// </summary> /// <param name="color">Color to outline the ellipse</param> /// <param name="rectangle">Location for the ellipse</param> public void DrawEllipse (Color color, Rectangle rectangle) { handler.DrawEllipse (color, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); }
/// <summary> /// Fills a rectangle with the specified <paramref name="color"/> /// </summary> /// <param name="color">Fill color</param> /// <param name="rectangle">Location for the rectangle</param> public void FillRectangle (Color color, Rectangle rectangle) { handler.FillRectangle (color, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); }
/// <summary> /// Draws an rectangle with colors on the top/left and bottom/right with the given <paramref name="width"/> /// </summary> /// <param name="topLeftColor">Color for top/left edges</param> /// <param name="bottomRightColor">Color for bottom/right edges</param> /// <param name="rectangle">Outside of inset rectangle to draw</param> /// <param name="width">Width of the rectangle, in pixels</param> public void DrawInsetRectangle (Color topLeftColor, Color bottomRightColor, Rectangle rectangle, int width = 1) { for (int i = 0; i < width; i++) { DrawLine (topLeftColor, rectangle.TopLeft, rectangle.InnerTopRight); DrawLine (topLeftColor, rectangle.TopLeft, rectangle.InnerBottomLeft); DrawLine (bottomRightColor, rectangle.InnerBottomLeft, rectangle.InnerBottomRight); DrawLine (bottomRightColor, rectangle.InnerTopRight, rectangle.InnerBottomRight); rectangle.Inflate (-1, -1); } }
public void Update(Eto.Drawing.Rectangle rect) { Invalidate(rect); }
public abstract void Set(Rectangle rect);
public abstract void Exclude(Rectangle rect);
public void DrawRectangle(Color color, Rectangle rectangle) { inner.DrawRectangle (color, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); }
/// <summary> /// Queues a repaint of the specified <paramref name="rect"/> of the control /// </summary> /// <remarks> /// This is only useful when the control is visible. /// </remarks> /// <param name="rect">Rectangle to repaint</param> public void Invalidate(Rectangle rect) { Handler.Invalidate(rect); }
static Control TestInitResize() { var app = Application.Instance; var control = new Button { Text = "Show splitter test of initial resize" }; Func<Splitter, Control> makebox = split => { var area = new TextArea(); area.SizeChanged += (s, e) => { var size = area.VisualParent.Size; if (split.Orientation == Orientation.Horizontal) size.Width -= split.SplitterWidth; else size.Height -= split.SplitterWidth; if (size.Width <= 0 || size.Height <= 0) return; app.AsyncInvoke(() => { area.Text = string.Format( "W:{0} ({1}%)\r\nH:{2} ({3}%)", area.Width, (area.Width * 200 + size.Width) / (size.Width + size.Width), area.Height, (area.Height * 200 + size.Height) / (size.Height + size.Height)); }); }; return area; }; Func<int, Form> makeform = i => { var wa = new Rectangle(Screen.PrimaryScreen.WorkingArea); var form = new Form { Title = "Test Form #" + (i + 1), Bounds = i == 0 ? new Rectangle(wa.X + 20, wa.Y + 20, wa.Width / 3, wa.Height / 3) : i == 1 ? new Rectangle(wa.X + 20, wa.Y + 40 + wa.Height / 3, wa.Width / 3, wa.Height * 2 / 3 - 60) : new Rectangle(wa.X + wa.Width / 3 + 40, wa.Y + 20, wa.Width * 2 / 3 - 60, wa.Height - 40) }; using (Context) { var main = new Splitter { Position = 80 }; var middle = new Splitter { FixedPanel = SplitterFixedPanel.Panel2, Width = 200, Position = 120 - main.SplitterWidth }; var ltop = new Splitter { Orientation = Orientation.Vertical, Position = 80 }; var lbottom = new Splitter { Orientation = Orientation.Vertical, FixedPanel = SplitterFixedPanel.Panel2, RelativePosition = 80 }; var right = new Splitter { Orientation = Orientation.Vertical, FixedPanel = SplitterFixedPanel.None, Height = 300 + main.SplitterWidth, Position = 100 // ~33% }; var center = new Splitter { FixedPanel = SplitterFixedPanel.None, RelativePosition = .4 }; main.Panel1 = ltop; main.Panel2 = middle; ltop.Panel1 = makebox(ltop); ltop.Panel2 = lbottom; lbottom.Panel1 = makebox(lbottom); lbottom.Panel2 = makebox(lbottom); middle.Panel1 = center; middle.Panel2 = right; right.Panel1 = makebox(right); right.Panel2 = makebox(right); center.Panel1 = makebox(center); center.Panel2 = makebox(center); form.Content = main; } form.Show(); return form; }; control.Click += (sender, e) => { var forms = new Form[3]; for (int i = 0; i < 3; i++) { forms[i] = makeform(i); forms[i].Closed += (fs, fe) => { var all = forms; forms = null; if (all != null) for (int j = 0; j < 3; j++) if (all[j] != fs) all[j].Close(); }; } }; return control; }
/// <summary> /// Draws the specified <paramref name="image"/> in a rectangle /// </summary> /// <remarks> /// This will scale the image to the specified width and height using the <see cref="ImageInterpolation"/> mode /// </remarks> /// <param name="image">Image to draw</param> /// <param name="rectangle">Where to draw the image</param> public void DrawImage (Image image, Rectangle rectangle) { handler.DrawImage (image, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); }
/// <summary> /// Sets the specified <paramref name="rectangle"/> in the region /// </summary> /// <param name="rectangle">Rectangle to set the region to</param> public void Set (Rectangle rectangle) { Handler.Set (rectangle); }
/// <summary> /// Draws the <paramref name="source"/> portion of an <paramref name="image"/>, scaling to the specified <paramref name="destination"/> /// </summary> /// <param name="image">Image to draw</param> /// <param name="source">Source rectangle of the image portion to draw</param> /// <param name="destination">Destination rectangle of where to draw the portion</param> public void DrawImage (Image image, Rectangle source, Point destination) { handler.DrawImage (image, source, new Rectangle (destination, source.Size)); }
public static Rectangle Union(Rectangle rect1, Rectangle rect2) { Rectangle rect = rect1; if (rect2.Left < rect.Left) rect.Left = rect2.Left; if (rect2.Top < rect.Top) rect.Top = rect2.Top; if (rect2.Right > rect.Right) rect.Right = rect2.Right; if (rect2.Bottom > rect.Bottom) rect.Bottom = rect2.Bottom; return rect; }
/// <summary> /// Draws the <paramref name="source"/> portion of an <paramref name="image"/>, scaling to the specified <paramref name="destination"/> /// </summary> /// <param name="image">Image to draw</param> /// <param name="source">Source rectangle of the image portion to draw</param> /// <param name="destination">Destination rectangle of where to draw the portion</param> public void DrawImage (Image image, Rectangle source, Rectangle destination) { handler.DrawImage (image, source, destination); }
public override void Read(BinaryReader reader) { base.Read(reader); Rectangle = reader.ReadRipRectangle(); reader.ReadRipNumber(); }
/// <summary> /// Draws the <paramref name="icon"/> at the specified location and size /// </summary> /// <param name="icon">Icon to draw</param> /// <param name="rectangle">Where to draw the icon</param> public void DrawIcon (Icon icon, Rectangle rectangle) { handler.DrawIcon (icon, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); }
/// <summary> /// Creates a clone of the bitmap /// </summary> public Bitmap Clone (Rectangle? rectangle = null) { return Handler.Clone (rectangle); }
public static System.Drawing.RectangleF ConvertF (Rectangle rect) { return new System.Drawing.RectangleF ((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height); }
/// <summary> /// Update the specified <paramref name="region"/> directly /// </summary> /// <remarks> /// This forces the region to be painted immediately. On some platforms, this will be similar to calling /// <see cref="Control.Invalidate(Rectangle)"/>, and queue the repaint instead of blocking until it is painted. /// </remarks> /// <param name="region">Region to update the control</param> public void Update(Rectangle region) { Handler.Update(region); }
void IControl.Invalidate(Eto.Drawing.Rectangle rect) { Control.View.SetNeedsDisplayInRect(Generator.ConvertF(rect)); }
public PaintEventArgs(Graphics graphics, Rectangle clipRectangle) { this.clipRectangle = clipRectangle; this.graphics = graphics; }
public void DrawImage(IImage image, Rectangle rect) { inner.DrawImage (image, rect.X, rect.Y, rect.Width, rect.Height); }
public void Invalidate(Eto.Drawing.Rectangle rect) { throw new NotImplementedException(); }
public void Update(Rectangle rect) { Handler.Update(rect); }
public void Invalidate(Eto.Drawing.Rectangle rect, bool invalidateChildren) { throw new NotImplementedException(); }
public static Eto.Drawing.RectangleF ScreenToLogical(this Eto.Drawing.Rectangle rect) => ScreenToLogical(rect.ToSD());