public void ConstructMouseDoubleClick(IMapDocument doc, System.Windows.Forms.MouseEventArgs e) { if (ActiveDisplay(doc) == null || _addContainer == null || _addContainer.Elements.Count == 0) { return; } GraphicPolygon element = _addContainer.Elements[0] as GraphicPolygon; if (element == null) { return; } // Remove the last 1 Points... element._polygon[0].RemovePoint(element._polygon[0].PointCount - 1); //element._polygon[0].ReomvePoint(element._polygon[0].PointCount - 1); element.Symbol = _symbol.Clone() as ISymbol; element.Template = element._polygon; IEnvelope env = element._polygon.Envelope; element.Scale(env.Width, env.Height); element.Translation(env.minx, env.miny); element._polygon = null; GraphicShape.AddElementToContainer(doc, element); _addContainer = null; _moveable = null; }
public void DrawShape(Rectangle rect, int radius, PenPlus pen, GraphicShape shape, RoundedCorners corners) { if (rect.Width < 1 || rect.Height < 1) return; PathFunc func = GetShapeFunc(shape); GraphicsPath path = func(rect, radius, 0, PathMode.All, corners); this.DrawPath(pen, path); }
public void ConstructMouseUp(IMapDocument doc, System.Windows.Forms.MouseEventArgs e) { _mousePressed = false; if (ActiveDisplay(doc) == null || _addContainer == null || _addContainer.Elements.Count == 0) { return; } Freehand element = _addContainer.Elements[0] as Freehand; if (element == null) { return; } element.Symbol = _symbol.Clone() as ISymbol; element.Template = element._pLine; IEnvelope env = element._pLine.Envelope; element.Scale(env.Width, env.Height); element.Translation(env.minx, env.miny); element._pLine = null; GraphicShape.AddElementToContainer(doc, element); _addContainer = null; }
public void DrawShape(Rectangle rect, int radius, PenPlus pen, GraphicShape shape, RoundedCorners corners) { if (rect.Width < 1 || rect.Height < 1) { return; } PathFunc func = GetShapeFunc(shape); GraphicsPath path = func(rect, radius, 0, PathMode.All, corners); this.DrawPath(pen, path); }
private static PathFunc GetShapeFunc(GraphicShape shape) { switch (shape) { case GraphicShape.Ellipse: return(GetEllipsePath); case GraphicShape.Back: return(GetBackPath); case GraphicShape.Next: return(GetNextPath); case GraphicShape.Rectangle: return(GetRectPath); default: return(GetRoundPath); } }
protected virtual void PaintButtonBackground(FluidPaintEventArgs e) { const int const_radius = 8; if (this.shape != ButtonShape.Flat || IsDown) { Rectangle rect = ButtonRectangle; rect.Width--; rect.Height--; if (rect.Width < 1 || rect.Height < 1) { return; } rect.Offset(e.ControlBounds.X, e.ControlBounds.Y); Graphics g = e.Graphics; int radius = e.ScaleX(const_radius); if (radius > rect.Width / 2) { radius = rect.Width / 2; } Color endColor = this.BackColor; if (!Enabled) { endColor = ColorConverter.AlphaBlendColor(Color.Black, endColor, 128); } int alpha = Enabled ? 127 : 32; Color startColor = ColorConverter.AlphaBlendColor(endColor, Color.White, alpha); //Color.FromArgb(0x7fffffff); Color borderColor = ColorConverter.AlphaBlendColor(endColor, Color.White, 100); GraphicShape shape = ButtonShapeToGraphic(this.shape); using (GraphicsPlus gp = new GraphicsPlus(g)) { GraphicsPlus.GradientMode mode = IsDown ? GraphicsPlus.GradientMode.Bottom : GraphicsPlus.GradientMode.Top; gp.GradientFillShape(rect, radius, startColor, endColor, mode, shape, corners); using (PenPlus pen = new PenPlus(borderColor, (float)1)) { gp.DrawShape(rect, radius, pen, shape, corners); } } } PerformPaintButtonContent(e); }
public DisplayObject GetDisplayObject() { GraphicShape graphicShape = new GraphicShape(parameters.Points); return(graphicShape); }
private static PathFunc GetShapeFunc(GraphicShape shape) { switch (shape) { case GraphicShape.Ellipse: return GetEllipsePath; case GraphicShape.Back: return GetBackPath; case GraphicShape.Next: return GetNextPath; case GraphicShape.Rectangle: return GetRectPath; default: return GetRoundPath; } }
public void GradientFillShape(Rectangle rect, int radius, Color startColor, Color endColor, GradientMode gradientMode, GraphicShape shape, RoundedCorners corners) { if (rect.Width < 1 || rect.Height < 1) return; PathFunc func = GetShapeFunc(shape); SmoothingMode mode = SmoothingMode; try { SmoothingMode = SmoothingMode.None; int x = rect.X, y = rect.Y, w = rect.Width, h = rect.Height; int reflectionHeight = h / 2; PointF p1 = new PointF(x, y); PointF p2 = new PointF(x, y + reflectionHeight); if (gradientMode == GradientMode.Top) { PathMode pathMode = endColor.A == 255 ? PathMode.Bottom : PathMode.All; using (GraphicsPath path = func(rect, radius, reflectionHeight, pathMode, corners)) { using (SolidBrushPlus brush = new SolidBrushPlus(endColor)) { this.FillPath(brush, path); } } using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.Top, corners)) { using (LinearGradientBrush brush = new LinearGradientBrush(p1, p2, startColor, endColor)) { this.FillPath(brush, path); } } } else { PathMode pathMode = endColor.A == 255 ? PathMode.Top : PathMode.All; using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.All, corners)) { using (SolidBrushPlus brush = new SolidBrushPlus(endColor)) { this.FillPath(brush, path); } } using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.Bottom, corners)) { p1.Y = y + reflectionHeight - 1; p2.Y = y + h; using (LinearGradientBrush brush = new LinearGradientBrush(p1, p2, endColor, startColor)) { this.FillPath(brush, path); } } } } finally { SmoothingMode = mode; } }
public void GradientFillShape(Rectangle rect, int radius, Color startColor, Color endColor, GradientMode gradientMode, GraphicShape shape, RoundedCorners corners) { if (rect.Width < 1 || rect.Height < 1) { return; } PathFunc func = GetShapeFunc(shape); SmoothingMode mode = SmoothingMode; try { SmoothingMode = SmoothingMode.None; int x = rect.X, y = rect.Y, w = rect.Width, h = rect.Height; int reflectionHeight = h / 2; PointF p1 = new PointF(x, y); PointF p2 = new PointF(x, y + reflectionHeight); if (gradientMode == GradientMode.Top) { PathMode pathMode = endColor.A == 255 ? PathMode.Bottom : PathMode.All; using (GraphicsPath path = func(rect, radius, reflectionHeight, pathMode, corners)) { using (SolidBrushPlus brush = new SolidBrushPlus(endColor)) { this.FillPath(brush, path); } } using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.Top, corners)) { using (LinearGradientBrush brush = new LinearGradientBrush(p1, p2, startColor, endColor)) { this.FillPath(brush, path); } } } else { PathMode pathMode = endColor.A == 255 ? PathMode.Top : PathMode.All; using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.All, corners)) { using (SolidBrushPlus brush = new SolidBrushPlus(endColor)) { this.FillPath(brush, path); } } using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.Bottom, corners)) { p1.Y = y + reflectionHeight - 1; p2.Y = y + h; using (LinearGradientBrush brush = new LinearGradientBrush(p1, p2, endColor, startColor)) { this.FillPath(brush, path); } } } } finally { SmoothingMode = mode; } }