Пример #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();
                }));
            });
        }
Пример #2
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()));
            });
        }