Exemple #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //default seeking bar for youtube channel
            tvkSeeking.is_show_icons = false;
            tvkSeeking.value = 0;

            //show version on title
            labelVersion.Text = "Version: " + AppConst.Version;

            //check if those 2 files exists on same folder
            if (!Utility.IsFileExist("fav.txt"))
                Utility.WriteFile("fav.txt", "", true);
            if (!Utility.IsFileExist("log.txt"))
                Utility.WriteFile("log.txt", "", true);

            //load configuration parameters from server
            LoadServerConfig();

            //set default country
            defaultCountry = Utility.ReadAppRegistry("TVKing2", "default_country");
            if (defaultCountry == "")
            {
                defaultCountry = "India";
            }

            //checked register
            switch (AppConst.appType)
            {
                case RegisterType.Ads:
                    barTrialHours.Visible = false;
                    break;
                case RegisterType.Free:
                    lbLeftDays.Visible = false;
                    label10.Visible = false;
                    label11.Text = "Register to watch OnlineTV UNLIMITED for FREE!";
                    lbRegisterText.Text = AppConst.TrialHours + " Hours watching TV";
                    label11.Left = lbRegisterText.Left;
                    label11.Top = lbRegisterText.Top + 20;
                    break;
                case RegisterType.Hours:
                    lbLeftDays.Visible = false;
                    label10.Visible = false;
                    label11.Text = "You are using Trial version. Please Register to remove Time Limit";
                    lbRegisterText.Text = AppConst.TrialHours + " Hours watching TV";
                    label11.Left = lbRegisterText.Left;
                    label11.Top = lbRegisterText.Top + 20;
                    break;
                case RegisterType.HoursDaily:
                    barTrialHours.Visible = false;
                    break;
                case RegisterType.Trial:
                    barTrialHours.Visible = false;
                    break;
            }

            //search keyword text to empty
            lbListTitle.Text = "";

            //set events for customed lists
            cbCategory.IndexChanged += new TVKing2.TVKComboBoxIndexChangedEvent(tvkComboBox2_IndexChanged);
            cbCountry.IndexChanged += new TVKing2.TVKComboBoxIndexChangedEvent(cbCountry_IndexChanged);
            lvStream.RatingClick += new DeRatingClick(lvStream_RatingClick);
            lvWeb.RatingClick += new DeRatingClick(lvStream_RatingClick);
            lvStream.DefaultClick += new DeTVKDefaultClick(lvStream_DefaultClick);

            //set height for customed lists
            cbCategory.SetListHeigh(150);
            cbCountry.SetListHeigh(250);

            //set channel title to empty
            txtTitle.Text = "";

            //check register
            RegisterCheck reg = new RegisterCheck();
            bool registerCheck = reg.IsRegister();
            registerCheck = true;
            if (registerCheck == true)
            {
                registerToolStripMenuItem.Enabled = false;
                tvkLabel2.Visible = false;
                tvkPictureBox2.Visible = false;
                lbRegisterText.Visible = false;
                lbLeftDays.Visible = false;
                label10.Visible = false;
                label11.Visible = false;
                barTrialHours.Visible = false;
                switch (AppConst.appType)
                {
                    case RegisterType.Free:
                        registerToolStripMenuItem1.Text = "Free Version";
                        registerToolStripMenuItem1.Visible = true;
                        registerToolStripMenuItem1.Enabled = false;
                        break;
                    case RegisterType.Hours:
                    case RegisterType.Ads:
                    case RegisterType.HoursDaily:
                    case RegisterType.Trial:
                        registerToolStripMenuItem1.Text = "Registering";
                        registerToolStripMenuItem1.Visible = true;
                        if (reg.IsRegister() == true)
                            registerToolStripMenuItem1.Enabled = false;
                        else
                            registerToolStripMenuItem1.Enabled = true;

                        break;
                }
            }
            else
            {
                switch (AppConst.appType)
                {
                    case RegisterType.Ads:
                        lbRegisterText.Text = "Please register to watch TV Without Ads";
                        lbLeftDays.Text = "";
                        label10.Text = "";
                        adv = new fmAdvertisement();
                        adv.Show();
                        tmAdvMoving.Enabled = true;
                        break;
                    case RegisterType.Free:
                        break;
                    case RegisterType.Hours:
                        reg.SetTimeUsed();
                        int timeLeft = reg.GetTimeLeft();
                        if (timeLeft < 0)
                        {
                            fmReg.Show();
                        }
                        break;
                    case RegisterType.HoursDaily:
                        break;
                    case RegisterType.Trial:
                        if (reg.IsExpired() == true)
                        {
                            isStop = true;
                            fmReg.Show();
                            tvkTrialScreen1.Visible = true;
                            pbErrorBG.Visible = true;
                        }
                        lbLeftDays.Text = reg.GetDayLeft() + " Days";
                        break;
                }
            }

            //get country and category from server
            Thread thCountry = new Thread(new ThreadStart(LoadCountry));
            Thread thCategory = new Thread(new ThreadStart(LoadCategory));
            thCountry.Start();
            thCategory.Start();

            //load flags into memory
            LoadFlags();

            //create folder to store channel logos
            string logFolder = Directory.GetCurrentDirectory() + @"\logos";
            if (!Directory.Exists(logFolder))
                Directory.CreateDirectory(logFolder);

            //pre-set location of all controls in main form
            LocateControls();

            //show main logo on center of main form
            pbErrorBG.Visible = true;

            //set loaded flags for stream and web control
            lvStream.SetImageList(flagList);
            lvStream.Clear();
            lvWeb.SetImageList(flagList);
            lvWeb.Clear();

            //set some default properties for windows media player
            player_wmp.Visible = false;
            player_wmp.uiMode = "none";
            player_wmp.stretchToFit = true;

            //show stop button
            pbStopSearch.Visible = false;

            //check version and update if it is old version
            Thread thCheckVersion = new Thread(new ThreadStart(InitCheckVersion));
            thCheckVersion.Start();

            //auto searching by default country
            SearchQuery(defaultCountry, true, false);
            SelectLabel(labelIndia);

            //set timer auto play checking if there is channel to play automatically
            bool isAutoplay = true;
            if (Utility.ReadAppRegistry("TVKing2", "auto_play") == "0")
                isAutoplay = false;
            if (isAutoplay)
            {
                tmAutoPlay.Enabled = true;
            }

            //set register form to the top
            fmReg.TopMost = true;

            //timer checking channel bandwidth is on
            tmBandwidth.Enabled = true;

            //download list of watchable channels
            DownloadCheckedList();

            if (server_config_ads == true)
            {
                tvkads = new TVKAdsRight(AppConst.ServerURL);
                tvkads.Show();
                timerRightBanner.Enabled = true;
            }

            //close startup flash
            flashpop.Close();

            //get user harddrive id and submit to server
            systemuser.deFinishedGetSystemUser = new DeFinishedGetSystemUser(CallbackFinishedGetSystemUser);
            Thread threadSystemUser = new Thread(new ThreadStart(systemuser.RequestToServer));
            threadSystemUser.Start();
            timerSystemUser.Enabled = true;
            GetUserEmail();

            //put more text on title to indicate version type
            switch (AppConst.appType)
            {
                case RegisterType.Ads:
                    break;
                case RegisterType.Free:
                    break;
                case RegisterType.Hours:
                    break;
                case RegisterType.HoursDaily:
                    if (reg.IsRegister() == false)
                    {
                        labelVersion.Text += " - 10 Minutes FREE watching";
                        Graphics g = labelVersion.CreateGraphics();
                        labelVersion.Width = (int)g.MeasureString(labelVersion.Text, labelVersion.Font).Width;
                        g.Dispose();
                    }
                    break;
                case RegisterType.Trial:
                    break;
            }
        }
