Пример #1
0
 private void Grouped()
 {
     _groups = new ObservableCollection<GroupChannel>();
     foreach (ChannelGroup item in App.ViewModel.UserAccount.channel_group)
     {
         ComboBoxItem cbi = new ComboBoxItem();
         cbi.Name = item.name;
         cbi.Content = item.name;
         ChCategory.Items.Add(cbi);
         ind++;
         var g = new GroupChannel { GroupName = item.name };
         foreach (Channel it in item.Channels)
         {
             Channel c = new Channel();
             c = it;
             c.icon = "http://sovok.tv" + c.icon;
             g.Channels.Add(c);
         }
         _groups.Add(g);
     }
     ComboBoxItem fcbi = new ComboBoxItem();
     fcbi.Content = fcbi.Name = "Favorite";
     ChCategory.Items.Add(fcbi);
     ind++;
     CList.Source = _groups;
 }
Пример #2
0
        private void Grouped()
        {
            _groups = new ObservableCollection<GroupChannel>();
            foreach (ChannelGroup item in App.ViewModel.UserAccount.channel_group)
            {
                ComboBoxItem cbi = new ComboBoxItem();
                cbi.Name = item.name;
                cbi.Content = item.name;
                ChCategory.Items.Add(cbi);

                var g = new GroupChannel { GroupName = item.name };
                foreach (Channel it in item.Channels)
                {
                    Channel c = new Channel();
                    c = it;
                    c.icon = "http://sovok.tv" + c.icon;
                    g.Channels.Add(c);
                }
                _groups.Add(g);
            }
            //var fg = new GroupChannel { GroupName = "Favorite" };
            ComboBoxItem fcbi = new ComboBoxItem();
            fcbi.Content = fcbi.Name = "Favorite";
            ChCategory.Items.Add(fcbi);
            /*foreach (FavoriteChannel item in App.ViewModel.UserAccount.favorite_channel)
            {
                Channel fc = new Channel();
                foreach (СhannelItem it in App.ViewModel.ChannelList)
                {
                    if (item.id_channel==it.ChannelId)
                    {
                        fc.epg_end = it.epg_end;
                        fc.epg_progname = it.Epg;
                        fc.epg_start = it.epg_start;
                        fc.icon = it.Image_Source.ToString();
                        fc.name = it.ChannelName;
                        break;
                    }
                }
                fg.Channels.Add(fc);
            }
            _groups.Add(fg);*/
            CList.Source = _groups;
        }
Пример #3
0
 private void ShowCategory(int index)
 {
     _groups.Clear();
     if (index == ind)
     {
         var fg = new GroupChannel { GroupName = "Favorite" };
         foreach (FavoriteChannel item in App.ViewModel.UserAccount.favorite_channel)
         {
             Channel fc = new Channel();
             foreach (СhannelItem it in App.ViewModel.ChannelList)
             {
                 if (item.id_channel == it.ChannelId)
                 {
                     fc.epg_end = it.epg_end;
                     fc.epg_progname = it.Epg;
                     fc.epg_start = it.epg_start;
                     fc.icon = it.Image_Source.ToString();
                     fc.name = it.ChannelName;
                     break;
                 }
             }
             fg.Channels.Add(fc);
         }
         _groups.Add(fg);
     }
     else
     {
         ChannelGroup item = App.ViewModel.UserAccount.channel_group[index];
         var g = new GroupChannel { GroupName = item.name };
         foreach (Channel it in item.Channels)
         {
             Channel c = new Channel();
             c = it;
             g.Channels.Add(c);
         }
         _groups.Add(g);
     }
     CList.Source = _groups;
 }
Пример #4
0
 private void ChannelProcced(Channel c)
 {
     foreach (FavoriteChannel item in App.ViewModel.UserAccount.favorite_channel)
     {
         if (c.id==item.id_channel)
         {
             App.ViewModel.IsFavorite = true;
             break;
         }
     }
 }
