private void RemoveStyles(Theme theme) { Theme theme1 = ThemeRepository.FindTheme(theme.Name); foreach (StyleGroup styleGroup1 in theme.StyleGroups) { for (int index = theme1.StyleGroups.Count - 1; index >= 0; --index) { StyleGroup styleGroup2 = theme1.StyleGroups[index]; if (styleGroup2.IsCompatible(styleGroup1)) { theme1.StyleGroups.Remove(styleGroup2); break; } } } foreach (StyleRepository repository1 in theme.Repositories) { for (int index = theme1.Repositories.Count - 1; index >= 0; --index) { StyleRepository repository2 = theme1.Repositories[index]; if (repository2.Key == repository1.Key) { theme1.Repositories.Remove(repository2); break; } } } ThemeResolutionService.RaiseThemeChanged(theme.Name, ""); }
public StyleSheet GetStyleSheet() { if (this.partiallyLoadedXmlData != null) { ThemeResolutionService.EnsureThemeRegistered(themeName); Theme theme = ThemeResolutionService.GetTheme(themeName); return(new PartiallyLoadableStyleSheet(theme, this.partiallyLoadedXmlData, this.ThemeLocation)); } else { return(new PartiallyLoadableStyleSheet(this, this.ThemeLocation)); } /* * StyleSheet res = new StyleSheet(); * if (this.PropertySettingGroups == null) * { * return res; * } * * PropertySettingGroupCollection resGroups = res.PropertySettingGroups; * XmlPropertySettingGroupCollection xmlGroups = this.PropertySettingGroups; * * DeserializePropertySettingGroups(res.PropertySettingGroups); * * return res;*/ }
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e) { if (e.Property == VisualElement.FontProperty) { this.OnFontChanged(EventArgs.Empty); } else if (e.Property == VisualElement.CustomFontProperty || e.Property == VisualElement.CustomFontSizeProperty || e.Property == VisualElement.CustomFontStyleProperty) { FontFamily family = (FontFamily)null; string customFont = this.CustomFont; if (!string.IsNullOrEmpty(customFont) && customFont != "None") { family = ThemeResolutionService.GetCustomFont(customFont); } if (family == null) { int num = (int)this.ResetValue(VisualElement.FontProperty, ValueResetFlags.DefaultValueOverride); return; } if (!string.IsNullOrEmpty(customFont)) { int num1 = (int)this.SetDefaultValueOverride(VisualElement.FontProperty, (object)new Font(family, this.CustomFontSize, this.CustomFontStyle)); } } base.OnPropertyChanged(e); }
public static bool LoadPackageResource(Assembly sourceAssembly, string resourcePath) { return(ThemeResolutionService.LoadPackageResource(new ThemeResolutionService.ResourceParams() { UserAssembly = sourceAssembly, ResourcePath = resourcePath }, true)); }
public static StyleGroup GetStyleSheetBuilder( IComponentTreeHandler control, string elementTypeFullName, string elementName, string proposedThemeName) { return(ThemeResolutionService.GetStyleSheetBuilder(control, elementTypeFullName, elementName, proposedThemeName, false, (StyleSheet)null)); }
public static void RegisterElementTypeDefaultStyleBuilder( string themeName, string elementTypeName, StyleGroup builder) { ThemeResolutionService.EnsureThemeRegistered(ThemeResolutionService.ControlDefaultThemeName); ThemeResolutionService.TripleNameKey tripleNameKey = new ThemeResolutionService.TripleNameKey("", themeName, elementTypeName); ThemeResolutionService.registeredBuildersDefaultByElementType[(object)tripleNameKey] = (object)builder; }
public static bool LoadPackageResource(string resourcePath) { return(ThemeResolutionService.LoadPackageResource(new ThemeResolutionService.ResourceParams() { CallingAssembly = Assembly.GetCallingAssembly(), ExecutingAssembly = Assembly.GetExecutingAssembly(), ResourcePath = resourcePath }, true)); }
protected override void Dispose(bool disposing) { if (!disposing) { return; } this.RootElement.Dispose(); ThemeResolutionService.UnsubscribeFromThemeChanged((IThemeChangeListener)this); }
public static void RegisterStyleBuilderByControlName( string controlName, string elementTypeName, StyleGroup builder, string themeName) { ThemeResolutionService.EnsureThemeRegistered(themeName); ThemeResolutionService.TripleNameKey tripleNameKey = new ThemeResolutionService.TripleNameKey("__ID" + controlName, elementTypeName, themeName); ThemeResolutionService.registeredBuildersByElementTypeControlID[(object)tripleNameKey] = (object)builder; }
public static void RegisterControlStyleBuilder( string controlTypeName, string elementTypeName, StyleGroup builder, string themeName) { ThemeResolutionService.EnsureThemeRegistered(themeName); ThemeResolutionService.TripleNameKey tripleNameKey = new ThemeResolutionService.TripleNameKey(controlTypeName, elementTypeName, themeName); ThemeResolutionService.registeredBuildersByElementTypeControlType[(object)tripleNameKey] = (object)builder; ThemeResolutionService.RaiseThemeChanged(themeName, controlTypeName); }
static ThemeResolutionService() { string str = "Telerik.WinControls.Resources."; ThemeResolutionService.LoadFont(str + "Roboto-Medium.ttf"); ThemeResolutionService.LoadFont(str + "Roboto-Regular.ttf"); ThemeResolutionService.LoadFont(str + "TelerikWebUI.ttf"); ThemeResolutionService.LoadFont(str + "WebComponentsIcons.ttf"); ThemeResolutionService.LoadFont(str + "Awesome-Brands-Regular.ttf"); ThemeResolutionService.LoadFont(str + "Awesome-Regular.ttf"); ThemeResolutionService.LoadFont(str + "Awesome-Solid.ttf"); }
public static StyleGroup[] GetStyleSheetBuilders(string themeName) { if (string.IsNullOrEmpty(themeName)) { themeName = ThemeResolutionService.ControlDefaultThemeName; } ArrayList res = new ArrayList(); foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersDefaultByElementType) { ThemeResolutionService.TripleNameKey key = (ThemeResolutionService.TripleNameKey)dictionaryEntry.Key; if (string.Compare(key.Name2, themeName, true) == 0) { StyleGroup builder = (StyleGroup)dictionaryEntry.Value; BuilderRegistrationType regType = BuilderRegistrationType.ElementTypeDefault; string name3 = key.Name3; string controlType = (string)null; string elementName = (string)null; string controlName = (string)null; ThemeResolutionService.AddBuilderToList(res, builder, regType, name3, controlType, elementName, controlName); } } foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersByElementTypeControlType) { ThemeResolutionService.TripleNameKey key = (ThemeResolutionService.TripleNameKey)dictionaryEntry.Key; if (string.Compare(key.Name3, themeName, true) == 0) { StyleGroup builder = (StyleGroup)dictionaryEntry.Value; BuilderRegistrationType regType = BuilderRegistrationType.ElementTypeControlType; string name2 = key.Name2; string name1 = key.Name1; string elementName = (string)null; string controlName = (string)null; ThemeResolutionService.AddBuilderToList(res, builder, regType, name2, name1, elementName, controlName); } } foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersName) { if (string.Compare((string)dictionaryEntry.Key, themeName, true) == 0) { StyleGroup builder = (StyleGroup)dictionaryEntry.Value; BuilderRegistrationType regType = BuilderRegistrationType.ElementTypeGlobal; string elementType = (string)null; string controlType = (string)null; string elementName = (string)null; string controlName = (string)null; ThemeResolutionService.AddBuilderToList(res, builder, regType, elementType, controlType, elementName, controlName); } } StyleGroup[] styleGroupArray = new StyleGroup[res.Count]; res.CopyTo((Array)styleGroupArray, 0); return(styleGroupArray); }
public static void ApplyThemeToControlTree(Control control, string themeName) { IComponentTreeHandler componentTreeHandler = control as IComponentTreeHandler; if (componentTreeHandler != null) { componentTreeHandler.ThemeName = themeName; } foreach (Control control1 in (ArrangedElementCollection)control.Controls) { ThemeResolutionService.ApplyThemeToControlTree(control1, themeName); } }
public static void RegisterThemeFromStorage( ThemeStorageType storageType, Assembly assembly, string themeLocation) { ThemeResolutionService.RegisterThemeFromStorage(storageType, new ThemeResolutionService.ResourceParams() { CallingAssembly = Assembly.GetCallingAssembly(), ExecutingAssembly = Assembly.GetExecutingAssembly(), ResourcePath = themeLocation, UserAssembly = assembly }); }
public static void RegisterThemeRepository(XmlStyleRepository styleRepository, string themeName) { XmlStyleRepository xmlStyleRepository = ThemeResolutionService.registeredStyleRepositoriesByThemeName[(object)themeName] as XmlStyleRepository; if (xmlStyleRepository != null) { xmlStyleRepository.MergeWith(styleRepository); } else { ThemeResolutionService.registeredStyleRepositoriesByThemeName[(object)themeName] = (object)styleRepository; } ThemeResolutionService.RaiseThemeChanged(themeName, (string)null); }
private static StyleGroup GetStyleSheetBuilder( IComponentTreeHandler control, string elementTypeFullName, string elementName, string proposedThemeName, bool rootElementHasStyle, StyleSheet rootElementStyle) { string controlType = typeof(RadControl).FullName; string themeName = (string)null; string controlID = string.Empty; if (control != null) { themeName = control.ThemeName; Control control1 = control as Control; if (control1 != null) { controlID = control1.Name; } controlType = control.ThemeClassName; } StyleGroup styleGroup = (StyleGroup)null; if (ThemeResolutionService.applicationThemeName != null) { styleGroup = ThemeResolutionService.LookUpStyleBuilder(controlID, controlType, elementName, elementTypeFullName, rootElementHasStyle, rootElementStyle, ThemeResolutionService.applicationThemeName); } bool flag = false; if (styleGroup == null && !string.IsNullOrEmpty(proposedThemeName)) { flag = true; styleGroup = ThemeResolutionService.LookUpStyleBuilder(controlID, controlType, elementName, elementTypeFullName, rootElementHasStyle, rootElementStyle, proposedThemeName); } if (!flag && styleGroup == null && !string.IsNullOrEmpty(themeName)) { flag = true; styleGroup = ThemeResolutionService.LookUpStyleBuilder(controlID, controlType, elementName, elementTypeFullName, rootElementHasStyle, rootElementStyle, themeName); } if (!flag && styleGroup == null) { styleGroup = ThemeResolutionService.LookUpStyleBuilder(controlID, controlType, elementName, elementTypeFullName, rootElementHasStyle, rootElementStyle, ThemeResolutionService.ControlDefaultThemeName); } if (styleGroup == null) { styleGroup = ThemeResolutionService.LookUpStyleBuilder(controlID, controlType, elementName, elementTypeFullName, rootElementHasStyle, rootElementStyle, "*"); } return(styleGroup); }
/// <summary> /// Deserializes a theme from a given %XmlTheme:Telerik.WinControls.XmlTheme% /// instance. Resulting theme is registered within ThemeReolutionService and can be obtained using the following /// ThemeResolutionService.GetTheme(xmlTheme.ThemeName) /// </summary> /// <param name="xmlTheme">An instance of the <see cref="XmlTheme"/>class /// which is deserialized.</param> /// <param name="registerBuildersWithThemeResService">Defines whether new <see cref="StyleBuilderRegistration"/> /// instances are added in the <see cref="ThemeResolutionService"/>.</param> public static void Deserialize(XmlTheme xmlTheme, bool registerBuildersWithThemeResService) { //ThemeResolutionService.BeginEditTheme(xmlTheme.ThemeName); if (string.IsNullOrEmpty(xmlTheme.ThemeName)) { return; } ThemeResolutionService.SuspendThemeChange(); try { //Copy theme parameters ThemeResolutionService.EnsureThemeRegistered(xmlTheme.ThemeName); Theme themeInstance = ThemeResolutionService.GetTheme(xmlTheme.ThemeName); foreach (KeyValuePair <string, object> dictionaryEntry in xmlTheme.ThemeProperties) { themeInstance.ThemeProperties[dictionaryEntry.Key] = dictionaryEntry.Value; } string[] themeNames = xmlTheme.ThemeName.Split(',', ';'); if (xmlTheme.HasRepository) { foreach (string themeName in themeNames) { //If a repository for this theme already exists, both are merged. ThemeResolutionService.RegisterThemeRepository(xmlTheme.StyleRepository, themeName.Trim()); } } //Register StyleBuilders if (registerBuildersWithThemeResService && xmlTheme.BuilderRegistrations != null) { foreach (XmlStyleBuilderRegistration registration in xmlTheme.BuilderRegistrations) { foreach (string themeName in themeNames) { ThemeResolutionService.RegisterStyleBuilder(registration.GetRegistration(), themeName.Trim()); } } } } finally { ThemeResolutionService.ResumeThemeChange(); } }
public static int LoadFont(Stream fontStream) { IntPtr num = Marshal.AllocCoTaskMem((int)fontStream.Length); byte[] numArray = new byte[fontStream.Length]; fontStream.Read(numArray, 0, (int)fontStream.Length); Marshal.Copy(numArray, 0, num, (int)fontStream.Length); uint pcFonts = 0; ThemeResolutionService.AddFontMemResourceEx(num, (uint)numArray.Length, IntPtr.Zero, ref pcFonts); ThemeResolutionService.customFonts.AddMemoryFont(num, (int)fontStream.Length); fontStream.Close(); Marshal.FreeCoTaskMem(num); return((int)pcFonts); }
public static void Remove(string themeName) { lock (ThemeRepository.lockObject) { if (ThemeRepository.registeredThemes.Contains((object)themeName)) { ThemeRepository.registeredThemes.Remove((object)themeName); } if (!ThemeRepository.themes.Contains((object)themeName)) { return; } ThemeRepository.themes.Remove((object)themeName); ThemeResolutionService.RaiseThemeChanged(themeName, (string)null); } }
/// <summary> /// Registers a StyleSheet found in styleBuilderRegistration using also the registration details specified under the theme name specified. /// </summary> /// <param name="styleBuilderRegistration"></param> /// <param name="themeName"></param> public static void RegisterStyleBuilder(StyleBuilderRegistration styleBuilderRegistration, string themeName) { foreach (RadStylesheetRelation relation in styleBuilderRegistration.StylesheetRelations) { switch (relation.RegistrationType) { case BuilderRegistrationType.ElementTypeDefault: ThemeResolutionService.RegisterElementTypeDefaultStyleBuilder( themeName, relation.ElementType, styleBuilderRegistration.Builder); break; case BuilderRegistrationType.ElementTypeControlType: ThemeResolutionService.RegisterControlStyleBuilder( relation.ControlType, relation.ElementType, styleBuilderRegistration.Builder, themeName); break; /*case BuilderRegistrationType.ElementNameControlType: * ThemeResolutionService.RegisterControlStyleBuilder( * styleBuilderRegistration.ControlType, * styleBuilderRegistration.ElementName, * styleBuilderRegistration.Builder, * themeName); * break;*/ case BuilderRegistrationType.ElementTypeControlName: ThemeResolutionService.RegisterStyleBuilderByControlName( relation.ControlName, relation.ElementType, styleBuilderRegistration.Builder, themeName); break; /* * case BuilderRegistrationType.ElementNameControlName: * ThemeResolutionService.RegisterControlStyleBuilder( * styleBuilderRegistration.ControlName, * styleBuilderRegistration.ElementName, * styleBuilderRegistration.Builder, * themeName); * break;*/ } } EnsureThemeRegistered(themeName); GetTheme(themeName).StyleBuilderRegistered(styleBuilderRegistration); }
public static void Add(Theme theme, bool replaceExistingStyle) { lock (ThemeRepository.lockObject) { string name = theme.Name; char[] chArray = new char[1] { ',' }; foreach (string str in name.Split(chArray)) { string themeName = str.Trim(); if (themeName == "*" || themeName == "ControlDefault") { if (theme != ThemeRepository.ControlDefault) { if (ThemeRepository.ControlDefault != null) { ThemeRepository.ControlDefault.Combine(theme, true, replaceExistingStyle); } else { ThemeRepository.controlDefault = theme; theme.MergeRepositories(); } } } else { Theme theme1 = ThemeRepository.FindTheme(themeName, false); if (theme1 != null) { if (theme != theme1) { theme1.Combine(theme, true, replaceExistingStyle); } } else { theme.MergeRepositories(); ThemeRepository.themes.Add((object)themeName, (object)theme); } } } } ThemeResolutionService.RaiseThemeChanged(theme.Name, (string)null); }
public static StyleGroup GetStyleSheetBuilder( RadElement element, string proposedThemeName) { if (!element.CanHaveOwnStyle) { return((StyleGroup)null); } IComponentTreeHandler control = (IComponentTreeHandler)null; string fullName = element.GetThemeEffectiveType().FullName; string name = element.Name; bool rootElementHasStyle = !(element is RootRadElement) && element.ElementTree != null; StyleSheet rootElementStyle = (StyleSheet)null; if (rootElementHasStyle) { rootElementStyle = element.ElementTree.RootElement.Style; } return(ThemeResolutionService.GetStyleSheetBuilder(control, fullName, name, proposedThemeName, rootElementHasStyle, rootElementStyle)); }
internal protected virtual void Dispose(bool disposing) { //we are already disposed of if (this.isDisposed) { return; } this.disposing = true; if (disposing) { elementPropertyChangeEventList.Dispose(); this.RootElement.Dispose(); } ThemeResolutionService.UnsubscribeFromThemeChanged(this); this.disposing = false; this.isDisposed = true; }
public static void ResumeThemeChange(bool raiseChanged) { lock (ThemeResolutionService.syncRoot) { if (ThemeResolutionService.themeChangeSuspendCounter > 0) { --ThemeResolutionService.themeChangeSuspendCounter; } if (ThemeResolutionService.themeChangeSuspendCounter != 0) { return; } if (raiseChanged) { foreach (ThemeResolutionService.ThemeChangeInfo themeChangeInfo in ThemeResolutionService.themesChangeDuringSuspend) { ThemeResolutionService.RaiseThemeChanged(themeChangeInfo.ThemeName, themeChangeInfo.TargetThemeClassName); } } ThemeResolutionService.themesChangeDuringSuspend.Clear(); } }
public static void RegisterStyleBuilder(StyleGroup styleBuilderRegistration, string themeName) { foreach (StyleRegistration registration in styleBuilderRegistration.Registrations) { switch (registration.RegistrationType) { case "ElementTypeDefault": ThemeResolutionService.RegisterElementTypeDefaultStyleBuilder(themeName, registration.ElementType, styleBuilderRegistration); continue; case "ElementTypeControlType": ThemeResolutionService.RegisterControlStyleBuilder(registration.ControlType, registration.ElementType, styleBuilderRegistration, themeName); continue; case "ElementTypeControlName": ThemeResolutionService.RegisterStyleBuilderByControlName(registration.ControlName, registration.ElementType, styleBuilderRegistration, themeName); continue; default: continue; } } ThemeResolutionService.EnsureThemeRegistered(themeName); }
public static StyleGroup GetStyleSheetBuilder(RadElement element) { return(ThemeResolutionService.GetStyleSheetBuilder(element, (string)null)); }
public ComponentThemableElementTree(IComponentTreeHandler owner) : base(owner) { ThemeResolutionService.SubscribeForThemeChanged((IThemeChangeListener)this); }
static RadScreenTip() { ThemeResolutionService.RegisterThemeFromStorage(ThemeStorageType.Resource, "Telerik.WinControls.UI.Resources.ScreenTipThemes.Office2007Silver.xml"); }
public static void ClearTheme(string themeName) { lock (ThemeResolutionService.syncRoot) { ArrayList arrayList = new ArrayList(); foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersByElementTypeControlType) { ThemeResolutionService.TripleNameKey key = (ThemeResolutionService.TripleNameKey)dictionaryEntry.Key; if (string.Compare(key.Name3, themeName, true) == 0) { arrayList.Add((object)key); } } foreach (object key in arrayList) { ThemeResolutionService.registeredBuildersByElementTypeControlType.Remove(key); } arrayList.Clear(); foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersByElementNameControlType) { ThemeResolutionService.TripleNameKey key = (ThemeResolutionService.TripleNameKey)dictionaryEntry.Key; if (string.Compare(key.Name3, themeName, true) == 0) { arrayList.Add((object)key); } } foreach (object key in arrayList) { ThemeResolutionService.registeredBuildersByElementNameControlType.Remove(key); } arrayList.Clear(); foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersByElementTypeControlID) { ThemeResolutionService.TripleNameKey key = (ThemeResolutionService.TripleNameKey)dictionaryEntry.Key; if (string.Compare(key.Name3, themeName, true) == 0) { arrayList.Add((object)key); } } foreach (object key in arrayList) { ThemeResolutionService.registeredBuildersByElementTypeControlID.Remove(key); } arrayList.Clear(); foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersDefaultByElementType) { ThemeResolutionService.TripleNameKey key = (ThemeResolutionService.TripleNameKey)dictionaryEntry.Key; if (string.Compare(key.Name3, themeName, true) == 0) { arrayList.Add((object)key); } } foreach (object key in arrayList) { ThemeResolutionService.registeredBuildersDefaultByElementType.Remove(key); } arrayList.Clear(); foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersName) { string key = (string)dictionaryEntry.Key; if (string.Compare(key, themeName, true) == 0) { arrayList.Add((object)key); } } foreach (object key in arrayList) { ThemeResolutionService.registeredBuildersName.Remove(key); } } ThemeResolutionService.RaiseThemeChanged(themeName, (string)null); }
public static int LoadFont(string resourcePath) { return(ThemeResolutionService.LoadFont(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcePath))); }