Example #1
0
        public SpaceThemeCollection GetSpaceThemes()
        {
            string[]             dirs   = null;
            SpaceThemeCollection themes = new SpaceThemeCollection();

            SpaceTheme theme = new SpaceTheme();

            theme.Name = "默认风格";
            theme.Dir  = "default";
            themes.Add(theme);

            try
            {
                dirs = Directory.GetDirectories(Globals.GetPath(SystemDirecotry.SpaceStyles));                //.ApplicationPath + "max-templates/default\\theme");
            }
            catch
            {
                return(themes);
            }

            foreach (string dir in dirs)
            {
                string cssFilePath = IOUtil.JoinPath(dir, "style.css");

                if (File.Exists(cssFilePath) && File.Exists(IOUtil.JoinPath(dir, "preview.jpg")))
                {
                    string nameLine = IOUtil.ReadFirstLine(cssFilePath, Encoding.Default);

                    if (nameLine.StartsWith("/*") == false || nameLine.EndsWith("*/") == false)
                    {
                        continue;
                    }

                    DirectoryInfo dirInfo = new DirectoryInfo(dir);

                    theme      = new SpaceTheme();
                    theme.Name = nameLine.Substring(2, nameLine.Length - 4);
                    theme.Dir  = dirInfo.Name;

                    themes.Add(theme);
                }
            }

            return(themes);
        }