You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
897 lines
24 KiB
897 lines
24 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Drawing; |
|
using System.Drawing.Drawing2D; |
|
using System.Drawing.Imaging; |
|
using System.Globalization; |
|
using System.IO; |
|
using System.Runtime.InteropServices; |
|
using System.Text; |
|
using System.Xml; |
|
using System.Xml.Serialization; |
|
using ArcShapeFileDLL; |
|
using Newtonsoft.Json; |
|
using Newtonsoft.Json.Converters; |
|
using Newtonsoft.Json.Serialization; |
|
|
|
namespace Kingo.Framework.LayerStyleConvert.XSDClass |
|
{ |
|
// Token: 0x0200006A RID: 106 |
|
public class CommonMethod |
|
{ |
|
// Token: 0x06000400 RID: 1024 RVA: 0x00016CFC File Offset: 0x00014EFC |
|
public static string SerializerToXml<T>(T obj) |
|
{ |
|
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); |
|
string result; |
|
using (MemoryStream memoryStream = new MemoryStream()) |
|
{ |
|
XmlSerializerNamespaces xmlSerializerNamespaces = new XmlSerializerNamespaces(); |
|
xmlSerializerNamespaces.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance"); |
|
xmlSerializerNamespaces.Add("xs", "http://www.w3.org/2001/XMLSchema"); |
|
xmlSerializerNamespaces.Add("typens", "http://www.esri.com/schemas/ArcGIS/10.1"); |
|
xmlSerializer.Serialize(memoryStream, obj, xmlSerializerNamespaces); |
|
string @string = Encoding.UTF8.GetString(memoryStream.ToArray()); |
|
result = @string; |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x06000401 RID: 1025 RVA: 0x00016DA4 File Offset: 0x00014FA4 |
|
public static string SerializerToXmlNoHeder<T>(T Obj) |
|
{ |
|
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); |
|
xmlWriterSettings.OmitXmlDeclaration = true; |
|
xmlWriterSettings.Encoding = Encoding.Default; |
|
string @string; |
|
using (MemoryStream memoryStream = new MemoryStream()) |
|
{ |
|
using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream, xmlWriterSettings)) |
|
{ |
|
XmlSerializerNamespaces xmlSerializerNamespaces = new XmlSerializerNamespaces(); |
|
xmlSerializerNamespaces.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance"); |
|
xmlSerializerNamespaces.Add("xs", "http://www.w3.org/2001/XMLSchema"); |
|
xmlSerializerNamespaces.Add("typens", "http://www.esri.com/schemas/ArcGIS/10.1"); |
|
XmlSerializer xmlSerializer = new XmlSerializer(Obj.GetType()); |
|
xmlSerializer.Serialize(xmlWriter, Obj, xmlSerializerNamespaces); |
|
} |
|
@string = Encoding.Default.GetString(memoryStream.ToArray()); |
|
} |
|
return @string; |
|
} |
|
|
|
// Token: 0x06000402 RID: 1026 RVA: 0x00016E94 File Offset: 0x00015094 |
|
public static void SerializerToFile<T>(T obj, string xmlFilePath) |
|
{ |
|
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); |
|
using (FileStream fileStream = File.Open(xmlFilePath, FileMode.Create, FileAccess.Write)) |
|
{ |
|
xmlSerializer.Serialize(fileStream, obj); |
|
} |
|
} |
|
|
|
// Token: 0x06000403 RID: 1027 RVA: 0x00016EF0 File Offset: 0x000150F0 |
|
public static T DeSerializerFromXml<T>(string xml) |
|
{ |
|
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); |
|
T result; |
|
using (MemoryStream memoryStream = new MemoryStream()) |
|
{ |
|
byte[] bytes = Encoding.UTF8.GetBytes(xml); |
|
memoryStream.Write(bytes, 0, bytes.Length); |
|
memoryStream.Position = 0L; |
|
object obj = xmlSerializer.Deserialize(memoryStream); |
|
result = (T)((object)obj); |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x06000404 RID: 1028 RVA: 0x00016F70 File Offset: 0x00015170 |
|
public static T DeSerializerFromFile<T>(string xmlFilePath) |
|
{ |
|
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); |
|
T result; |
|
using (FileStream fileStream = File.OpenRead(xmlFilePath)) |
|
{ |
|
object obj = xmlSerializer.Deserialize(fileStream); |
|
result = (T)((object)obj); |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x06000405 RID: 1029 RVA: 0x00016FCC File Offset: 0x000151CC |
|
public static string SerializerToJson(object item) |
|
{ |
|
JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings |
|
{ |
|
ContractResolver = new CamelCasePropertyNamesContractResolver() |
|
}; |
|
jsonSerializerSettings.Converters.Add(new StringEnumConverter()); |
|
return JsonConvert.SerializeObject(item, jsonSerializerSettings); |
|
} |
|
|
|
// Token: 0x06000406 RID: 1030 RVA: 0x0001700C File Offset: 0x0001520C |
|
public static T DeSerializerFromJson<T>(string json) |
|
{ |
|
return (T)((object)JsonConvert.DeserializeObject(json, typeof(T))); |
|
} |
|
|
|
// Token: 0x06000407 RID: 1031 RVA: 0x00017034 File Offset: 0x00015234 |
|
public static string GetCreateSqlTypeFormShapeField(ShapeFieldInfo field) |
|
{ |
|
string result; |
|
if (field.FieldName.ToLower() == "objectid") |
|
{ |
|
result = "integer"; |
|
} |
|
else |
|
{ |
|
eFieldType fieldType = field.FieldType; |
|
switch (fieldType) |
|
{ |
|
case eFieldType.shpBoolean: |
|
return "int16"; |
|
case (eFieldType)2: |
|
case (eFieldType)5: |
|
case (eFieldType)9: |
|
case (eFieldType)11: |
|
goto IL_E4; |
|
case eFieldType.shpInteger: |
|
case eFieldType.shpSingle: |
|
return "int32"; |
|
case eFieldType.shpLong: |
|
return "int64"; |
|
case eFieldType.shpDouble: |
|
break; |
|
case eFieldType.shpDate: |
|
return "realdate"; |
|
case eFieldType.shpText: |
|
return string.Format("text({0})", field.FieldSize); |
|
case eFieldType.shpMemo: |
|
return "text(100000000)"; |
|
default: |
|
switch (fieldType) |
|
{ |
|
case eFieldType.shpNumeric: |
|
if (field.FieldDecimal == 0) |
|
{ |
|
return "int32"; |
|
} |
|
return "float64"; |
|
case eFieldType.shpFloat: |
|
break; |
|
default: |
|
goto IL_E4; |
|
} |
|
break; |
|
} |
|
return "float64"; |
|
IL_E4: |
|
result = "undifine"; |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x06000408 RID: 1032 RVA: 0x00017130 File Offset: 0x00015330 |
|
public static int GetFieldSDE_Type(ShapeFieldInfo field) |
|
{ |
|
eFieldType fieldType = field.FieldType; |
|
switch (fieldType) |
|
{ |
|
case eFieldType.shpBoolean: |
|
return 1; |
|
case (eFieldType)2: |
|
case (eFieldType)5: |
|
case (eFieldType)9: |
|
case (eFieldType)11: |
|
goto IL_8B; |
|
case eFieldType.shpInteger: |
|
return 2; |
|
case eFieldType.shpLong: |
|
return 11; |
|
case eFieldType.shpSingle: |
|
case eFieldType.shpDouble: |
|
break; |
|
case eFieldType.shpDate: |
|
return 7; |
|
case eFieldType.shpText: |
|
return 5; |
|
case eFieldType.shpMemo: |
|
return 13; |
|
default: |
|
switch (fieldType) |
|
{ |
|
case eFieldType.shpNumeric: |
|
if (field.FieldDecimal == 0) |
|
{ |
|
return 2; |
|
} |
|
return 4; |
|
case eFieldType.shpFloat: |
|
break; |
|
default: |
|
goto IL_8B; |
|
} |
|
break; |
|
} |
|
return 4; |
|
IL_8B: |
|
return 5; |
|
} |
|
|
|
// Token: 0x06000409 RID: 1033 RVA: 0x000171D0 File Offset: 0x000153D0 |
|
public static string GetShapeMultiPolygonString(ShapeFiles shapeFile) |
|
{ |
|
string result; |
|
if (shapeFile.Vertices == null || shapeFile.Vertices.Count == 0) |
|
{ |
|
result = "MULTIPOLYGON EMPTY"; |
|
} |
|
else |
|
{ |
|
StringBuilder stringBuilder = new StringBuilder("MULTIPOLYGON (("); |
|
foreach (object obj in shapeFile.Parts) |
|
{ |
|
Part part = (Part)obj; |
|
stringBuilder.Append("("); |
|
for (int i = part.Begins; i <= part.Ends; i++) |
|
{ |
|
stringBuilder.AppendFormat("{0} {1},", shapeFile.Vertices[i].X_Cord, shapeFile.Vertices[i].Y_Cord); |
|
} |
|
stringBuilder.Remove(stringBuilder.Length - 1, 1); |
|
stringBuilder.Append("),"); |
|
} |
|
stringBuilder.Remove(stringBuilder.Length - 1, 1); |
|
stringBuilder.Append("))"); |
|
result = stringBuilder.ToString(); |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x0600040A RID: 1034 RVA: 0x0001732C File Offset: 0x0001552C |
|
public static esriFieldType ConvertFromShpFieldType(ShapeFieldInfo field) |
|
{ |
|
eFieldType fieldType = field.FieldType; |
|
switch (fieldType) |
|
{ |
|
case eFieldType.shpBoolean: |
|
return esriFieldType.esriFieldTypeSmallInteger; |
|
case (eFieldType)2: |
|
case (eFieldType)5: |
|
case (eFieldType)9: |
|
case (eFieldType)11: |
|
goto IL_85; |
|
case eFieldType.shpInteger: |
|
case eFieldType.shpLong: |
|
return esriFieldType.esriFieldTypeInteger; |
|
case eFieldType.shpSingle: |
|
case eFieldType.shpDouble: |
|
break; |
|
case eFieldType.shpDate: |
|
return esriFieldType.esriFieldTypeDate; |
|
case eFieldType.shpText: |
|
return esriFieldType.esriFieldTypeString; |
|
case eFieldType.shpMemo: |
|
return esriFieldType.esriFieldTypeString; |
|
default: |
|
switch (fieldType) |
|
{ |
|
case eFieldType.shpNumeric: |
|
if (field.FieldDecimal == 0) |
|
{ |
|
return esriFieldType.esriFieldTypeInteger; |
|
} |
|
return esriFieldType.esriFieldTypeDouble; |
|
case eFieldType.shpFloat: |
|
break; |
|
default: |
|
goto IL_85; |
|
} |
|
break; |
|
} |
|
return esriFieldType.esriFieldTypeDouble; |
|
IL_85: |
|
return esriFieldType.esriFieldTypeString; |
|
} |
|
|
|
// Token: 0x0600040B RID: 1035 RVA: 0x000173C4 File Offset: 0x000155C4 |
|
public static object GetShpFieldTypeDefaultValue(ShapeFiles.eFieldType type) |
|
{ |
|
//switch (type) |
|
//{ |
|
//case 1: |
|
//case 3: |
|
//case 4: |
|
// return 0; |
|
//case 2: |
|
//case 5: |
|
//case 9: |
|
//case 11: |
|
// goto IL_78; |
|
//case 6: |
|
//case 7: |
|
// break; |
|
//case 8: |
|
// return "null"; |
|
//case 10: |
|
//case 12: |
|
// return ""; |
|
//default: |
|
// switch (type) |
|
// { |
|
// case 19: |
|
// case 20: |
|
// break; |
|
// default: |
|
// goto IL_78; |
|
// } |
|
// break; |
|
//} |
|
//return 0.0; |
|
//IL_78: |
|
return ""; |
|
} |
|
|
|
// Token: 0x0600040C RID: 1036 RVA: 0x00017454 File Offset: 0x00015654 |
|
public static long UNIX_TIMESTAMP(DateTime dateTime) |
|
{ |
|
return (dateTime.Ticks - DateTime.Parse("1970-01-01 00:00:00").Ticks) / 10000000L; |
|
} |
|
|
|
// Token: 0x0600040D RID: 1037 RVA: 0x00017488 File Offset: 0x00015688 |
|
public static Image GetImageFromBase64(string base64) |
|
{ |
|
Image result; |
|
if (string.IsNullOrEmpty(base64)) |
|
{ |
|
result = null; |
|
} |
|
else |
|
{ |
|
byte[] buffer = Convert.FromBase64String(base64); |
|
result = Image.FromStream(new MemoryStream(buffer) |
|
{ |
|
Position = 0L |
|
}); |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x0600040E RID: 1038 RVA: 0x000174C8 File Offset: 0x000156C8 |
|
public static string GetBase64FromImage(Image img) |
|
{ |
|
string result; |
|
if (img == null) |
|
{ |
|
result = ""; |
|
} |
|
else |
|
{ |
|
using (MemoryStream memoryStream = new MemoryStream()) |
|
{ |
|
if (img.RawFormat.Guid == ImageFormat.MemoryBmp.Guid) |
|
{ |
|
img.Save(memoryStream, ImageFormat.Bmp); |
|
} |
|
else |
|
{ |
|
img.Save(memoryStream, img.RawFormat); |
|
} |
|
memoryStream.Position = 0L; |
|
result = Convert.ToBase64String(memoryStream.ToArray()); |
|
} |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x0600040F RID: 1039 RVA: 0x0001756C File Offset: 0x0001576C |
|
public static string GetBMPBase64FromImage(Image img) |
|
{ |
|
string result; |
|
if (img == null) |
|
{ |
|
result = ""; |
|
} |
|
else |
|
{ |
|
Bitmap bitmap = new Bitmap(img.Width, img.Height, PixelFormat.Format8bppIndexed); |
|
using (Graphics graphics = Graphics.FromImage(bitmap)) |
|
{ |
|
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; |
|
graphics.SmoothingMode = SmoothingMode.HighQuality; |
|
graphics.CompositingQuality = CompositingQuality.HighQuality; |
|
graphics.DrawImage(img, 0, 0); |
|
} |
|
using (MemoryStream memoryStream = new MemoryStream()) |
|
{ |
|
bitmap.Save(memoryStream, ImageFormat.Bmp); |
|
memoryStream.Position = 0L; |
|
result = Convert.ToBase64String(memoryStream.ToArray()); |
|
} |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x06000410 RID: 1040 RVA: 0x00017644 File Offset: 0x00015844 |
|
public static Color GetColorFromInt4Color(int[] array) |
|
{ |
|
Color result; |
|
if (array == null || array.Length != 4) |
|
{ |
|
result = Color.Black; |
|
} |
|
else |
|
{ |
|
result = Color.FromArgb(array[3], array[0], array[1], array[2]); |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x06000411 RID: 1041 RVA: 0x00017680 File Offset: 0x00015880 |
|
public static int[] GetInt4ColorFromColor(Color color) |
|
{ |
|
int[] array = new int[4]; |
|
bool flag = 1 == 0; |
|
array[0] = (int)color.R; |
|
array[1] = (int)color.G; |
|
array[2] = (int)color.B; |
|
array[3] = (int)color.A; |
|
return array; |
|
} |
|
|
|
// Token: 0x06000412 RID: 1042 RVA: 0x000176CC File Offset: 0x000158CC |
|
public static Bitmap ConvertTo1Bpp1(Bitmap bmp) |
|
{ |
|
int num = 0; |
|
for (int i = 0; i < bmp.Width; i++) |
|
{ |
|
for (int j = 0; j < bmp.Height; j++) |
|
{ |
|
num += (int)bmp.GetPixel(i, j).B; |
|
} |
|
} |
|
num /= bmp.Width * bmp.Height; |
|
for (int i = 0; i < bmp.Width; i++) |
|
{ |
|
for (int j = 0; j < bmp.Height; j++) |
|
{ |
|
int num2 = (int)(byte.MaxValue - bmp.GetPixel(i, j).B); |
|
Color color = (num2 > num) ? Color.FromArgb(0, 0, 0) : Color.FromArgb(255, 255, 255); |
|
bmp.SetPixel(i, j, color); |
|
} |
|
} |
|
return bmp; |
|
} |
|
|
|
// Token: 0x06000413 RID: 1043 RVA: 0x000177B4 File Offset: 0x000159B4 |
|
public static Bitmap ConvertTo1Bpp2(Bitmap img) |
|
{ |
|
int width = img.Width; |
|
int height = img.Height; |
|
Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format1bppIndexed); |
|
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, PixelFormat.Format1bppIndexed); |
|
for (int i = 0; i < height; i++) |
|
{ |
|
byte[] array = new byte[(width + 7) / 8]; |
|
for (int j = 0; j < width; j++) |
|
{ |
|
if ((double)img.GetPixel(j, i).GetBrightness() >= 0.5) |
|
{ |
|
byte[] array2 = array; |
|
int num = j / 8; |
|
array2[num] |= (byte)(128 >> j % 8); |
|
} |
|
} |
|
Marshal.Copy(array, 0, (IntPtr)((int)bitmapData.Scan0 + bitmapData.Stride * i), array.Length); |
|
} |
|
return bitmap; |
|
} |
|
|
|
// Token: 0x06000414 RID: 1044 RVA: 0x000178B0 File Offset: 0x00015AB0 |
|
public static string Get1BppBase64FromImage(Image img) |
|
{ |
|
Bitmap img2 = CommonMethod.ConvertTo1Bpp2(img as Bitmap); |
|
return CommonMethod.GetBase64FromImage(img2); |
|
} |
|
|
|
// Token: 0x06000415 RID: 1045 RVA: 0x000178D4 File Offset: 0x00015AD4 |
|
public static string ConvertBase64To1BppBase64(string base64) |
|
{ |
|
Image imageFromBase = CommonMethod.GetImageFromBase64(base64); |
|
return CommonMethod.Get1BppBase64FromImage(imageFromBase); |
|
} |
|
|
|
// Token: 0x06000416 RID: 1046 RVA: 0x000178F4 File Offset: 0x00015AF4 |
|
public static Renderer GetAdvDrawingInfoRender(Renderer itemInfoRender) |
|
{ |
|
Renderer result; |
|
if (itemInfoRender is SimpleRenderer) |
|
{ |
|
SimpleRenderer simpleRenderer = itemInfoRender as SimpleRenderer; |
|
result = new SimpleRenderer |
|
{ |
|
Description = simpleRenderer.Description, |
|
Label = simpleRenderer.Label, |
|
Symbol = CommonMethod.GetCIMSymbolReference(simpleRenderer.Symbol as FSymbol) |
|
}; |
|
} |
|
else if (itemInfoRender is UniqueValueRenderer) |
|
{ |
|
UniqueValueRenderer uniqueValueRenderer = itemInfoRender as UniqueValueRenderer; |
|
UniqueValueRenderer uniqueValueRenderer2 = new UniqueValueRenderer |
|
{ |
|
Field1 = uniqueValueRenderer.Field1, |
|
Field2 = uniqueValueRenderer.Field2, |
|
Field3 = uniqueValueRenderer.Field3, |
|
DefaultLabel = uniqueValueRenderer.DefaultLabel, |
|
FieldDelimiter = uniqueValueRenderer.FieldDelimiter |
|
}; |
|
CIMSymbolReference cimsymbolReference = CommonMethod.GetCIMSymbolReference(uniqueValueRenderer.DefaultSymbol as FSymbol); |
|
uniqueValueRenderer2.DefaultSymbol = cimsymbolReference; |
|
for (int i = 0; i < uniqueValueRenderer.UniqueValueInfos.Count; i++) |
|
{ |
|
UniqueValueInfo uniqueValueInfo = uniqueValueRenderer.UniqueValueInfos[i]; |
|
UniqueValueInfo uniqueValueInfo2 = new UniqueValueInfo |
|
{ |
|
Label = uniqueValueInfo.Label, |
|
Description = uniqueValueInfo.Description, |
|
Value = uniqueValueInfo.Value |
|
}; |
|
CIMSymbolReference cimsymbolReference2 = CommonMethod.GetCIMSymbolReference(uniqueValueInfo.Symbol as FSymbol); |
|
cimsymbolReference2.SymbolName = "Symbol_" + (i + 2).ToString(); |
|
uniqueValueInfo2.Symbol = cimsymbolReference2; |
|
uniqueValueRenderer2.UniqueValueInfos.Add(uniqueValueInfo2); |
|
} |
|
result = uniqueValueRenderer2; |
|
} |
|
else |
|
{ |
|
result = null; |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x06000417 RID: 1047 RVA: 0x00017AE0 File Offset: 0x00015CE0 |
|
private static CIMSymbolReference GetCIMSymbolReference(FSymbol fSymbol) |
|
{ |
|
CIMSymbolReference cimsymbolReference = new CIMSymbolReference(); |
|
cimsymbolReference.SymbolName = "Symbol_1"; |
|
CIMPolygonSymbol cimpolygonSymbol = new CIMPolygonSymbol(); |
|
cimpolygonSymbol.SymbolLayers = new List<SymbolLayer>(); |
|
CIMFilledStroke cimfilledStroke = new CIMFilledStroke(); |
|
cimfilledStroke.Pattern = new CIMSolidPattern |
|
{ |
|
Color = fSymbol.Outline.Color |
|
}; |
|
cimfilledStroke.Width = fSymbol.Outline.Width; |
|
cimpolygonSymbol.SymbolLayers.Add(cimfilledStroke); |
|
if (fSymbol is PFSymbol) |
|
{ |
|
PFSymbol pfsymbol = fSymbol as PFSymbol; |
|
CIMFill cimfill = new CIMFill(); |
|
CIMTiledPattern cimtiledPattern = new CIMTiledPattern |
|
{ |
|
Height = pfsymbol.Height, |
|
Url = "data:image/bmp;base64," + CommonMethod.ConvertBase64To1BppBase64(pfsymbol.ImageData) |
|
}; |
|
cimtiledPattern.ColorSubstitutions.Add(new CIMColorSubstitution |
|
{ |
|
NewColor = fSymbol.Outline.Color, |
|
OldColor = new int[] |
|
{ |
|
0, |
|
0, |
|
0, |
|
255 |
|
} |
|
}); |
|
cimtiledPattern.ColorSubstitutions.Add(new CIMColorSubstitution |
|
{ |
|
NewColor = new int[] |
|
{ |
|
255, |
|
255, |
|
255, |
|
255 |
|
}, |
|
OldColor = new int[] |
|
{ |
|
255, |
|
255, |
|
255, |
|
255 |
|
} |
|
}); |
|
cimfill.Pattern = cimtiledPattern; |
|
cimpolygonSymbol.SymbolLayers.Add(cimfill); |
|
} |
|
CIMFill cimfill2 = new CIMFill(); |
|
if (fSymbol is SFSymbol) |
|
{ |
|
SFSymbol sfsymbol = fSymbol as SFSymbol; |
|
cimfill2.Pattern = new CIMSolidPattern |
|
{ |
|
Color = sfsymbol.Color |
|
}; |
|
} |
|
else |
|
{ |
|
cimfill2.Pattern = new CIMSolidPattern |
|
{ |
|
Color = new int[] |
|
{ |
|
255, |
|
255, |
|
255, |
|
255 |
|
} |
|
}; |
|
} |
|
cimpolygonSymbol.SymbolLayers.Add(cimfill2); |
|
cimsymbolReference.Symbol = cimpolygonSymbol; |
|
return cimsymbolReference; |
|
} |
|
|
|
// Token: 0x06000418 RID: 1048 RVA: 0x00017CEC File Offset: 0x00015EEC |
|
public static float[] rgb2hsb(int rgbR, int rgbG, int rgbB) |
|
{ |
|
int[] array = new int[] |
|
{ |
|
rgbR, |
|
rgbG, |
|
rgbB |
|
}; |
|
Array.Sort<int>(array); |
|
int num = array[2]; |
|
int num2 = array[0]; |
|
float num3 = (float)num / 255f; |
|
float num4 = (num == 0) ? 0f : ((float)(num - num2) / (float)num); |
|
float num5 = 0f; |
|
if (num == rgbR && rgbG >= rgbB) |
|
{ |
|
num5 = (float)(rgbG - rgbB) * 60f / (float)(num - num2) + 0f; |
|
} |
|
else if (num == rgbR && rgbG < rgbB) |
|
{ |
|
num5 = (float)(rgbG - rgbB) * 60f / (float)(num - num2) + 360f; |
|
} |
|
else if (num == rgbG) |
|
{ |
|
num5 = (float)(rgbB - rgbR) * 60f / (float)(num - num2) + 120f; |
|
} |
|
else if (num == rgbB) |
|
{ |
|
num5 = (float)(rgbR - rgbG) * 60f / (float)(num - num2) + 240f; |
|
} |
|
if (float.IsNaN(num5)) |
|
{ |
|
num5 = 0f; |
|
} |
|
return new float[] |
|
{ |
|
num5, |
|
num4, |
|
num3 |
|
}; |
|
} |
|
|
|
// Token: 0x06000419 RID: 1049 RVA: 0x00017E28 File Offset: 0x00016028 |
|
public static float[] rgb2hsb(Color color) |
|
{ |
|
return CommonMethod.rgb2hsb((int)color.R, (int)color.G, (int)color.B); |
|
} |
|
|
|
// Token: 0x0600041A RID: 1050 RVA: 0x00017E54 File Offset: 0x00016054 |
|
public static Color hsb2rgb(float h, float s, float v) |
|
{ |
|
float num = 0f; |
|
float num2 = 0f; |
|
float num3 = 0f; |
|
int num4 = (int)(h / 60f % 6f); |
|
float num5 = h / 60f - (float)num4; |
|
float num6 = v * (1f - s); |
|
float num7 = v * (1f - num5 * s); |
|
float num8 = v * (1f - (1f - num5) * s); |
|
switch (num4) |
|
{ |
|
case 0: |
|
num = v; |
|
num2 = num8; |
|
num3 = num6; |
|
break; |
|
case 1: |
|
num = num7; |
|
num2 = v; |
|
num3 = num6; |
|
break; |
|
case 2: |
|
num = num6; |
|
num2 = v; |
|
num3 = num8; |
|
break; |
|
case 3: |
|
num = num6; |
|
num2 = num7; |
|
num3 = v; |
|
break; |
|
case 4: |
|
num = num8; |
|
num2 = num6; |
|
num3 = v; |
|
break; |
|
case 5: |
|
num = v; |
|
num2 = num6; |
|
num3 = num7; |
|
break; |
|
} |
|
return Color.FromArgb((int)((double)num * 255.0), (int)((double)num2 * 255.0), (int)((double)num3 * 255.0)); |
|
} |
|
|
|
// Token: 0x0600041B RID: 1051 RVA: 0x00017F50 File Offset: 0x00016150 |
|
public static void BuildItemInfoTypes(ItemInfo itemInfo) |
|
{ |
|
if (itemInfo.DrawingInfo.Renderer is UniqueValueRenderer) |
|
{ |
|
UniqueValueRenderer uniqueValueRenderer = itemInfo.DrawingInfo.Renderer as UniqueValueRenderer; |
|
foreach (UniqueValueInfo uniqueValueInfo in uniqueValueRenderer.UniqueValueInfos) |
|
{ |
|
UniqueType uniqueType = new UniqueType |
|
{ |
|
Id = uniqueValueInfo.Value, |
|
Name = uniqueValueInfo.Value |
|
}; |
|
Template template = CommonMethod.GetTemplate(itemInfo); |
|
if (uniqueValueRenderer.DefaultSymbol is MSymbol) |
|
{ |
|
template.DrawingTool = "esriFeatureEditToolPoint"; |
|
} |
|
else if (uniqueValueRenderer.DefaultSymbol is FSymbol) |
|
{ |
|
template.DrawingTool = "esriFeatureEditToolPolygon"; |
|
} |
|
else if (uniqueValueRenderer.DefaultSymbol is LSymbol) |
|
{ |
|
template.DrawingTool = "esriFeatureEditToolLine"; |
|
} |
|
template.Name = uniqueValueInfo.Value; |
|
template.SetAttributeValue(itemInfo.TypeIdField, uniqueValueInfo.Value); |
|
uniqueType.Templates.Add(template); |
|
itemInfo.Types.Add(uniqueType); |
|
} |
|
itemInfo.Templates.Clear(); |
|
} |
|
else if (itemInfo.DrawingInfo.Renderer is SimpleRenderer) |
|
{ |
|
Template template = CommonMethod.GetTemplate(itemInfo); |
|
Symbol symbol = (itemInfo.DrawingInfo.Renderer as SimpleRenderer).Symbol; |
|
if (symbol is MSymbol) |
|
{ |
|
template.DrawingTool = "esriFeatureEditToolPoint"; |
|
} |
|
else if (symbol is FSymbol) |
|
{ |
|
template.DrawingTool = "esriFeatureEditToolPolygon"; |
|
} |
|
else if (symbol is LSymbol) |
|
{ |
|
template.DrawingTool = "esriFeatureEditToolLine"; |
|
} |
|
template.Name = itemInfo.Name; |
|
itemInfo.Templates.Clear(); |
|
itemInfo.Templates.Add(template); |
|
itemInfo.Types.Clear(); |
|
} |
|
} |
|
|
|
// Token: 0x0600041C RID: 1052 RVA: 0x000181A0 File Offset: 0x000163A0 |
|
private static Template GetTemplate(ItemInfo itemInfo) |
|
{ |
|
Template template = new Template(); |
|
foreach (Field field in itemInfo.Fields) |
|
{ |
|
template.Prototype.Attributes.Add(field.Name, CommonMethod.GetFieldDefaultValue(field.Type)); |
|
} |
|
return template; |
|
} |
|
|
|
// Token: 0x0600041D RID: 1053 RVA: 0x00018224 File Offset: 0x00016424 |
|
private static object GetFieldDefaultValue(esriFieldType fieldType) |
|
{ |
|
object result = null; |
|
switch (fieldType) |
|
{ |
|
case esriFieldType.esriFieldTypeSmallInteger: |
|
case esriFieldType.esriFieldTypeInteger: |
|
case esriFieldType.esriFieldTypeSingle: |
|
case esriFieldType.esriFieldTypeDouble: |
|
case esriFieldType.esriFieldTypeOID: |
|
result = 0; |
|
break; |
|
case esriFieldType.esriFieldTypeString: |
|
case esriFieldType.esriFieldTypeGUID: |
|
case esriFieldType.esriFieldTypeGlobalID: |
|
case esriFieldType.esriFieldTypeXML: |
|
result = " "; |
|
break; |
|
case esriFieldType.esriFieldTypeDate: |
|
case esriFieldType.esriFieldTypeGeometry: |
|
case esriFieldType.esriFieldTypeBlob: |
|
case esriFieldType.esriFieldTypeRaster: |
|
result = null; |
|
break; |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x0600041E RID: 1054 RVA: 0x00018290 File Offset: 0x00016490 |
|
public static Image GetImageFrom(FSymbol fSymbol, int height, int width) |
|
{ |
|
float num = (float)((height > width) ? width : height) / 2f - 1f; |
|
float num2 = (float)fSymbol.Outline.Width; |
|
Bitmap bitmap = new Bitmap(width, height); |
|
Graphics graphics = Graphics.FromImage(bitmap); |
|
SolidBrush brush = new SolidBrush(CommonMethod.GetColorFromInt4Color(fSymbol.Outline.Color)); |
|
graphics.FillRectangle(brush, 0, 0, width, height); |
|
if (num2 > num) |
|
{ |
|
num2 = num; |
|
} |
|
Brush brush2 = null; |
|
if (fSymbol is SFSymbol) |
|
{ |
|
SFSymbol sfsymbol = fSymbol as SFSymbol; |
|
brush2 = new SolidBrush(CommonMethod.GetColorFromInt4Color(sfsymbol.Color)); |
|
} |
|
else if (fSymbol is PFSymbol) |
|
{ |
|
PFSymbol pfsymbol = fSymbol as PFSymbol; |
|
brush2 = new TextureBrush(CommonMethod.GetImageFromBase64(pfsymbol.ImageData)); |
|
} |
|
Image result; |
|
if (brush2 == null) |
|
{ |
|
result = null; |
|
} |
|
else |
|
{ |
|
graphics.FillRectangle(brush2, num2, num2, (float)width - num2 * 2f, (float)height - num2 * 2f); |
|
graphics.Save(); |
|
graphics.Dispose(); |
|
result = bitmap; |
|
} |
|
return result; |
|
} |
|
|
|
// Token: 0x0600041F RID: 1055 RVA: 0x000183B0 File Offset: 0x000165B0 |
|
public static LabelingInfo GetLabelInfo(Font font, Color fontColor, string fieldName, int minScale, int maxScale) |
|
{ |
|
LabelingInfo labelingInfo = new LabelingInfo(); |
|
labelingInfo.LabelExpression = string.Format("[{0}]", fieldName); |
|
labelingInfo.MaxScale = maxScale; |
|
labelingInfo.MinScale = minScale; |
|
labelingInfo.Symbol = new TSSymbol(); |
|
labelingInfo.Symbol.Color = new int[] |
|
{ |
|
(int)fontColor.R, |
|
(int)fontColor.G, |
|
(int)fontColor.B, |
|
(int)fontColor.A |
|
}; |
|
labelingInfo.Symbol.Font = new ESRIFont |
|
{ |
|
Family = font.FontFamily.GetName(CultureInfo.GetCultureInfo("en-us").LCID), |
|
Size = (int)font.Size |
|
}; |
|
if (font.Bold) |
|
{ |
|
labelingInfo.Symbol.Font.Weight = "bold"; |
|
} |
|
if (font.Underline) |
|
{ |
|
labelingInfo.Symbol.Font.Decoration = "underline"; |
|
} |
|
return labelingInfo; |
|
} |
|
} |
|
}
|
|
|