ReadDouble() public method

public ReadDouble ( ) : double
return double
Example #1
0
        public Node(System.IO.Stream stream)
        {
            int id;
            double lat,lon;

            try{
                byte[] array = new byte[sizeof(int) + sizeof(double) * 2];
                stream.Read(array, 0, array.Length);
            //                ByteBuffer buffer = new ByteBuffer(array);
                MemoryStream ms = new MemoryStream(array);
                BinaryReader buffer = new BinaryReader(ms);

                id = buffer.ReadInt32();
                lat = buffer.ReadDouble();
                lon = buffer.ReadDouble();
            //                BinaryReader by = new BinaryReader(stream);
                //id = by.ReadInt32();
                //lat = by.ReadDouble();
                //lon = by.ReadDouble();
            }
            catch(Exception e)
            {
                id = 0;
                lat = 0.0;
                lon = 0.0;
            }

            this.id = id;
            this.lat = lat;
            this.lon = lon;
        }
Example #2
0
        public static IList<Station> ParseStations(Stream stream)
        {
            using (var reader = new BinaryReader (stream, System.Text.Encoding.UTF8, true)) {
                var count = reader.ReadInt32 ();
                var stations = new Station[count];
                for (int i = 0; i < count; i++) {
                    stations [i] = new Station {
                        Id = reader.ReadInt32 (),
                        Street = reader.ReadString (),
                        Name = reader.ReadString(),
                        StationType = reader.ReadInt32(),
                        b = reader.ReadBoolean(),
                        su = reader.ReadBoolean(),
                        t = reader.ReadBoolean(),
                        bk = reader.ReadBoolean(),
                        bl = reader.ReadBoolean(),
                        Latitude = reader.ReadDouble(),
                        Longitude = reader.ReadDouble(),
                        EmptySlotCount = reader.ReadInt32(),
                        dx = reader.ReadInt32(),
                        BikeCount = reader.ReadInt32(),
                        bx = reader.ReadInt32()
                    };
                }

                return stations;
            }
        }
 public override void ReadFromRecorder(BinaryReader reader)
 {
     PredictedLeftLegAngle = reader.ReadDouble();
     PredictedRightLegAngle = reader.ReadDouble();
     PredictedPersonHeading = reader.ReadDouble();
     IsLearned = reader.ReadDouble() == 1d;
 }
Example #4
0
        /// <summary>
        /// Loads a room data and image file
        /// </summary>
        /// <param name="dataFile">Room data file</param>
        /// <param name="imageFile">Room image file</param>
        /// <returns></returns>
        public static Room Load(string dataFile,string imageFile)
        {
            var dataFileWithPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName+@"\Images\"+dataFile;
            Room newRoom;
            if (!File.Exists(dataFileWithPath)) return null;
            using (var stream = File.Open(dataFileWithPath, FileMode.Open))
            using (var reader = new BinaryReader(stream, Encoding.UTF8))
            {

                var hd = Encoding.UTF8.GetBytes(Header);
                var buffer = new byte[hd.Length];
                reader.Read(buffer, 0, buffer.Length);
                var readHeader = Encoding.UTF8.GetString(buffer);
                if (readHeader != Header) return null;

                var posX = reader.ReadDouble();
                var posY = reader.ReadDouble();
                var tilesLength = reader.ReadInt32();
                newRoom = new Room(new Vector2((float)posX,(float)posY),imageFile)
                {
                    Tiles = new Tile[tilesLength]
                };

                for (var i = 0; i < tilesLength; i++)
                {
                    var tt = (TileTypes)reader.ReadInt32();
                    newRoom.Tiles[i] = new Tile() { TileType = tt };
                }
            }
            return newRoom;

        }
Example #5
0
		public override object Read(BinaryReader reader)
		{
			reader.ReadByte();
			int id = reader.ReadInt32();
			InstrumentType type = (InstrumentType)reader.ReadByte();
			string symbol = reader.ReadString();
			string description = reader.ReadString();
			byte currencyId = reader.ReadByte();
			string exchange = reader.ReadString();
			Instrument instrument = new Instrument(id, type, symbol, description, currencyId, exchange);
			instrument.tickSize = reader.ReadDouble();
			instrument.maturity = new DateTime(reader.ReadInt64());
			instrument.factor = reader.ReadDouble();
			instrument.strike = reader.ReadDouble();
			instrument.putcall = (PutCall)reader.ReadByte();
			instrument.margin = reader.ReadDouble();
			int num = reader.ReadInt32();
			for (int i = 0; i < num; i++)
			{
				AltId altId = new AltId();
				altId.providerId = reader.ReadByte();
				altId.symbol = reader.ReadString();
				altId.exchange = reader.ReadString();
				instrument.altId.Add(altId);
			}
			return instrument;
		}
Example #6
0
        public static Room Load(string filename)
        {
            Room newRoom;
            if (!File.Exists(filename)) return null;
            using (var stream = File.Open(filename, FileMode.Open))
            using (var reader = new BinaryReader(stream, Encoding.UTF8))
            {

                var hd = Encoding.UTF8.GetBytes(Header);
                var buffer = new byte[hd.Length];
                reader.Read(buffer, 0, buffer.Length);
                var readHeader = Encoding.UTF8.GetString(buffer);
                if (readHeader != Header) return null;

                //writer.Write(hd, 0, hd.Length);
                var posX = reader.ReadDouble();
                //writer.Write(room.Position.X);
                var posY = reader.ReadDouble();
                // writer.Write(room.Position.Y);
                var tilesLength = reader.ReadInt32();
                //writer.Write(room.Tiles.Length);
                newRoom = new Room(new Point(posX, posY))
                {
                    Tiles = new Tile[tilesLength]
                };

                for (var i = 0; i < tilesLength; i++)
                {
                    var tt = (TileTypes)reader.ReadInt32();
                    newRoom.Tiles[i] = new Tile() { TileType = tt };
                }
            }
            return newRoom;

        }
        public void StatisticRead(string FileName)
        {
            // Read the file.
            FileStream fs;
            // Create the reader for data.
            fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
            BinaryReader r = new BinaryReader(fs);
            // Read data from Test.data.
            double[] ar = new double [FileLenght];

            string str = "";
            //		StatisticalData [] stat = new StatisticalData[FileLenght];
            for (int i = 0; i < FileLenght; i++)
            {
            //		ar[i] = r.ReadDouble();
                stat[i].mean = r.ReadByte();
                stat[i].sigma = r.ReadByte();
                stat[i].K = r.ReadDouble();
                stat[i].P = r.ReadDouble();
                stat[i].Z = r.ReadDouble();
                //		str = str + ";" + ar[i].ToString();
                //	Console.WriteLine(r.ReadInt32());
            }

            //	MessageBox.Show("Loaded data is: " + str);
            str.Remove(0,str.Length);
            r.Close();
            fs.Close();
        }
