示例#1
0
        public static skTheme ParseThemeXML(string ThemeXML)
        {
            skTheme ThemeObject = new skTheme();

            if (ThemeXML != "<>")
            {
                XDocument SettingsXML = XDocument.Parse(ThemeXML);
                Type      T           = ThemeObject.GetType();

                var settings = from rs in SettingsXML.Descendants()
                               select new
                {
                    objectvalue = rs.Value,
                    code        = rs.Name
                };

                foreach (var item in settings)
                {
                    PropertyInfo PropToAssign = T.GetProperty(item.code.ToString());

                    if (PropToAssign != null)
                    {
                        PropToAssign.SetValue(ThemeObject, item.objectvalue);
                    }
                }
            }
            else
            {
                throw new Exception("No Default Theme Set !");
            }

            return(ThemeObject);
        }
示例#2
0
 public PreferenceStyleViewModel()
 {
     if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject()))
     {
         return;
     }
     try
     {
         _ThemeOBJ  = new skTheme();
         UP         = new UserPreference();
         ColourLIst = new ObservableCollection <string>();
         _Update    = new Command(UpdatePref);
         LoadColours();
     }
     catch (Exception E)
     {
         ExepionLogger.Logger.LogException(E);
         ExepionLogger.Logger.Show(E);
     }
 }
示例#3
0
        public static string CreateThemeXML(skTheme ThemeObject)
        {
            XDocument SettingXML = new XDocument();
            Type      T          = ThemeObject.GetType();

            PropertyInfo[] Props = T.GetProperties();

            XElement root = new XElement("Theme_Properties");

            foreach (PropertyInfo P in Props)
            {
                if (P.PropertyType == typeof(string) && Attribute.IsDefined(P, typeof(ThemeProp)))
                {
                    root.Add(new XElement(P.Name, P.GetValue(ThemeObject)));
                }
            }

            SettingXML.Add(root);

            return(SettingXML.ToString());
        }