Esempio n. 1
0
        private void Window_Loaded(object s, RoutedEventArgs ea)
        {
            /*client = new MJPEGClient("http://81.167.44.38/mjpg/video.mjpg");
             * client.FrameReceived += delegate(object sender, FrameReceivedEventArgs e)
             * {
             *  Dispatcher.Invoke(delegate() { client_FrameReceived(sender, e); });
             * };
             * client.Start();*/

            StreamInputDialog sid = new StreamInputDialog();

            if (sid.ShowDialog() == true)
            {
                client = sid.StreamInput;
                client.FrameReceived += delegate(object sender, FrameReceivedEventArgs e)
                {
                    Dispatcher.Invoke(delegate() { client_FrameReceived(sender, e); });
                };
                client.ReceivedStatisticsUpdate += client_ReceivedStatisticsUpdate;
                client.StreamLost += client_StreamLost;
                Connect();
            }
            else
            {
                this.Close();
            }
        }
        private GenericProtocol Read(IStreamInput pDataInput)
        {
            var index = pDataInput.ReadShort();
            var node  = CopyRef(index);

            // Rekursive Methode:
            Read(pDataInput, index, node);
            return(node);
        }
        private void Button_Click_3(object ss, RoutedEventArgs ee)
        {
            MJPEGProfileDialog md = new MJPEGProfileDialog();

            if (md.ShowDialog() == true)
            {
                StreamInput = new MJPEGClient(md.SelectedProfile);

                this.DialogResult = true;
            }
            else
            {
                this.DialogResult = false;
            }
        }
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            IPProfileDialog ippd = new IPProfileDialog();

            if (ippd.ShowDialog() == true)
            {
                this.DialogResult = true;

                StreamInput = new FrameClient(ippd.SelectedProfile);
                this.Close();
            }
            else
            {
                this.DialogResult = false;
                this.Close();
            }
        }
        private static string ReadChars(IStreamInput pInput)
        {
            // Länge der Zeichenkette:
            int length = pInput.ReadUnsignedByte(); // b = index 2

            if (length == 255)
            {
                return(null);
            }

            if (length >= 128) // offset 52
            {
                length = length - 128 << 16 | pInput.ReadUnsignedByte() << 8 | pInput.ReadUnsignedByte();
            }
            // offset 17
            var stringBuilder = new StringBuilder(length + 2); // sb = index 3

            for (int i4 = 0; i4 < length; i4++)                // offset 86
            {
                stringBuilder.Append(pInput.ReadChar());
            }
            // offset 81
            return(stringBuilder.ToString());
        }
        private object Read(IStreamInput pDataInput, int pIndex, GenericProtocol pNode)
        {
            if (pNode == null)
            {
                pNode = CopyRef(pIndex);
            }
            // --------------------------
            List <int> nodeIndices = pNode.NodeIndices[pIndex];

            for (int i = 0; i < nodeIndices.Count; i++)
            {
                int    localNodeIndex = nodeIndices[i];
                string localNodeName;
                switch (localNodeIndex)
                {
                case 0:
                    return(pDataInput.ReadByte());    // Byte

                case 1:
                    return(pDataInput.ReadBoolean());    // Bool(ean)

                case 2:
                    return(pDataInput.ReadByte());    // Byte

                case 3:
                    return(pDataInput.ReadShort());    // Short

                case 4:
                    return(pDataInput.ReadInt());    // Int

                case 5:
                    return(pDataInput.ReadLong());    // Long

                case 6:
                    return(pDataInput.ReadFloat());    // Float

                case 7:
                    return(pDataInput.ReadDouble());    // Double

                case 8:
                    return(pDataInput.ReadChar());    // Char

                case 9:
                    return(pDataInput.ReadUTF().Replace('\u20AD', 'K'));    // String

                case 10:
                    break;

                case 11:
                    i++;
                    localNodeIndex = nodeIndices[i];
                    localNodeName  = NodeNames[localNodeIndex];
                    var arrList = new List <object>();
                    pNode.Add(localNodeName, arrList);
                    while (pDataInput.ReadByte() == 11)
                    {
                        arrList.Add(Read(pDataInput, localNodeIndex, null));
                    }
                    i++;
                    break;

                case 12:     // Ende der Liste
                    break;

                case 13:     // new | seit ungefähr dem applet 90aeh
                    return(ReadChars(pDataInput));

                //break;
                default:
                    localNodeName = NodeNames[localNodeIndex];
                    pNode.Add(localNodeName, Read(pDataInput, localNodeIndex, null));
                    break;
                }
            }
            // --------------------------
            return(pNode);
        }