/// <summary> /// Gets the singleton instance /// </summary> /// <returns></returns> public static ThemeProvider Singleton() { if (singleton == null) singleton = new ThemeProvider(); return singleton; }
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (context == null) { return(new TypeConverter.StandardValuesCollection(new ArrayList())); } Control instance = context.Instance as Control; ArrayList values = new ArrayList(); if ((instance != null) && (instance.Site != null)) { IThemeResolutionService service = (IThemeResolutionService)instance.Site.GetService(typeof(IThemeResolutionService)); ThemeProvider stylesheetThemeProvider = service.GetStylesheetThemeProvider(); ThemeProvider themeProvider = service.GetThemeProvider(); if (stylesheetThemeProvider != null) { values.AddRange(stylesheetThemeProvider.GetSkinsForControl(instance.GetType())); values.Remove(string.Empty); } if (themeProvider != null) { foreach (string str in themeProvider.GetSkinsForControl(instance.GetType())) { if (!values.Contains(str)) { values.Add(str); } } values.Remove(string.Empty); } values.Sort(); } return(new TypeConverter.StandardValuesCollection(values)); }
public SkinBuilder (ThemeProvider provider, Control control, ControlBuilder skinBuilder, string themePath) { throw new NotImplementedException (); }
public override async Task Execute(params object[] args) { Page page; Color pageColor; using (var one = new OneNote(out page, out _)) { pageColor = page.GetPageColor(out _, out _); } var analyzer = new StyleAnalyzer(page.Root); var style = analyzer.CollectFromSelection(); if (style == null) { return; } using (var dialog = new StyleDialog(style, pageColor)) { if (dialog.ShowDialog(owner) == DialogResult.OK) { if (dialog.Style != null) { ThemeProvider.Save(dialog.Style); ribbon.Invalidate(); } } } await Task.Yield(); }
public SkinBuilder(ThemeProvider provider, Control control, ControlBuilder skinBuilder, string themePath) { throw new NotImplementedException(); }
private void SaveTheme(object sender, EventArgs e) { using (var dialog = new SaveFileDialog()) { dialog.DefaultExt = "xml"; dialog.Filter = "Theme files (*.xml)|*.xml|All files (*.*)|*.*"; dialog.Title = "Save Style Theme"; dialog.ShowHelp = true; // stupid, but this is needed to avoid hang var path = PathFactory.GetAppDataPath(); if (Directory.Exists(path)) { dialog.InitialDirectory = path; } else { dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); } var result = dialog.ShowDialog(); if (result == DialogResult.OK) { var key = Path.GetFileNameWithoutExtension(dialog.FileName); theme = new Theme(MakeStyles(), key, key, theme.Dark); ThemeProvider.Save(theme, dialog.FileName); Text = string.Format( Resx.StyleDialog_ThemeText, Path.GetFileNameWithoutExtension(dialog.FileName)); } } }
public override async Task Execute(params object[] args) { using (var one = new OneNote(out var page, out _)) { var color = page.GetPageColor(out _, out _); using (var dialog = new ChangePageColorDialog(color)) { if (dialog.ShowDialog(owner) != DialogResult.OK) { return; } UpdatePageColor(page, dialog.PageColor); ThemeProvider.RecordTheme(dialog.ThemeKey); if (dialog.ApplyStyle) { new ApplyStylesCommand().Apply(page); } } await one.Update(page); } }
public Theme LoadTheme() { var path = Path.Combine(PathFactory.GetAppDataPath(), Resx.ThemesFolder); PathFactory.EnsurePathExists(path); using (var dialog = new OpenFileDialog()) { dialog.DefaultExt = "xml"; dialog.Filter = "Theme files (*.xml)|*.xml|All files (*.*)|*.*"; dialog.Multiselect = false; dialog.Title = "Open Style Theme"; dialog.ShowHelp = true; // stupid, but this is needed to avoid hang dialog.AutoUpgradeEnabled = true; // simpler UI, faster dialog.InitialDirectory = path; if (dialog.ShowDialog(owner) != DialogResult.OK) { return(null); } var theme = new ThemeProvider(dialog.FileName).Theme; if (theme != null) { var styles = theme.GetStyles(); if (styles.Count > 0) { return(theme); } } UIHelper.ShowError("could not load theme file or them contains no styles"); return(null); } }
private static string WrapInHtmlDocument(string theme, string sourceFilePath, string html, string title, bool disableHeaderNumbering, string configurableParametersFileName, ref List <ProcessorError> errors) { var layout = ThemeProvider.GetContent(theme); IAfterConversionToHtmlStep[] steps = { new BodyPlaceholder(html), // should be the first step new CssPlaceholder(theme), new AfterConversionToHtml.TitlePlaceholder(title), new DatePlaceholder(), new AuthorLine(), new HeaderNumbering(!disableHeaderNumbering), new IconBlocks(), new IconLists(), new SetCorrectChaptersLinkTitle(sourceFilePath), new EmbedImages(sourceFilePath), new ConfigurablePlaceholders(sourceFilePath, configurableParametersFileName) }; var result = layout; foreach (var step in steps) { var stepResult = step.Apply(result); errors.AddRange(stepResult.Errors); result = stepResult.ResultingHtml; } return(result); }
public virtual ActionResult AcsSettings(AccessControlServiceSettings acsSettings) { ViewBag.Themes = ThemeProvider.GetThemes(); ViewBag.FileRepositories = FileRepositoriesInfo().Keys; if (!ModelState.IsValid) { ModelState.AddModelError("", "Your settings could not be saved. Please fix the errors shown below."); return(View(acsSettings)); } // Special validation that the AudienceUris are indeed Uris. Only save the ones that are. acsSettings.AudienceUris = string.Join( Constants.Strings.NewLine, acsSettings .AudienceUris .Split(Constants.Chars.NewLine, Constants.Chars.Space) .Where(a => { Uri uri; return(Uri.TryCreate(a, UriKind.Absolute, out uri)); }) .Select(a => new Uri(a))); SettingsProvider.SaveSettings(acsSettings); FederatedAuthenticationConfigurator.InitiateFederatedAuthentication(acsSettings); return(RedirectToAction("AcsSettings").AndFlash("Your changes have been saved")); }
public override IXrmToolBoxPluginControl GetControl() { ExcelPackage.LicenseContext = LicenseContext.NonCommercial; var themeProvider = new ThemeProvider(); return(new MainView(themeProvider).SetIcon()); }
private string GetTranspiledCss() { var scss = ThemeProvider.GetScss(_theme); var css = SharpScss.Scss.ConvertToCss(scss); return(css.Css); }
private static Style GetStyle() { Style style = null; // use custom Caption style if it exists var styles = new ThemeProvider().Theme.GetStyles(); if (styles?.Count > 0) { style = styles.FirstOrDefault(s => s.Name.Equals("Caption")); } // otherwise use default style if (style == null) { style = new Style { Color = "#5B9BD5", // close to CornflowerBlue FontSize = "10pt", IsBold = true }; } return(style); }
public async Task Load_Manifest_Json_Type_Test() { // Arrange Mock <ISiteManifestRepository> mockSiteManfiestRepository = new Mock <ISiteManifestRepository>(); mockSiteManfiestRepository .Setup(a => a.GetSiteManifestsAsync(It.IsAny <IEnumerable <string> >(), It.IsAny <string>())) .Returns(Task.FromResult(new List <LetPortal.CMS.Core.Entities.SiteManifest> { new LetPortal.CMS.Core.Entities.SiteManifest { Key = "CompanyLink", ConfigurableValue = ConvertUtil.SerializeObject(new LinkModel { }), EditorType = LetPortal.CMS.Core.Entities.ManifestEditorType.Textbox } })); ThemeProvider themeProvider = new ThemeProvider(mockSiteManfiestRepository.Object, null); // Act JsonModel result = await themeProvider.LoadAsync(new JsonModel(), "1"); // Assert Assert.NotNull(result.CompanyLink); }
public override async Task Execute(params object[] args) { Color pageColor; using (var one = new OneNote(out var page, out _)) { pageColor = page.GetPageColor(out _, out var black); if (black) { // if Office Black theme, translate to softer Black Shadow pageColor = BasicColors.BlackSmoke; } } var theme = new ThemeProvider().Theme; using (var dialog = new StyleDialog(theme, pageColor)) { if (dialog.ShowDialog(owner) == DialogResult.OK) { ThemeProvider.Save(dialog.Theme); ThemeProvider.RecordTheme(dialog.Theme.Key); ribbon.Invalidate(); } } ribbon.Invalidate(); await Task.Yield(); }
public virtual ActionResult AcsSettings() { var settings = SettingsProvider.GetSettings <AccessControlServiceSettings>(); ViewBag.Themes = ThemeProvider.GetThemes(); ViewBag.FileRepositories = FileRepositoriesInfo().Keys; return(View(settings)); }
public virtual ActionResult Settings() { var settings = SettingsProvider.GetSettings <FunnelWebSettings>(); ViewBag.Themes = ThemeProvider.GetThemes(); ViewBag.FileRepositories = FileRepositoriesInfo().Keys; return(View(settings)); }
public PymeAdminService(PymeProvider pymeManager, ImageProvider imageManager, ThemeProvider themeManager, ISettingStore settingStore, IThemeClientService themeClientService) { _pymeManager = pymeManager; _imageManager = imageManager; _themeManager = themeManager; _settingStore = settingStore; _themeClientService = themeClientService; _server = HttpContext.Current.Server; }
public SkinBuilder (ThemeProvider provider, Control control, ControlBuilder skinBuilder, string themePath) { //this.provider = provider; this.control = control; //this.skinBuilder = skinBuilder; //this.themePath = themePath; }
public SkinBuilder(ThemeProvider provider, Control control, ControlBuilder skinBuilder, string themePath) { //this.provider = provider; this.control = control; //this.skinBuilder = skinBuilder; //this.themePath = themePath; }
private static string GetStyle(string themeName) { var theme = ThemeProvider.GetInstance().GetTheme(themeName); if (theme == null) { return(string.Empty); } return(theme.Style); }
public void TestDefaults() { var tp = ThemeProvider.Deserialize("something wrong"); var themes = tp.GetThemes(); Assert.AreEqual(3, themes.Count()); var defTheme = themes.First(); Assert.AreEqual("Light", defTheme.Name); }
public override async Task Execute(params object[] args) { var theme = LoadTheme(); if (theme != null) { ThemeProvider.RecordTheme(theme.Key); ribbon.Invalidate(); } await Task.Yield(); }
public virtual ActionResult Settings(FunnelWebSettings settings) { ViewBag.Themes = ThemeProvider.GetThemes(); ViewBag.FileRepositories = FileRepositoriesInfo().Keys; if (!ModelState.IsValid) { ModelState.AddModelError("", "Your settings could not be saved. Please fix the errors shown below."); return(View(settings)); } SettingsProvider.SaveSettings(settings); return(RedirectToAction("Settings", "Admin").AndFlash("Your changes have been saved")); }
public TenantAppService( TenantManager tenantManager, RoleManager roleManager, EditionManager editionManager, IAbpZeroDbMigrator abpZeroDbMigrator, ISettingStore settingStore, PymeProvider pymeProvider, ThemeProvider themeProvider) { _tenantManager = tenantManager; _roleManager = roleManager; _editionManager = editionManager; _abpZeroDbMigrator = abpZeroDbMigrator; _settingStore = settingStore; _pymeProvider = pymeProvider; _themeProvider = themeProvider; }
public static async Task ConvertHtmlTPdf(string theme, string html, string baseDirectory, string sourceFilePath, string targetFilePath, string title, DateTime?ignoreGitCommitsSince) { var settings = ThemeProvider.GetOptions(theme); var pdfOptions = new PdfOptions { FooterHtml = ReplacePlaceholders(theme, ThemeProvider.GetFooter(theme), sourceFilePath, title, ignoreGitCommitsSince), HeaderHtml = ReplacePlaceholders(theme, ThemeProvider.GetHeader(theme), sourceFilePath, title, ignoreGitCommitsSince), FooterHeight = settings.Pdf.FooterHeight, HeaderHeight = settings.Pdf.HeaderHeight }; var pdfer = new AdliancePdfer(new AdliancePdferSettings()); var pdf = await pdfer.HtmlToPdf(html, pdfOptions); await File.WriteAllBytesAsync(targetFilePath, pdf); }
public void TestAddAndSerialize() { var tp = ThemeProvider.Deserialize("something wrong"); tp.AddTheme("new"); var themes = tp.GetThemes(); Assert.AreEqual(4, themes.Count()); var serialized = tp.Serialize(); var ntp = ThemeProvider.Deserialize(serialized); Assert.AreEqual(4, ntp.GetThemes().Count()); var serialized2 = ntp.Serialize(); Assert.AreEqual(serialized, serialized2); }
private bool ApplyCurrentTheme() { var styles = new ThemeProvider().Theme.GetStyles(); if (ApplyStyles(styles)) { // lists require some inline styling ApplyToLists(styles); if (page.GetPageColor(out _, out _).GetBrightness() < 0.5) { // hyperlinks require some inline styling ApplyToHyperlinks(); } return(true); } return(false); }
public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { ThemeProvider themeProvider = null; if (context != null) { Control instance = context.Instance as Control; if ((instance != null) && (instance.Site != null)) { IThemeResolutionService service = (IThemeResolutionService)instance.Site.GetService(typeof(IThemeResolutionService)); if (service != null) { themeProvider = service.GetThemeProvider(); if (themeProvider == null) { themeProvider = service.GetStylesheetThemeProvider(); } } } } return(themeProvider != null); }
private async Task RemoveSpacing() { using (var one = new OneNote(out var page, out var ns)) { logger.StartClock(); var elements = page.Root.Descendants(page.Namespace + "OE") .Where(e => e.Attribute("spaceBefore") != null || e.Attribute("spaceAfter") != null || e.Attribute("spaceBetween") != null) .ToList(); page.GetTextCursor(); if (page.SelectionScope != SelectionScope.Empty) { elements = elements.Where(e => e.Attribute("selected") != null).ToList(); } if (elements.Count == 0) { logger.StopClock(); return; } var quickStyles = page.GetQuickStyles() .Where(s => s.StyleType == StyleType.Heading); var customStyles = new ThemeProvider().Theme.GetStyles() .Where(e => e.StyleType == StyleType.Heading) .ToList(); var modified = false; foreach (var element in elements) { // is this a known Heading style? var attr = element.Attribute("quickStyleIndex"); if (attr != null) { var index = int.Parse(attr.Value, CultureInfo.InvariantCulture); if (quickStyles.Any(s => s.Index == index)) { if (includeHeadings) { modified |= CleanElement(element); } continue; } } // is this a custom Heading style? var style = new Style(element.CollectStyleProperties(true)); if (customStyles.Any(s => s.Equals(style))) { if (includeHeadings) { modified |= CleanElement(element); } continue; } // normal paragraph modified |= CleanElement(element); } logger.WriteTime("removed spacing, now saving..."); if (modified) { await one.Update(page); } } }
// Constructors public SkinBuilder(ThemeProvider provider, Control control, ControlBuilder skinBuilder, string themePath) { }
public ThemeAdminService(ThemeProvider themeManager, ISettingStore settingStore) { _themeManager = themeManager; _settingStore = settingStore; _server = HttpContext.Current.Server; }
/* * Find consecutive empty lines that need to be collapsed... */ public bool CollapseEmptyLines(Page page, XNamespace ns) { var elements = (from e in page.Root.Descendants(ns + "OE") let t = e.Elements().FirstOrDefault() where (t?.Name.LocalName == "T") && (t.TextValue().Trim().Length == 0) select e) .ToList(); if (elements?.Any() != true) { return(false); } var modified = false; var quickStyles = page.GetQuickStyles() .Where(s => s.StyleType == StyleType.Heading); var customStyles = new ThemeProvider().Theme.GetStyles() .Where(e => e.StyleType == StyleType.Heading) .ToList(); foreach (var element in elements) { // is this a known Heading style? var attr = element.Attribute("quickStyleIndex"); if (attr != null) { var index = int.Parse(attr.Value, CultureInfo.InvariantCulture); if (quickStyles.Any(s => s.Index == index)) { // remove empty standard heading element.Remove(); modified = true; continue; } } // is this a custom Heading style? var style = new Style(element.CollectStyleProperties(true)); if (customStyles.Any(s => s.Equals(style))) { // remove empty custom heading element.Remove(); modified = true; continue; } // is this an empty paragraph preceded by an empty paragraph? if (element.PreviousNode != null && element.PreviousNode.NodeType == System.Xml.XmlNodeType.Element) { var prev = element.PreviousNode as XElement; if (prev.Name.LocalName == "OE") { var t = prev.Elements().Last(); if (t.Name.LocalName == "T" && t.TextValue().Trim().Length == 0) { // remove consecutive empty line prev.Remove(); modified = true; } } } } return(modified); }