Ejemplo n.º 1
0
        private void applyButton_Click(object sender, EventArgs e)
        {
            applyButton.Enabled = false;
            bool themeDownloaded = true;

            if (selectedIndex > 0)
            {
                themeDownloaded = ThemeManager.IsThemeDownloaded(ThemeManager.themeSettings[selectedIndex - 1]);
            }

            if (!themeDownloaded)
            {
                DownloadDialog downloadDialog = new DownloadDialog()
                {
                    Owner = this
                };
                downloadDialog.FormClosed += OnDownloadDialogClosed;
                downloadDialog.Show();
                this.Enabled = false;
                downloadDialog.InitDownload(ThemeManager.themeSettings[selectedIndex - 1]);
            }
            else
            {
                ApplySelectedTheme();
            }

            applyButton.Enabled = true;
        }
Ejemplo n.º 2
0
        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            var hitTestInfo = listView1.HitTest(listView1.PointToClient(Cursor.Position));
            int itemIndex   = hitTestInfo.Item?.Index ?? -1;

            if (itemIndex <= 0)
            {
                e.Cancel = true;
                return;
            }

            string      themeId = (string)listView1.Items[itemIndex].Tag;
            ThemeConfig theme   = ThemeManager.themeSettings.Find(t => t.themeId == themeId);

            contextMenuStrip1.Items[0].Enabled = ThemeManager.IsThemeDownloaded(theme);

            if (ThemeManager.defaultThemes.Contains(themeId))
            {
                contextMenuStrip1.Items[0].Text = _("Delete");
            }
            else
            {
                contextMenuStrip1.Items[0].Text = _("Delete permanently");
            }
        }
        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            imageListView1.HitTest(imageListView1.PointToClient(Cursor.Position), out var hitTestInfo);
            int    itemIndex = hitTestInfo.ItemIndex;
            string themeId   = (string)imageListView1.Items[itemIndex].Tag;

            if (itemIndex == 0)
            {
                e.Cancel = true;
            }
            else if (ThemeManager.defaultThemes.Contains(themeId))
            {
                ThemeConfig theme = ThemeManager.themeSettings.Find(t => t.themeId == themeId);

                if (ThemeManager.IsThemeDownloaded(theme))
                {
                    contextMenuStrip1.Items[0].Text = _("Delete");
                }
                else
                {
                    contextMenuStrip1.Items[0].Text = _("Download");
                }
            }
            else
            {
                contextMenuStrip1.Items[0].Text = _("Delete permanently");
            }
        }
Ejemplo n.º 4
0
        private void UpdateSelectedItem()
        {
            if (listView1.SelectedItems.Count == 0)
            {
                applyButton.Enabled = false;
                return;
            }

            selectedIndex = listView1.SelectedIndices[0];
            bool        themeDownloaded = true;
            ThemeConfig theme           = null;

            if (selectedIndex > 0)
            {
                string themeId = (string)listView1.Items[selectedIndex].Tag;
                selectedIndex   = ThemeManager.themeSettings.FindIndex(t => t.themeId == themeId) + 1;
                theme           = ThemeManager.themeSettings[selectedIndex - 1];
                themeDownloaded = ThemeManager.IsThemeDownloaded(theme);
            }

            downloadButton.Enabled = !themeDownloaded;
            applyButton.Enabled    = true;

            previewer.ViewModel.PreviewTheme(theme);
        }
Ejemplo n.º 5
0
        private void UpdateSelectedItem()
        {
            if (listView1.SelectedItems.Count == 0)
            {
                applyButton.Enabled = false;
                return;
            }

            selectedIndex = listView1.SelectedIndices[0];
            bool themeDownloaded = true;
            string previewHtml = null;

            if (selectedIndex > 0)
            {
                string themeId = (string)listView1.Items[selectedIndex].Tag;
                selectedIndex = ThemeManager.themeSettings.FindIndex(t => t.themeId == themeId) + 1;
                ThemeConfig theme = ThemeManager.themeSettings[selectedIndex - 1];

                themeDownloaded = ThemeManager.IsThemeDownloaded(theme);
                previewHtml = ThemePreviewer.GeneratePreviewHtml(theme);
            }
            else
            {
                previewHtml = ThemePreviewer.GeneratePreviewHtml(null);
            }

            downloadButton.Enabled = !themeDownloaded;
            applyButton.Enabled = true;

            chromiumWebBrowser1.LoadHtml(previewHtml, "file://");
        }
