コード例 #1
0
 public CefWebBeforeDownloadEventArgs(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
 {
     Cancel        = false;
     Browser       = browser;
     DownloadItem  = downloadItem;
     SuggestedName = suggestedName;
     Callback      = callback;
 }
コード例 #2
0
        internal BeforeDownloadEventArgs(CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
        {
            _downloadItem = downloadItem;
            SuggestedName = suggestedName;
            _callback     = callback;


            DownloadFileId     = (int)_downloadItem.Id;
            ContentDisposition = _downloadItem.ContentDisposition;
            IsValid            = _downloadItem.IsValid;
            MimeType           = _downloadItem.MimeType;
            OriginalUrl        = _downloadItem.OriginalUrl;
            TotalBytes         = _downloadItem.TotalBytes;
            Url = _downloadItem.Url;
        }
コード例 #3
0
 protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
 {
     callback.Continue(string.Empty, true);
 }
コード例 #4
0
 public BeforeDownloadEventArgs(CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
 {
     this.downloadItem  = downloadItem;
     this.suggestedName = suggestedName;
     this.callback      = callback;
 }
コード例 #5
0
 public override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
 {
     _implementation.OnBeforeDownload(browser, downloadItem, suggestedName, callback);
 }
コード例 #6
0
        protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
        {
            //public void Continue( string downloadPath, bool showDialog )

            owner.PerformDownloadBefore(downloadItem, suggestedName, callback);

            //Log.Info( "OnBeforeDownload: " + suggestedName );

            base.OnBeforeDownload(browser, downloadItem, suggestedName, callback);
        }
コード例 #7
0
 protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
 {
     callback.Continue(suggestedName, true);
     base.OnBeforeDownload(browser, downloadItem, suggestedName, callback);
     webBrowser.OnBeforeDownload();
 }
コード例 #8
0
        protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
        {
            var e = new BeforeDownloadEventArgs(downloadItem, suggestedName, callback);

            _owner.InvokeIfRequired(() => _owner.OnBeforeDownload(e));
        }
コード例 #9
0
        protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
        {
            var args = new BeginDownloadEventArgs(downloadItem.Url, downloadItem.MimeType);

            _owner.OnBeforeDownload(args);

            if (string.IsNullOrEmpty(args.DownloadPath))
            {
                callback.Continue(string.Empty, true);
            }
            else
            {
                callback.Continue(args.DownloadPath, false);
            }
        }
コード例 #10
0
 protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
 {
     callback.Continue(downloadItem.SuggestedFileName, showDialog: true);
 }
コード例 #11
0
        protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
        {
            using (callback)
            {
                var saveFileDialog = new SaveFileDialog();
                saveFileDialog.FileName = suggestedName;
                saveFileDialog.Filter   = "|*" + System.IO.Path.GetExtension(saveFileDialog.FileName);

                if (saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.FileName != "")
                {
                    callback.Continue(saveFileDialog.FileName, showDialog: false);
                }
            }
        }
コード例 #12
0
        protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
        {
            base.OnBeforeDownload(browser, downloadItem, suggestedName, callback);

            CefWebBrowser.CefWebBeforeDownloadEventArgs args = new CefWebBrowser.CefWebBeforeDownloadEventArgs(browser, downloadItem, suggestedName, callback);
            _core.OnBeforeDownload(args);
        }
コード例 #13
0
        protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
        {
            string DownloadID = downloadItem.Id.ToString();

            //base.OnBeforeDownload(browser, downloadItem, suggestedName, callback);
            if (suggestedName.Contains("@"))
            {
                System.Windows.Forms.MessageBox.Show(CefConstHelper.CefDownLoadWarling, "CefiBrowser", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                return;
            }
            string       JsuggestedName     = suggestedName.Substring(0, suggestedName.LastIndexOf("."));
            string       GsuggestedName     = JsuggestedName;
            string       JsuggestedEndName  = suggestedName.Substring(suggestedName.LastIndexOf("."), suggestedName.Length - suggestedName.LastIndexOf("."));
            string       Jfilepath          = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\downloads";
            Jdownloading dwitem             = new Jdownloading();
            Jdownload    WrDownloadListItem = new Jdownload();

            MainForm.Instance.Invoke(new Action(() =>
            {
                MainForm.Instance.faTabStrip1.SelectedItem.BrowserIsLoading = false; //下载的时候不显示Gif动画
                if (MainForm.Instance.DownloadPanel3.Visible == false)
                {
                    MainForm.Instance.DownloadPanel3.Visible = true;
                    MainForm.Instance.faTabStrip1.Height     = MainForm.Instance.Height - MainForm.Instance.DownloadPanel3.Height;//修正下载时进度控件位置错误
                }
                for (int i = 0; i < 1000; i++)
                {
                    if (CheckFileExists(Jfilepath + "\\" + JsuggestedName + JsuggestedEndName) != true)
                    {
                        if (CheckFileExists(Jfilepath + "\\" + JsuggestedName + JsuggestedEndName + ".cfg") != true || CheckFileExists(Jfilepath + "\\" + JsuggestedName + JsuggestedEndName + ".tfg") != true)
                        {
                            break;
                        }
                        else
                        {
                            JsuggestedName = GsuggestedName + "(" + (i + 1) + ")";
                        }
                    }
                    else
                    {
                        JsuggestedName = GsuggestedName + "(" + (i + 1) + ")";
                    }
                }
                dwitem.label1.Font      = Label1Font;
                dwitem.label2.Font      = Label2Font;
                dwitem.label1.ForeColor = Color.DimGray;
                dwitem.label1.Text      = JsuggestedName + JsuggestedEndName;
                dwitem.FileName         = JsuggestedName + JsuggestedEndName;
                dwitem.label2.Text      = downloadItem.PercentComplete + "%";
                //dwitem.Startime = downloadItem.StartTime.ToString().ToLower().Trim();
                dwitem.Height = 36;
                //dwitem.DownloadIndex = downloadItem.Id;
                dwitem.FilePaths     = Jfilepath + "\\" + JsuggestedName + JsuggestedEndName;
                dwitem.DownloadIndex = DownloadID;
                dwitem.IsDownloaded  = false;
                dwitem.Location      = new Point((MainForm.Instance.DownloadPanel3.Controls.Count - 2) * dwitem.Width + 6, 2);
                MainForm.Instance.DownloadPanel3.Controls.Add(dwitem);
                if (MainForm.Instance.faTabStrip1.SelectedItem.Title == "加载中...")
                {
                    //MainForm.Instance.faTabStrip1.SelectedItem.Title = "下载...";
                    //MainForm.Instance.faTabStrip1.SelectedItem.ItemIcon = Resources.AppIconNormal;
                    MainForm.Instance.faTabStrip1.RemoveTab(MainForm.Instance.faTabStrip1.SelectedItem);
                }
            }));
            callback.Continue(Jfilepath + "\\" + JsuggestedName + JsuggestedEndName, false); //这里true就是显示弹框,如果为False就不用弹
            //PublicClass.mDownload( downloadItem.Url, Jfilepath , JsuggestedName + JsuggestedEndName,(int)dwitem.DownloadIndex);
            //callback.Dispose();
            ////写入下载记录表中

            WrDownloadListItem.DownLoadTime  = DateTime.Now.TimeOfDay.ToString();
            WrDownloadListItem.FileName      = JsuggestedName + JsuggestedEndName;
            WrDownloadListItem.FullFilePaths = dwitem.FilePaths;
            WrDownloadListItem.DownloadUrl   = downloadItem.Url;
            WrDownloadListItem.DownloadID    = DownloadID;
            //WrDownloadListItem.Startime = downloadItem.StartTime.ToString().ToLower().Trim();
            WrDownloadListItem.IsDownloading   = true;
            WrDownloadListItem.FileAlreadyDele = false;
            WrDownloadListItem.ImageBase64str  = PublicClass.IamgeToBase64(Resources.AppIconNormal); //要修改这个默认的APP图标
            WrDownloadListItem.Width           = MainForm.Instance.faTabStrip1.SelectedItem.Width / 3;
            mDownloadRecode.WritemDownloadRecode(WrDownloadListItem);

            //判断下载Tab是否打开
            bool           DownloadTabIsOpen = false;
            FATabStripItem fATab             = new FATabStripItem();

            MainForm.Instance.Invoke(new Action(() =>
            {
                for (int i = 0; i < MainForm.Instance.faTabStrip1.Items.Count; i++)
                {
                    if (MainForm.Instance.faTabStrip1.Items[i].Title == CefConstHelper.CefDownloadTitle)
                    {
                        fATab             = MainForm.Instance.faTabStrip1.Items[i];
                        DownloadTabIsOpen = true;
                        break;
                    }
                }
                if (DownloadTabIsOpen)
                {
                    MainForm.Instance.LoadDownList_Info();
                }
            }));
            Jfilepath         = null;
            JsuggestedEndName = null;
            JsuggestedName    = null;
            //dwitem = null;
            GsuggestedName     = null;
            WrDownloadListItem = null;
            GC.Collect();
        }
コード例 #14
0
ファイル: DownloadHandler.cs プロジェクト: PlumpMath/CefPaste
        protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, String suggestedName, CefBeforeDownloadCallback callback)
        {
            if (this.Client.HandleDownloadStarting != null)
            {
                var fileName = this.Client.HandleDownloadStarting(suggestedName);
                if (fileName != null)
                {
                    callback.Continue(fileName, false);
                }
            }

            Log.Trace("DownloadHandler.OnBeforeDownload( browser: {0}, downloadItem: {1}, suggestedName: {2} )", browser.Identifier, downloadItem.Id, suggestedName);

            //base.OnBeforeDownload( browser, downloadItem, suggestedName, callback );
        }
コード例 #15
0
 internal void PerformDownloadBefore(CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
 {
     DownloadBefore?.Invoke(this, downloadItem, suggestedName, callback);
 }
コード例 #16
0
 internal protected virtual void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
 {
 }