Example #8
0
 public override void DeserializeBody(BinaryReader br)
 {
     n = br.ReadInt32();
     x = br.ReadDouble();
     y = br.ReadDouble();
     zoom = br.ReadDouble();
 }
Example #9
0
		public override void Initialize(DrawArgs drawArgs)
		{
			FileInfo boundaryFileInfo = new FileInfo(this._boundaryFilePath);
			if(!boundaryFileInfo.Exists)
			{
				this.isInitialized = true;
				return;
			}

			using( FileStream boundaryFileStream = boundaryFileInfo.OpenRead() )
			using( BinaryReader boundaryFileReader = new BinaryReader(boundaryFileStream, System.Text.Encoding.ASCII) ) {
				int numBoundaries = boundaryFileReader.ReadInt32();
				int count = boundaryFileReader.ReadInt32();
				this.vertices = new CustomVertex.PositionColored[count];

				for(int i = 0; i < count; i++) {
					double lat = boundaryFileReader.ReadDouble();
					double lon = boundaryFileReader.ReadDouble();
					Vector3 v = MathEngine.SphericalToCartesian((float)lat, (float)lon, (float)(this._parentWorld.EquatorialRadius + this._distanceAboveSurface));
					this.vertices[i].X = v.X;
					this.vertices[i].Y = v.Y;
					this.vertices[i].Z = v.Z;
					this.vertices[i].Color = this._color;
				}

			}
			this.isInitialized = true;
		}
        /// <summary>
        /// データ 読み込み
        /// </summary>
        /// <param name="strm"></param>
        public void Read(BinaryReader strm)
        {
            strm.ReadInt32(); // 要素数

            wdPosX = strm.ReadDouble();
            wdPosY = strm.ReadDouble();
        }
Example #11
0
        public Poly(BinaryReader file, int shapeType, string entryType, int misc, string country)
        {
            ShapeType = shapeType;
            EntryType = entryType;
            Misc = misc;
            Country = country;

            //read Poly from Shapefile
            float minX = (float)file.ReadDouble();
            float minY = (float)file.ReadDouble();
            float maxX = (float)file.ReadDouble();
            float maxY = (float)file.ReadDouble();
            box = new RectangleF(minX, minY, maxX - minX, maxY - minY);

            int numParts = file.ReadInt32();
            parts = new PointF[numParts][];

            int numPoints = file.ReadInt32(); //total number of points
            file.ReadInt32(); //skip first part index (which should always be 0)
            int prevPartIndex = 0;

            for (int i = 0; i < numParts - 1; i++)
            {
                int partIndex = file.ReadInt32(); //index to first point in (next) part
                parts[i] = new PointF[partIndex - prevPartIndex];
                prevPartIndex = partIndex;
            }
            parts[parts.Length - 1] = new PointF[numPoints - prevPartIndex]; //final part

            for (int i = 0; i < numParts; i++)
                for (int j = 0; j < parts[i].Length; j++)
                    parts[i][j] = new PointF((float)file.ReadDouble(), (float)file.ReadDouble());
        }
Example #12
0
 public override object Read(BinaryReader reader, byte version)
 {
     if (version == 0)
         return new Bid(new DateTime(reader.ReadInt64()), reader.ReadByte(), reader.ReadInt32(), reader.ReadDouble(), reader.ReadInt32());
     else
         return new Bid(new DateTime(reader.ReadInt64()), new DateTime(reader.ReadInt64()), reader.ReadByte(), reader.ReadInt32(), reader.ReadDouble(), reader.ReadInt32());
 }
Example #13
0
		public override object Read(BinaryReader reader)
		{
			if (reader.ReadByte() == 0)
			{
				return new Ask(new DateTime(reader.ReadInt64()), reader.ReadByte(), reader.ReadInt32(), reader.ReadDouble(), reader.ReadInt32());
			}
			return new Ask(new DateTime(reader.ReadInt64()), new DateTime(reader.ReadInt64()), reader.ReadByte(), reader.ReadInt32(), reader.ReadDouble(), reader.ReadInt32());
		}
Example #14
0
            public void Read(BinaryReader reader, UInt16 version)
            {
                float x, y;
                x = (float)reader.ReadDouble();
                y = (float)reader.ReadDouble();

                Location = new PointF(x, y);
            }
Example #15
0
 public Molecule(BinaryReader reader)
 {
     AtomCount = FileUtils.ReadInt32Array(reader);
     AtomType = FileUtils.ReadInt32Array(reader);
     MolecularWeight = reader.ReadDouble();
     MonoIsotopicMass = reader.ReadDouble();
     mostLikelyMass = reader.ReadDouble();
 }
Example #16
0
 public CubicSpline(BinaryReader reader)
 {
     x = FileUtils.ReadDoubleArray(reader);
     Y = FileUtils.ReadDoubleArray(reader);
     Yp1 = reader.ReadDouble();
     Ypn = reader.ReadDouble();
     y2 = FileUtils.ReadDoubleArray(reader);
 }
Example #17
0
 public static GeoPoint ParseFromStream(Stream stream)
 {
     using (var reader = new BinaryReader (stream, System.Text.Encoding.UTF8, true)) {
         return new GeoPoint {
             Lat = reader.ReadDouble (),
             Lon = reader.ReadDouble ()
         };
     }
 }
Example #18
0
 public void Read(BinaryReader reader, UInt16 version)
 {
     float x, y;
     x = (float)reader.ReadDouble();
     y = (float)reader.ReadDouble();
     Location = new PointF(x, y);
     Size = (float)reader.ReadDouble();
     Color = FileFormat.ReadColor(reader);
 }
Example #19
0
        public Point(BinaryReader file, int shapeType, string entryType, int misc, string country)
        {
            ShapeType = shapeType;
            EntryType = entryType;
            Misc = misc;
            Country = country;

            point = new PointF((float)file.ReadDouble(), (float)file.ReadDouble());
        }
Example #20
0
 public void Read(BinaryReader r)
 {
     e = (StEvent) r.ReadInt32();
     userId = r.ReadInt32();
     discussionId = r.ReadInt32();
     topicId = r.ReadInt32();
     devType = (DeviceType) r.ReadInt32();
     StickHeight = r.ReadDouble();
     Span = TimeSpan.FromSeconds(r.ReadDouble());
 }
 public LinearInterpolator(BinaryReader reader)
 {
     int len = reader.ReadInt32();
     xvals = new double[len];
     yvals = new double[len];
     for (int i = 0; i < len; i++){
         xvals[i] = reader.ReadDouble();
         yvals[i] = reader.ReadDouble();
     }
 }
 public static BottomProfilePoint[] ToBottomProfileArray(this byte[] blob)
 {
     if (blob == null) return null;
     using (var reader = new BinaryReader(new MemoryStream(blob)))
     {
         var result = new BottomProfilePoint[reader.ReadInt32()];
         for (var index = 0; index < result.Length; index++) result[index] = new BottomProfilePoint { Range = reader.ReadDouble(), Depth = reader.ReadDouble() };
         return result;
     }
 }