Ejemplo n.º 6
0
        private void OnDownloadDialogClosed(object sender, FormClosedEventArgs e)
        {
            if (ThemeManager.IsThemeDownloaded(ThemeManager.themeSettings[selectedIndex - 1]))
            {
                UpdateSelectedItem();
            }

            this.Enabled = true;
        }
        private void OnDownloadDialogClosed(object sender, FormClosedEventArgs e)
        {
            if (ThemeManager.IsThemeDownloaded(ThemeManager.themeSettings[selectedIndex - 1]))
            {
                if (((DownloadDialog)sender).applyPending)
                {
                    ApplySelectedTheme();
                }

                UpdateSelectedItem();
            }

            this.Enabled = !ThemeManager.importMode;
        }
Ejemplo n.º 8
0
        public static string GeneratePreviewHtml(ThemeConfig theme)
        {
            string htmlText = Properties.Resources.preview_html;
            Dictionary <string, string> replacers = new Dictionary <string, string>();

            replacers.Add("basePath", new Uri(Environment.CurrentDirectory).AbsoluteUri);

            if (theme != null)
            {
                replacers.Add("themeName", ThemeManager.GetThemeName(theme));
                replacers.Add("themeAuthor", ThemeManager.GetThemeAuthor(theme));
                replacers.Add("previewMessage", string.Format(_("Previewing {0}"), "<span id=\"previewText\"></span>"));

                SolarData      solarData = SunriseSunsetService.GetSolarData(DateTime.Today);
                SchedulerState wpState   = AppContext.wpEngine.GetImageData(solarData, theme);

                if (ThemeManager.IsThemeDownloaded(theme))
                {
                    // TODO Why are images flickering?
                    ThemeImageData imageData   = GetThemeImageData(theme);
                    int            activeImage = imageData.FindIndex(entry => entry.Item2 == wpState.daySegment4) +
                                                 wpState.imageNumber;

                    replacers.Add("downloadMessage", "");
                    replacers.Add("carouselIndicators", GetCarouselIndicators(imageData.Count, activeImage));
                    replacers.Add("carouselItems", GetCarouselItems(imageData, activeImage, theme));
                }
                else
                {
                    replacers.Add("downloadMessage", string.Format("<div id=\"bottomCenterPanel\">{0}</div>",
                                                                   _("Theme is not downloaded. Click Download button to enable full preview.")));
                    replacers.Add("carouselIndicators", "");
                    replacers.Add("carouselItems", GetCarouselItems(wpState, theme));
                }
            }
            else
            {
                replacers.Add("themeAuthor", "Microsoft");

                int    startCarouselIndex = htmlText.IndexOf("<!--");
                int    endCarouselIndex   = htmlText.LastIndexOf("-->") + 3;
                string imageTag           = string.Format("<img src=\"{0}\">",
                                                          (new Uri(ThemeThumbLoader.GetWindowsWallpaper())).AbsoluteUri);

                htmlText = htmlText.Substring(0, startCarouselIndex) + imageTag +
                           htmlText.Substring(endCarouselIndex + 1);
            }

            return(RenderTemplate(htmlText, replacers));
        }
Ejemplo n.º 9
0
        private void UpdateSelectedItem()
        {
            if (imageListView1.SelectedItems.Count > 0)
            {
                selectedIndex = imageListView1.SelectedItems[0].Index;
                int  imageNumber     = 1;
                bool themeDownloaded = true;

                if (selectedIndex > 0)
                {
                    string themeId = (string)imageListView1.Items[selectedIndex].Tag;
                    selectedIndex = ThemeManager.themeSettings.FindIndex(
                        t => t.themeId == themeId) + 1;
                    ThemeConfig theme = ThemeManager.themeSettings[selectedIndex - 1];
                    themeDownloaded = ThemeManager.IsThemeDownloaded(theme);

                    if (themeDownloaded)
                    {
                        SolarData solarData = SunriseSunsetService.GetSolarData(DateTime.Today);
                        imageNumber = ThemeManager.GetThemeImageList(theme).IndexOf(
                            AppContext.wpEngine.GetImageData(solarData, theme).Item1) + 1;
                    }
                    else
                    {
                        LoadPreviewImage((Image)Properties.Resources.ResourceManager.GetObject(
                                             themeId + "_thumbnail"));
                    }
                }

                SetThemeDownloaded(themeDownloaded);
                creditsLabel.Text = GetCreditsText(themeDownloaded);

                if (themeDownloaded)
                {
                    maxImageNumber = GetMaxImageNumber();
                    LoadPreviewImage(imageNumber);
                }

                applyButton.Enabled = true;
            }
            else
            {
                applyButton.Enabled = false;
            }
        }
