| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- using System;
- using System.IO;
- namespace MuchInfo.Chart.Data
- {
- /// <summary>
- /// Class DrawingToolInfo
- /// </summary>
- 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);
- }
- }
- }
- }
|