Example #23
0
 public void Load(BinaryReader Input)
 {
     this.objID = Input.ReadInt32 ();
     this.stddev = Input.ReadDouble();
     this.mean = Input.ReadDouble();
     this.last_near = Input.ReadDouble();
     this.first_far = Input.ReadDouble();
     this.num_near= Input.ReadInt32();
     this.num_far=Input.ReadInt32();
 }
Example #24
0
 public static Matrix3D Read(this Matrix3D m3D, BinaryReader strm)
 {
     char test = strm.ReadChar();
     if (test == 'I')
     {
         m3D.SetIdentity();
     }
     else
     {
         m3D.M11 = strm.ReadDouble();
         m3D.M12 = strm.ReadDouble();
         m3D.M13 = strm.ReadDouble();
         m3D.M14 = strm.ReadDouble();
         m3D.M21 = strm.ReadDouble();
         m3D.M22 = strm.ReadDouble();
         m3D.M23 = strm.ReadDouble();
         m3D.M24 = strm.ReadDouble();
         m3D.M31 = strm.ReadDouble();
         m3D.M32 = strm.ReadDouble();
         m3D.M33 = strm.ReadDouble();
         m3D.M34 = strm.ReadDouble();
         m3D.OffsetX = strm.ReadDouble();
         m3D.OffsetY = strm.ReadDouble();
         m3D.OffsetZ = strm.ReadDouble();
         m3D.M44 = strm.ReadDouble();
     }
     return m3D;
 }
		public override object Read(BinaryReader reader)
		{
			reader.ReadByte();
			return new ExecutionReport
			{
				DateTime = new DateTime(reader.ReadInt64()),
				instrumentId = reader.ReadInt32(),
				commandID = reader.ReadInt32(),
				currencyId = reader.ReadByte(),
				execType = (ExecType)reader.ReadInt32(),
				ordType = (OrderType)reader.ReadInt32(),
				side = (OrderSide)reader.ReadInt32(),
				timeInForce = (TimeInForce)reader.ReadInt32(),
				ordStatus = (OrderStatus)reader.ReadInt32(),
				lastPx = reader.ReadDouble(),
				avgPx = reader.ReadDouble(),
				ordQty = reader.ReadDouble(),
				cumQty = reader.ReadDouble(),
				lastQty = reader.ReadDouble(),
				leavesQty = reader.ReadDouble(),
				price = reader.ReadDouble(),
				stopPx = reader.ReadDouble(),
				commission = reader.ReadDouble()
			};
		}
Example #26
0
        public Material(System.IO.BinaryReader br)
        {
            m_ambientColor = new Vec4(br);
            m_diffuseColor = new Vec4(br);
            m_name         = br.ReadString();
            bool isOpacityMapNull = br.ReadBoolean();

            if (isOpacityMapNull)
            {
                this.m_opacityMap = null;
            }
            else
            {
                this.m_opacityMap = MaterialMap.Load(br);
            }

            this.m_shininess     = (float)br.ReadDouble();
            this.m_specularColor = new Vec4(br);
            int count = br.ReadInt32();

            if (count > 0)
            {
                for (int i = 0; i < count; ++i)
                {
                    AddMaterialMap(MaterialMap.Load(br));
                }
            }

            this.Transparency = (float)br.ReadDouble();
            this.m_twoSided   = br.ReadBoolean();
            this.m_scale      = (float)br.ReadDouble();
            if (this.m_scale != 1)
            {
                this.hasTexTransform = true;
            }
            if (br.ReadBoolean())
            {
                remapUV    = new Vec2[2];
                remapUV[0] = Vec2.Load(br);
                remapUV[1] = Vec2.Load(br);
            }
            else
            {
                remapUV = null;
            }
            if (br.PeekChar() == '~')
            {
                br.ReadChar();
                count = br.ReadInt32();
                for (int i = 0; i < count; ++i)
                {
                    AddShader(Shader.Load(br));
                }
            }
        }
Example #27
0
 public virtual void DeSerialize(BinaryReader r)
 {
     var x = r.ReadDouble();
     var y = r.ReadDouble();
     var d = r.ReadDouble();
     var m = r.ReadDouble();
     IsMoving = r.ReadBoolean();
     Position = new Vector(x,y);
     Direction = d;
     MoveSpeed = m;
 }
Example #28
0
        public static SecondLineVIP FromStream(System.IO.BinaryReader br)
        {
            SecondLineVIP data = new SecondLineVIP();

            data.TotalVIPs  = br.ReadInt32();
            data.StartChain = br.ReadDouble();
            data.EndChain   = br.ReadDouble();
            data.Interval   = br.ReadDouble();

            return(data);
        }
Example #29
0
        public static VIPData FromStream(System.IO.BinaryReader br)
        {
            VIPData data = new VIPData();

            data.VIPNo     = br.ReadInt32();
            data.VIP_Chain = br.ReadDouble();
            data.VIP_level = br.ReadDouble();
            data.VCL1      = br.ReadDouble();
            data.VCL2      = br.ReadDouble();

            return(data);
        }
Example #30
0
        public Command(byte[] data)
        {
            MemoryStream ms = new MemoryStream(data);
            BinaryReader br = new BinaryReader(ms);

            this.entity_id = br.ReadInt32();
            this.ct = (CommandType)br.ReadByte();
            this.position.X = (float)br.ReadDouble();
            this.position.Y = (float)br.ReadDouble();
            this.direction.X = (float)br.ReadDouble();
            this.direction.Y = (float)br.ReadDouble();
        }
Example #31
0
            public void Read(BinaryReader reader, UInt16 version)
            {
                float x, y;

                x = (float)reader.ReadDouble();
                y = (float)reader.ReadDouble();

                LightColor = FileFormat.ReadColor(reader);
                LightRadius = (float)reader.ReadDouble();

                LightAttenuation = FileFormat.ReadVec3(reader);
            }
Example #32
0
 public void Load(System.IO.BinaryReader _br)
 {
     IsFilter        = _br.ReadBoolean();
     CurrentType     = _br.ReadInt32();
     CurrentSubType  = _br.ReadInt32();
     Order           = _br.ReadInt32();
     CutoffFrequency = _br.ReadDouble();
     WidthFrequency  = _br.ReadDouble();
     CenterFrequency = _br.ReadDouble();
     RippleDb        = _br.ReadDouble();
     Rolloff         = _br.ReadDouble();
 }
Example #33
0
        public static VVIP FromStream(System.IO.BinaryReader br)
        {
            VVIP obj = new VVIP();

            obj.chainx = br.ReadDouble();
            obj.chainy = br.ReadDouble();
            obj.sym    = br.ReadBoolean();
            obj.grade  = br.ReadDouble();
            obj.vcl1   = br.ReadDouble();
            obj.vcl2   = br.ReadDouble();

            return(obj);
        }
