private void Draw(System.Drawing.Drawing2D.DashStyle DashStyle, Graphics g, int Width, int Height) { Pen p = new Pen(Color.Black, 2); p.DashStyle = DashStyle; g.DrawLine(p, 0, Height / 2, Width, Height / 2); }
private void setupStyles(System.Windows.Forms.Panel pan, System.Drawing.Drawing2D.DashStyle[] styles) { var gb = new System.Windows.Forms.FlowLayoutPanel(); gb.SuspendLayout(); gb.Margin = new System.Windows.Forms.Padding(1, 1, 1, 1); gb.AutoSize = true; // SOLID, DASHED, DOTTED for (int idx = 0; idx < styles.Length; ++idx) { var rb = new System.Windows.Forms.RadioButton(); rb.Appearance = System.Windows.Forms.Appearance.Button; var im = new Bitmap(30, 20); var graph = Graphics.FromImage(im); var impen = new Pen(ChartControl.AxisColor, 1.0f); impen.DashStyle = styles[idx]; graph.DrawLine(impen, 0, 10, 30, 10); rb.Image = im; var thisst = styles[idx]; rb.Click += ((s, e) => { cachedObj = null; selectedStyle = thisst; }); rb.Size = im.Size; gb.Controls.Add(rb); if (idx == 0) { rb.Checked = true; selectedStyle = thisst; } } gb.ResumeLayout(false); pan.Controls.Add(gb); }
/// <summary> /// Change the dashStyle of the current struct instance and return a copy of the modified struct. /// </summary> /// <param name="dashStyle"></param> /// <returns></returns> public IRectangleBorder SetDashStyle(System.Drawing.Drawing2D.DashStyle dashStyle) { Top = new BorderLine(Top.Color, Top.Width, dashStyle, Top.Padding); Bottom = new BorderLine(Bottom.Color, Bottom.Width, dashStyle, Bottom.Padding); Left = new BorderLine(Left.Color, Left.Width, dashStyle, Left.Padding); Right = new BorderLine(Right.Color, Right.Width, dashStyle, Right.Padding); return(this); }
private void SetStyle(string s) { try { this.DashStyle = (System.Drawing.Drawing2D.DashStyle)Enum.Parse(typeof(System.Drawing.Drawing2D.DashStyle), s, true); } catch { } }
public FormulaData() { this.AxisYIndex = 0; this.FormulaType = Easychart.Finance.FormulaType.Array; this.FormulaColor = Color.Empty; this.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; this.LineWidth = -1; this.Format = "f2"; this.LabelIndex = 0; this.VAlign = VerticalAlign.Top; }
protected override Geometry OnCreateOutlineFillGeometry(RectDouble bounds, IDictionary <string, object> settingValues) { Geometry ellipseGeometry = this.GetEllipseGeometry(bounds); float num = (float)settingValues[ToolSettings.Null.Pen.Width.Path]; System.Drawing.Drawing2D.DashStyle gdipDashStyle = (System.Drawing.Drawing2D.DashStyle)settingValues[ToolSettings.Null.Pen.DashStyle.Path]; PaintDotNet.UI.Media.DashStyle style2 = DashStyleUtil.ToMedia(gdipDashStyle); StrokeStyle style3 = new StrokeStyle { DashStyle = style2 }.EnsureFrozen <StrokeStyle>(); WidenedGeometry freezable = new WidenedGeometry { Geometry = ellipseGeometry, Thickness = num, StrokeStyle = style3, FlatteningTolerance = 0.0001 }; return(freezable.EnsureFrozen <WidenedGeometry>()); }
public static System.Drawing.Pen CreatePen(this AppSettings.ToolsSection toolSettings, ColorBgra32 foreColor, ColorBgra32 backColor) { System.Drawing.Pen pen; LineCap cap3; CustomLineCap cap4; LineCap cap5; CustomLineCap cap6; float width = toolSettings.Pen.Width.Value; LineCap2 cap = toolSettings.Pen.StartCap.Value; LineCap2 cap2 = toolSettings.Pen.EndCap.Value; System.Drawing.Drawing2D.DashStyle style = toolSettings.Pen.DashStyle.Value; if (((PaintDotNet.BrushType)toolSettings.Brush.Type.Value) == PaintDotNet.BrushType.None) { pen = new System.Drawing.Pen((Color)foreColor, width); } else { pen = new System.Drawing.Pen(toolSettings.CreateGdipBrush(foreColor, backColor), width); } LineCapToLineCap2(cap, out cap3, out cap4); if (cap4 != null) { pen.CustomStartCap = cap4; } else { pen.StartCap = cap3; } LineCapToLineCap2(cap2, out cap5, out cap6); if (cap6 != null) { pen.CustomEndCap = cap6; } else { pen.EndCap = cap5; } pen.DashStyle = style; return(pen); }
public static PaintDotNet.UI.Media.DashStyle ToMedia(System.Drawing.Drawing2D.DashStyle gdipDashStyle) { switch (gdipDashStyle) { case System.Drawing.Drawing2D.DashStyle.Solid: return(DashStyles.Solid); case System.Drawing.Drawing2D.DashStyle.Dash: return(DashStyles.Dash); case System.Drawing.Drawing2D.DashStyle.Dot: return(DashStyles.Dot); case System.Drawing.Drawing2D.DashStyle.DashDot: return(DashStyles.DashDot); case System.Drawing.Drawing2D.DashStyle.DashDotDot: return(DashStyles.DashDotDot); } throw ExceptionUtil.InvalidEnumArgumentException <System.Drawing.Drawing2D.DashStyle>(gdipDashStyle, "gdipDashStyle"); }
/// <summary> /// Initializes a new instance of the <see cref="ZeroitMetroGraph" /> class. /// </summary> public ZeroitMetroGraph() { this._Style = Design.Style.Light; this._DefaultColor = Design.MetroColors.LightDefault; this._GridColor = Design.MetroColors.PopUpBorder; this._SingleLineColor = Design.MetroColors.AccentBlue; this._ClassicLineColor = Design.MetroColors.AccentBlue; this._ClassicFillColor = Color.FromArgb(50, Design.MetroColors.AccentBlue); this._GradientColor = Color.FromArgb(50, Design.MetroColors.ChangeColorBrightness(Design.MetroColors.AccentBlue, -0.2f)); this._HoverColor = Design.MetroColors.AccentLightBlue; this._HoverBoxColor = Design.MetroColors.LightDefault; this._HoverBoxBorderColor = Design.MetroColors.PopUpBorder; this._BorderColor = Design.MetroColors.LightBorder; this._DrawHoverLine = true; this._DrawHoverData = true; this._ClassicLineThickness = 2; this._UseGradient = true; this._DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; this._DrawVerticalLines = false; this._DrawHorizontalLines = true; this._SingleLine = false; this._SingleLineThickness = 5; this._SingleLineShadow = true; this._SidePadding = false; this._OverrideMinimum = false; this._OverrideMaximum = false; this._OverriddenMinimum = 0; this._OverriddenMaximum = 100; this._Minimum = float.MinValue; this._Maximum = float.MaxValue; this._Index = -1; this._GradientPointA = new Point(checked ((int)Math.Round((double)this.Width / 2)), 0); this._GradientPointB = new Point(checked ((int)Math.Round((double)this.Width / 2)), this.Height); this._AutoStyle = true; this.Font = new System.Drawing.Font("Segoe UI", 9f); this.SetStyle(ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); this.UpdateStyles(); this._Values = new List <float>(); this._SmoothValues = new List <float>(); }
protected override void OnStartUp() { var colors = new Color[] { Color.Black, Color.White, Color.Gray, Color.Firebrick, Color.Red, Color.OrangeRed, Color.Orange, Color.Goldenrod, Color.Yellow, Color.YellowGreen, Color.Green, Color.DarkCyan, Color.DarkBlue, Color.Blue, Color.Indigo, Color.Violet }; // these must be in order from smallest to largest... var sizes = new int[] { 1, 2, 3, 4 }; var styles = new System.Drawing.Drawing2D.DashStyle[] { System.Drawing.Drawing2D.DashStyle.Solid, System.Drawing.Drawing2D.DashStyle.Dash, System.Drawing.Drawing2D.DashStyle.DashDot, System.Drawing.Drawing2D.DashStyle.DashDotDot, System.Drawing.Drawing2D.DashStyle.Dot }; var fstyles = new System.Drawing.FontStyle[] { System.Drawing.FontStyle.Regular, System.Drawing.FontStyle.Bold, System.Drawing.FontStyle.Italic }; drawPanel = new System.Windows.Forms.FlowLayoutPanel(); drawPanel.Dock = System.Windows.Forms.DockStyle.Bottom; drawPanel.AutoSize = true; drawPanel.SuspendLayout(); cachedObj = null; setupColorList(drawPanel, colors); setupSizes(drawPanel, sizes); setupStyles(drawPanel, styles); setupFontStyles(drawPanel, fstyles); drawPanel.ResumeLayout(false); ChartControl.Controls.Add(drawPanel); if (toggleSwitch) { System.Windows.Forms.Control[] coll = ChartControl.Controls.Find("tsrTool", false); if (coll.Length > 0) { hideBtn = new System.Windows.Forms.ToolStripButton("+DrawOpts+"); hideBtn.Click += hideShowPanel; strip = (System.Windows.Forms.ToolStrip)coll[0]; strip.Items.Add(hideBtn); drawPanel.Hide(); } } }
protected override CResultAErreur MySerialize(C2iSerializer serializer) { //return CResultAErreur.True; int nVersion = GetNumVersion(); CResultAErreur result = serializer.TraiteVersion(ref nVersion); if (!result) { return(result); } result = base.MySerialize(serializer); if (!result) { return(result); } int nTmp = m_gridSize.Width; serializer.TraiteInt(ref nTmp); m_gridSize.Width = nTmp; nTmp = m_gridSize.Height; serializer.TraiteInt(ref nTmp); m_gridSize.Height = nTmp; int nStyle = (int)m_borderStyle; serializer.TraiteInt(ref nStyle); m_borderStyle = (PanelBorderStyle)nStyle; serializer.TraiteInt(ref m_borderWidth); int nLineStyle = (int)m_lineStyle; serializer.TraiteInt(ref nLineStyle); m_lineStyle = (System.Drawing.Drawing2D.DashStyle)nLineStyle; if (nVersion < 2) { int nFillStyle = (int)m_fillStyle; serializer.TraiteInt(ref nFillStyle); m_fillStyle = (PanelFillStyle)nFillStyle; } if (nVersion > 3) { int? nVal = (int?)m_hatchStyle; bool bHasVal = nVal != null; serializer.TraiteBool(ref bHasVal); if (bHasVal) { nTmp = nVal != null ? nVal.Value : 0; serializer.TraiteInt(ref nTmp); m_hatchStyle = (HatchStyle?)nTmp; } else { nVal = null; m_hatchStyle = (HatchStyle?)nVal; } IList listTmp = new ArrayList(); for (int i = 0; i < 4; i++) { double dTmp = (double)m_customDashPattern[i]; listTmp.Add((object)dTmp); } serializer.TraiteListeObjetsSimples(ref listTmp); if (serializer.Mode == ModeSerialisation.Lecture) { for (int i = 0; i < 4; i++) { m_customDashPattern[i] = (float)(double)listTmp[i]; } } return(result); } return(result); }
/// <summary> /// Draws diagonal lines on the bitmap (usefull for watermark protection) /// </summary> /// <param name="SourceBitmap"></param> /// <param name="LineColor"></param> /// <param name="LineStyle"></param> /// <returns></returns> public static Bitmap DrawDiagonalLines(this Bitmap SourceBitmap, string LineColor, System.Drawing.Drawing2D.DashStyle LineStyle = DashStyle.Solid) { Graphics _photo = Graphics.FromImage(SourceBitmap); _photo.SmoothingMode = SmoothingMode.HighQuality; Pen _dotpen = new Pen(GetColorFromHex(LineColor)); _dotpen.DashStyle = LineStyle; _photo.DrawLine(new Pen(GetColorFromHex(LineColor)), 0, 0, SourceBitmap.Width, SourceBitmap.Height); _photo.DrawLine(new Pen(GetColorFromHex(LineColor)), 0, SourceBitmap.Height, SourceBitmap.Width, 0); return(SourceBitmap); }
/// <summary> /// Draws vertical lines on the bitmap (usefull for watermark protection) /// </summary> /// <param name="SourceBitmap"></param> /// <param name="LineSpacing"></param> /// <param name="LineColor"></param> /// <param name="LineStyle"></param> /// <returns></returns> public static Bitmap DrawVerticalLines(this Bitmap SourceBitmap, int LineSpacing, string LineColor, System.Drawing.Drawing2D.DashStyle LineStyle = DashStyle.Dot) { Graphics _graph = Graphics.FromImage(SourceBitmap); int _position = LineSpacing; while (_position < SourceBitmap.Width) { Pen _dotpen = new Pen(GetColorFromHex(LineColor)); _dotpen.DashStyle = LineStyle; _graph.DrawLine(_dotpen, new Point(_position, 0), new Point(_position, SourceBitmap.Height)); _position += LineSpacing; } return(SourceBitmap); }
/// /////////////////////////////////////// protected override CResultAErreur MySerialize(C2iSerializer serializer) { int nVersion = GetNumVersion(); CResultAErreur result = serializer.TraiteVersion(ref nVersion); if (!result) { return(result); } result = base.MySerialize(serializer); if (!result) { return(result); } serializer.TraiteInt(ref m_nLineWidth); int nLineStyle = (int)m_lineStyle; serializer.TraiteInt(ref nLineStyle); m_lineStyle = (System.Drawing.Drawing2D.DashStyle)nLineStyle; serializer.TraiteBool(ref m_bClosed); serializer.TraiteBool(ref m_bBezier); int nTmp; if (nVersion > 2) { int? nVal = (int?)m_hatchStyle; bool bHasVal = nVal != null; serializer.TraiteBool(ref bHasVal); if (bHasVal) { nTmp = nVal != null ? nVal.Value : 0; serializer.TraiteInt(ref nTmp); m_hatchStyle = (HatchStyle?)nTmp; } else { nVal = null; m_hatchStyle = (HatchStyle?)nVal; } } int nStartCap = (int)m_startCap; serializer.TraiteInt(ref nStartCap); m_startCap = (System.Drawing.Drawing2D.LineCap)nStartCap; int nEndCap = (int)m_endCap; serializer.TraiteInt(ref nEndCap); m_endCap = (System.Drawing.Drawing2D.LineCap)nEndCap; int nNbPts = m_arrayPoints.Count; serializer.TraiteInt(ref nNbPts); switch (serializer.Mode) { case ModeSerialisation.Ecriture: { foreach (Point pt in m_arrayPoints) { int nX = pt.X; int nY = pt.Y; serializer.TraiteInt(ref nX); serializer.TraiteInt(ref nY); } break; } case ModeSerialisation.Lecture: { m_arrayPoints.Clear(); for (int n = 0; n < nNbPts; n++) { int nX = 0; int nY = 0; serializer.TraiteInt(ref nX); serializer.TraiteInt(ref nY); m_arrayPoints.Add(new Point(nX, nY)); } break; } } IList listTmp = new ArrayList(); for (int i = 0; i < 4; i++) { double dTmp = (double)m_customDashPattern[i]; listTmp.Add((object)dTmp); } serializer.TraiteListeObjetsSimples(ref listTmp); if (serializer.Mode == ModeSerialisation.Lecture) { for (int i = 0; i < 4; i++) { m_customDashPattern[i] = (float)(double)listTmp[i]; } } return(result); }
public float DrawLine(string s, System.Drawing.Font font, System.Drawing.Printing.PrintPageEventArgs e, System.Drawing.Drawing2D.DashStyle dashStyle, float y, int textAlign) { float x; float width; System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Brushes.Black); if (dashStyle != System.Drawing.Drawing2D.DashStyle.Custom) { pen.DashStyle = dashStyle; } if (s == "" || s == null) { width = e.PageBounds.Width; } else { width = e.Graphics.MeasureString(s, font).Width; } if (textAlign == 1) { x = 0; } else if (textAlign == 2) { x = (float)Math.Abs(((float)e.PageBounds.Width - e.Graphics.MeasureString(s, font).Width) / 2); } else { x = e.PageBounds.Width - e.Graphics.MeasureString(s, font).Width; } e.Graphics.DrawLine(pen, x, y, x + width, y); y += 2; return(y); }
/// <summary> /// Draws horizontal lines on the bitmap (usefull for watermark protection) /// </summary> /// <param name="SourceBitmap"></param> /// <param name="LineSpacing"></param> /// <param name="LineColor"></param> /// <param name="LineStyle"></param> /// <returns></returns> public static Bitmap DrawHorizontalLines(this Bitmap SourceBitmap, int LineSpacing, string LineColor, System.Drawing.Drawing2D.DashStyle LineStyle = DashStyle.Dot) { Graphics _graph = Graphics.FromImage(SourceBitmap); int _position = LineSpacing; while (_position < SourceBitmap.Width) { Pen _dotpen = new Pen(GetColorFromHex(LineColor)); _dotpen.DashStyle = LineStyle; _graph.SmoothingMode = SmoothingMode.HighQuality; _graph.DrawLine(_dotpen, new Point(0, _position), new Point(SourceBitmap.Width, _position)); _position += LineSpacing; } return(SourceBitmap); }
private void dashedButton1_Click(object sender, EventArgs e) { this.penStyle = System.Drawing.Drawing2D.DashStyle.Dash; }