/// <summary> /// return the dashPattern according to the line type /// </summary> /// <param name="lineType"></param> /// <returns></returns> public static float[] GetDashPattern(CtrlLineType lineType) { float[] dashPattern = null; switch (lineType) { case CtrlLineType.Normal: break; case CtrlLineType.Dash: #if !PocketPC dashPattern = DASH_PATTERN; break; #endif case CtrlLineType.Dot: #if !PocketPC dashPattern = DOT_PATTERN; break; #endif case CtrlLineType.Dashdot: #if !PocketPC dashPattern = DASHDOT_PATTERN; break; #endif case CtrlLineType.Dashdotdot: #if !PocketPC dashPattern = DASHDOTDOT_PATTERN; #else // Mobile supports only solid or dashed lines. All other styles fall through to dash pen.DashStyle = DashStyle.Dash; #endif break; } return(dashPattern); }
/// <summary> /// Paints the Line control /// TODO : Move this method to LineRenderer /// </summary> public static void PaintLineForeGround(Graphics g, Color fgColor, ControlStyle style, int lineWidth, CtrlLineType lineStyle, Point pt1, Point pt2) { #if !PocketPC SmoothingMode orgmode = g.SmoothingMode; g.SmoothingMode = SmoothingMode.AntiAlias; #endif Pen pen = new Pen(fgColor, lineWidth); // TODO : use new pen's cache here float[] dashPattern = ControlRenderer.GetDashPattern(lineStyle); if (dashPattern != null) { pen.DashPattern = dashPattern; } LineRenderer.Draw(g, pen, pt1, pt2, style); #if !PocketPC g.SmoothingMode = orgmode; #endif }
/// <summary> /// Creates pen for border painting /// </summary> /// <returns></returns> public static Pen InitPenForPaint(Color foreColor, ControlStyle controlStyle, CtrlLineType lineType, int lineWidth) { Pen pen = new Pen(foreColor); // set properties of pen pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset; // Paint from inside when pen width is greater than 1 if (controlStyle == ControlStyle.TwoD) { pen.Width = lineWidth; float[] dashPattern = ControlRenderer.GetDashPattern(lineType); if (dashPattern != null) { pen.DashPattern = dashPattern; } } return(pen); }