Exemple #2
0
 private void lvWeb_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     RegisterCheck reg = new RegisterCheck();
     if (reg.IsRegister() == false)
     {
         switch (AppConst.appType)
         {
             case RegisterType.Ads:
                 lbRegisterText.Text = "Please register to watch TV Without Ads";
                 lbLeftDays.Text = "";
                 label10.Text = "";
                 adv = new fmAdvertisement();
                 adv.Show();
                 tmAdvMoving.Enabled = true;
                 return;
             case RegisterType.Free:
                 break;
             case RegisterType.Hours:
                 reg.SetTimeUsed();
                 int timeLeft = reg.GetTimeLeft();
                 if (timeLeft < 0)
                 {
                     fmReg.Show();
                 }
                 return;
             case RegisterType.HoursDaily:
                 if (reg.IsRegister() == false && reg.IsExpired() == false)
                 {
                     isStop = true;
                     fmReg.Show();
                     tvkTrialScreen1.Visible = true;
                     pbErrorBG.Visible = true;
                     return;
                 }
                 break;
             case RegisterType.Trial:
                 if (reg.IsExpired() == true)
                 {
                     isStop = true;
                     fmReg.Show();
                     tvkTrialScreen1.Visible = true;
                     pbErrorBG.Visible = true;
                 }
                 lbLeftDays.Text = reg.GetDayLeft() + " Days";
                 return;
         }
     }
     string selectedId = lvWeb.SelectedId();
     foreach (Channel ch in webList)
     {
         if (ch.id.ToString() == selectedId)
         {
             System.Diagnostics.Process.Start(ch.web);
             break;
         }
     }
 }