Ejemplo n.º 10
0
        private void UpdateSelectedItem()
        {
            if (imageListView1.SelectedItems.Count > 0)
            {
                selectedIndex = imageListView1.SelectedItems[0].Index;
                int  imageNumber     = 1;
                bool themeDownloaded = true;

                if (selectedIndex > 0)
                {
                    string themeId = (string)imageListView1.Items[selectedIndex].Tag;
                    selectedIndex = ThemeManager.themeSettings.FindIndex(t => t.themeId == themeId) + 1;
                    ThemeConfig theme = ThemeManager.themeSettings[selectedIndex - 1];
                    nameLabel.Text  = ThemeManager.GetThemeName(theme);
                    themeDownloaded = ThemeManager.IsThemeDownloaded(theme);

                    if (themeDownloaded)
                    {
                        SolarData solarData = SunriseSunsetService.GetSolarData(DateTime.Today);
                        imageNumber = ThemeManager.GetThemeImageList(theme).IndexOf(
                            AppContext.wpEngine.GetImageData(solarData, theme).imageId) + 1;
                        LoadPreviewImage(imageNumber);
                    }
                    else
                    {
                        LoadPreviewImage((Image)Properties.Resources.ResourceManager.GetObject(themeId + "_thumbnail"));
                    }
                }
                else
                {
                    nameLabel.Text = _("Windows Default");
                    LoadPreviewImage(new Bitmap(windowsWallpaper));
                }

                creditsLabel.Text        = GetCreditsText();
                downloadLabel.Visible    = selectedIndex > 0 && !themeDownloaded;
                previewLinkLabel.Visible = selectedIndex > 0 && themeDownloaded;
                applyButton.Enabled      = true;
            }
            else
            {
                applyButton.Enabled = false;
            }
        }
Ejemplo n.º 11
0
        private void themeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int         itemIndex = imageListView1.SelectedItems[0].Index;
            string      themeId   = (string)imageListView1.Items[itemIndex].Tag;
            ThemeConfig theme     = ThemeManager.themeSettings.Find(t => t.themeId == themeId);

            if (ThemeManager.IsThemeDownloaded(theme))
            {
                DialogResult result = MessageDialog.ShowQuestion(string.Format(_("Are you sure you want to remove the " +
                                                                                 "'{0}' theme?"), ThemeManager.GetThemeName(theme)), _("Question"), true);

                if (result == DialogResult.Yes)
                {
                    if (!ThemeManager.defaultThemes.Contains(theme.themeId))
                    {
                        imageListView1.Items.RemoveAt(itemIndex);
                        imageListView1.Items[itemIndex - 1].Selected = true;
                        themeNames.RemoveAt(itemIndex - 1);
                    }

                    Task.Run(() => {
                        ThemeManager.RemoveTheme(theme);

                        if (ThemeManager.defaultThemes.Contains(theme.themeId))
                        {
                            this.Invoke(new Action(() => UpdateSelectedItem()));
                        }
                    });
                }
            }
            else
            {
                DownloadDialog downloadDialog = new DownloadDialog()
                {
                    Owner = this, applyPending = false
                };
                downloadDialog.FormClosed += OnDownloadDialogClosed;
                downloadDialog.Show();
                this.Enabled = false;
                downloadDialog.InitDownload(theme);
            }
        }
Ejemplo n.º 12
0
        private void applyButton_Click(object sender, EventArgs e)
        {
            applyButton.Enabled = false;
            bool themeDownloaded = true;

            if (selectedIndex > 0)
            {
                themeDownloaded = ThemeManager.IsThemeDownloaded(ThemeManager.themeSettings[selectedIndex - 1]);
            }

            if (!themeDownloaded)
            {
                DownloadTheme(ThemeManager.themeSettings[selectedIndex - 1], true);
            }
            else
            {
                ApplySelectedTheme();
            }

            applyButton.Enabled = true;
        }