private void LoadParentalControl()
 {
     if (File.Exists(Utils.CONF_PATH + "amiIptvParentalControl.json"))
     {
         using (StreamReader r = new StreamReader(Utils.CONF_PATH + "amiIptvParentalControl.json"))
         {
             string             json          = r.ReadToEnd();
             List <ChannelInfo> blockChannels = JsonConvert.DeserializeObject <List <ChannelInfo> >(json);
             foreach (var ch in blockChannels)
             {
                 ParentalControl.Get().AddBlockList(ch);
             }
         }
     }
 }
        private void FillChannelList()
        {
            Channels       channels        = Channels.Get();
            List <GrpInfo> groups          = channels.GetGroups();
            var            groupsNodeWhite = new List <TreeNode>();
            var            groupsNodeBlack = new List <TreeNode>();

            foreach (var group in groups)
            {
                var grpNode = new TreeNode(group.Title);
                grpNode.Tag = group;
                var grpNodeBlack = new TreeNode(group.Title);
                grpNodeBlack.Tag = group;
                foreach (var ch in channels.GetChannelsByGroup(group))
                {
                    var chNode = new TreeNode(ch.Title);
                    chNode.Tag = ch;
                    if (ParentalControl.Get().IsChBlock(ch))
                    {
                        grpNodeBlack.Nodes.Add(chNode);
                    }
                    else
                    {
                        grpNode.Nodes.Add(chNode);
                    }
                }
                if (grpNode.Nodes.Count > 0)
                {
                    groupsNodeWhite.Add(grpNode);
                }
                if (grpNodeBlack.Nodes.Count > 0)
                {
                    groupsNodeBlack.Add(grpNodeBlack);
                }
            }
            treeList.Nodes.AddRange(groupsNodeWhite.ToArray());
            treeBlock.Nodes.AddRange(groupsNodeBlack.ToArray());
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(owner: this, Strings.SaveBlockList, "AmiIptvPlayer", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
     {
         ParentalControl.Get().Clear();
         foreach (TreeNode groupNode in treeBlock.Nodes)
         {
             foreach (TreeNode chNodel in groupNode.Nodes)
             {
                 ParentalControl.Get().AddBlockList((ChannelInfo)chNodel.Tag);
             }
         }
         if (File.Exists(Utils.CONF_PATH + "amiIptvParentalControl.json"))
         {
             File.Delete(Utils.CONF_PATH + "amiIptvParentalControl.json");
         }
         using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "amiIptvParentalControl.json"))
         {
             JsonSerializer serializer = new JsonSerializer();
             serializer.Serialize(file, ParentalControl.Get().GetBlockList());
         }
         this.Close();
     }
 }
        private void ChangeChannelTo(ChannelInfo channel, string number)
        {
            if (channel == null)
            {
                MessageBox.Show(Strings.NOT_FOUND_CH + number);
            }
            else
            {
                if (ParentalControl.Get().IsChBlock(channel))
                {
                    using (var askForm = new AskPass())
                    {
                        var result = askForm.ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }
                Logger.Current.Info($"[ChangeChannelTo] Change channel to {channel.TVGName}");
                playerForm.Stop();
                playerForm.SetIsChannel(channel.ChannelType == ChType.CHANNEL);
                playerForm.SetIsPaused(false);
                Thread.Sleep(500);
                currLang = -1;
                currSub  = -1;
                int currPostion = 0;
                if (channel.currentPostion != null && !channel.seen)
                {
                    if (MessageBox.Show(owner: this, Strings.Resume, "AmiIptvPlayer", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        currPostion = (int)channel.currentPostion;
                    }
                    else
                    {
                        channel.currentPostion = null;
                        SeenResumeChannels.Get().RemoveResume(channel.Title);
                        RefreshListView();
                    }
                }
                playerForm.SetMedia(channel.URL, currPostion, currLang, currSub);
                try
                {
                    string        chName = channel.TVGName.Length < 100 ? channel.TVGName : channel.TVGName.Substring(0, 99);
                    Task <string> stats  = Utils.GetAsync("http://amian.es:5085/stats?ctype=connected&app=net&chn=" + chName);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR SENDING STATS");
                }

                logoChannel.LoadCompleted -= logoLoaded;

                logoChannel.Image = Image.FromFile("./resources/images/nochannel.png");
                if (!string.IsNullOrEmpty(channel.TVGLogo))
                {
                    logoChannel.LoadAsync(channel.TVGLogo);
                    logoChannel.LoadCompleted += logoLoaded;
                }

                string title = channel.Title;
                if (title.Length > 20)
                {
                    title = title.Substring(0, 20) + "...";
                }
                lbChName.Text = title;
                chnl          = channel;
                currentChType = channel.ChannelType;
                SetEPG(channel);
            }
            playerForm.SetFocusOnVideoPanel();
        }