1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
using System;
using awt = java.awt;
using geom = java.awt.geom;
namespace System.Drawing {
internal sealed class StrokeFactory {
StrokeFactory() {}
interface StrokeCreator {
awt.Stroke Create(float width, int cap, int join, float miterlimit,
float[] dash, float dash_phase, geom.AffineTransform penTransform,
geom.AffineTransform outputTransform, PenFit penFit);
}
sealed class AdvancedCreator : StrokeCreator {
#region StrokeCreator Members
public awt.Stroke Create(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase, geom.AffineTransform penTransform,
geom.AffineTransform outputTransform, PenFit penFit) {
if ((penFit == PenFit.NotThin) &&
(outputTransform == null || outputTransform.isIdentity()) &&
(penTransform == null || penTransform.isIdentity()))
return new awt.BasicStroke(width, cap, join, miterlimit, dash, dash_phase);
return new System.Drawing.AdvancedStroke(width, cap, join, miterlimit, dash, dash_phase, penTransform, outputTransform, penFit);
}
#endregion
}
sealed class DefaultCreator : StrokeCreator {
#region StrokeCreator Members
public awt.Stroke Create(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase, geom.AffineTransform penTransform,
geom.AffineTransform outputTransform, PenFit penFit) {
return new awt.BasicStroke(width, cap, join, miterlimit, dash, dash_phase);
}
#endregion
}
static readonly StrokeCreator Creator;
static StrokeFactory() {
try {
Type type = typeof(System.Drawing.AdvancedStroke);
Activator.CreateInstance(type);
Creator = new AdvancedCreator();
}
catch{
Creator = new DefaultCreator();
}
}
static public bool CanCreateAdvancedStroke {
get {
return !(Creator is DefaultCreator);
}
}
static public awt.Stroke CreateStroke(float width, int cap, int join, float miterlimit,
float[] dash, float dash_phase, geom.AffineTransform penTransform,
geom.AffineTransform outputTransform, PenFit penFit) {
return Creator.Create(width, cap, join, miterlimit, dash, dash_phase, penTransform, outputTransform, penFit);
}
}
}
|