markus / ConvertService / ConverterService / ImageFields / FieldBase.cs @ 366f00c2
이력 | 보기 | 이력해설 | 다운로드 (8.01 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Globalization; |
6 |
using System.Data.Entity.Design; |
7 |
using System.IO; |
8 |
|
9 |
namespace ImageFields |
10 |
{ |
11 |
public abstract class ImageFieldsBase : DZTEvents |
12 |
{ |
13 |
// Fields |
14 |
private bool conversionCopyMetadata = false; |
15 |
private double conversionImageQuality = 0.8; |
16 |
private ImageFormat conversionTileFormat = ImageFormat.AutoSelect; |
17 |
private int conversionTileOverlap = 1; |
18 |
private int conversionTileSize = 0xfe; |
19 |
protected const bool DefaultConversionCopyMetadata = false; |
20 |
protected const double DefaultConversionImageQuality = 0.8; |
21 |
protected const ImageFormat DefaultConversionTileFormat = ImageFormat.AutoSelect; |
22 |
protected const int DefaultConversionTileOverlap = 1; |
23 |
protected const int DefaultConversionTileSize = 0xfe; |
24 |
protected const ImageFormat DefaultImageFormat = ImageFormat.AutoSelect; |
25 |
public const double DefaultImageQuality = 0.8; |
26 |
protected const int DefaultMaxLevel = 30; |
27 |
protected const int DefaultTileOverlap = 1; |
28 |
protected const int DefaultTileSize = 0xfe; |
29 |
private double imageQuality = 0.8; |
30 |
private int maxLevel = 30; |
31 |
private bool lowLevelPass = false; |
32 |
public const int MaxTileSize = 0x800; |
33 |
public const int MinTileSize = 1; |
34 |
internal EntityStoreSchemaFilterEffect notInUse; |
35 |
private ImageFormat tileFormat = ImageFormat.AutoSelect; |
36 |
private int tileOverlap = 1; |
37 |
private int tileSize = 0xfe; |
38 |
|
39 |
// Methods |
40 |
protected ImageFieldsBase() |
41 |
{ |
42 |
this.conversionImageQuality = 0.8; |
43 |
this.conversionTileSize = 0xfe; |
44 |
this.conversionTileOverlap = 1; |
45 |
this.conversionTileFormat = ImageFormat.AutoSelect; |
46 |
this.conversionCopyMetadata = false; |
47 |
this.notInUse = EntityStoreSchemaFilterEffect.Allow; |
48 |
this.UseOptimizations = false; |
49 |
this.ServerFormat = ServerFormats.Default; |
50 |
} |
51 |
|
52 |
internal string CreateDirectories(string outputPath, int maxLevel) |
53 |
{ |
54 |
string str = Path.ChangeExtension(outputPath, null) + "_files"; |
55 |
DirectoryEventArgs e = new DirectoryEventArgs |
56 |
{ |
57 |
DirectoryName = str |
58 |
}; |
59 |
base.OnCreateDirectory(e); |
60 |
|
61 |
int _minLevel = 0; |
62 |
|
63 |
if (lowLevelPass) |
64 |
_minLevel = 8; |
65 |
|
66 |
for (int i = _minLevel; i <= maxLevel; i++) |
67 |
{ |
68 |
string str2 = Path.Combine(str, i.ToString(CultureInfo.InvariantCulture)); |
69 |
e.DirectoryName = str2; |
70 |
base.OnCreateDirectory(e); |
71 |
} |
72 |
return str; |
73 |
} |
74 |
|
75 |
internal static ICollection<Image> StringsToImages(ICollection<string> strings) |
76 |
{ |
77 |
List<Image> list = new List<Image>(); |
78 |
foreach (string str in strings) |
79 |
{ |
80 |
Image item = new Image(str) |
81 |
{ |
82 |
ViewportWidth = 0.0 |
83 |
}; |
84 |
list.Add(item); |
85 |
} |
86 |
return list; |
87 |
} |
88 |
|
89 |
// Properties |
90 |
public bool ConversionCopyMetadata |
91 |
{ |
92 |
get |
93 |
{ |
94 |
return this.conversionCopyMetadata; |
95 |
} |
96 |
set |
97 |
{ |
98 |
this.conversionCopyMetadata = value; |
99 |
} |
100 |
} |
101 |
|
102 |
public double ConversionImageQuality |
103 |
{ |
104 |
get |
105 |
{ |
106 |
return this.conversionImageQuality; |
107 |
} |
108 |
set |
109 |
{ |
110 |
if ((value > 1.0) || (value < 0.0)) |
111 |
{ |
112 |
throw new ArgumentOutOfRangeException("value", "ConversionImageQuality must be between 0 and 1."); |
113 |
} |
114 |
this.conversionImageQuality = value; |
115 |
} |
116 |
} |
117 |
|
118 |
public ImageFormat ConversionTileFormat |
119 |
{ |
120 |
get |
121 |
{ |
122 |
return this.conversionTileFormat; |
123 |
} |
124 |
set |
125 |
{ |
126 |
this.conversionTileFormat = value; |
127 |
} |
128 |
} |
129 |
|
130 |
public int ConversionTileOverlap |
131 |
{ |
132 |
get |
133 |
{ |
134 |
return this.conversionTileOverlap; |
135 |
} |
136 |
set |
137 |
{ |
138 |
if ((value > (this.conversionTileSize / 2)) || (value < 0)) |
139 |
{ |
140 |
throw new ArgumentOutOfRangeException("value", "ConversionTileOverlap must be between 0 and half the ConversionTileSize."); |
141 |
} |
142 |
this.conversionTileOverlap = value; |
143 |
} |
144 |
} |
145 |
|
146 |
public virtual int ConversionTileSize |
147 |
{ |
148 |
get |
149 |
{ |
150 |
return this.conversionTileSize; |
151 |
} |
152 |
set |
153 |
{ |
154 |
if ((value > 0x800) || (value < 1)) |
155 |
{ |
156 |
string[] strArray = new string[5]; |
157 |
strArray[0] = "ConversionTileSize must be between "; |
158 |
int num = 1; |
159 |
strArray[1] = num.ToString(CultureInfo.CurrentUICulture); |
160 |
strArray[2] = " and "; |
161 |
strArray[3] = 0x800.ToString(CultureInfo.CurrentUICulture); |
162 |
strArray[4] = "."; |
163 |
throw new ArgumentOutOfRangeException("value", string.Concat(strArray)); |
164 |
} |
165 |
this.conversionTileSize = value; |
166 |
} |
167 |
} |
168 |
|
169 |
public double ImageQuality |
170 |
{ |
171 |
get |
172 |
{ |
173 |
return this.imageQuality; |
174 |
} |
175 |
set |
176 |
{ |
177 |
if ((value > 1.0) || (value < 0.0)) |
178 |
{ |
179 |
throw new ArgumentOutOfRangeException("value", "Image Quality must be between 0 and 1."); |
180 |
} |
181 |
this.imageQuality = value; |
182 |
} |
183 |
} |
184 |
|
185 |
public bool LowLevelPass |
186 |
{ |
187 |
get |
188 |
{ |
189 |
return this.lowLevelPass; |
190 |
} |
191 |
set |
192 |
{ |
193 |
this.lowLevelPass = value; |
194 |
} |
195 |
} |
196 |
|
197 |
public int MaxLevel |
198 |
{ |
199 |
get |
200 |
{ |
201 |
return this.maxLevel; |
202 |
} |
203 |
set |
204 |
{ |
205 |
if ((value > 30) || (value < 0)) |
206 |
{ |
207 |
throw new ArgumentOutOfRangeException("value", "Max Level must be between 0 and " + 30 + "."); |
208 |
} |
209 |
this.maxLevel = value; |
210 |
} |
211 |
} |
212 |
|
213 |
public ServerFormats ServerFormat { get; set; } |
214 |
|
215 |
public ImageFormat TileFormat |
216 |
{ |
217 |
get |
218 |
{ |
219 |
return this.tileFormat; |
220 |
} |
221 |
set |
222 |
{ |
223 |
this.tileFormat = value; |
224 |
} |
225 |
} |
226 |
|
227 |
public int TileOverlap |
228 |
{ |
229 |
get |
230 |
{ |
231 |
return this.tileOverlap; |
232 |
} |
233 |
set |
234 |
{ |
235 |
if ((value > (this.tileSize / 2)) || (value < 0)) |
236 |
{ |
237 |
throw new ArgumentOutOfRangeException("value", "TileOverlap must be between 0 and half the TileSize."); |
238 |
} |
239 |
this.tileOverlap = value; |
240 |
} |
241 |
} |
242 |
|
243 |
public virtual int TileSize |
244 |
{ |
245 |
get |
246 |
{ |
247 |
return this.tileSize; |
248 |
} |
249 |
set |
250 |
{ |
251 |
if ((value > 0x800) || (value < 1)) |
252 |
{ |
253 |
string[] strArray = new string[5]; |
254 |
strArray[0] = "TileSize must be between "; |
255 |
int num = 1; |
256 |
strArray[1] = num.ToString(CultureInfo.CurrentUICulture); |
257 |
strArray[2] = " and "; |
258 |
strArray[3] = 0x800.ToString(CultureInfo.CurrentUICulture); |
259 |
strArray[4] = "."; |
260 |
throw new ArgumentOutOfRangeException("value", string.Concat(strArray)); |
261 |
} |
262 |
this.tileSize = value; |
263 |
} |
264 |
} |
265 |
|
266 |
public bool UseOptimizations { get; set; } |
267 |
} |
268 |
|
269 |
|
270 |
} |