Esempio n. 1
0
        private void LoadImportedThemes(List <ThemeConfig> themes, ImportDialog importDialog)
        {
            themes.Sort((t1, t2) => t1.themeId.CompareTo(t2.themeId));

            foreach (ThemeConfig theme in themes)
            {
                foreach (ListViewItem item in listView1.Items)
                {
                    if ((string)item.Tag == theme.themeId)
                    {
                        listView1.Items.RemoveAt(item.Index);
                        listView1.LargeImageList.Images[item.ImageIndex].Dispose();
                        break;
                    }
                }
            }

            Task.Run(() =>
            {
                LoadThemes(themes);

                this.Invoke(new Action(() =>
                {
                    importDialog.thumbnailsLoaded = true;
                    importDialog.Close();
                }));
            });
        }
Esempio n. 2
0
        public void ImportThemes(List<string> themePaths)
        {
            this.Enabled = false;
            List<string> duplicateThemeNames = new List<string>();

            foreach (string themePath in themePaths)
            {
                string themeId = Path.GetFileNameWithoutExtension(themePath);
                int themeIndex = ThemeManager.themeSettings.FindIndex(t => t.themeId == themeId);

                if (themeIndex != -1)
                {
                    duplicateThemeNames.Add(ThemeManager.GetThemeName(ThemeManager.themeSettings[themeIndex]));
                }
            }

            if (duplicateThemeNames.Count > 0)
            {
                DialogResult result = MessageDialog.ShowQuestion(string.Format(_("The following themes are already " +
                    "installed:\n\t{0}\n\nDo you want to overwrite them?"), string.Join("\n\t", duplicateThemeNames)),
                    _("Question"), true);

                if (result != DialogResult.Yes)
                {
                    this.Enabled = true;
                    return;
                }
            }

            ImportDialog importDialog = new ImportDialog() { Owner = this };
            importDialog.FormClosing += OnImportDialogClosing;
            importDialog.Show();
            importDialog.InitImport(themePaths);
        }
Esempio n. 3
0
        public void ImportThemes(List <string> themePaths)
        {
            ImportDialog importDialog = new ImportDialog()
            {
                Owner = this
            };

            importDialog.FormClosing += OnImportDialogClosing;
            importDialog.Show();
            importDialog.InitImport(themePaths);
        }
Esempio n. 4
0
        private void OnImportDialogClosing(object sender, FormClosingEventArgs e)
        {
            ImportDialog importDialog = (ImportDialog)sender;

            if (!importDialog.thumbnailsLoaded)
            {
                e.Cancel = true;
                LoadImportedThemes(ThemeManager.importedThemes, importDialog);
            }
            else
            {
                ThemeManager.importedThemes.Clear();
                this.Enabled = !ThemeManager.downloadMode;
            }
        }
Esempio n. 5
0
        private void LoadImportedThemes(List <ThemeConfig> themes, ImportDialog importDialog)
        {
            themes.Sort((t1, t2) => t1.themeId.CompareTo(t2.themeId));
            Size thumbnailSize        = ThemeThumbLoader.GetThumbnailSize(this);
            ImageListViewItem newItem = null;

            Task.Run(() =>
            {
                for (int i = 0; i < themes.Count; i++)
                {
                    this.Invoke(new Action(() => EnsureThemeNotDuplicated(themes[i].themeId)));

                    string themeName = ThemeManager.GetThemeName(themes[i]);
                    themeNames.Add(themeName);
                    themeNames.Sort();
                    int itemIndex = themeNames.IndexOf(themeName) + 1;

                    using (Image thumbnailImage = ThemeThumbLoader.GetThumbnailImage(themes[i], thumbnailSize, false))
                    {
                        this.Invoke(new Action(() =>
                        {
                            imageListView1.Items.Insert(itemIndex, ThemeManager.GetThemeName(themes[i]),
                                                        thumbnailImage);
                            newItem     = imageListView1.Items[itemIndex];
                            newItem.Tag = themes[i].themeId;
                        }));
                    }
                }

                if (newItem != null)
                {
                    this.Invoke(new Action(() =>
                    {
                        imageListView1.ClearSelection();
                        newItem.Selected = true;
                        imageListView1.EnsureVisible(newItem.Index);
                    }));
                }

                ThemeThumbLoader.CacheThumbnails(imageListView1.Items);
                importDialog.thumbnailsLoaded = true;
                this.Invoke(new Action(() => importDialog.Close()));
            });
        }