CraftSynth.ImageEditor – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System;
2 using System.Drawing;
3 using System.Drawing.Drawing2D;
4  
5 namespace CraftSynth.ImageEditor
6 {
7 public class DrawingPens
8 {
9 #region Enumerations
10 public enum PenType
11 {
12 Solid,
13 Dash,
14 Dash_Dot,
15 Dot,
16 DoubleLine
17 }
18 #endregion Enumerations
19  
20 public static string GetPenTypeAsString(PenType penType)
21 {
22 switch (penType)
23 {
24 case PenType.Solid:
25 return "___";
26 break;
27 case PenType.Dash:
28 return "- - -";
29 break;
30 case PenType.Dash_Dot:
31 return "- . -";
32 break;
33 case PenType.Dot:
34 return ". . .";
35 break;
36 case PenType.DoubleLine:
37 return "===";
38 break;
39 default:
40 throw new ArgumentOutOfRangeException("penType");
41 }
42 }
43  
44 /// <summary>
45 /// Return a pen based on the type requested
46 /// </summary>
47 /// <param name="_penType">Type of pen from the PenType enumeration</param>
48 /// <returns>Requested pen</returns>
49 public static void SetCurrentPen(ref Pen pen, PenType _penType, LineCap endCap)
50 {
51 switch (_penType)
52 {
53 case PenType.Solid:
54 pen.DashStyle = DashStyle.Solid;
55 break;
56 case PenType.Dash:
57 pen.DashStyle = DashStyle.Dash;
58 break;
59 case PenType.Dash_Dot:
60 pen.DashStyle = DashStyle.DashDot;
61 break;
62 case PenType.Dot:
63 pen.DashStyle = DashStyle.Dot;
64 break;
65 case PenType.DoubleLine:
66 pen.CompoundArray = new float[] {0.0f, 0.1f, 0.2f, 0.3f, 0.7f, 0.8f, 0.9f, 1.0f};
67 break;
68 default:
69 throw new ArgumentOutOfRangeException("_penType");
70 }
71 pen.LineJoin = LineJoin.Round;
72 pen.EndCap = endCap;
73 pen.StartCap = LineCap.Round;
74 }
75 }
76 }