Пример #5
0
        private async void ChangeActiveChannel(object sender, SelectionChangedEventArgs e)
        {
            Channel c = new Channel();
            index = ChannelListView.SelectedIndex;
            if (index<=-1)
            {
                return;
            }
            c = (Channel)ChannelListView.SelectedItems[0];
            App.ViewModel.Active_Channel = c;
            App.ViewModel.UpdateTitle();

            App.ViewModel.EpgTimeStart = c.epg_start.AddHours(App.ViewModel.Time).Hour + ":" + c.epg_start.AddHours(App.ViewModel.Time).Minute;
            App.ViewModel.EpgTimeEnd = c.epg_end.AddHours(App.ViewModel.Time).Hour + ":" + c.epg_end.AddHours(App.ViewModel.Time).Minute;

            var dif = (c.epg_end.AddHours(App.ViewModel.Time) - c.epg_start.AddHours(App.ViewModel.Time)).TotalMinutes;
            var dif1 = (DateTime.Now - c.epg_start.AddHours(App.ViewModel.Time)).TotalMinutes;
            App.ViewModel.EpgProgress = Math.Round(dif1/dif * 100);

            OpenStream(c.id);
            ChannelProcced(c);
            OpenEPG(c.id);
        }
Пример #6
0
 private void ChannelProcced(Channel c)
 {
     foreach (FavoriteChannel item in App.ViewModel.UserAccount.favorite_channel)
     {
         if (c.id == item.id_channel)
         {
             App.ViewModel.IsFavorite = true;
             break;
         }
     }
     foreach (ChannelGroup item in App.ViewModel.UserAccount.channel_group)
     {
         if (item.name.IndexOf("HD") != -1)
         {
             foreach (Channel it in item.Channels)
             {
                 if (it.name.IndexOf(c.name) != -1)
                 {
                     if (it.id != c.id)
                     {
                         //QualityButton.Content = "HD";
                         quality_stream = it.id;
                         break;
                     }
                 }
             }
             break;
         }
         else continue;
     }
 }
Пример #7
0
        private async void ChangeActiveChannel(object sender, SelectionChangedEventArgs e)
        {
            Channel c = new Channel();
            index = ChannelListView.SelectedIndex;
            if (index <= -1)
            {
                return;
            }
            c = (Channel)ChannelListView.SelectedItems[0];
            App.ViewModel.Active_Channel = c;
            OpenStream(c.id);
            ChannelProcced(c);
            OpenEPG(c.id);

            ChCategory.Visibility = Visibility.Collapsed;
            ChannelListView.Visibility = Visibility.Collapsed;
            HideListButton.Visibility = Visibility.Collapsed;
            showlist = false;
        }
Пример #8
0
        public void ChangeChannel()
        {
            Channel c = new Channel();
            int i = -1;
            bool isbreak=false;
            foreach (ChannelGroup item in UserAccount.channel_group)
            {
                foreach (Channel it in item.Channels)
                {
                    i++;
                    if (i==SelectedChannelIndex)
                    {
                        c = it;
                        isbreak = true;
                        break;
                    }
                }
                if (isbreak) break;
            }

            if (App.ViewModel.Active_Channel == c)
            {
                return;
            }
            App.ViewModel.Active_Channel = c;
            App.ViewModel.UpdateTitle();

            App.ViewModel.IsPlay = true;
            App.ViewModel.EpgTimeStart = TimeFromate(c.epg_start.AddHours(App.ViewModel.Time).Hour.ToString()) + ":" + TimeFromate(c.epg_start.AddHours(App.ViewModel.Time).Minute.ToString()) + ":00";
            App.ViewModel.EpgTimeEnd = TimeFromate(c.epg_end.AddHours(App.ViewModel.Time).Hour.ToString()) + ":" + TimeFromate(c.epg_end.AddHours(App.ViewModel.Time).Minute.ToString()) + ":00";

            App.ViewModel.EpgTimeStart = c.epg_start.AddHours(App.ViewModel.Time).Hour + ":" + c.epg_start.AddHours(App.ViewModel.Time).Minute;
            App.ViewModel.EpgTimeEnd = c.epg_end.AddHours(App.ViewModel.Time).Hour + ":" + c.epg_end.AddHours(App.ViewModel.Time).Minute;

            var dif = (c.epg_end.AddHours(App.ViewModel.Time) - c.epg_start.AddHours(App.ViewModel.Time)).TotalMinutes;
            var dif1 = (DateTime.Now - c.epg_start.AddHours(App.ViewModel.Time)).TotalMinutes;
            App.ViewModel.EpgProgress = Math.Round(dif1 / dif * 100);

            OpenStream(c.id);
            ChannelProcced(c);
        }
