Example #1
0
        private static void OnStorageTypeChanged(RadObject d, RadPropertyChangedEventArgs e)
        {
            ThemeSource themeSource = (ThemeSource)d;

            if (!themeSource.SettingsAreValid)
            {
                return;
            }
            themeSource.ReloadThemeFromStorage();
        }
        /// <summary>
        /// Regesters theme from a file or resource that contains a xml-serilized Theme object.
        /// The Visual Style Builder application for example is capable of designing and serializing
        /// themes. Theme files generally contain Theme with one or several style sheets each assigned a
        /// registration that defines which RadControl and/or RadElment the style sheet applies.
        /// </summary>
        /// <param name="storageType"></param>
        /// <param name="resourceParams"></param>
        public static void RegisterThemeFromStorage(ThemeStorageType storageType, ResourceParams resourceParams)
        {
            ThemeSource source         = new ThemeSource();
            Assembly    lookUpAssembly = resourceParams.UserAssembly;

            if (lookUpAssembly == null)
            {
                lookUpAssembly = resourceParams.CallingAssembly;
            }

            source.SetCallingAssembly(lookUpAssembly);
            source.StorageType   = storageType;
            source.ThemeLocation = resourceParams.ResourcePath;
            source.ReloadThemeFromStorage();
        }
        public static void RegisterThemeFromStorage(
            ThemeStorageType storageType,
            ThemeResolutionService.ResourceParams resourceParams)
        {
            ThemeSource themeSource = new ThemeSource();
            Assembly    assembly    = resourceParams.UserAssembly;

            if ((object)assembly == null)
            {
                assembly = resourceParams.CallingAssembly;
            }
            themeSource.CallingAssembly = assembly;
            themeSource.StorageType     = storageType;
            themeSource.ThemeLocation   = resourceParams.ResourcePath;
            themeSource.ReloadThemeFromStorage();
        }
        public static void RegisterThemeFromAssembly(Assembly assembly, string themeName)
        {
            string[] manifestResourceNames = assembly.GetManifestResourceNames();

            foreach (string currentName in manifestResourceNames)
            {
                if (!currentName.Contains(themeName) || !currentName.EndsWith(".xml"))
                {
                    continue;
                }

                ThemeSource source = new ThemeSource();
                source.SetCallingAssembly(Assembly.GetCallingAssembly());
                source.StorageType   = ThemeStorageType.Resource;
                source.ThemeLocation = currentName;
                source.ReloadThemeFromStorage();
            }
        }