示例#1
0
        // Corresponds to "File/Open"
        private void Open_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog();

            openFileDialog.AddExtension    = true;
            openFileDialog.CheckFileExists = true;
            openFileDialog.DefaultExt      = "frb";
            openFileDialog.Filter          = "Fortune Street Board (.frb) | *.frb";
            openFileDialog.Multiselect     = false;
            if (openFileDialog.ShowDialog() != true)
            {
                return;
            }

            currentFileName = openFileDialog.FileName;
            loneFileName    = openFileDialog.SafeFileName;

            using (var stream = openFileDialog.OpenFile())
            {
                MiscUtil.IO.EndianBinaryReader binReader = new MiscUtil.IO.EndianBinaryReader(MiscUtil.Conversion.EndianBitConverter.Big, stream);
                var Board = BoardFile.LoadFromStream(binReader);
                this.DataContext = Board;
            }
            UpdateTitle();
        }
示例#2
0
文件: Main.cs 项目: txdv/qutter
        public StreamInspector(int bufferSize, TcpClient source, TcpClient destination)
        {
            BufferSize = bufferSize;

            Source = source;
            Destination = destination;
            var sourceStream = source.GetStream();
            var destinationStream = destination.GetStream();

            Action<Stream, Stream, Action<byte[]>> move = (src, dst, callback) => {
                MiscUtil.IO.EndianBinaryReader br = new MiscUtil.IO.EndianBinaryReader(MiscUtil.Conversion.EndianBitConverter.Big, src);
                MiscUtil.IO.EndianBinaryWriter bw = new MiscUtil.IO.EndianBinaryWriter(MiscUtil.Conversion.EndianBitConverter.Big, dst);
                while (true) {
                    int len = br.ReadInt32();
                    var packet = br.ReadBytes(len);
                    callback(packet);
                    bw.Write(len);
                    bw.Write(packet);
                }
            };

            SourceThread = new Thread((o) => move(sourceStream, destinationStream, OnSend));
            SourceThread.Start();
            DestinationThread = new Thread((o) => move(destinationStream, sourceStream, OnReceive));
            DestinationThread.Start();
        }
示例#3
0
 public LoginRequestClient(MiscUtil.IO.EndianBinaryReader reader)
 {
     ProtocolVersion = reader.ReadInt32();
     Username        = ReadString16(reader);
     Unused1         = reader.ReadInt64();
     Unused2         = reader.ReadInt32();
     Unused3         = reader.ReadSByte();
     Unused4         = reader.ReadSByte();
     Unused5         = reader.ReadSByte();
     Unused6         = reader.ReadSByte();
 }
示例#4
0
        public BinaryPacket ReadNext(System.IO.Stream stream)
        {
            var reader = new MiscUtil.IO.EndianBinaryReader(Configuration.EndianBitConverter, stream, Configuration.Encoding);
            var type = reader.ReadInt32();

            var bufferLen = reader.ReadInt32();
            var buffer = reader.ReadBytes(bufferLen);

            var packet = new Packets.BinaryPacket();
            packet.Tag = (uint)type;
            packet.PayLoadBuffer = buffer;

            return packet;
        }
示例#5
0
        /// <summary>
        /// Reads a block of bytes from the file stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        /// <param name="length">The lenght of the data to be read.</param>
        /// <returns>Returns the string representation of the read block of bytes.</returns>
        public static string Read(MiscUtil.IO.EndianBinaryReader stream, long length)
        {
            int    theLength = (int)length;
            string result    = null;

            try
            {
                byte[] bytes     = new byte[length];
                int    readBytes = stream.Read(bytes, 0, theLength);
                if (readBytes > 0)
                {
                    result = System.Text.Encoding.ASCII.GetString(bytes, 0, readBytes);
                }
            }
            catch
            {
            }
            return(result);
        }
示例#6
0
 public QVariant Receive()
 {
     MiscUtil.IO.EndianBinaryReader br = new MiscUtil.IO.EndianBinaryReader(MiscUtil.Conversion.EndianBitConverter.Big, ns);
     int len = br.ReadInt32();
     MemoryStream ms = new MemoryStream(br.ReadBytes(len));
     ms.Seek(0, SeekOrigin.Begin);
     return QTypeManager.Deserialize<QVariant>(ms);
 }
示例#7
0
 protected override void Parse(MiscUtil.IO.EndianBinaryReader r)
 {
     MaxSize = ReadVarInt(r);
 }
示例#8
0
        public override void DeserializePayload(MiscUtil.IO.EndianBinaryReader reader, ushort length)
        {
            byte data_len = reader.ReadByte();

            data = reader.ReadBytes(data_len);
        }