Example #34
0
        public static Detail FromStream(System.IO.BinaryReader br)
        {
            Detail detail = new Detail();

            detail.ModelName  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(30));
            detail.StringName = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));
            detail.XMin       = br.ReadDouble();
            detail.YMin       = br.ReadDouble();
            detail.TextSize   = br.ReadDouble();
            detail.Rotation   = br.ReadDouble();

            return(detail);
        }
Example #35
0
		public override object Read(BinaryReader reader)
		{
			reader.ReadByte();
			return new Fill
			{
				dateTime = new DateTime(reader.ReadInt64()),
				instrumentId = reader.ReadInt32(),
				currencyId = reader.ReadByte(),
				side = (OrderSide)Enum.Parse(typeof(OrderSide), reader.ReadString()),
				qty = reader.ReadDouble(),
				price = reader.ReadDouble(),
				text = reader.ReadString()
			};
		}
Example #36
0
 void readLaserEnergyCorrectionStruct(System.IO.BinaryReader r, UInt16 rowIndex)
 {
     for (int repetitionIndex = 0; repetitionIndex < NoOfPulseDividerValues; repetitionIndex++)
     {
         double[] polynomialCoefficients = new double[NoOfCoefficients];
         double   averagePower           = r.ReadDouble();
         double   attenuation            = r.ReadDouble();
         for (int coefficientIndex = 0; coefficientIndex < NoOfCoefficients; coefficientIndex++)
         {
             polynomialCoefficients[coefficientIndex] = r.ReadDouble();
         }
         _laserWavelengthVsRepetitions[rowIndex, repetitionIndex] = new LaserEnergyCorrectionStruct(averagePower, attenuation, polynomialCoefficients);
     }
 }
Example #37
0
 public static PixelBuffer OpenBinary(Stream s)
 {
     using (var w = new BinaryReader (s)) {
         var width = w.ReadInt32 ();
         var height = w.ReadInt32 ();
         var pb = new PixelBuffer (width, height);
         for (var i = 0; i < width*height; i++) {
             pb.Buffer [i].X = w.ReadDouble ();
             pb.Buffer [i].Y = w.ReadDouble ();
             pb.Buffer [i].Z = w.ReadDouble ();
         }
         return pb;
     }
 }
Example #38
0
        internal PdfFont(System.IO.BinaryReader reader)
        {
            _fontName           = reader.ReadString();
            _fullName           = reader.ReadString();
            _familyName         = reader.ReadString();
            _weight             = reader.ReadString();
            _isCIDFont          = reader.ReadBoolean();
            _italicAngle        = reader.ReadDouble();
            _isFixedPitch       = reader.ReadBoolean();
            _characterSet       = reader.ReadString();
            _fontBBox           = new AfmRectangle(reader);
            _underlinePosition  = reader.ReadInt16();
            _underlineThickness = reader.ReadInt16();
            _capHeight          = reader.ReadInt16();
            _xheight            = reader.ReadInt16();
            _ascender           = reader.ReadInt16();
            _descender          = reader.ReadInt16();
            _stdHW = reader.ReadInt16();
            _stdVW = reader.ReadInt16();

            _charMetric = new AfmCharMetric[65536];

            UInt16 pos;

            while ((pos = reader.ReadUInt16()) != 0)
            {
                _charMetric[pos] = new AfmCharMetric(reader);
            }
        }
        public BlockVector(string PATH, int SIZE_BLOCK)
        {
            //PATH + "Sizebin" - путь файла для чтения
            //FileMode - для открытия
            using (var Reader = new System.IO.BinaryReader(File.Open(PATH + "Size.bin", FileMode.Open)))
            {
                N = Reader.ReadInt32();
            }

            if (N % SIZE_BLOCK != 0)
            {
                throw new Exception("Block_Vector: cant be separated on blocks");
            }

            using (var Reader = new System.IO.BinaryReader(File.Open(PATH + "F.bin", FileMode.Open)))
            {
                N         /= SIZE_BLOCK;
                Size_Block = SIZE_BLOCK;
                Block      = new Vector[N];

                for (int j = 0; j < N; j++)
                {
                    Block[j] = new Vector(Size_Block);

                    for (int k = 0; k < Size_Block; k++)
                    {
                        Block[j].Elem[k] = Reader.ReadDouble();
                    }
                }
            }
        }
        //<Snippet1>
        // The binary layout is as follows:
        //    Bytes 0 - 19: string text, padded to the right with null characters
        //    Bytes 20+: Double value

        // using Microsoft.SqlServer.Server;
        public void Read(System.IO.BinaryReader r)
        {
            int maxStringSize = 20;

            char[] chars;
            int    stringEnd;
            string stringValue;
            double doubleValue;

            // Read the characters from the binary stream.
            chars = r.ReadChars(maxStringSize);

            // Find the start of the null character padding.
            stringEnd = Array.IndexOf(chars, '\0');

            if (stringEnd == 0)
            {
                stringValue = null;
                return;
            }

            // Build the string from the array of characters.
            stringValue = new String(chars, 0, stringEnd);

            // Read the double value from the binary stream.
            doubleValue = r.ReadDouble();

            // Set the object's properties equal to the values.
            this.StringValue = stringValue;
            this.DoubleValue = doubleValue;
        }
Example #41
0
        //конструктор с чтением из бинарного файла
        public Matrix(string PATH)
        {
            //PATH + "Size.bin" - путь файла для чтения
            //FileMode - для открытия
            using (var Reader = new System.IO.BinaryReader(File.Open(PATH + "Size.bin", FileMode.Open)))
            {
                M = Reader.ReadInt32();
                N = M;
            }

            Elem = new double[M][];

            using (var Reader = new System.IO.BinaryReader(File.Open(PATH + "Matrix.bin", FileMode.Open)))
            {
                try
                {
                    for (int i = 0; i < M; i++)
                    {
                        Elem[i] = new double[N];
                        for (int j = 0; j < N; j++)
                        {
                            Elem[i][j] = Reader.ReadDouble();
                        }
                    }
                }
                catch { throw new Exception("Matrix: data file is not correct..."); }
            }
        }
        public RecievePacket handleData(System.IO.BinaryReader br, System.IO.BinaryWriter bw, System.Net.Sockets.TcpClient client)
        {
            double        server = br.ReadDouble();
            List <object> l      = new List <object>();

            l.Add(server);
            return(new RecievePacket(l));
        }
        public BlockMatrix(string PATH, int SIZE_BLOCK)
        {
            //PATH + "Sizebin" - путь файла для чтения
            //FileMode - для открытия
            using (var Reader = new System.IO.BinaryReader(File.Open(PATH + "Size.bin", FileMode.Open)))
            {
                M = Reader.ReadInt32();
                N = M;
            }

            if (M % SIZE_BLOCK != 0)
            {
                throw new Exception("Block_Matrix: cant be separated on blocks");
            }

            M         /= SIZE_BLOCK;
            N         /= SIZE_BLOCK;
            Size_Block = SIZE_BLOCK;
            Block      = new Matrix[M][];

            using (var Reader = new System.IO.BinaryReader(File.Open(PATH + "Matrix.bin", FileMode.Open)))
            {
                var LU_Decomposition = new LU_Decomposition();

                for (int i = 0; i < N; i++)
                {
                    Block[i] = new Matrix[N];

                    //определение блоков в блочной матрице
                    for (int j = 0; j < M; j++)
                    {
                        Block[i][j] = new Matrix(Size_Block, Size_Block);
                    }

                    for (int ii = 0; ii < Size_Block; ii++)
                    {
                        for (int j = 0; j < M; j++)
                        {
                            for (int k = 0; k < Size_Block; k++)
                            {
                                Block[i][j].Elem[ii][k] = Reader.ReadDouble();
                            }
                        }
                    }

                    LU_Decomposition.CreateLU(Block[i][i]);

                    //копируем элементы из LU в блочную матрицу
                    for (int Row = 0; Row < Size_Block; Row++)
                    {
                        for (int Column = 0; Column < Size_Block; Column++)
                        {
                            Block[i][i].Elem[Row][Column] = LU_Decomposition.LU.Elem[Row][Column];
                        }
                    }
                }
            }
        }
