using System; using System.IO; namespace MuchInfo.Chart.Data { /// /// Class DrawingToolInfo /// public class DrawingToolInfo { public long DrawingID; public Guid DrawingGUID; public int ContactID; public int? SymbolID; public string Symbol; public DateTime Created; public DateTime Updated; public long? TimeFrame; public Guid? ScaleGUID; public short? DrawType; public DateTime? P1Date; public float? P1Val; public DateTime? P2Date; public float? P2Val; public DateTime? P3Date; public float? P3Val; public int? Color1; public int? Color2; public bool? Bool1; public bool? Bool2; public string XML; public bool isDeleted; public bool DrawOnAllSymbols; public short CreatedIn; public short LastEditedIn; public string ChartID; public DrawingToolInfo() { this.Created = DateTime.Now; this.Updated = DateTime.Now; this.isDeleted = false; this.DrawOnAllSymbols = false; this.CreatedIn = 1; this.LastEditedIn = 1; } public DrawingToolInfo Copy() { var memoryStream = new MemoryStream(); DrawingToolInfo result; try { while (true) { BinaryWriter binaryWriter = new BinaryWriter(memoryStream); try { while (true) { BinaryReader binaryReader = new BinaryReader(memoryStream); try { this.toBytes(binaryWriter); memoryStream.Position = (0L); result = DrawingToolInfo.fromBytes(binaryReader); return result; } finally { bool flag = binaryReader != null; if (flag) { binaryReader.Dispose(); } } } } finally { bool flag = binaryWriter != null; if (flag) { binaryWriter.Dispose(); } } } } finally { bool flag = memoryStream != null; if (flag) { memoryStream.Dispose(); } } //return result; } public Guid OriginalScaleGUID() { if (!string.IsNullOrEmpty(ChartID) && this.ChartID.StartsWith("ORIGSCALEGUID|")) { return new Guid(this.ChartID.Substring("ORIGSCALEGUID|".Length)); } return Guid.Empty; } public static DrawingToolInfo fromBytes(BinaryReader read) { bool flag = read.ReadByte() == 1; DrawingToolInfo result; if (flag) { var drawingToolInfo = new DrawingToolInfo(); drawingToolInfo.DrawingID = read.ReadInt64(); drawingToolInfo.DrawingGUID = new Guid(read.ReadBytes(16)); drawingToolInfo.ContactID = read.ReadInt32(); flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.SymbolID = read.ReadInt32(); } drawingToolInfo.Symbol = read.ReadString(); drawingToolInfo.Created = new DateTime(read.ReadInt64()); drawingToolInfo.Updated = new DateTime(read.ReadInt64()); flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.TimeFrame = read.ReadInt64(); } flag = (read.ReadByte() == 1); if (flag) { DrawingToolInfo arg_E5_0 = drawingToolInfo; Guid guid = new Guid(read.ReadBytes(16)); arg_E5_0.ScaleGUID = guid; } flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.DrawType = read.ReadInt16(); } flag = (read.ReadByte() == 1); if (flag) { DrawingToolInfo arg_12E_0 = drawingToolInfo; DateTime dateTime = new DateTime(read.ReadInt64()); arg_12E_0.P1Date = dateTime; } flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.P1Val = read.ReadSingle(); } flag = (read.ReadByte() == 1); if (flag) { DrawingToolInfo arg_177_0 = drawingToolInfo; DateTime dateTime = new DateTime(read.ReadInt64()); arg_177_0.P2Date = dateTime; } flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.P2Val = read.ReadSingle(); } flag = (read.ReadByte() == 1); if (flag) { DrawingToolInfo arg_1C0_0 = drawingToolInfo; DateTime dateTime = new DateTime(read.ReadInt64()); arg_1C0_0.P3Date = dateTime; } flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.P3Val = read.ReadSingle(); } flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.Color1 = read.ReadInt32(); } flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.Color2 = read.ReadInt32(); } flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.Bool1 = read.ReadBoolean(); } flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.Bool2 = read.ReadBoolean(); } flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.XML = read.ReadString(); } drawingToolInfo.isDeleted = read.ReadBoolean(); drawingToolInfo.DrawOnAllSymbols = read.ReadBoolean(); drawingToolInfo.CreatedIn = read.ReadInt16(); drawingToolInfo.LastEditedIn = read.ReadInt16(); flag = (read.ReadByte() == 1); if (flag) { drawingToolInfo.ChartID = read.ReadString(); } result = drawingToolInfo; } else { result = null; } return result; } public void toBytes(BinaryWriter write) { write.Write(1); write.Write(this.DrawingID); write.Write(this.DrawingGUID.ToByteArray()); write.Write(this.ContactID); bool flag = this.SymbolID.HasValue; if (flag) { write.Write(1); write.Write(this.SymbolID.Value); } else { write.Write(0); } write.Write(this.Symbol); write.Write(this.Created.Ticks); write.Write(this.Updated.Ticks); flag = this.TimeFrame.HasValue; if (flag) { write.Write(1); write.Write(this.TimeFrame.Value); } else { write.Write(0); } flag = this.ScaleGUID.HasValue; if (flag) { write.Write(1); write.Write(this.ScaleGUID.Value.ToByteArray()); } else { write.Write(0); } flag = this.DrawType.HasValue; if (flag) { write.Write(1); write.Write(this.DrawType.Value); } else { write.Write(0); } flag = this.P1Date.HasValue; if (flag) { write.Write(1); write.Write(this.P1Date.Value.Ticks); } else { write.Write(0); } flag = this.P1Val.HasValue; if (flag) { write.Write(1); write.Write(this.P1Val.Value); } else { write.Write(0); } flag = this.P2Date.HasValue; if (flag) { write.Write(1); write.Write(this.P2Date.Value.Ticks); } else { write.Write(0); } flag = this.P2Val.HasValue; if (flag) { write.Write(1); write.Write(this.P2Val.Value); } else { write.Write(0); } flag = this.P3Date.HasValue; if (flag) { write.Write(1); write.Write(this.P3Date.Value.Ticks); } else { write.Write(0); } flag = this.P3Val.HasValue; if (flag) { write.Write(1); write.Write(this.P3Val.Value); } else { write.Write(0); } flag = this.Color1.HasValue; if (flag) { write.Write(1); write.Write(this.Color1.Value); } else { write.Write(0); } flag = this.Color2.HasValue; if (flag) { write.Write(1); write.Write(this.Color2.Value); } else { write.Write(0); } flag = this.Bool1.HasValue; if (flag) { write.Write(1); write.Write(this.Bool1.Value); } else { write.Write(0); } flag = this.Bool2.HasValue; if (flag) { write.Write(1); write.Write(this.Bool2.Value); } else { write.Write(0); } if (!string.IsNullOrEmpty(this.XML)) { write.Write(1); write.Write(this.XML); } else { write.Write(0); } write.Write(this.isDeleted); write.Write(this.DrawOnAllSymbols); write.Write(this.CreatedIn); write.Write(this.LastEditedIn); if (string.IsNullOrEmpty(this.ChartID)) { write.Write(1); write.Write(this.ChartID); } else { write.Write(0); } } } }