Пример #1
0
        public ProgressWindow(Wallbase wall)
        {
            InitializeComponent();

            bw.RunWorkerCompleted += (sender, e) =>
            {
                bw.Dispose();
            };

            bw.DoWork += (sender, e) =>
            {
                try
                {
                    wall.OnWallbaseDownload += wall_OnWallbaseDownload;
                    wall.DownloadWallpapers();
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show("There was an error trying to download: " + ex.Message + "\n\nPerhaps your login was wrong?", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            };

            bw.RunWorkerAsync();
        }
        private void Download()
        {
            if (Directory.Exists(FolderPath))
                if (!HandleExistingDir(FolderPath))
                    return;

            if (!Directory.Exists(FolderPath))
                Directory.CreateDirectory(FolderPath);

            LockGUI(false);

            var wall = new Wallbase(FolderPath, Username, Password, UsePermissions,
                 txtUrl.Text, CreateList, CreateLog, Sort);
            {
                var wnd = new ProgressWindow(wall);
                wnd.Closed += (sender, e) => { LockGUI(true); };
                wnd.ShowDialog();
            }
        }