Example #44
0
        public static Circletype FromStream(System.IO.BinaryReader br)
        {
            Circletype circle = new Circletype();

            circle.elatt  = br.ReadInt16();
            circle.scatt  = br.ReadInt16();
            circle.Layer  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));
            circle.laatt  = br.ReadInt16();
            circle.xc     = br.ReadDouble();
            circle.yc     = br.ReadDouble();
            circle.Radius = br.ReadDouble();
            circle.color  = br.ReadInt16();
            circle.style  = br.ReadInt16();
            circle.Width  = br.ReadInt16();
            circle.Label  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));

            return(circle);
        }
Example #45
0
        public string Label;      //20 char

        public static Boxtype FromStream(System.IO.BinaryReader br)
        {
            Boxtype box = new Boxtype();

            box.elatt = br.ReadInt16();
            box.scatt = br.ReadInt16();
            box.Layer = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));
            box.laatt = br.ReadInt16();
            box.x1    = br.ReadDouble();
            box.y1    = br.ReadDouble();
            box.x2    = br.ReadDouble();
            box.y2    = br.ReadDouble();
            box.color = br.ReadInt16();
            box.style = br.ReadInt16();
            box.Width = br.ReadInt16();
            box.Label = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));

            return(box);
        }
Example #46
0
        public string Label;         //20

        public static TEXTtype FromStream(System.IO.BinaryReader br)
        {
            TEXTtype text = new TEXTtype();

            text.Length = br.ReadInt16();
            text.scatt  = br.ReadInt16();
            text.Layer  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));
            text.laatt  = br.ReadInt16();
            text.x1     = br.ReadDouble();
            text.y1     = br.ReadDouble();
            text.Size   = br.ReadDouble();
            text.rotn   = br.ReadDouble();
            text.Color  = br.ReadInt16();
            text.style  = br.ReadInt16();
            text.text   = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(60));
            text.Label  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));

            return(text);
        }
        public JToken ReadOne()
        {
            string ReadString()
            {
                //internalReader.ReadBytes(4);
                if (internalReader.ReadByte() == 1)
                {
                    return(string.Empty);
                }
                else
                {
                    uint len = internalReader.ReadByte();
                    if (len == 255)
                    {
                        len = internalReader.ReadUInt32();
                    }
                    return(Encoding.UTF8.GetString(internalReader.ReadBytes((int)len)));
                }
            }

            var t   = internalReader.ReadByte();
            var any = internalReader.ReadByte();

            switch (t)
            {
            case 0:
                return(JValue.CreateNull());

            case 1:
                return(new JValue(0 != internalReader.ReadByte()));

            case 2:
                return(new JValue(internalReader.ReadDouble()));

            case 3:
                return(new JValue(ReadString()));

            case 4:
            case 5:
            {
                var  rv  = new JObject();
                uint len = internalReader.ReadUInt32();
                for (uint i = 0; i < len; i++)
                {
                    rv.Add(ReadString(), ReadOne());
                }

                return(rv);
            }
            }

            return(null);
        }
Example #48
0
        public static double[][] binLoad_SGG_data(string fn)
        {
            System.IO.FileInfo fi = new System.IO.FileInfo(fn);
            long size             = fi.Length / 8 / 4;

            System.IO.Stream       file = System.IO.File.Open(fn, System.IO.FileMode.Open);
            System.IO.BinaryReader br   = new System.IO.BinaryReader(file);
            double[][]             d    = new double[size][];
            int nsize = 0;

            System.Text.DecoderReplacementFallbackBuffer fb = new DecoderReplacementFallbackBuffer(new DecoderReplacementFallback("x"));
            while ((br.BaseStream.Length - br.BaseStream.Position) > 8)
            {
                double d1 = br.ReadDouble(), d2 = br.ReadDouble(), d3 = br.ReadDouble(), d4 = br.ReadDouble();
                d[nsize] = new double[] { d1, d2, d3, d4 };
                nsize++;
            }
            br.Close();
            file.Close();
            return(d);
        }
Example #49
0
        public static JSONNode Deserialize(System.IO.BinaryReader aReader)
        {
            JSONBinaryTag type = (JSONBinaryTag)aReader.ReadByte();
            switch (type)
            {
                case JSONBinaryTag.Array:
                    {
                        int count = aReader.ReadInt32();
                        JSONArray tmp = new JSONArray();
                        for (int i = 0; i < count; i++)
                            tmp.Add(Deserialize(aReader));
                        return tmp;
                    }
                case JSONBinaryTag.Class:
                    {
                        int count = aReader.ReadInt32();
                        JSONClass tmp = new JSONClass();
                        for (int i = 0; i < count; i++)
                        {
                            string key = aReader.ReadString();
                            var val = Deserialize(aReader);
                            tmp.Add(key, val);
                        }
                        return tmp;
                    }
                case JSONBinaryTag.Value:
                    {
                        return new JSONData(aReader.ReadString());
                    }
                case JSONBinaryTag.IntValue:
                    {
                        return new JSONData(aReader.ReadInt32());
                    }
                case JSONBinaryTag.DoubleValue:
                    {
                        return new JSONData(aReader.ReadDouble());
                    }
                case JSONBinaryTag.BoolValue:
                    {
                        return new JSONData(aReader.ReadBoolean());
                    }
                case JSONBinaryTag.FloatValue:
                    {
                        return new JSONData(aReader.ReadSingle());
                    }

                default:
                    {
                        throw new Exception("Error deserializing JSON. Unknown tag: " + type);
                    }
            }
        }
 /// <summary>
 /// Reads an object of type <see cref="double"/> from the current stream
 /// and advances the stream position.
 /// This method reads directly from the underlying stream.
 /// </summary>
 /// <returns>object read from the stream</returns>
 public double ReadDouble()
 {
     //have to move to unsafe for this
     //FillBuffer(8);
     //uint num = (uint)(((readBuffer[0] | (readBuffer[1] << 8)) | (readBuffer[2] << 0x10)) | (readBuffer[3] << 0x18));
     //uint num2 = (uint)(((readBuffer[4] | (readBuffer[5] << 8)) | (readBuffer[6] << 0x10)) | (readBuffer[7] << 0x18));
     //ulong num3 = (num2 << 0x20) | num;
     //return *(((double*)&num3));
     if (reader == null)
     {
         reader = new BinaryReader(stream);
     }
     return(reader.ReadDouble());
 }
