Beispiel #1
0
        public Form1()
        {
            InitializeComponent();

            vlcControl1.Video.IsMouseInputEnabled = false;
            vlcControl1.Video.IsKeyInputEnabled   = false;
            vlcControl2.Video.IsMouseInputEnabled = false;
            vlcControl2.Video.IsKeyInputEnabled   = false;

            if (!CountyUtils.CheckEthernet())
            {
                ethernetErrorPanel.Visible = true;
                Timer timer = new Timer();
                timer.Interval = (3 * 1000); // 3 secs
                timer.Tick    += new EventHandler(timer_Tick);
                timer.Start();
            }

            else
            {
                try
                {
                    CreateChannelList();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Source);
                }
            }
        }
Beispiel #2
0
 private void timer_Tick(object sender, EventArgs e)
 {
     if (CountyUtils.CheckEthernet())
     {
         ethernetErrorPanel.Visible = false;
         try
         {
             CreateChannelList();
         }
         catch (Exception e2)
         {
             Console.WriteLine(e2.Source);
         }
     }
 }
Beispiel #3
0
        public void CreateChannelList()
        {
            string ip = CountyUtils.GetLocalIPAddress();

            string[] ipParts = ip.Split('.');
            Int32    subnet  = Int32.Parse(ipParts[1]);

            if (subnet > 11 && subnet < 134)
            {
                // This section added School Broadcast and School TV channels
                try
                {
                    Button       channelButton = new Button();
                    WebClient    wc            = new WebClient();
                    byte[]       imageData     = wc.DownloadData(resourceFolderPath + "schools\\" + subnet + ".png");
                    MemoryStream stream        = new MemoryStream(imageData);
                    Image        logo          = Image.FromStream(stream);

                    channelButton.FlatStyle = FlatStyle.Flat;
                    channelButton.FlatAppearance.BorderSize = 0;

                    channelButton.TextImageRelation = TextImageRelation.ImageAboveText;
                    channelButton.Image             = logo;
                    channelButton.Text      = "School Broadcast";
                    channelButton.ForeColor = Color.LightGray;
                    channelButton.Font      = new Font("Ariel", 10, FontStyle.Bold);
                    channelButton.Size      = new Size((flowLayoutPanel1.Width - SystemInformation.VerticalScrollBarWidth - 6), logo.Size.Height + 20);

                    channelButton.Click += (sender1, e1) =>
                    {
                        currentChannel = "udp://@225.168.3." + subnet + ":1234/";
                        PlayChannel(currentChannel);
                    };
                    flowLayoutPanel1.Controls.Add(channelButton);
                }
                catch
                {
                    flowLayoutPanel1.Controls.Add(ChannelButton("School Broadcast", "udp://@225.168.3." + subnet + ":1234/"));
                }

                // This Section check for third channel
                try
                {
                    using (XmlReader reader = XmlReader.Create(resourceFolderPath + "schools\\" + subnet + ".xml"))
                    {
                        string[] attr = new string[2];
                        while (reader.Read())
                        {
                            if (reader.IsStartElement())
                            {
                                if (reader.Name.ToString() == "channelName")
                                {
                                    attr[0] = reader.ReadString();
                                }
                                if (reader.Name.ToString() == "channelAddress")
                                {
                                    attr[1] = reader.ReadString();
                                }
                            }
                            if (attr[1] != null)
                            {
                                Button       channelButton = new Button();
                                WebClient    wc            = new WebClient();
                                byte[]       imageData     = wc.DownloadData(resourceFolderPath + "schools\\" + subnet + ".png");
                                MemoryStream stream        = new MemoryStream(imageData);
                                Image        logo          = Image.FromStream(stream);

                                channelButton.FlatStyle = FlatStyle.Flat;
                                channelButton.FlatAppearance.BorderSize = 0;

                                channelButton.TextImageRelation = TextImageRelation.ImageAboveText;
                                channelButton.Image             = logo;
                                channelButton.Text      = attr[0];
                                channelButton.ForeColor = Color.LightGray;
                                channelButton.Font      = new Font("Ariel", 10, FontStyle.Bold);
                                channelButton.Size      = new Size((flowLayoutPanel1.Width - SystemInformation.VerticalScrollBarWidth - 6), logo.Size.Height + 20);
                                string udpAddress = attr[1];

                                channelButton.Click += (sender1, e1) =>
                                {
                                    currentChannel = udpAddress;
                                    PlayChannel(currentChannel);
                                };
                                flowLayoutPanel1.Controls.Add(channelButton);
                                attr[0] = null;
                                attr[1] = null;
                            }
                        }
                    }
                }
                catch { }

                finally
                {
                    flowLayoutPanel1.Controls.Add(ChannelButton("School Cable", "udp://@225.168.4." + subnet + ":1234/"));
                }
            }

            // This section added main cable channels
            using (XmlReader reader = XmlReader.Create(resourceFolderPath + "list.xml"))
            {
                string[] attr = new string[2];
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        if (reader.Name.ToString() == "channelName")
                        {
                            attr[0] = reader.ReadString();
                        }
                        if (reader.Name.ToString() == "channelAddress")
                        {
                            attr[1] = reader.ReadString();
                        }
                    }
                    if (attr[1] != null)
                    {
                        flowLayoutPanel1.Controls.Add(ChannelButton(attr[0], attr[1]));
                        attr[0] = null;
                        attr[1] = null;
                    }
                }
            }
        }