Пример #9
0
 private void ShowCategory(int index)
 {
     _groups.Clear();
     if (index == 15)
     {
         var fg = new GroupChannel { GroupName = "Favorite" };
         foreach (FavoriteChannel item in App.ViewModel.UserAccount.favorite_channel)
         {
             Channel fc = new Channel();
             foreach (СhannelItem it in App.ViewModel.ChannelList)
             {
                 if (item.id_channel == it.ChannelId)
                 {
                     fc.epg_end = it.epg_end;
                     fc.epg_progname = it.Epg;
                     fc.epg_start = it.epg_start;
                     fc.icon = it.Image_Source.ToString();
                     fc.name = it.ChannelName;
                     break;
                 }
             }
             fg.Channels.Add(fc);
         }
         _groups.Add(fg);    
     }
     else
     {
         if (index<=0 || index>=App.ViewModel.UserAccount.channel_group.Count)
         {
             index = 0;
         }
         try
         {
             ChannelGroup item = App.ViewModel.UserAccount.channel_group[index];
             var g = new GroupChannel { GroupName = item.name };
             foreach (Channel it in item.Channels)
             {
                 Channel c = new Channel();
                 c = it;
                 g.Channels.Add(c);
             }
             _groups.Add(g);
         }catch(Exception ex)
         {
             var mes = new MessageDialog(index+"\n"+App.ViewModel.UserAccount.channel_group.Count);
             mes.ShowAsync();
         }
     }
     CList.Source = _groups;
 }
Пример #10
0
 private void channellist_processing(string data)
 {
     List<Channel> cl = new List<Channel>();
     List<ChannelGroup> lg = new List<ChannelGroup>();
     try
     {
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(data);
         foreach (XmlElement xe in doc.DocumentElement.SelectNodes("//channels"))
         {
             string s = "<root>" + xe.ParentNode.GetXml() + "</root>";
             XmlDocument pdoc = new XmlDocument();
             pdoc.LoadXml(s);
             ChannelGroup g = new ChannelGroup();
             List<Channel> lc = new List<Channel>();
             g.id = pdoc.DocumentElement.SelectSingleNode("//id").InnerText;
             g.name = pdoc.DocumentElement.SelectSingleNode("//name").InnerText;
             g.color = pdoc.DocumentElement.SelectSingleNode("//color").InnerText;
             g.id = pdoc.DocumentElement.SelectSingleNode("//id").InnerText;
             XmlDocument cdoc = new XmlDocument();
             cdoc.LoadXml("<rt>" + pdoc.DocumentElement.SelectSingleNode("//channels").GetXml() + "</rt>"); 
             foreach (XmlElement lnks in cdoc.DocumentElement.SelectNodes("//item"))
             {
                 Channel c = new Channel();
                 XmlDocument d = new XmlDocument();
                 d.LoadXml("<r>" + lnks.GetXml() + "</r>");
                 foreach (XmlElement lnk in d.DocumentElement.SelectNodes("//id"))
                 {
                     c.id = lnk.InnerText;
                 }
                 foreach (XmlElement lnk in d.DocumentElement.SelectNodes("//name"))
                 {
                     c.name = lnk.InnerText;
                 }
                 foreach (XmlElement lnk in d.DocumentElement.SelectNodes("//is_video"))
                 {
                     c.is_video = lnk.InnerText;
                 }
                 foreach (XmlElement lnk in d.DocumentElement.SelectNodes("//icon"))
                 {
                     c.icon = lnk.InnerText;
                 }
                 foreach (XmlElement lnk in d.DocumentElement.SelectNodes("//epg_progname"))
                 {
                     c.epg_progname = lnk.InnerText;
                 }
                 foreach (XmlElement lnk in d.DocumentElement.SelectNodes("//epg_start"))
                 {
                     if (!String.IsNullOrEmpty(lnk.InnerText))
                     {
                         double dt = Convert.ToDouble(lnk.InnerText);
                         c.epg_start = ConvertFromUnixTimestamp(dt);
                     }
                 }
                 foreach (XmlElement lnk in d.DocumentElement.SelectNodes("//epg_end"))
                 {
                     if (!String.IsNullOrEmpty(lnk.InnerText))
                     {
                         double dt = Convert.ToDouble(lnk.InnerText);
                         c.epg_end = ConvertFromUnixTimestamp(dt);
                     }
                 }
                 lc.Add(c);
             }
             g.Channels = lc;
             lg.Add(g);
         }
         account.channel_group = lg;
     }
     catch (Exception ex)
     {
         throw new System.InvalidOperationException("Error to get list of channels");
     }
 }