Exemple #1
0
        public void InitDownload(ThemeConfig theme)
        {
            ThemeManager.downloadMode = true;
            this.Invoke(new Action(() =>
                                   label1.Text = string.Format(_("Downloading images for '{0}'..."), ThemeManager.GetThemeName(theme))));

            themeUris     = DefaultThemes.GetThemeUriList(theme.themeId).ToList();
            themeUriIndex = 0;
            themeZipDest  = Path.Combine("themes", theme.themeId + ".zip");
            DownloadNext(theme);
        }
        public static void CalcThemeDownloadSize(ThemeConfig theme, Action <string> setSize)
        {
            Task.Run(() =>
            {
                foreach (Uri themeUri in DefaultThemes.GetThemeUriList(theme.themeId))
                {
                    var client = new RestClient(themeUri);
                    ProxyWrapper.ApplyProxyToClient(client);
                    var response = client.Head(new RestRequest());

                    if (response.IsSuccessful)
                    {
                        long sizeBytes = Convert.ToInt64(response.Headers.ToList()
                                                         .Find(x => x.Name == "Content-Length").Value);
                        setSize(string.Format(_("{0} MB"), (sizeBytes / 1024d / 1024d).ToString("0.#")));
                        break;
                    }
                }
            });
        }
        public static void Initialize()
        {
            Directory.CreateDirectory("themes");
            ConfigMigrator.CompatibilizeThemes();

            defaultThemes = DefaultThemes.GetDefaultThemes();
            List <string> themeIds = new List <string>();

            foreach (string filePath in Directory.EnumerateFiles("themes", "*.json", SearchOption.AllDirectories))
            {
                string themeId = Path.GetFileName(Path.GetDirectoryName(filePath));

                if (!themeId.StartsWith("."))
                {
                    themeIds.Add(themeId);
                }
            }

            LoadInstalledThemes(themeIds);
        }