public static void ApplyElementTheme(Theme theme, IThemeable element, MemberInfo member) { if (theme != null) { var newTheme = Theme.CreateTheme(theme); newTheme.MergeTheme(element.Theme); element.Theme = newTheme; } if (member != null) { ApplyMemberTheme(member, element); } if (element is IRoot) { foreach (var section in ((IRoot)element).Sections) { foreach (var e in section.Elements) { ApplyElementTheme(element.Theme, e, null); } } } if (element is ISection) { foreach (var e in ((ISection)element).Elements) { ApplyElementTheme(element.Theme, e, null); } } }
/// <summary> /// Updates the themes on the given program to the themes with the given ids. Ensure the themes /// are already loaded via the context before calling this method. /// </summary> /// <param name="themeIds">The themes by id.</param> /// <param name="themeable">The program to update.</param> public void SetThemes(List <int> themeIds, IThemeable themeable) { Contract.Requires(themeIds != null, "The theme ids must not be null."); Contract.Requires(themeable != null, "The themeable entity must not be null."); var themesToRemove = themeable.Themes.Where(x => !themeIds.Contains(x.ThemeId)).ToList(); var themesToAdd = new List <Theme>(); themeIds.Where(x => !themeable.Themes.Select(c => c.ThemeId).ToList().Contains(x)).ToList() .Select(x => new Theme { ThemeId = x }).ToList() .ForEach(x => themesToAdd.Add(x)); themesToAdd.ForEach(x => { var localEntity = Context.GetLocalEntity <Theme>(y => y.ThemeId == x.ThemeId); if (localEntity == null) { if (Context.GetEntityState(x) == EntityState.Detached) { Context.Themes.Attach(x); } themeable.Themes.Add(x); } else { themeable.Themes.Add(localEntity); } }); themesToRemove.ForEach(x => { themeable.Themes.Remove(x); }); }
public ActionResult ChangeTheme(string theme) { if (String.IsNullOrEmpty(theme)) { return JsonError("Тема не указана", JsonRequestBehavior.AllowGet); } IThemeable themable = HttpContext.ApplicationInstance as IThemeable; if (themable == null) { return JsonError("Приложение не поддерживает темы.", JsonRequestBehavior.AllowGet); } if (!themable.SetTheme(theme)) { return JsonError("Тема не найдена", JsonRequestBehavior.AllowGet); } UserContext.Theme = theme; IAppConfiguration config = HttpContext.ApplicationInstance as IAppConfiguration; return JsonModel( new { theme = theme, css = Url.Content(config.GetWebAssetThemeCssStylePath(theme)) } , JsonRequestBehavior.AllowGet); }
protected override void OnInitialized() { base.OnInitialized(); IThemeable .Configure(this, out _appIsDark, out _themeIsDark, out _isDark, out _rootIsDark, out _themeClasses, out _rootThemeClasses, out _cascadingTheme) .DisposeWith(_disposables); IColorable .Configure(this) .DisposeWith(_disposables); }
public static void ApplyMemberTheme(MemberInfo member, IThemeable themeableElement) { var themeAttribute = member.GetCustomAttribute<ThemeAttribute>(); if (themeableElement != null && themeAttribute != null && themeAttribute.ThemeType != null) { var theme = Activator.CreateInstance(themeAttribute.ThemeType) as Theme; if (themeAttribute.ThemeUsage == ThemeUsage.Merge) themeableElement.Theme.MergeTheme(theme); else themeableElement.Theme = theme; } }
private static void ApplyElementTheme(Theme theme, IThemeable element, MemberInfo member) { if (theme != null) { var newTheme = Theme.CreateTheme(theme); newTheme.MergeTheme(element.Theme); element.Theme = newTheme; } if (member != null) { ApplyMemberTheme(member, element); } }
public static void ApplyMemberTheme(MemberInfo member, IThemeable themeableElement) { var themeAttribute = member.GetCustomAttribute <ThemeAttribute>(); if (themeableElement != null && themeAttribute != null && themeAttribute.ThemeType != null) { var theme = Activator.CreateInstance(themeAttribute.ThemeType) as Theme; if (themeAttribute.ThemeUsage == ThemeUsage.Merge) { themeableElement.Theme.MergeTheme(theme); } else { themeableElement.Theme = theme; } } }
public static void ApplyRootTheme(object view, IThemeable element) { Theme theme = null; var themeAttributes = view.GetType().GetCustomAttributes(typeof(ThemeAttribute), true); foreach (ThemeAttribute themeAttribute in themeAttributes) { if (element != null) { if (themeAttribute != null && themeAttribute.ThemeType != null) { theme = Activator.CreateInstance(themeAttribute.ThemeType) as Theme; element.Theme.MergeTheme(theme); } } } var root = element as IRoot; if (root != null) root.Theme = element.Theme; }
public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex) { base.InitializeCell(cell, cellType, rowState, rowIndex); if (cell != null) { if (cellType == DataControlCellType.DataCell) { if (this.ColumnSpan > 1) { cell.ColumnSpan = this.ColumnSpan; } foreach (System.Web.UI.Control ctl in cell.Controls) { IThemeable t = ctl as IThemeable; if (t != null) { t.Theme = this.Theme; } } } } }
public static void ApplyRootTheme(object view, IThemeable element) { Theme theme = null; var themeAttributes = view.GetType().GetCustomAttributes(typeof(ThemeAttribute), true); foreach (ThemeAttribute themeAttribute in themeAttributes) { if (element != null) { if (themeAttribute != null && themeAttribute.ThemeType != null) { theme = Activator.CreateInstance(themeAttribute.ThemeType) as Theme; element.Theme.MergeTheme(theme); } } } var root = element as IRoot; if (root != null) { root.Theme = element.Theme; } }
public static void ApplyElementTheme(Theme theme, IThemeable element, MemberInfo member) { if (theme != null) { var newTheme = Theme.CreateTheme(theme); newTheme.MergeTheme(element.Theme); element.Theme = newTheme; } if (member != null) ApplyMemberTheme(member, element); if (element is IRoot) { foreach(var section in ((IRoot)element).Sections) foreach(var e in section.Elements) ApplyElementTheme(element.Theme, e, null); } if (element is ISection) foreach(var e in ((ISection)element).Elements) ApplyElementTheme(element.Theme, e, null); }
public static void ApplyElementTheme(Theme theme, IThemeable element, MemberInfo member) { if (theme != null) { var newTheme = Theme.CreateTheme(theme); newTheme.MergeTheme(element.Theme); element.Theme = newTheme; } if (member != null) ApplyMemberTheme(member, element); var root = element as IRoot; if (root != null) { foreach (var s in root.Sections) foreach (var e in s.Elements) ApplyElementTheme(element.Theme, e, null); } var section = element as ISection; if (section != null) { foreach (var e in section.Elements) ApplyElementTheme(element.Theme, e, null); } }
private static void ApplyElementTheme(Theme theme, IThemeable element, MemberInfo member) { if (theme != null) { var newTheme = Theme.CreateTheme(theme); newTheme.MergeTheme(element.Theme); element.Theme = newTheme; } if (member != null) ApplyMemberTheme(member, element); }