Example #51
0
        public static Grid FromStream(System.IO.BinaryReader br)
        {
            Grid grid = new Grid();

            grid.ModelName  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(30));
            grid.StringName = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));
            grid.MinX       = br.ReadDouble();
            grid.MinY       = br.ReadDouble();
            grid.MaxX       = br.ReadDouble();
            grid.MaxY       = br.ReadDouble();
            grid.XInterval  = br.ReadDouble();
            grid.YInterval  = br.ReadDouble();
            grid.TextSize   = br.ReadDouble();
            grid.Rotation   = br.ReadDouble();
            return(grid);
        }
Example #52
0
        public static object LoadKey(this DbColumnType keyType, io.BinaryReader reader)
        {
            switch (keyType)
            {
            case DbColumnType.Char:
                //
                return(reader.ReadChar());

            case DbColumnType.Byte:
                //
                return(reader.ReadByte());

            case DbColumnType.Int16:
                //
                return(reader.ReadInt16());

            case DbColumnType.Int32:
                //
                return(reader.ReadInt32());

            case DbColumnType.Int64:
                //
                return(reader.ReadInt64());

            case DbColumnType.Single:
                //
                return(reader.ReadSingle());

            case DbColumnType.Double:
                //
                return(reader.ReadDouble());

            case DbColumnType.Decimal:
                //
                return(reader.ReadDecimal());

            case DbColumnType.String:
                //
                var length = reader.ReadByte();
                var chars  = reader.ReadChars(length);
                return(new string(chars));

            default:
                return(null);
            }
        }
Example #53
0
        public static MathNet.Numerics.LinearAlgebra.Double.DenseVector readDenceVectorFromBinFile(string file, MainForm.setProgressDel d)
        {
            string[]               meta = System.IO.File.ReadAllLines(file + ".metainfo");
            System.IO.FileStream   fs   = new System.IO.FileStream(file, System.IO.FileMode.Open);
            System.IO.BinaryReader br   = new System.IO.BinaryReader(fs, System.Text.Encoding.Default);
            int cols = int.Parse(meta[1]);

            MathNet.Numerics.LinearAlgebra.Double.DenseVector dv = new MathNet.Numerics.LinearAlgebra.Double.DenseVector(cols);
            for (int j = 0; j < cols; j++)
            {
                dv[j] = br.ReadDouble();
                d.Invoke(br.BaseStream.Position / br.BaseStream.Length, 1, "Завантаження");
            }
            br.Close();
            fs.Close();
            fs.Dispose();
            return(dv);
        }
        public Vector(string PATH)
        {
            //PATH + "Sizebin" - путь файла для чтения
            //FileMode - для открытия
            using (var Reader = new System.IO.BinaryReader(File.Open(PATH + "Size.bin", FileMode.Open)))
            {
                N = Reader.ReadInt32();
            }

            Elem = new double[N];

            using (var Reader = new System.IO.BinaryReader(File.Open(PATH + "F.bin", FileMode.Open)))
            {
                for (int j = 0; j < N; j++)
                {
                    Elem[j] = Reader.ReadDouble();
                }
            }
        }
Example #55
0
        public static Arctype FromStream(System.IO.BinaryReader br)
        {
            Arctype arc = new Arctype();

            arc.elatt  = br.ReadInt16();
            arc.scatt  = br.ReadInt16();
            arc.Layer  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));
            arc.laatt  = br.ReadInt16();
            arc.xs     = br.ReadDouble();
            arc.ys     = br.ReadDouble();
            arc.xe     = br.ReadDouble();
            arc.ye     = br.ReadDouble();
            arc.xc     = br.ReadDouble();
            arc.yc     = br.ReadDouble();
            arc.Radius = br.ReadDouble();
            arc.Color  = br.ReadInt16();
            arc.style  = br.ReadInt16();
            arc.Width  = br.ReadInt16();
            arc.Label  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));

            return(arc);
        }
Example #56
0
        public static Linetype FromStream(System.IO.BinaryReader br)
        {
            Linetype line = new Linetype();

            line.elatt = br.ReadInt16();
            line.scatt = br.ReadInt16();
            line.layer = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));
            line.laatt = br.ReadInt16();
            line.x1    = br.ReadDouble();
            line.y1    = br.ReadDouble();
            line.z1    = br.ReadDouble();
            line.x2    = br.ReadDouble();
            line.y2    = br.ReadDouble();
            line.z2    = br.ReadDouble();
            line.color = br.ReadInt16();
            line.style = br.ReadInt16();
            line.width = br.ReadInt16();
            line.label = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));

            return(line);
        }
