public void OnBeforeDownload(IBrowser browser, DownloadItem item, IBeforeDownloadCallback callback)
        {
            if (!callback.IsDisposed)
            {
                using (callback)
                {
                    myForm.UpdateDownloadItem(item);

                    // ask browser what path it wants to save the file into
                    string path = myForm.CalcDownloadPath(item);

                    // if file should not be saved, path will be null, so skip file
                    if (path != null)
                    {
                        // skip file
                        callback.Continue(path, false);
                    }
                    else
                    {
                        // download file
                        callback.Dispose();

                        // open the downloads tab
                        myForm.OpenDownloadsTab();
                    }
                }
            }
        }
 public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
 {
     if (!callback.IsDisposed)
     {
         callback.Continue(downloadItem.SuggestedFileName, showDialog: true);
         callback.Dispose();
     }
 }
示例#3
0
 public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
 {
     if (!callback.IsDisposed)
     {
         callback.Continue(downloadItem.SuggestedFileName, showDialog: true);
         callback.Dispose();
     }
 }
        public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
        {
            if (RuntimeSettings.EnableWebDownloadMode)
            {
                MessageBox.Show("Web downloads are disabled in this mode.", "Downloads Disabled", MessageBoxButton.OK, MessageBoxImage.Information);
                callback.Dispose();
                return;
            }

            if (!callback.IsDisposed)
            {
                using (callback)
                {
                    callback.Continue(downloadItem.SuggestedFileName, showDialog: true);
                }
            }
        }
示例#5
0
 void IDownloadHandler.OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
 {
     if (!callback.IsDisposed)
     {
         try
         {
             callback.Continue(downloadItem.SuggestedFileName, true);
         }
         finally
         {
             if (callback != null)
             {
                 callback.Dispose();
             }
         }
     }
 }
示例#6
0
        public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
        {
            var handler = OnBeforeDownloadFired;

            if (handler != null)
            {
                handler(this, downloadItem);
            }

            if (!callback.IsDisposed)
            {
                String thisPath = _defaultPath;
                IEnumerable <Invoice> thisInvoice = MainWindow.invoiceIpc.invoices.Where(x => !String.IsNullOrWhiteSpace(x.norm_szamlaszam) && downloadItem.SuggestedFileName.Contains(x.norm_szamlaszam));
                if (thisInvoice != null && thisInvoice.Count() > 0 && thisInvoice.First() != null)
                {
                    thisPath = legalisePath(_defaultPath.Replace(MainWindow.mask_ev, thisInvoice.First().kibocsatas.Substring(0, 4)).Replace(MainWindow.mask_szolgaltato, thisInvoice.First().szolgaltato).Replace(MainWindow.mask_issuer, thisInvoice.First().kibocsato));
                    System.IO.Directory.CreateDirectory(thisPath);
                }
                else
                {
                    thisPath = legalisePath(_defaultPath.Replace(MainWindow.mask_ev, "").Replace(MainWindow.mask_szolgaltato, "").Replace(MainWindow.mask_issuer, "").Replace(@"\\", @"\"));
                    System.IO.Directory.CreateDirectory(thisPath);
                }
                using (callback)
                {
                    String fullpath = System.IO.Path.Combine(thisPath, legaliseFileName(downloadItem.SuggestedFileName));
                    if (_overwriteFiles || System.IO.File.Exists(fullpath))
                    {
                        callback.Continue(fullpath, showDialog: false);
                    }
                    else
                    {
                        //skip download but notify browser, we are done
                        callback.Dispose();
                        if (browser != null)
                        {
                            CefSharp.LoadingStateChangedEventArgs e = new LoadingStateChangedEventArgs(browser, true, false, false);
                            OnLoadingStateChanged(e);
                        }
                    }
                }
            }
        }