private void OnProcessFileDialog(object sender, FileDialogEventArgs e)
 {
     switch (e.Mode)
     {
     case FileDialogMode.Save:
         using (var saveDialog = new SaveFileDialog())
         {
             saveDialog.Title            = e.Title;
             saveDialog.Filter           = e.Filter;
             saveDialog.FileName         = Path.GetFileName(e.DefaultFileName);
             saveDialog.InitialDirectory = Path.Combine(
                 Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
                 "Downloads");
             if (saveDialog.ShowDialog(_siteContainer.ParentBundle.MainForm) != DialogResult.Cancel)
             {
                 FormDownloadProgress.ShowProgress(_siteContainer.ParentBundle.MainForm);
                 Application.DoEvents();
                 FormDownloadProgress.SetTitle("Downloading…");
                 Application.DoEvents();
                 FormDownloadProgress.SetDetails(Path.GetFileName(saveDialog.FileName));
                 Application.DoEvents();
                 _siteContainer.SuspendPages();
                 Application.DoEvents();
                 e.Continue(saveDialog.FileName);
             }
             else
             {
                 e.Cancel();
             }
         }
         break;
     }
     e.Handled = true;
 }
Example #2
0
 private void OnExtensionWebViewLoadFailed(object sender, LoadFailedEventArgs e)
 {
     if (e.ErrorCode == ErrorCode.ProceedAsDownload)
     {
         return;
     }
     _siteContainer.ResumePages();
     FormDownloadProgress.CloseProgress();
 }
Example #3
0
 private void DownloadFile(string url, AfterDownloadAction afterDownloadAction = AfterDownloadAction.None)
 {
     _afterDownloadAction = afterDownloadAction;
     FormDownloadProgress.ShowProgress(_siteContainer.ParentBundle.MainForm);
     FormDownloadProgress.SetTitle("Downloading…");
     _siteContainer.SuspendPages();
     Application.DoEvents();
     _extensionDownloadView.WebView.LoadUrl(url.Replace(@"SalesLibraries/SalesLibraries", "SalesLibraries"));
 }
Example #4
0
        public FormDownloadCG(FormDownloadProgress gui, MainController ctrl)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            // Initialize variables
            this.gui  = gui;
            this.ctrl = ctrl;
            pbars     = new List <CustomProgressBar>();

            // styling form
            gui.SuspendLayout();
            gui.Text = "Downloader";
        }
 private void OnWebViewDownloadCompleted(object sender, DownloadEventArgs e)
 {
     _siteContainer.ResumePages();
     FormDownloadProgress.CloseProgress();
     if (".MP4".Equals(Path.GetExtension(e.Item.FullPath), StringComparison.OrdinalIgnoreCase))
     {
         if (HandleVideoDownloaded(e.Item.FullPath))
         {
             return;
         }
     }
     using (var formComplete = new FormFileDownloadComplete(e.Item.FullPath))
     {
         formComplete.ShowDialog(_siteContainer.ParentBundle.MainForm);
     }
 }
Example #6
0
        public MainController(FormMain gui)
        {
            this.gui  = gui;
            this.auth = new Authentication(this);

            // Initialize variables
            videoUrls  = new List <string>();
            videoNames = new List <string>();
            dlt        = new List <Download>();

            // UI setting
            dlf        = new FormDownloadProgress(gui);
            dlf.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            dlcg       = new FormDownloadCG(dlf, this);


            // get default folder
            downloadFolder        = FolderCtrl.getDownloadDir();
            playFolder            = FolderCtrl.getVideoDir();
            gui.input_dwndir.Text = downloadFolder;

            // listing video
            loadVideoList();
        }
 private void OnWebViewDownloadCanceled(object sender, DownloadEventArgs e)
 {
     _siteContainer.ResumePages();
     FormDownloadProgress.CloseProgress();
 }
 private void OnWebViewDownloadUpdated(object sender, DownloadEventArgs e)
 {
     Application.DoEvents();
     FormDownloadProgress.SetDetails(String.Format("{0} - {1}%", Path.GetFileName(e.Item.FullPath), e.Item.PercentageComplete));
     Application.DoEvents();
 }
Example #9
0
 private void OnExtensionsWebViewDownloadCompleted(Object sender, DownloadEventArgs e)
 {
     _siteContainer.ResumePages();
     FormDownloadProgress.CloseProgress();
 }