Example #57
0
        internal override void Read(System.IO.BinaryReader reader, BinaryReadInfo readInfo)
        {
            uint length = reader.ReadUInt32();

            ID = reader.ReadUInt32();
            uint numSections = reader.ReadUInt32();

            string componentName = null;
            bool   canResize     = false;
            bool   canFlip       = false;
            double minSize       = ComponentHelper.GridSize;
            List <ComponentProperty>          properties          = new List <ComponentProperty>();
            List <ConnectionGroup>            connections         = new List <ConnectionGroup>();
            List <RenderDescription>          renderDescriptions  = new List <RenderDescription>();
            List <Conditional <FlagOptions> > flagOptions         = new List <Conditional <FlagOptions> >();
            ComponentDescriptionMetadata      descriptionMetadata = new ComponentDescriptionMetadata();
            uint?iconResourceId = null;

            for (uint sectionCounter = 0; sectionCounter < numSections; sectionCounter++)
            {
                ushort sectionType   = reader.ReadUInt16();
                uint   sectionLength = reader.ReadUInt32();

                #region Metadata
                if (sectionType == (uint)BinaryConstants.ComponentSectionType.Metadata)
                {
                    componentName              = reader.ReadString();
                    canResize                  = reader.ReadBoolean();
                    canFlip                    = reader.ReadBoolean();
                    minSize                    = reader.ReadDouble();
                    descriptionMetadata.Type   = String.Format("Binary r{0} (*.cdcom)", readInfo.FormatVersion);
                    descriptionMetadata.GUID   = new Guid(reader.ReadBytes(16));
                    descriptionMetadata.Author = reader.ReadString();
                    if (readInfo.IsSignatureValid && readInfo.Certificate != null && readInfo.IsCertificateTrusted)
                    {
                        descriptionMetadata.Author = readInfo.Certificate.GetNameInfo(X509NameType.EmailName, false);
                    }
                    descriptionMetadata.Version = new Version(reader.ReadUInt16(), reader.ReadUInt16());
                    descriptionMetadata.AdditionalInformation          = reader.ReadString();
                    descriptionMetadata.ImplementSet                   = reader.ReadString();
                    descriptionMetadata.ImplementItem                  = reader.ReadString();
                    descriptionMetadata.Signature.IsHashValid          = readInfo.IsSignatureValid;
                    descriptionMetadata.Signature.Certificate          = readInfo.Certificate;
                    descriptionMetadata.Signature.IsCertificateTrusted = readInfo.IsCertificateTrusted;
                    int iconResource = reader.ReadInt32();
                    if (iconResource != -1)
                    {
                        iconResourceId = (uint)iconResource;
                    }
                    long created = reader.ReadInt64();
                }
                #endregion
                #region Flags
                else if (sectionType == (uint)BinaryConstants.ComponentSectionType.Flags)
                {
                    uint numFlagGroups = reader.ReadUInt32();
                    for (uint j = 0; j < numFlagGroups; j++)
                    {
                        IConditionTreeItem conditions;
                        if (readInfo.FormatVersion > 1)
                        {
                            conditions = reader.ReadConditionTree();
                        }
                        else
                        {
                            conditions = reader.ReadConditionCollection();
                        }

                        FlagOptions value = (FlagOptions)reader.ReadUInt32();
                        flagOptions.Add(new Conditional <FlagOptions>(value, conditions));
                    }
                }
                #endregion
                #region Properties
                else if (sectionType == (uint)BinaryConstants.ComponentSectionType.Properties)
                {
                    uint numProperties = reader.ReadUInt32();
                    for (uint j = 0; j < numProperties; j++)
                    {
                        string        propertyName   = reader.ReadString();
                        string        serializedName = reader.ReadString();
                        string        displayName    = reader.ReadString();
                        BinaryType    propType;
                        object        rawDefaultValue = reader.ReadType(out propType);
                        PropertyUnion defaultValue    = propType.ToPropertyUnion(rawDefaultValue);
                        string[]      enumOptions     = null;
                        if (propType == BinaryType.Enum)
                        {
                            enumOptions = new string[reader.ReadInt32()];
                            for (int k = 0; k < enumOptions.Length; k++)
                            {
                                enumOptions[k] = reader.ReadString();
                            }
                        }

                        // Format rules
                        List <ComponentPropertyFormat> formatRules = new List <ComponentPropertyFormat>();
                        uint numFormatRules = reader.ReadUInt32();
                        for (uint k = 0; k < numFormatRules; k++)
                        {
                            IConditionTreeItem conditions;
                            if (readInfo.FormatVersion > 1)
                            {
                                conditions = reader.ReadConditionTree();
                            }
                            else
                            {
                                conditions = reader.ReadConditionCollection();
                            }
                            string formatRule = reader.ReadString();
                            formatRules.Add(new ComponentPropertyFormat(formatRule, conditions));
                        }

                        // Other conditions
                        uint numOtherConditions = reader.ReadUInt32();
                        Dictionary <PropertyOtherConditionType, IConditionTreeItem> otherConditions = new Dictionary <PropertyOtherConditionType, IConditionTreeItem>((int)numOtherConditions);
                        for (uint k = 0; k < numOtherConditions; k++)
                        {
                            uint uintConditionType = reader.ReadUInt32();
                            IConditionTreeItem conditions;
                            if (readInfo.FormatVersion > 1)
                            {
                                conditions = reader.ReadConditionTree();
                            }
                            else
                            {
                                conditions = reader.ReadConditionCollection();
                            }
                            PropertyOtherConditionType conditionType = (PropertyOtherConditionType)uintConditionType;
                            otherConditions.Add(conditionType, conditions);
                        }

                        properties.Add(new ComponentProperty(propertyName, serializedName, displayName, BinaryIOExtentions.BinaryTypeToPropertyType(propType), defaultValue, formatRules.ToArray(), otherConditions, enumOptions));
                    }
                }
                #endregion
                #region Configurations
                else if (sectionType == (uint)BinaryConstants.ComponentSectionType.Configurations)
                {
                    uint numConfigurations = reader.ReadUInt32();
                    for (int j = 0; j < numConfigurations; j++)
                    {
                        string configurationName  = reader.ReadString();
                        string implementationName = reader.ReadString();

                        int numSetters = reader.ReadInt32();
                        var setters    = new Dictionary <string, PropertyUnion>(numSetters);
                        for (int k = 0; k < numSetters; k++)
                        {
                            BinaryType tempType;
                            string     name        = reader.ReadString();
                            var        setterValue = reader.ReadType(out tempType);
                            setters.Add(name, tempType.ToPropertyUnion(setterValue));
                        }

                        int iconID = reader.ReadInt32();

                        var configuration = new ComponentConfiguration(implementationName, configurationName, setters);
                        descriptionMetadata.Configurations.Add(configuration);

                        if (iconID != -1)
                        {
                            iconResources.Add(configuration, (uint)iconID);
                        }
                    }
                }
                #endregion
                #region Connections
                else if (sectionType == (uint)BinaryConstants.ComponentSectionType.Connections)
                {
                    uint numConnectionGroups = reader.ReadUInt32();
                    List <ConnectionGroup> connectionGroups = new List <ConnectionGroup>();
                    for (int j = 0; j < numConnectionGroups; j++)
                    {
                        IConditionTreeItem conditions;
                        if (readInfo.FormatVersion > 1)
                        {
                            conditions = reader.ReadConditionTree();
                        }
                        else
                        {
                            conditions = reader.ReadConditionCollection();
                        }

                        List <ConnectionDescription> tConnections = new List <ConnectionDescription>();
                        uint numConnections = reader.ReadUInt32();
                        for (uint k = 0; k < numConnections; k++)
                        {
                            tConnections.Add(new ConnectionDescription(reader.ReadComponentPoint(), reader.ReadComponentPoint(), (ConnectionEdge)reader.ReadInt32(), reader.ReadString()));
                        }

                        connections.Add(new ConnectionGroup(conditions, tConnections.ToArray()));
                    }
                }
                #endregion
                #region Render
                else if (sectionType == (uint)BinaryConstants.ComponentSectionType.Render)
                {
                    uint numRenderGroups = reader.ReadUInt32();
                    for (uint j = 0; j < numRenderGroups; j++)
                    {
                        IConditionTreeItem conditions;
                        if (readInfo.FormatVersion > 1)
                        {
                            conditions = reader.ReadConditionTree();
                        }
                        else
                        {
                            conditions = reader.ReadConditionCollection();
                        }

                        int numRenderCommands = (int)reader.ReadUInt32();
                        List <IRenderCommand> renderCommands = new List <IRenderCommand>(numRenderCommands);
                        for (int k = 0; k < numRenderCommands; k++)
                        {
                            RenderCommandType commandType = (RenderCommandType)reader.ReadUInt32();
                            switch (commandType)
                            {
                            case RenderCommandType.Line:
                            {
                                ComponentPoint start     = reader.ReadComponentPoint();
                                ComponentPoint end       = reader.ReadComponentPoint();
                                double         thickness = reader.ReadDouble();
                                renderCommands.Add(new Line(start, end, thickness));
                            }
                                continue;

                            case RenderCommandType.Rect:
                            {
                                ComponentPoint location  = reader.ReadComponentPoint();
                                double         width     = reader.ReadDouble();
                                double         height    = reader.ReadDouble();
                                double         thickness = reader.ReadDouble();
                                bool           fill      = (reader.ReadUInt32() == 0 ? false : true);
                                renderCommands.Add(new Rectangle(location, width, height, thickness, fill));
                            }
                                continue;

                            case RenderCommandType.Ellipse:
                            {
                                ComponentPoint centre    = reader.ReadComponentPoint();
                                double         radiusX   = reader.ReadDouble();
                                double         radiusY   = reader.ReadDouble();
                                double         thickness = reader.ReadDouble();
                                bool           fill      = (reader.ReadUInt32() == 0 ? false : true);
                                renderCommands.Add(new Ellipse(centre, radiusX, radiusY, thickness, fill));
                            }
                                continue;

                            case RenderCommandType.Path:
                            {
                                ComponentPoint start     = reader.ReadComponentPoint();
                                double         thickness = reader.ReadDouble();
                                bool           fill      = (reader.ReadUInt32() == 0 ? false : true);

                                int numCommands = reader.ReadInt32();
                                List <IPathCommand> pathCommands = new List <IPathCommand>(numCommands);
                                for (int l = 0; l < numCommands; l++)
                                {
                                    CommandType  pType      = (CommandType)reader.ReadInt32();
                                    IPathCommand theCommand = null;
                                    switch (pType)
                                    {
                                    case CommandType.MoveTo:
                                        theCommand = new MoveTo();
                                        break;

                                    case CommandType.LineTo:
                                        theCommand = new LineTo();
                                        break;

                                    case CommandType.CurveTo:
                                        theCommand = new CurveTo();
                                        break;

                                    case CommandType.EllipticalArcTo:
                                        theCommand = new EllipticalArcTo();
                                        break;

                                    case CommandType.QuadraticBeizerCurveTo:
                                        theCommand = new QuadraticBeizerCurveTo();
                                        break;

                                    case CommandType.SmoothCurveTo:
                                        theCommand = new SmoothCurveTo();
                                        break;

                                    case CommandType.SmoothQuadraticBeizerCurveTo:
                                        theCommand = new SmoothQuadraticBeizerCurveTo();
                                        break;

                                    default:
                                        theCommand = new ClosePath();
                                        break;
                                    }
                                    theCommand.Read(reader);
                                    pathCommands.Add(theCommand);
                                }

                                renderCommands.Add(new RenderPath(start, thickness, fill, pathCommands));
                            }
                                continue;

                            case RenderCommandType.Text:
                            {
                                byte           formattedTextVersion = reader.ReadByte();
                                ComponentPoint location             = reader.ReadComponentPoint();
                                TextAlignment  alignment            = (TextAlignment)reader.ReadUInt32();

                                uint           numTextRuns = reader.ReadUInt32();
                                List <TextRun> textRuns    = new List <TextRun>((int)numTextRuns);
                                for (uint l = 0; l < numTextRuns; l++)
                                {
                                    TextRunFormattingType formattingType = (TextRunFormattingType)reader.ReadUInt32();
                                    double runSize = reader.ReadDouble();
                                    string runText = reader.ReadString();
                                    textRuns.Add(new TextRun(runText, new TextRunFormatting(formattingType, runSize)));
                                }

                                renderCommands.Add(new Text(location, alignment, textRuns));
                            }
                                continue;
                            }
                        }

                        renderDescriptions.Add(new RenderDescription(conditions, renderCommands.ToArray()));
                    }
                }
                #endregion
                #region Skip
                else
                {
                    // Unknown type - skip
                    reader.BaseStream.Seek(sectionLength, SeekOrigin.Current);
                }
                #endregion
            }

            ComponentDescription = new ComponentDescription(ID.ToString(), componentName, canResize, canFlip, minSize, properties.ToArray(), connections.ToArray(), renderDescriptions.ToArray(), flagOptions.ToArray(), descriptionMetadata);

            if (iconResourceId.HasValue)
            {
                mainIconResource = iconResourceId.Value;
            }
        }
