protected override void OnFillRegionComputed(Point[][] polygonSet) { using (PdnGraphicsPath path = new PdnGraphicsPath()) { path.AddPolygons(polygonSet); using (PdnRegion fillRegion = new PdnRegion(path)) { Rectangle boundingBox = fillRegion.GetBoundsInt(); Surface surface = ((BitmapLayer)ActiveLayer).Surface; RenderArgs ra = new RenderArgs(surface); HistoryMemento ha; using (PdnRegion affected = Utility.SimplifyAndInflateRegion(fillRegion)) { ha = new BitmapHistoryMemento(Name, Image, DocumentWorkspace, DocumentWorkspace.ActiveLayerIndex, affected); } ra.Graphics.CompositingMode = AppEnvironment.GetCompositingMode(); ra.Graphics.FillRegion(brush, fillRegion.GetRegionReadOnly()); HistoryStack.PushNewMemento(ha); ActiveLayer.Invalidate(boundingBox); Update(); } } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (mouseDown) { return; } if (((e.Button & MouseButtons.Left) == MouseButtons.Left) || ((e.Button & MouseButtons.Right) == MouseButtons.Right)) { mouseDown = true; mouseButton = e.Button; tracePoints = new List <Point>(); bitmapLayer = (BitmapLayer)ActiveLayer; renderArgs = new RenderArgs(bitmapLayer.Surface); clipRegion?.Dispose(); clipRegion = null; clipRegion = Selection.CreateRegion(); renderArgs.Graphics.SetClip(clipRegion.GetRegionReadOnly(), CombineMode.Replace); OnMouseMove(e); } }
private void DrawSelectionOutline(Graphics g) { if (selectionOutline == null) { return; } g.FillRegion(outlinebrush, selectionOutline.GetRegionReadOnly()); }
private void DrawSelectionTinting(Graphics g) { if (unSelection == null) { return; } CompositingMode oldCM = g.CompositingMode; g.CompositingMode = CompositingMode.SourceOver; g.FillRegion(tintbrush, unSelection.GetRegionReadOnly()); g.CompositingMode = oldCM; }
protected override void OnStylusDown(StylusEventArgs e) { base.OnStylusDown(e); if (!this.shapeWasCommited) { CommitShape(); } this.ClearSavedMemory(); this.ClearSavedRegion(); cursorMouseUp = Cursor; Cursor = cursorMouseDown; if (mouseDown && e.Button == mouseButton) { return; } if (mouseDown) { moveOriginMode = true; lastXY = new PointF(e.Fx, e.Fy); OnStylusMove(e); } else if (((e.Button & MouseButtons.Left) == MouseButtons.Left) || ((e.Button & MouseButtons.Right) == MouseButtons.Right)) { // begin new shape this.shapeWasCommited = false; OnShapeBegin(); mouseDown = true; mouseButton = e.Button; using (PdnRegion clipRegion = Selection.CreateRegion()) { renderArgs.Graphics.SetClip(clipRegion.GetRegionReadOnly(), CombineMode.Replace); } // reset the points we're drawing! points = new List <PointF>(); OnStylusMove(e); } }
protected override void OnStylusDown(StylusEventArgs e) { base.OnStylusDown(e); if (mouseDown) { return; } ClearSavedMemory(); this.previewRenderer.Visible = false; Cursor = cursorMouseDown; if (((e.Button & MouseButtons.Left) == MouseButtons.Left) || ((e.Button & MouseButtons.Right) == MouseButtons.Right)) { mouseButton = e.Button; if ((mouseButton & MouseButtons.Left) == MouseButtons.Left) { brush = AppEnvironment.CreateBrush(false); } else if ((mouseButton & MouseButtons.Right) == MouseButtons.Right) { brush = AppEnvironment.CreateBrush(true); } lastMouseXY.X = e.Fx; lastMouseXY.Y = e.Fy; mouseDown = true; mouseButton = e.Button; using (PdnRegion clipRegion = Selection.CreateRegion()) { renderArgs.Graphics.SetClip(clipRegion.GetRegionReadOnly(), CombineMode.Replace); } this.OnStylusMove(new StylusEventArgs(e.Button, e.Clicks, unchecked (e.Fx + 0.01f), e.Fy, e.Delta, e.Pressure)); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); this.Cursor = this.cursorMouseDown; if (((e.Button & MouseButtons.Left) == MouseButtons.Left) || ((e.Button & MouseButtons.Right) == MouseButtons.Right)) { this.previewRenderer.Visible = false; mouseDown = true; mouseButton = e.Button; lastMouseXY.X = e.X; lastMouseXY.Y = e.Y; PdnRegion clipRegion = Selection.CreateRegion(); renderArgs.Graphics.SetClip(clipRegion.GetRegionReadOnly(), CombineMode.Replace); clipRegion.Dispose(); OnMouseMove(e); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (mouseDown) { return; } if (((e.Button & MouseButtons.Left) == MouseButtons.Left) || ((e.Button & MouseButtons.Right) == MouseButtons.Right)) { mouseDown = true; mouseButton = e.Button; tracePoints = new List<Point>(); bitmapLayer = (BitmapLayer)ActiveLayer; renderArgs = new RenderArgs(bitmapLayer.Surface); if (clipRegion != null) { clipRegion.Dispose(); clipRegion = null; } clipRegion = Selection.CreateRegion(); renderArgs.Graphics.SetClip(clipRegion.GetRegionReadOnly(), CombineMode.Replace); OnMouseMove(e); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (mouseDown) { return; } if (BtnDownMouseLeft(e) || BtnDownMouseRight(e)) { this.previewRenderer.Visible = false; mouseDown = true; Cursor = cursorMouseDown; if ((!KeyDownControlOnly()) && (!KeyDownShiftOnly())) { mouseButton = e.Button; lastMouseXY.X = e.X; lastMouseXY.Y = e.Y; // parses and establishes the active selection area if (clipRegion != null) { clipRegion.Dispose(); clipRegion = null; } clipRegion = Selection.CreateRegion(); renderArgs.Graphics.SetClip(clipRegion.GetRegionReadOnly(), CombineMode.Replace); // find the replacement color and the color to replace colorReplacing = AppEnvironment.PrimaryColor; colorToReplace = AppEnvironment.SecondaryColor; penWidth = AppEnvironment.PenInfo.Width; // get the pen width find the ceiling integer of half of the pen width ceilingPenWidth = (int)Math.Max(Math.Ceiling(penWidth), 3); // used only for cursor positioning halfPenWidth = (int)Math.Ceiling(penWidth / 2.0f); // set hasDrawn to false since nothing has been drawn hasDrawn = false; // render the circle via GDI+ so the AA techniques can precisely // mimic GDI+. this.brushRenderArgs = RenderCircleBrush(); // establish tolerance myTolerance = (int)(AppEnvironment.Tolerance * 256); // restrict tolerance so no overlap is permitted RestrictTolerance(); OnMouseMove(e); } else { modifierDown = ModifierKeys; OnMouseMove(e); } } }
private void DrawGradient(Graphics g) { Rectangle rectangle; double num; g.PixelOffsetMode = PixelOffsetMode.Half; System.Windows.Forms.Orientation orientation = this.orientation; if (orientation != System.Windows.Forms.Orientation.Horizontal) { if (orientation != System.Windows.Forms.Orientation.Vertical) { throw ExceptionUtil.InvalidEnumArgumentException <System.Windows.Forms.Orientation>(this.orientation, "this.Orientation"); } } else { num = 180.0; goto Label_0040; } num = 90.0; Label_0040: rectangle = base.ClientRectangle; orientation = this.orientation; if (orientation != System.Windows.Forms.Orientation.Horizontal) { if (orientation != System.Windows.Forms.Orientation.Vertical) { throw ExceptionUtil.InvalidEnumArgumentException <System.Windows.Forms.Orientation>(this.orientation, "this.Orientation"); } } else { rectangle.Inflate(-3, -4); goto Label_0082; } rectangle.Inflate(-4, -3); Label_0082: if (((this.customGradient != null) && (rectangle.Width > 1)) && (rectangle.Height > 1)) { Surface surface = new Surface(rectangle.Size.ToSizeInt32()); using (RenderArgs args = new RenderArgs(surface)) { ColorRectangle.Draw(args.Graphics, args.Bounds, Color.Transparent, true, false); if (this.Orientation == System.Windows.Forms.Orientation.Horizontal) { for (int j = 0; j < surface.Width; j++) { double num16; double num17; double num18; double d = ((double)(j * (this.customGradient.Length - 1))) / ((double)(surface.Width - 1)); int index = (int)Math.Floor(d); double num5 = 1.0 - (d - index); int num6 = (int)Math.Min((double)(this.customGradient.Length - 1), Math.Ceiling(d)); Color c = this.customGradient[index]; Color disabledColor = this.customGradient[num6]; if (!base.Enabled) { c = DisabledRendering.GetDisabledColor(c); disabledColor = DisabledRendering.GetDisabledColor(disabledColor); } double num7 = ((double)c.A) / 255.0; double num8 = ((double)c.R) / 255.0; double num9 = ((double)c.G) / 255.0; double num10 = ((double)c.B) / 255.0; double num11 = ((double)disabledColor.A) / 255.0; double num12 = ((double)disabledColor.R) / 255.0; double num13 = ((double)disabledColor.G) / 255.0; double num14 = ((double)disabledColor.B) / 255.0; double num15 = (num5 * num7) + ((1.0 - num5) * num11); if (num15 == 0.0) { num16 = 0.0; num17 = 0.0; num18 = 0.0; } else { num16 = (((num5 * num7) * num8) + (((1.0 - num5) * num11) * num12)) / num15; num17 = (((num5 * num7) * num9) + (((1.0 - num5) * num11) * num13)) / num15; num18 = (((num5 * num7) * num10) + (((1.0 - num5) * num11) * num14)) / num15; } int num19 = ((int)Math.Round((double)(num15 * 255.0), MidpointRounding.AwayFromZero)).Clamp(0, 0xff); int num20 = ((int)Math.Round((double)(num16 * 255.0), MidpointRounding.AwayFromZero)).Clamp(0, 0xff); int num21 = ((int)Math.Round((double)(num17 * 255.0), MidpointRounding.AwayFromZero)).Clamp(0, 0xff); int num22 = ((int)Math.Round((double)(num18 * 255.0), MidpointRounding.AwayFromZero)).Clamp(0, 0xff); for (int k = 0; k < surface.Height; k++) { ColorBgra bgra = surface[j, k]; int num24 = ((num20 * num19) + (bgra.R * (0xff - num19))) / 0xff; int num25 = ((num21 * num19) + (bgra.G * (0xff - num19))) / 0xff; int num26 = ((num22 * num19) + (bgra.B * (0xff - num19))) / 0xff; surface[j, k] = ColorBgra.FromBgra((byte)num26, (byte)num25, (byte)num24, 0xff); } } g.DrawImage(args.Bitmap, rectangle, args.Bounds, GraphicsUnit.Pixel); } else if (this.Orientation != System.Windows.Forms.Orientation.Vertical) { throw ExceptionUtil.InvalidEnumArgumentException <System.Windows.Forms.Orientation>(this.orientation, "this.Orientation"); } } surface.Dispose(); } else { Color color3 = base.Enabled ? this.maxColor : DisabledRendering.GetDisabledColor(this.maxColor); Color color4 = base.Enabled ? this.minColor : DisabledRendering.GetDisabledColor(this.minColor); using (LinearGradientBrush brush = new LinearGradientBrush(base.ClientRectangle, color3, color4, (float)num, false)) { g.FillRectangle(brush, rectangle); } } using (PdnRegion region = new PdnRegion()) { region.MakeInfinite(); region.Exclude(rectangle); using (SolidBrush brush2 = new SolidBrush(this.BackColor)) { g.FillRegion(brush2, region.GetRegionReadOnly()); } } for (int i = 0; i < this.vals.Length; i++) { Brush blue; Pen pen; Point point; Point point2; Point point3; Point point4; Point point5; Point point6; int x = this.ValueToPosition(this.vals[i]); if (i == this.highlight) { blue = Brushes.Blue; pen = (Pen)Pens.White.Clone(); } else { blue = base.Enabled ? Brushes.Black : Brushes.Gray; pen = (Pen)Pens.Gray.Clone(); } g.SmoothingMode = SmoothingMode.AntiAlias; orientation = this.orientation; if (orientation != System.Windows.Forms.Orientation.Horizontal) { if (orientation != System.Windows.Forms.Orientation.Vertical) { throw ExceptionUtil.InvalidEnumArgumentException <System.Windows.Forms.Orientation>(this.orientation, "this.Orientation"); } } else { point = new Point(x - 3, 0); point2 = new Point(x, 6); point3 = new Point(x + 3, 0); point4 = new Point(point.X, (base.Height - 1) - point.Y); point5 = new Point(point2.X, (base.Height - 1) - point2.Y); point6 = new Point(point3.X, (base.Height - 1) - point3.Y); goto Label_0678; } point = new Point(0, x - 3); point2 = new Point(6, x); point3 = new Point(0, x + 3); point4 = new Point((base.Width - 1) - point.X, point.Y); point5 = new Point((base.Width - 1) - point2.X, point2.Y); point6 = new Point((base.Width - 1) - point3.X, point3.Y); Label_0678: if (this.drawNearNub) { Point[] points = new Point[] { point, point2, point3, point }; g.FillPolygon(blue, points); } if (this.drawFarNub) { Point[] pointArray2 = new Point[] { point4, point5, point6, point4 }; g.FillPolygon(blue, pointArray2); } if (pen != null) { if (this.drawNearNub) { Point[] pointArray3 = new Point[] { point, point2, point3, point }; g.DrawPolygon(pen, pointArray3); } if (this.drawFarNub) { Point[] pointArray4 = new Point[] { point4, point5, point6, point4 }; g.DrawPolygon(pen, pointArray4); } pen.Dispose(); } } }