Esempio n. 1
0
        private void Download(dynamic options)
        {
            string oldOptions;

            lock (this.serializeLock)
            {
                oldOptions  = Ydl.Options.Serialize();
                Ydl.Options = Options.Deserialize(options.options.ToString());
            }

            if (Ydl.Options.GeneralOptions.Update)
            {
                Process update = Ydl.Download(true);
                update.Exited += delegate
                {
                    Electron.IpcMain.Send(MainWindow, Messages.DOWNLOAD_COMPLETE);
                    Ydl.Options = Options.Deserialize(oldOptions);
                };
            }
            else
            {
                string[] urls    = options.urls.ToObject <string[]>();
                string[] badUrls = urls.
                                   Where(url => url == null || !url.IsHttpUri() && !string.IsNullOrWhiteSpace(url)).
                                   ToArray();

                if (badUrls.Length > 0)
                {
                    Electron.IpcMain.Send(MainWindow, Messages.URL_PARSING_ERROR,
                                          JsonConvert.SerializeObject(badUrls));
                    return;
                }

                Ydl.Options.FilesystemOptions.Output +=
                    Path.DirectorySeparatorChar + DefaultTemplate;

                // Start the download
                Process download = Ydl.Download(string.Join(" ", urls));

                DownloadTable table = new DownloadTable(Ydl.Info);

                download.Exited += (sender, args) =>
                {
                    Electron.IpcMain.Send(MainWindow, Messages.DOWNLOAD_COMPLETE);
                    NotificationOptions notificationOptions =
                        new NotificationOptions("Yodel", "Download complete!")
                    {
                        OnClick = delegate { MainWindow.Focus(); }
                    };

                    Electron.Notification.Show(notificationOptions);
                    table.Dispose();
                };

                table.TableUpdateEvent += delegate(object sender, EventArgs args)
                {
                    Electron.IpcMain.Send(MainWindow, Messages.UPDATE_TABLE, sender as string);
                };
            }
        }
Esempio n. 2
0
    // ReSharper disable once UnusedMember.Local
    // ReSharper disable once InconsistentNaming
    // ReSharper disable once ArrangeTypeMemberModifiers
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Debug.LogError("More than one Manager in scene");
        }

        days = DownloadTable.reloadData();
    }
Esempio n. 3
0
    private void DownloadRootModule()
    {
        Module        module = ModuleMgr.Instance.GetModule(moduleName);
        DownloadTable table  = new DownloadTable()
        {
            Befor       = DownloadBefor,
            Progress    = DownloadProgress,
            OneComplete = DownloadOneComplete,
            AllComplete = DownloadAllComplete,
            Error       = DownloadError
        };

        module.CheckAndDownload(table);
    }