Beispiel #1
0
        private Form createWindow(Decoder dec)
        {
            Form fr = new Form();
            fr.FormClosed += new FormClosedEventHandler(delegate(object sender, FormClosedEventArgs args) { Environment.Exit(0); });
            PictureBox b = new PictureBox();
            b.Size = new Size(dec.format.width, dec.format.height);
            b.Paint += new PaintEventHandler(delegate(object sender, PaintEventArgs args) {
                //Need b.Invoke or not?
                int wait = (1000 * dec.format.frame_rate_denominator) / dec.format.frame_rate_numerator;

                Picture pic = dec.Pull();
                while (pic.status != Decoder.Status.DONE)
                {
                    if (pic != null &&
                       pic.error == null)
                    {
                        b.Image = pic.GetImage();
                    }
                    Thread.Sleep(wait);
                }
            });
            fr.Controls.Add(b);
            fr.Show();
            return fr;
        }
Beispiel #2
0
        public void main()
        {
            //TODO dialogue to ask string
            string[] a = new string[0];

            Decoder dec = new Decoder();
            int ev = 0;
            FileStream input = null;
            Form win;
            try {
                input = tryOpen(a);
                byte[] packet;
                while(dec.format == null) {
                    packet = readPacket(input);
                    dec.Push(packet, 0, packet.Length);
                }
                ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object o) { dec.Decode(); }));

                win = createWindow(dec);
                while(input.Length > 0 && !dec.Done()) {
                    packet = readPacket(input);
                    dec.Push(packet, 0, packet.Length);
                }
                dec.status = Decoder.Status.DONE;
                input.Close();
                win.Visible = false;
                win.Dispose();
            } catch(Exception e) {
                Console.WriteLine(e);
                ev = 1;
            } finally {
                Environment.Exit(ev);
            }
        }