Example #58
0
 //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
 public static double readDecimal(System.IO.BinaryReader in_Renamed)
 {
     return(in_Renamed.ReadDouble());
 }
Example #59
0
        public override object[] ReadDbRecord(int offset)
        {
            var mainMask = Table.RowMask;
            var bytes    = Table.RowMaskLength;

            //point to record offset
            reader.BaseStream.Position = offset;

            //read record
            var buffer = new byte[sizeof(UInt64)];

            reader.Read(buffer, 0, bytes);
            var recordMask = BitConverter.ToUInt64(buffer, 0);
            //copy main
            var bitMask     = mainMask;
            var columnCount = Table.Count;

            //create record according to table columns
            var dbRecord = new object[columnCount];

            for (var i = 0; i < columnCount; i++)
            {
                var colType = Table.ColumnTypes[i];

                if ((recordMask & bitMask) == 0)
                {
                    //not null value
                    object value = null;

                    switch (colType)
                    {
                    case DbColumnType.Char:
                        value = reader.ReadChar();
                        break;

                    case DbColumnType.Byte:
                        value = reader.ReadByte();
                        break;

                    case DbColumnType.Int16:
                        value = reader.ReadInt16();
                        break;

                    case DbColumnType.Int32:
                        value = reader.ReadInt32();
                        break;

                    case DbColumnType.Int64:
                        value = reader.ReadInt64();
                        break;

                    case DbColumnType.Single:
                        value = reader.ReadSingle();
                        break;

                    case DbColumnType.Double:
                        value = reader.ReadDouble();
                        break;

                    case DbColumnType.Decimal:
                        value = reader.ReadDecimal();
                        break;

                    case DbColumnType.String:
                        value = reader.ReadString();
                        break;

                    default:
                        throw new ArgumentException($"invalid column type: {colType}");
                    }
                    //store value in right spot
                    dbRecord[i] = value;
                }
                bitMask >>= 1;
            }
            //
            return(dbRecord);
        }
Example #60
0
 public double getDouble()
 {
     return(reader.ReadDouble());
 }