Esempio n. 1
0
        public static void ReadCommands(this NetIncomingMessage message, RipDocument document, IList <RipCommand> commands)
        {
            var stream = message.ReadStream();
            var reader = new BinaryReader(stream);

            try {
                while (true)
                {
                    char b = (char)reader.ReadRipByte();
                    if (b == '|')
                    {
                        string op = ((char)reader.ReadRipByte()).ToString();
                        if (op == "1")
                        {
                            op += (char)reader.ReadRipByte();
                        }

                        var command = RipCommands.Create(op, document);
                        if (command != null)
                        {
                            command.Read(reader);
                            if (command.Store)
                            {
                                commands.Add(command);
                            }
                        }
                    }
                }
            } catch (EndOfStreamException) {
            }
        }
Esempio n. 2
0
 public T Create <T>()
     where T : RipCommand
 {
     return(RipCommands.Create <T>(this));
 }
Esempio n. 3
0
 public T Create <T, CT>()
     where T : RipCommand, new()
     where CT : RipCommandType
 {
     return(RipCommands.Create <T, CT>(this));
 }
Esempio n. 4
0
        public void Load(Stream stream, RipDocument document, RipHandler handler)
        {
            var reader   = new BinaryReader(stream);
            var commands = document.Commands;

            commands.Clear();
            bool lastEnableZoom = true;

            /*
             */
            if (document.AnimateView && Application.Instance != null)
            {
                document.BGI.DelayDraw = true;                 // for faster animation
                Application.Instance.Invoke(delegate {
                    //lastEnableZoom = handler.EnableZoom;
#if DESKTOP
                    handler.EnableZoom = false;
#endif
                });
            }

            try {
                var args = new WaitEventArgs();
                while (true)
                {
                    if (document.AnimateView)
                    {
                        document.OnWait(args);
                        if (args.Exit)
                        {
                            break;
                        }
                    }
                    byte b = reader.ReadRipByte();

                    /*
                     */
                    if (b == (byte)'|')
                    {
                        string op = ((char)reader.ReadRipByte()).ToString();
                        if (op == "1")
                        {
                            op += ((char)reader.ReadRipByte());
                        }
                        else if (op == "#")
                        {
                            break;                             // done reading rip!
                        }
                        var command = RipCommands.Create(op, document);
                        if (command != null)
                        {
                            command.Read(reader);
                            command.Apply();
                            if (command.Store)
                            {
                                commands.Add(command);
                            }
                        }
                    }

                    /*
                     */
                }
            } catch (EndOfStreamException) {
            } finally {
                if (document.AnimateView && Application.Instance != null)
                {
                    Application.Instance.Invoke(delegate {
                        if (document.AnimateView)
                        {
                            handler.EnableZoom = lastEnableZoom;
                        }
                    });
                }
            }
        }