Exemple #1
0
        private void importButton_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            string themePath = openFileDialog1.FileName;

            tempTheme = ThemeManager.ImportTheme(themePath);

            if (tempTheme == null)
            {
                return;
            }
            else if (Path.GetExtension(themePath) == ".zip")
            {
                LoadImportedTheme();
            }
            else
            {
                ProgressDialog downloadDialog = new ProgressDialog();
                downloadDialog.FormClosed += OnDownloadDialogClosed;
                downloadDialog.Show();

                this.Enabled = false;
                downloadDialog.LoadQueue(new List <ThemeConfig>()
                {
                    tempTheme
                });
                downloadDialog.DownloadNext();
            }
        }
        private void ImportNext()
        {
            if (ThemeManager.importPaths.Count > 0)
            {
                foreach (string themePath in ThemeManager.importPaths)
                {
                    importQueue.Enqueue(themePath);
                }

                numJobs += ThemeManager.importPaths.Count;
                ThemeManager.importPaths.Clear();
            }

            this.Invoke(new Action(() => UpdateTotalPercentage(0)));

            if (importQueue.Count > 0)
            {
                string themePath = importQueue.Peek();
                this.Invoke(new Action(() =>
                                       label1.Text = string.Format(_("Importing theme from {0}..."),
                                                                   Path.GetFileName(themePath))));

                ThemeResult result = ThemeManager.ImportTheme(themePath);
                result.Match(e => this.Invoke(new Action(() => ThemeLoader.HandleError(e))),
                             theme => ThemeManager.importedThemes.Add(theme));

                importQueue.Dequeue();
                ImportNext();
            }
            else
            {
                ThemeManager.importMode = false;
                this.Invoke(new Action(() => this.Close()));
            }
        }
        private void importButton_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            string themeJson = openFileDialog1.FileName;

            tempTheme = ThemeManager.ImportTheme(themeJson);

            ProgressDialog downloadDialog = new ProgressDialog();

            downloadDialog.FormClosed += OnDownloadDialogClosed;
            downloadDialog.Show();

            this.Enabled = false;
            downloadDialog.LoadQueue(new List <ThemeConfig>()
            {
                tempTheme
            });
            downloadDialog.DownloadNext();
        }
Exemple #4
0
        private void ImportNext()
        {
            if (importQueue.Count > 0)
            {
                this.Invoke(new Action(() => UpdateTotalPercentage(0)));
                string themePath = importQueue.Peek();

                ThemeConfig theme = ThemeManager.ImportTheme(themePath);

                if (theme != null)
                {
                    if (Path.GetExtension(themePath) == ".json")
                    {
                        downloadQueue = new Queue <ThemeConfig>(new List <ThemeConfig>()
                        {
                            theme
                        });
                        DownloadNext();
                    }

                    importQueue.Dequeue();
                    ThemeManager.importedThemes.Add(theme);
                    ImportNext();
                }
            }
            else
            {
                this.Invoke(new Action(() => this.Close()));
            }
        }
        private void ImportNext()
        {
            if (ThemeManager.importPaths.Count > 0)
            {
                foreach (string themePath in ThemeManager.importPaths)
                {
                    importQueue.Enqueue(themePath);
                }

                numJobs += ThemeManager.importPaths.Count;
                ThemeManager.importPaths.Clear();
            }

            this.Invoke(new Action(() => UpdateTotalPercentage(0)));

            if (importQueue.Count > 0)
            {
                string themePath = importQueue.Peek();
                this.Invoke(new Action(() => UpdateImportStatus(themePath)));
                ThemeConfig theme = ThemeManager.ImportTheme(themePath);
                this.Invoke(new Action(() => ThemeLoader.HandleError(
                                           Path.GetFileNameWithoutExtension(themePath))));

                if (theme != null)
                {
                    if (Path.GetExtension(themePath) == ".json")
                    {
                        downloadQueue = new Queue <ThemeConfig>(
                            new List <ThemeConfig>()
                        {
                            theme
                        });
                        DownloadNext();  // TODO Test this
                    }

                    ThemeManager.importedThemes.Add(theme);
                }

                importQueue.Dequeue();
                ImportNext();
            }
            else
            {
                ThemeManager.importMode = false;
                this.Invoke(new Action(() => this.Close()));
            }
        }