/// <summary> /// Gets the font description from this selector or the parent. /// </summary> /// <returns></returns> public FontDescription GetFontDescription() { // If we have a value, then use that directly. if (FontDescription != null) { return(FontDescription); } // If we have a ParentBlockStyle, then cascade up into it. if (ParentBlockStyle != null) { return(ParentBlockStyle.GetFontDescription()); } // Otherwise, return a sane default. return(FontDescriptionCache.GetFontDescription("Sans 12")); }
/// <summary> /// Configures the theme for all the elements used in the demo. /// </summary> private void SetupTheme() { // Grab the theme. Theme theme = editorView.Theme; // Set up the indicator styles. theme.IndicatorStyles["Error"] = new IndicatorStyle( "Error", 100, new Color(1, 0, 0)); theme.IndicatorStyles["Warning"] = new IndicatorStyle( "Warning", 10, new Color(1, 165 / 255.0, 0)); theme.IndicatorRenderStyle = IndicatorRenderStyle.Ratio; theme.IndicatorPixelHeight = 2; theme.IndicatorRatioPixelGap = 1; var indicatorBackgroundStyle = new RegionBlockStyle(); indicatorBackgroundStyle.BackgroundColor = new Color(1, 0.9, 1); //indicatorBackgroundStyle.Borders.SetBorder(new Border(1, new Color(0.5, 0, 0))); theme.RegionStyles[IndicatorView.BackgroundRegionName] = indicatorBackgroundStyle; var indicatorVisibleStyle = new RegionBlockStyle(); indicatorVisibleStyle.BackgroundColor = new Color(1, 1, 0.9); indicatorVisibleStyle.Borders.SetBorder(new Border(1, new Color(0, 0.5, 0))); theme.RegionStyles[IndicatorView.VisibleRegionName] = indicatorVisibleStyle; // Set up the editable text styles. for (var type = DemoLineStyleType.Default; type <= DemoLineStyleType.Break; type++) { // Create a line style for this type. var lineStyle = new LineBlockStyle(theme.TextLineStyle); theme.LineStyles[type.ToString()] = lineStyle; // Custom the style based on type. switch (type) { case DemoLineStyleType.Chapter: lineStyle.FontDescription = FontDescriptionCache.GetFontDescription("Serif Bold 24"); lineStyle.Borders.Bottom = new Border(2, new Color(0, 0, 0)); lineStyle.Margins.Top = 6; lineStyle.Margins.Bottom = 6; break; case DemoLineStyleType.Heading: lineStyle.FontDescription = FontDescriptionCache.GetFontDescription("Sans Bold 18"); lineStyle.Padding.Left = 25; break; case DemoLineStyleType.Borders: lineStyle.Padding.Left = 15; lineStyle.Padding.Right = 15; lineStyle.Margins.Left = 10; lineStyle.Margins.Right = 10; lineStyle.Margins.Top = 10; lineStyle.Margins.Bottom = 10; lineStyle.Borders.Bottom = new Border(5, new Color(1, 0, 0)); lineStyle.Borders.Top = new Border(5, new Color(0, 1, 0)); lineStyle.Borders.Right = new Border(5, new Color(0, 0, 1)); lineStyle.Borders.Left = new Border(5, new Color(1, 0, 1)); break; case DemoLineStyleType.Default: lineStyle.Padding.Left = 50; break; case DemoLineStyleType.Break: lineStyle.Padding.Left = 50; lineStyle.Alignment = Alignment.Center; break; } } // Create the inactive header style. var inactiveHeadingStyle = new LineBlockStyle(theme.LineStyles["Heading"]); inactiveHeadingStyle.ForegroundColor = new Color(0.8, 0.8, 0.8); theme.LineStyles["Inactive Heading"] = inactiveHeadingStyle; }
/// <summary> /// Sets up the theme elements. /// </summary> /// <param name="theme"></param> public static void SetupTheme(Theme theme) { // Set up the indicator elements. SetupThemeIndicators(theme); // Use slightly more muted colors for the current line. theme.RegionStyles["EditorViewCurrentLine"].BackgroundColor = new Color( 1, 1, 1); theme.RegionStyles["EditorViewCurrentWrappedLine"].BackgroundColor = new Color(245 / 255.0, 245 / 255.0, 220 / 255.0); // Set up the paragraph style. var paragraphyStyle = new LineBlockStyle(theme.TextLineStyle) { FontDescription = FontDescriptionCache.GetFontDescription("Source Code Pro 16"), Margins = { Top = 8, Bottom = 8 } }; // Set up the chapter style. var chapterStyle = new LineBlockStyle(theme.TextLineStyle) { FontDescription = FontDescriptionCache.GetFontDescription("Source Code Pro Bold 32"), Margins = { Bottom = 5 }, Borders = { Bottom = new Border(2, new Color(0, 0, 0)) } }; // Set up the scene style. var sceneStyle = new LineBlockStyle(theme.TextLineStyle) { FontDescription = FontDescriptionCache.GetFontDescription("Source Code Pro Italic 24"), ForegroundColor = new Color(.5, .5, .5) }; // Set up the epigraph style. var epigraphStyle = new LineBlockStyle(theme.TextLineStyle) { FontDescription = FontDescriptionCache.GetFontDescription("Source Code Pro 12"), Padding = { Left = 20 } }; // Set up the epigraph attributation style. var epigraphAttributationStyle = new LineBlockStyle(theme.TextLineStyle) { FontDescription = FontDescriptionCache.GetFontDescription("Source Code Pro Italic 12"), Padding = { Left = 20 } }; // Add all the styles into the theme. theme.LineStyles[BlockTypeSupervisor.ParagraphName] = paragraphyStyle; theme.LineStyles[BlockTypeSupervisor.ChapterName] = chapterStyle; theme.LineStyles[BlockTypeSupervisor.SceneName] = sceneStyle; theme.LineStyles[BlockTypeSupervisor.EpigraphName] = epigraphStyle; theme.LineStyles[BlockTypeSupervisor.EpigraphAttributionName] = epigraphAttributationStyle; }