private void DrawPath(IGraphics graphics, GraphicsPath path, RectangleF rectangle, Color[] gradientColors, float width) { PenAlignment penAlignment = (width <= 1) ? PenAlignment.Inset : PenAlignment.Center; if (this.borderElement.GradientStyle == GradientStyles.Solid) { graphics.DrawPath(path, gradientColors[0], penAlignment, width); } else if (this.borderElement.GradientStyle == GradientStyles.Linear) { graphics.DrawLinearGradientPath(path, rectangle, gradientColors, penAlignment, width, this.borderElement.GradientAngle); } else { if (this.borderElement.GradientStyle == GradientStyles.Radial) { graphics.DrawRadialGradientPath(path, Rectangle.Round(rectangle), gradientColors[0], new Color[] { gradientColors[1], gradientColors[2], gradientColors[3] } , penAlignment, width); } } }
public void DrawBorder(Graphics graphics, Pen Pen, int borderSize, Rectangle rect, bool rightToLeft) { // back up the original properties float originalwidth = Pen.Width; PenAlignment originalAlignment = Pen.Alignment; // draw_3d_rect(Gui, hdc, &Rect, TRUE, TRUE); // BorderRenderer.PaintBorder(graphics, Pen, rect, ControlStyle.ThreeDSunken, true); rect.Width--; rect.Height--; // InflateRect(&Rect, -factor, -factor); rect.Inflate(-1, -1); // left line and top lines in Black // draw_table_secondary_border () graphics.DrawLine(rightToLeft ? SystemPens.ControlLight: SystemPens.ControlText, new Point(rect.Left, rect.Top), new Point(rect.Left, rect.Bottom)); graphics.DrawLine(SystemPens.ControlText, new Point(rect.Left, rect.Top), new Point(rect.Right, rect.Top)); // right and bottom lines in ControlLight if (rightToLeft) { rect.Width++; } graphics.DrawLine(rightToLeft ? SystemPens.ControlText : SystemPens.ControlLight, new Point(rect.Right, rect.Top), new Point(rect.Right, rect.Bottom)); graphics.DrawLine(SystemPens.ControlLight, new Point(rect.Left, rect.Bottom), new Point(rect.Right, rect.Bottom)); Pen.Alignment = originalAlignment; }
private Image GenerateLineImage() { int w = VirtualBounds.Width / Zoom; int h = VirtualBounds.Height / Zoom; using (Image lineImg = new Bitmap(w == 0?1:w, h == 0?1:h)) { using (Graphics gh = Graphics.FromImage(lineImg)) { gh.Clear(Color.Transparent); Point start = RelationStart; Point end = RelationEnd; PenAlignment pl = PenAlignment.Inset; using (var pen = _cache.GetPen(DrawingColor, BorderWidth, pl, LineDashStyle)) { gh.DrawLine(pen , start , end); } } return(FormatImage(lineImg, VirtualBounds)); } }
/// <summary> /// /// </summary> /// <param name="g"></param> /// <param name="rect"></param> /// <param name="fgColor"></param> /// <param name="style"></param> /// <param name="textBoxBorder"></param> /// <param name="borderType"></param> public static void PaintBorder(Graphics g, Rectangle rect, Color fgColor, ControlStyle style, bool textBoxBorder, BorderType borderType = BorderType.Thin) { Pen pen = null; bool shouldPaintBorder = !(style == ControlStyle.TwoD && borderType == BorderType.NoBorder); if (shouldPaintBorder) { if (style == ControlStyle.TwoD) { pen = PensCache.GetInstance().Get(fgColor); } if (style == ControlStyle.TwoD && borderType == BorderType.Thick) { // back up the original properties of pen PenAlignment originalAlligment = pen.Alignment; float originalwidth = pen.Width; // set properties of pen pen.Width = 2; pen.Alignment = PenAlignment.Inset; PaintBorder(g, pen, rect, style, textBoxBorder); // restore the original properties of pen pen.Alignment = originalAlligment; pen.Width = originalwidth; } else { PaintBorder(g, pen, rect, style, textBoxBorder); } } }
private void DrawPath( IGraphics graphics, GraphicsPath path, RectangleF rectangle, Color[] gradientColors, float width) { graphics.ChangeSmoothingMode(this.borderElement.SmoothingMode); PenAlignment penAlignment = (double)width <= 1.0 ? PenAlignment.Inset : PenAlignment.Center; if (this.borderElement.GradientStyle == GradientStyles.Solid) { graphics.DrawPath(path, gradientColors[0], penAlignment, width, this.borderElement.BorderDashStyle, this.borderElement.BorderDashPattern); } else if (this.borderElement.GradientStyle == GradientStyles.Linear) { graphics.DrawLinearGradientPath(path, rectangle, gradientColors, penAlignment, width, this.borderElement.GradientAngle, this.borderElement.BorderDashStyle, this.borderElement.BorderDashPattern); } else if (this.borderElement.GradientStyle == GradientStyles.Radial) { graphics.DrawRadialGradientPath(path, Rectangle.Round(rectangle), gradientColors[0], new Color[3] { gradientColors[1], gradientColors[2], gradientColors[3] }, penAlignment, width, this.borderElement.BorderDashStyle, this.borderElement.BorderDashPattern); } graphics.RestoreSmoothingMode(); }
/// <summary> /// Gets a new Pen with desired parameters /// </summary> /// <param name="color"></param> /// <param name="width"></param> /// <param name="alignment"></param> /// <returns></returns> public static Pen GetPencil(Color color, float width, PenAlignment alignment) { return(new Pen(color, width) { Alignment = alignment }); }
public Pen GetPen(Color color, int width, PenAlignment alignment, DashStyle dashStyle) { Pen pen = new Pen(color, width); pen.Alignment = alignment; pen.DashStyle = dashStyle; return(pen); }
public void Calculate (Vector2 p, Vector2 edgeAB, PenWorkspace ws, PenAlignment alignment, bool start) { edgeAB.Normalize(); // [ eAB.X -eAB.Y ] // [ eAB.Y eAB.X ] float tC = edgeAB.X * _width; float tS = edgeAB.Y * _width; float tX = p.X; float tY = p.Y; switch (alignment) { case PenAlignment.Center: break; case PenAlignment.Inset: if (start) { tX = p.X + (-.5f * tS); tY = p.Y - (-.5f * tC); } else { tX = p.X - (-.5f * tS); tY = p.Y + (-.5f * tC); } break; case PenAlignment.Outset: if (start) { tX = p.X + (.5f * tS); tY = p.Y - (.5f * tC); } else { tX = p.X - (.5f * tS); tY = p.Y + (.5f * tC); } break; } for (int i = 0; i < _xyBuffer.Length; i++) ws.XYBuffer[i] = new Vector2(_xyBuffer[i].X * tC - _xyBuffer[i].Y * tS + tX, _xyBuffer[i].X * tS + _xyBuffer[i].Y * tC + tY); for (int i = 0; i < _uvBuffer.Length; i++) ws.UVBuffer[i] = _uvBuffer[i]; for (int i = 0; i < _indexBuffer.Length; i++) ws.IndexBuffer[i] = _indexBuffer[i]; for (int i = 0; i < _outlineBuffer.Length; i++) ws.OutlineIndexBuffer[i] = _outlineBuffer[i]; ws.XYBuffer.Index = _xyBuffer.Length; ws.UVBuffer.Index = _uvBuffer.Length; ws.IndexBuffer.Index = _indexBuffer.Length; ws.OutlineIndexBuffer.Index = _outlineBuffer.Length; }
public Pen (Brush brush, float width) { _brush = (Brush)brush.Clone();; _width = width; _dashStyle = DashStyle.Solid; _startCap = LineCap.Flat; _dashCap = DashCap.Flat; _endCap = LineCap.Flat; _alignment = PenAlignment.Center; _lineJoin = LineJoin.Miter; _miterLimit = 10f; _transform = new Matrix(); }
public Pen(Brush brush, float width) { _brush = (Brush)brush.Clone();; _width = width; _dashStyle = DashStyle.Solid; _startCap = LineCap.Flat; _dashCap = DashCap.Flat; _endCap = LineCap.Flat; _alignment = PenAlignment.Center; _lineJoin = LineJoin.Miter; _miterLimit = 10f; _transform = new Matrix(); }
/// <summary> /// draw border /// </summary> /// <param name="graphics"></param> /// <param name="Pen"></param> /// <param name="borderSize"></param> /// <param name="rect"></param> public void DrawBorder(Graphics graphics, Pen Pen, int borderSize, Rectangle rect, bool rightToLeft) { // back up the original properties float originalwidth = Pen.Width; PenAlignment originalAlignment = Pen.Alignment; Pen.Width = borderSize; Pen.Alignment = PenAlignment.Inset; BorderRenderer.PaintBorder(graphics, Pen, rect, ControlStyle.TwoD, true); // restore the original properties Pen.Width = originalwidth; Pen.Alignment = originalAlignment; }
/// <summary> /// draw border /// </summary> /// <param name="graphics"></param> /// <param name="Pen"></param> /// <param name="borderSize"></param> /// <param name="rect"></param> public void DrawBorder(Graphics graphics, Pen Pen, int borderSize, Rectangle rect, bool rightToLeft) { // back up the original properties float originalwidth = Pen.Width; PenAlignment originalAlignment = Pen.Alignment; Pen.Alignment = PenAlignment.Inset; // draw_3d_rect (Gui, hDC, &Rect, TRUE); BorderRenderer.PaintBorder(graphics, Pen, rect, ControlStyle.ThreeDSunken, true); // InflateRect (&Rect, -factor, -factor); rect.Inflate(-1, -1); // Gui->ctx->gui_.dc_->frame_rect (&Rect, FIX_SYS_COLOR_BTNTEXT, 1, 0L); BorderRenderer.PaintBorder(graphics, SystemPens.ControlText, rect, ControlStyle.TwoD, true); Pen.Alignment = originalAlignment; }
GdipGetPenMode(GpPen pen, out PenAlignment penMode);
GdipSetPenMode(GpPen pen, PenAlignment penMode);
public Pen(Color color, float width, PenAlignment alignment) : this(new SolidColorBrush(color), width, true) { Alignment = alignment; }
internal static extern GpStatus GdipGetPenMode(GpPen pen, out PenAlignment penMode);
public void Calculate(CCVector2 p, CCVector2 edgeAB, PenWorkspace ws, PenAlignment alignment, bool start) { edgeAB.Normalize(); // [ eAB.X -eAB.Y ] // [ eAB.Y eAB.X ] float tC = edgeAB.X * _width; float tS = edgeAB.Y * _width; float tX = p.X; float tY = p.Y; switch (alignment) { case PenAlignment.Center: break; case PenAlignment.Inset: if (start) { tX = p.X + (-.5f * tS); tY = p.Y - (-.5f * tC); } else { tX = p.X - (-.5f * tS); tY = p.Y + (-.5f * tC); } break; case PenAlignment.Outset: if (start) { tX = p.X + (.5f * tS); tY = p.Y - (.5f * tC); } else { tX = p.X - (.5f * tS); tY = p.Y + (.5f * tC); } break; } for (int i = 0; i < _xyBuffer.Length; i++) { ws.XYBuffer[i] = new CCVector2(_xyBuffer[i].X * tC - _xyBuffer[i].Y * tS + tX, _xyBuffer[i].X * tS + _xyBuffer[i].Y * tC + tY); } for (int i = 0; i < _uvBuffer.Length; i++) { ws.UVBuffer[i] = _uvBuffer[i]; } for (int i = 0; i < _indexBuffer.Length; i++) { ws.IndexBuffer[i] = _indexBuffer[i]; } for (int i = 0; i < _outlineBuffer.Length; i++) { ws.OutlineIndexBuffer[i] = _outlineBuffer[i]; } ws.XYBuffer.Index = _xyBuffer.Length; ws.UVBuffer.Index = _uvBuffer.Length; ws.IndexBuffer.Index = _indexBuffer.Length; ws.OutlineIndexBuffer.Index = _outlineBuffer.Length; }
public void SetAlignment(PenAlignment penAlignment) { SetStatus(GdiPlus.GdipSetPenMode(nativePen, penAlignment)); }
extern static internal GpStatus GdipGetPenMode(GpPen pen, out PenAlignment penMode);
internal static extern int GdipGetPenMode(HandleRef pen, out PenAlignment penAlign);
/// <summary> /// Copies the properties of another instance to this instance. /// </summary> /// <param name="pen">the PenHolder object to copy</param> public void CopyFrom(PenX pen) { if (object.ReferenceEquals(this, pen)) return; _SetPenVariable(null); this._configuredProperties = pen._configuredProperties; this._penType = pen.PenType; this._alignment = pen.Alignment; if (0 != (this._configuredProperties & Configured.Brush)) this._brush = new BrushX(pen._brush); this._color = pen.Color; if (null != pen._compoundArray) this._compoundArray = (float[])pen.CompoundArray.Clone(); else this._compoundArray = null; this._dashPattern = pen._dashPattern; // immutable this._dashCap = pen._dashCap; this._cachedDashStyle = pen._cachedDashStyle; if (null != pen._cachedDashPattern) this._cachedDashPattern = (float[])pen._cachedDashPattern.Clone(); else this._cachedDashPattern = null; this._cachedDashOffset = pen._cachedDashOffset; this._endCap = pen.EndCap; this._lineJoin = pen.LineJoin; this._miterLimit = pen.MiterLimit; this._startCap = pen.StartCap; if (null != pen._transformation) this._transformation = pen.Transform.Clone(); else this._transformation = null; this._width = pen.Width; // note: there is an problem with Pen.Clone() : if the Color of the pen // was set to a known color, the color of the cloned pen is the same, but no longer a known color // therefore we avoid the cloning of the pen here // if(m_CachedMode && null!=pen.m_Pen) // _SetPenVariable( (Pen)pen.m_Pen.Clone() ); // else // _SetPenVariable(null); }
public OutlineSettings(Color c, int alpha, float w, PenAlignment align) { oline_color = Color.FromArgb(oline_alpha = alpha, c); oline_width = w; oline_style = align; }
/// <summary> /// Creates Pen object using the BorderColor and BorderWidth properties. /// </summary> public Pen GetBorderPen(float scaleFactor, PenAlignment penAlignment) { Pen pen = new Pen(_BorderColor, (float)Math.Round(_BorderWidth * scaleFactor, 0)); pen.Alignment = penAlignment; return pen; }
public ColourOutline(float width, PenAlignment outline_style) : this(string.Empty, width, outline_style) { }
public ColourOutline(string name, float width, PenAlignment outline_style) { Width = width; Style = outline_style; }
public GpStatus SetAlignment(PenAlignment penAlignment) { return(SetStatus(NativeMethods.GdipSetPenMode(nativePen, penAlignment))); }
protected int GetPenHash(Color color, int width, PenAlignment alignment, DashStyle style) { return(color.GetHashCode() ^ width ^ (int)alignment ^ (int)style); }
internal static extern Status GdipGetPenMode (IntPtr pen, out PenAlignment alignment);
public static extern GpStatus GdipSetPenMode(GpPen pen, PenAlignment penMode);
/// <summary> /// Copies the properties of another instance to this instance. /// </summary> /// <param name="pen">the PenHolder object to copy</param> public void CopyFrom(PenX pen) { _SetPenVariable(null); this.m_ConfiguredProperties = pen.m_ConfiguredProperties; this.m_PenType = pen.PenType; this.m_Alignment = pen.Alignment; if (0 != (this.m_ConfiguredProperties & Configured.Brush)) this.m_Brush = new BrushX(pen.m_Brush); this.m_Color = pen.Color; if (null != pen.m_CompoundArray) this.m_CompoundArray = (float[])pen.CompoundArray.Clone(); else this.m_CompoundArray = null; this.m_DashCap = pen.DashCap; this.m_DashOffset = pen.DashOffset; if (null != pen.m_DashPattern) this.m_DashPattern = (float[])pen.DashPattern.Clone(); else this.m_DashPattern = null; this.m_DashStyle = pen.DashStyle; this.m_EndCap = pen.EndCap; this.m_LineJoin = pen.LineJoin; this.m_MiterLimit = pen.MiterLimit; this.m_StartCap = pen.StartCap; if (null != pen.m_Transform) this.m_Transform = pen.Transform.Clone(); else this.m_Transform = null; this.m_Width = pen.Width; // note: there is an problem with Pen.Clone() : if the Color of the pen // was set to a known color, the color of the cloned pen is the same, but no longer a known color // therefore we avoid the cloning of the pen here // if(m_CachedMode && null!=pen.m_Pen) // _SetPenVariable( (Pen)pen.m_Pen.Clone() ); // else // _SetPenVariable(null); }
public Pen GetPen(Color color, int width, PenAlignment alignment) { return(GetPen(color, width, alignment, DashStyle.Solid)); }
public GpStatus SetAlignment(PenAlignment penAlignment) { return SetStatus(NativeMethods.GdipSetPenMode(nativePen, penAlignment)); }