Beispiel #1
0
 private void SetText(string text)
 {
     if (richTextBox1.InvokeRequired == true)
     {
         SetTextHandler set = new SetTextHandler(SetText);//委托的方法参数应和SetText一致
         richTextBox1.Invoke(set, new object[] { text }); //此方法第二参数用于传入方法,代替形参text
     }
     else
     {
         richTextBox1.AppendText(text);
     }
 }
		public SafeLabel() : base()
		{
            SetText += new SetTextHandler(SafeLabel_SetText);
            GetText += new GetTextHandler(SafeLabel_GetText);
		}
        void clsDownload_VideoInfoReceived(clsMain.VideoInfoEventArgs VideoInfo)
        {
            SetTextHandler sth = new SetTextHandler(SetText);
            strCurrentVideoTitle = VideoInfo.strTitle;
            object[] text = { txtInfo, "[AUTHOR YOUTUBE CHANNEL:]" + Environment.NewLine + VideoInfo.strAuthor + Environment.NewLine + Environment.NewLine + "[VIDEO VIEWS:]" + Environment.NewLine + VideoInfo.strViews + Environment.NewLine + Environment.NewLine + "[LIKES:]" + Environment.NewLine + VideoInfo.strLikes + Environment.NewLine + Environment.NewLine + "[DISLIKES:]" + Environment.NewLine + VideoInfo.strDislikes + Environment.NewLine + Environment.NewLine + "[VIDEO DURATION:]" + Environment.NewLine + VideoInfo.strLength };
            txtInfo.Invoke(sth, text);
            SetImageHandler si = new SetImageHandler(SetImage);
            //object[] objLoading = { picVideoPic,Properties.Resources.Loading };
            //picVideoPic.Invoke(si, objLoading);

            object[] objImage = { picVideoPic, VideoInfo.strPic };
            picVideoPic.Invoke(si, objImage);
            SetControlPos scp = new SetControlPos(SetConPos);
            object[] objScroll = { lblScroll, pnlScroll.Left };
            lblScroll.Invoke(scp, objScroll);
            object[] strTitle = { lblScroll, VideoInfo.strTitle };
            lblScroll.Invoke(sth, strTitle);
        }
 void clsDownload_Progress(clsMain.ProgressEventArgs Status)
 {
     SetTextHandler sth = new SetTextHandler(SetText);
     if (Status.Status == "Donwload links done")
     {
         EnDisableControlHandler edch = new EnDisableControlHandler(EnDisableControl);
         object[] objState = { txtUrl, true };
         txtUrl.Invoke(edch, objState);
         object[] objLinks = { lblStatus, "Done (" + Status.strDownloadLinks.Count.ToString() + " download links found)" };
         lblStatus.Invoke(sth, objLinks);
     }
     else
     {
         object[] objStatus = { lblStatus, Status.Status };
         lblStatus.Invoke(sth, objStatus);
     }
 }
 void clsDownload_Error(string err)
 {
     MessageBox.Show(err);
     SetTextHandler sth = new SetTextHandler(SetText);
     object[] objText = { txtUrl, "" };
     txtUrl.Invoke(sth, objText);
     ZeroParamHandler cuh = new ZeroParamHandler(CleanUp);
     this.Invoke(cuh);
     object[] objErr = { lblStatus, err };
     lblStatus.Invoke(sth, objErr);
     Environment.Exit(-1);
 }
        void clsDownload_DownloadLinksDone(clsMain.ProgressEventArgs Status)
        {
            string DownloadLinks = "";
            SetTextHandler sth = new SetTextHandler(SetText);
            ComboBoxAddItemhandler cbaih = new ComboBoxAddItemhandler(ComboBoxAddItem);
            for (int i = 0; i < Status.strDownloadLinks.Count; i++)
            {
                //object[] objCombo = {cbDownOpt, Status.strDownloadLinks[i]};
                object[] objCombo = { cbDownOpt, Status.strQuality[i] + " ( " + Status.strType[i] + " ) [" + Status.strSize[i] + " ]" };
                cbDownOpt.Invoke(cbaih, objCombo);
                DownloadLinks += Status.strDownloadLinks[i] + "\t\t" + Status.strQuality[i] + "\t\t" + Status.strType[i] + Environment.NewLine + Environment.NewLine; //+ "\t\t\t"  +Status.strQuality[i] + Status.strType[i] + Environment.NewLine + Environment.NewLine;

                strDownloadLinks.Add(new LinkInfo());
                LinkInfo liTmp = strDownloadLinks[i];
                liTmp.strVideoTitle = strCurrentVideoTitle;
                liTmp.strVideoSize = Status.strSize[i];
                liTmp.strVideoType = Status.strType[i];
                liTmp.strQuality = Status.strQuality[i];
                liTmp.strVideoLink = Status.strDownloadLinks[i];
                strDownloadLinks[i] = liTmp;

            }
            EnDisableControlHandler edch = new EnDisableControlHandler(EnDisableControl);
            object[] objEnable = { cbDownOpt, true };
            cbDownOpt.Invoke(edch, objEnable);
        }