public static DocumentBuilder Run() { return(DocumentBuilder .New() .ApplyStyle(StyleBuilder.New().SetLineSpacing(1.2f)) .AddReceiptSection()); }
public void Change(MouseEventArgs e) { StyleToRender = StyleBuilder.Default("background-color", "red") .AddStyle("border", "1px solid black") .Build(); }
private void FillBoardingTableFirstRow(TableBuilder tableBuilder, BoardingCell bi) { for (int k = 0; k < 2; k++) { var rowBuilder = tableBuilder.AddRow(); if (k == 1) { rowBuilder.ApplyStyle( StyleBuilder.New() .SetBorderBottom(0.5f, Stroke.Solid, Color.Black) .SetPaddingBottom(6) ); } var cellBuilder = rowBuilder.AddCell(); cellBuilder.SetColSpan(2); if (k == 0) { cellBuilder.SetFont(FNT9).AddParagraph(bi.name); } else { if (bi.image != null) { cellBuilder.AddTable(builder => { ImageThenText(builder, bi); }); } else { TextOnly(cellBuilder.AddParagraph(), bi); } } } }
protected virtual IEnumerable <IStyleRule> CreateStyleForListView(StyleBuilder b) { var widgetStyles = b.StyleSystem.StylesFor <WidgetStyleDefinition>(); return(new List <IStyleRule> { b.CreateRule( b.SelectForType("ListView").WithDirectChild(b.SelectForType("ScrollPanel")), b.CreateStyle() .WithBox(widgetStyles.FrameTexture, "UI/ListView/ListFrame", new Insets(10)) .WithValue(widgetStyles.Padding, new Insets(10))), b.CreateRule( b.SelectForType <ListDataItemRenderer>(), b.CreateStyle() .WithBox(widgetStyles.FrameTexture, "UI/ListView/ListRowFrame", new Insets(10)) .WithValue(widgetStyles.Padding, new Insets(10))), b.CreateRule( b.SelectForType <ListDataItemRenderer>() .WithCondition(StyleBuilderExtensions.HasAttribute(nameof(IListDataItemRenderer.Selected), true)), b.CreateStyle() .WithBox(widgetStyles.FrameTexture, "UI/ListView/ListRowFrameSelected", new Insets(10)) .WithValue(widgetStyles.Padding, new Insets(10))), b.CreateRule( b.SelectForType <ListDataItemRenderer>().WithCondition(StyleBuilderExtensions.HasPseudoClass(WidgetPseudoClasses.FocusedPseudoClass)), b.CreateStyle().WithBox(widgetStyles.FocusedOverlayTexture, "UI/ListView/ListRowFrameFocused", new Insets(10))), b.CreateRule( b.SelectForType <ListDataItemRenderer>().WithCondition(StyleBuilderExtensions.HasPseudoClass(WidgetPseudoClasses.HoveredPseudoClass)), b.CreateStyle().WithBox(widgetStyles.HoverOverlayTexture, "UI/ListView/ListRowFrameHover", new Insets(10))) }); }
public void ShouldBuildConditionalInlineStylesFromAttributes() { //arrange var hasBorder = true; var isOnTop = false; var top = 2; var bottom = 10; var left = 4; var right = 20; //act var styleToRender = new StyleBuilder("background-color", "DodgerBlue") .AddStyle("border-width", $"{top}px {right}px {bottom}px {left}px", when: hasBorder) .AddStyle("z-index", "999", when: isOnTop) .AddStyle("z-index", "-1", when: !isOnTop) .AddStyle("padding", "35px") .Build(); IReadOnlyDictionary <string, object> attributes = new Dictionary <string, object> { { "style", styleToRender } }; var classToRender = new StyleBuilder().AddStyleFromAttributes(attributes).Build(); //assert classToRender.Should().Be("background-color:DodgerBlue;border-width:2px 20px 10px 4px;z-index:-1;padding:35px;"); }
public void WriteDescendantRule() { var uiStyle = LayoutTestStyle.Create(); var b = new StyleBuilder(uiStyle.StyleSystem); var widgetStyles = b.StyleSystem.StylesFor <WidgetStyleDefinition>(); var rules = b.CreateRule( b.SelectForType("Button") .WithCondition(StyleBuilderExtensions.HasAttribute("name", "button")) .WithDirectChild(b.SelectForType("IconLabel").WithCondition(StyleBuilderExtensions.HasAttribute("name", "iconlabel"))) .WithDirectChild(b.SelectForType("Label").WithCondition(StyleBuilderExtensions.HasAttribute("name", "label"))), b.CreateStyle().WithBox(widgetStyles.FrameTexture, "texture-on-label")); var styleWriter = uiStyle.StyleSystem.CreateWriter(); var document = styleWriter.Write(new List <IStyleRule> { rules }); var w = new StringWriter(); document.Save(w); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "style-descendand-rule.xml"), w.ToString()); var p = uiStyle.StyleSystem.CreateParser(); var parsed = p.Read(document); parsed.Count.Should().Be(1); parsed[0].Weight.Should().Be(rules.Weight); parsed[0].Selector.ToString().Should().Be(rules.Selector.ToString()); }
public override bool CreatePrintingTable() { int rows = this.GetTotalRows(); int cols = this.GetTotalColumns(); if (rows == 0 || cols == 0) { return(false); } this.PrintingTable = new WebbTable(rows, cols); this.SetValues(); Int32Collection indicators = new Int32Collection(); StyleBuilder.StyleRowsInfo m_StyleInfo = new Styles.StyleBuilder.StyleRowsInfo(indicators, indicators, indicators, false, true); StyleBuilder styleBuilder = new StyleBuilder(); styleBuilder.BuildStyle(this.PrintingTable, m_StyleInfo, null, this.Styles, new Int32Collection()); this.PrintingTable.AutoAdjustSize(this.ExControl.CreateGraphics(), false, true); this.PrintingTable.SetNoWrap(); if (this.AdjustWidth) { this.ApplyColumnWidthStyle(cols); } return(true); }
public void GetDifferenceOfTest() { StyleBuilder Parent = new StyleBuilder() { BackgroundColor = Color.Red, Width = Length.cm(24.50), FontFamiliy = Font.TimesNewRoman, Margin = Length.Percent(50), MarginTop = Length.cm(2.0) }; StyleBuilder Child = new StyleBuilder() { BackgroundColor = Color.Red, Width = Length.cm(2), FontFamiliy = Font.Arial, MarginLeft = Length.mm(32.0) }; StyleBuilder expected = new StyleBuilder() { Width = Length.cm(2), FontFamiliy = Font.Arial, MarginLeft = Length.mm(32.0) }; StyleBuilder actual; actual = StyleBuilder.GetDifferenceOf(Parent, Child); Assert.AreEqual(expected, actual); }
public void WordWrap_SetGet() { var builder = new StyleBuilder(); builder.WordWrap = false; Assert.AreEqual(false, builder.WordWrap.Value); }
public void Color_SetGet() { var builder = new StyleBuilder(); builder.Color = Color.Red; Assert.AreEqual(Color.Red, builder.Color.Value); }
public void FirstLineIndent_SetGet() { var builder = new StyleBuilder(); builder.FirstLineIndent = 10; Assert.AreEqual(10, builder.FirstLineIndent.Value); }
public void RightMargin_SetGet() { var builder = new StyleBuilder(); builder.RightMargin = 10; Assert.AreEqual(10, builder.RightMargin.Value); }
public void ToStyleNoArguments_WhenNoPropertiesAreInherited_ReturnsStyleGeneratedFromProperties() { var builder = new StyleBuilder() { Font = SystemFonts.SmallCaptionFont, Color = Color.Red, TabStopRuler = new PixelTabStopRuler(30, 10), WordWrap = false, LeftMargin = 10, RightMargin = 20, FirstLineIndent = 15 }; var style = builder.ToStyle(); Assert.Multiple(() => { Assert.AreEqual(SystemFonts.SmallCaptionFont, style.Font); Assert.AreEqual(Color.Red, style.Color); Assert.AreEqual(new PixelTabStopRuler(30, 10), style.TabStopRuler); Assert.AreEqual(false, style.WordWrap); Assert.AreEqual(10, style.LeftMargin); Assert.AreEqual(20, style.RightMargin); Assert.AreEqual(15, style.FirstLineIndent); }); }
static TutorialCRunner() { ProjectDir = Directory.GetCurrentDirectory(); KeywordsJsonFile = Path.Combine(ProjectDir, "Content", "tutorialc_keywords.json"); KeywordsJsonContent = File.ReadAllText(KeywordsJsonFile); KeywordsList = JsonConvert.DeserializeObject <List <Keywords> >(KeywordsJsonContent); ImageUrl = Path.Combine(ProjectDir, "images", "customers"); FontBuilder documentFont() => Fonts.Times(12f); FontBuilder italicFont() => documentFont().SetName("Times-Italic"); FontBuilder boldFont() => documentFont().SetName("Times-Bold"); DocumentFont = documentFont(); DocumentFontBold = boldFont(); ItalicFont = italicFont(); ItalicBrownFont = italicFont().SetColor(Color.FromRgba(0.4, 0.3, 0.0)); CodeExamplesStyle = StyleBuilder.New() .SetFont(Fonts.Courier(12f)) .SetBackColor(Color.FromHtml("#F0F0F0")) .SetMarginTop(14f).SetMarginBottom(14f); ColorBackground = Color.FromRgba(201.0 / 255, 107.0 / 255, 20.0 / 255); DocumentFontBoldOrange = boldFont().SetColor(ColorBackground); SmallFont = documentFont().SetSize(10f); DocumentFontBrown = documentFont().SetColor(Color.FromRgba(0.4, 0.3, 0.0)); DocumentFontRedUnderline = boldFont() .SetColor(Color.FromRgba(0.4, 0.3, 0.0)) .SetUnderlineStroke(Stroke.Solid) .SetUnderlineColor(Color.FromRgba(201.0 / 255, 107.0 / 255, 20.0 / 255)); DocumentFontTitleWhite = documentFont().SetSize(16f).SetColor(Color.White); DocumentFontBoldLarge = boldFont().SetSize(16f); HeaderFontBoldLarge = Fonts.Helvetica(15f).SetBold(); PageMargins = new Box(40); }
private void AddOptionsToCell(TableCellBuilder cellBuilder) { AddParagraph(cellBuilder, "Account options", FNT10_5B); var paragraphBuilder = cellBuilder.AddParagraph(); paragraphBuilder .SetUrlStyle( StyleBuilder.New() .SetFontColor(Color.Blue) .SetFontName("Helvetica") .SetFontSize(7f) .SetFontUnderline(Stroke.Solid, Color.Blue) ) .SetFont(FNT7) .AddTextToParagraph( "A check mark in the box indicates you have these convenient services with your account(s). Go to ") .AddUrlToParagraph("https://" + statementInfo.AccountOptions, statementInfo.AccountOptions) .AddTextToParagraph( " or call the number above if you have questions or if you would like to add new services"); Field[] fields = new Field[] { new Field("Business Online Banking", "true"), new Field("Online Statements", "true"), new Field("Business Bill Pay", "true"), new Field("Business Spending Report", "true"), new Field("Overdraft Protection", "true"), }; AddCheckBoxes(cellBuilder, fields); }
public void ShouldAddComplexStyles() { //var td = new StringBuilder(); //if (hasStyle.Font_Underline) td.Append("underline "); //if (hasStyle.Font_Overline) td.Append("overline "); //if (hasStyle.Font_Strikeout) td.Append("line-through"); //bool HasFontUnderline = true; //bool HasOverline = false; //bool HasStrikeout = true; var styleToRender = StyleBuilder.Empty() .AddStyle("text-decoration", v => v .AddValue("underline", true) .AddValue("overline", false) .AddValue("line-through", true), when: true) .AddStyle("z-index", "-1") .Build(); // Double ;; is valid HTML. // The CSS syntax allows for empty declarations, which means that you can add leading and trailing semicolons as you like. For instance, this is valid CSS // .foo { ;;;display:none;;;color:black;;; } // Trimming is possible, but is it worth the operations for a non-issue? styleToRender.Should().Be("text-decoration:underline line-through;z-index:-1;"); }
internal static void BuildHeaderWithBar(RepeatingAreaBuilder builder, float pageWidth) { var tableBuilder = builder.AddTable(); tableBuilder .SetBorder(Stroke.None) .SetWidth(XUnit.FromPercent(100)) .AddColumnPercentToTable("", 50) .AddColumnPercentToTable("", 50); var rowBuilder = tableBuilder.AddRow(); rowBuilder.AddCell() .AddImage(Path.Combine("images", "ra-logo-2x.png"), XSize.FromHeight(120)); rowBuilder.AddCell() .SetHorizontalAlignment(HorizontalAlignment.Right) .AddImage(Path.Combine("images", "ra-barcode.png"), XSize.FromHeight(120)); builder.AddParagraph() .SetAlignment(HorizontalAlignment.Right) .SetUrlStyle( StyleBuilder.New() .SetFont(URL_FONT)) .AddUrlToParagraph("http://www.bestlandlords.com/billing"); builder.AddLine(pageWidth, 1.5f, Stroke.Solid, Color.Gray) .SetMarginTop(5); }
public void Nested_Widgets_Revalidate_Styles() { var style = LayoutTestStyle.Create(); var b = new StyleBuilder(style.StyleSystem); var widgetStyles = b.StyleSystem.StylesFor <TestStyleDefinition>(); style.StyleResolver.StyleRules.Add( b.CreateRule(b.SelectForType <Button>().WithCondition(StyleBuilderExtensions.HasClass("Test")), b.CreateStyle().WithValue(widgetStyles.Inherited, "FromButton-With-Test"))); style.StyleResolver.StyleRules.Add(b.CreateRule(b.SelectForType <Button>(), b.CreateStyle().WithValue(widgetStyles.Inherited, "FromButton"))); var button = new Button(style); style.StyleResolver.AddRoot(button); button.ValidateStyle(); button.Content.Style.GetValue(widgetStyles.Inherited).Should().Be("FromButton"); button.AddStyleClass("Test"); button.ValidateStyle(); button.Style.GetValue(widgetStyles.Inherited).Should().Be("FromButton-With-Test"); button.Content.Style.GetValue(widgetStyles.Inherited).Should().Be("FromButton-With-Test"); button.ValidateStyle(); }
public void GetStyleAtIndex_WhenIndexValid_ReturnsStyleAtIndex() { var document = new SplashDocument(); var style = new StyleBuilder() { Color = Color.Red }.ToStyle(); document.AppendText("some "); using (document.BeginStyle(style)) document.AppendText("text"); document.AppendText("..."); Assert.Multiple(() => { for (int i = 0; i < 5; i++) { Assert.AreEqual(Style.Default, document.GetStyleAtIndex(i)); } for (int i = 5; i < 9; i++) { Assert.AreEqual(style, document.GetStyleAtIndex(i)); } for (int i = 9; i < 12; i++) { Assert.AreEqual(Style.Default, document.GetStyleAtIndex(i)); } }); }
protected virtual IEnumerable <IStyleRule> CreateStyleForButton(StyleBuilder b) { var widgetStyles = b.StyleSystem.StylesFor <WidgetStyleDefinition>(); var textStyles = b.StyleSystem.StylesFor <TextStyleDefinition>(); return(new List <IStyleRule> { b.CreateRule( b.SelectForType <Button>(), b.CreateStyle() .WithValue(widgetStyles.Padding, new Insets(20, 20)) .WithValue(textStyles.Alignment, Alignment.Center) .WithValue(textStyles.TextColor, new Color(224, 224, 224)) .WithBox(widgetStyles.FrameTexture, "UI/Button/ButtonFrame", new Insets(20))), b.CreateRule( b.SelectForType <Button>().WithDirectChild(b.SelectForType <IconLabel>()).WithDirectChild(b.SelectForType <Label>()), b.CreateStyle().WithValue(textStyles.Alignment, Alignment.Center)), b.CreateRule( b.SelectForType <Button>().WithDirectChild(b.SelectForType <IconLabel>()), b.CreateStyle().WithValue(widgetStyles.Padding, new Insets(0))), b.CreateRule( b.SelectForType <Button>().WithCondition(StyleBuilderExtensions.HasPseudoClass(WidgetPseudoClasses.HoveredPseudoClass)), b.CreateStyle().WithBox(widgetStyles.HoverOverlayTexture, "UI/Button/ButtonHover", new Insets(20))), b.CreateRule( b.SelectForType <Button>().WithCondition(StyleBuilderExtensions.HasPseudoClass(WidgetPseudoClasses.FocusedPseudoClass)), b.CreateStyle().WithBox(widgetStyles.FocusedOverlayTexture, "UI/Button/ButtonFocus", new Insets(20))), b.CreateRule( b.SelectForType <Button>().WithCondition(StyleBuilderExtensions.HasPseudoClass(ButtonPseudoClasses.DownPseudoClass)), b.CreateStyle() .WithBox(widgetStyles.FrameTexture, "UI/Button/ButtonFrameDown", new Insets(20)) .WithBox(widgetStyles.FrameOverlayTexture, "UI/Button/ButtonPress", new Insets(20))) }); }
protected virtual IEnumerable <IStyleRule> CreateStyleForTextField(StyleBuilder b) { var widgetStyles = b.StyleSystem.StylesFor <WidgetStyleDefinition>(); var textStyles = b.StyleSystem.StylesFor <TextStyleDefinition>(); return(new List <IStyleRule> { b.CreateRule( b.SelectForType <TextField>(), b.CreateStyle() .WithBox(widgetStyles.FrameTexture, "UI/TextField/TextFieldFrame", new Insets(20)) .WithValue(widgetStyles.Padding, new Insets(15)) .WithFont(textStyles.Font, "Fonts/MediumFont") .WithValue(textStyles.TextColor, Color.White)), b.CreateRule( b.SelectForType <TextField>().WithDirectChild(b.SelectForType("Caret")), b.CreateStyle() .WithValue(widgetStyles.Visibility, Visibility.Collapsed) .WithValue(widgetStyles.Color, Color.White) .WithValue(textStyles.SelectionColor, Color.Gray) .WithValue(textStyles.CaretWidth, 1)), b.CreateRule( b.SelectForType <TextField>() .WithCondition(StyleBuilderExtensions.HasPseudoClass(WidgetPseudoClasses.FocusedPseudoClass)) .WithDirectChild(b.SelectForType("Caret")), b.CreateStyle().WithValue(widgetStyles.Visibility, Visibility.Visible)) }); }
protected virtual IEnumerable <IStyleRule> CreateStyleFor(StyleBuilder b) { var rules = new List <IStyleRule>(); rules.AddRange(CreateStyleForAll(b)); rules.AddRange(CreateStyleForButton(b)); rules.AddRange(CreateStyleForNotebook(b)); rules.AddRange(CreateStyleForProgressBar(b)); rules.AddRange(CreateStyleForRadioButtons(b)); rules.AddRange(CreateStyleForTooltip(b)); rules.AddRange(CreateStyleForTextField(b)); rules.AddRange(CreateStyleForPasswordField(b)); rules.AddRange(CreateStyleForSpinningWheel(b)); rules.AddRange(CreateStyleForSlider(b)); rules.AddRange(CreateStyleForListView(b)); rules.AddRange(CreateStyleForLabel(b)); rules.AddRange(CreateStyleForIconLabel(b)); rules.AddRange(CreateStyleForDropDown(b)); rules.AddRange(CreateStyleForScrollbar(b)); rules.AddRange(CreateStyleForOptionPane(b)); rules.AddRange(CreateStyleForTextArea(b)); rules.AddRange(CreateStyleForCheckBox(b)); rules.AddRange(CreateStyleForGlassPane(b)); rules.AddRange(CreateStyleForSplitter(b)); return(rules); }
public virtual IEnumerable <IStyleRule> LoadRules(IStyleSystem style) { var b = new StyleBuilder(style); var rules = new List <IStyleRule>(); rules.AddRange(CreateStyleFor(b)); return(rules); }
public StyleMap(StyleManager ownerStyleManager, StyleBuilder styleBuilder, RadElement styleRoot) { this.ownerStyleManager = ownerStyleManager; Debug.Assert(styleRoot != null, "The root element can not be null."); this.styleRootElement = styleRoot; this.styleBuilder = styleBuilder; }
public void TestBuildComplexRule() { var b = new StyleBuilder(LayoutTestStyle.CreateStyleSystem()); var step2 = b.SelectForType <Button>().WithDirectChild(b.SelectForType <IconLabel>()).WithDirectChild(b.SelectForType <Label>()); step2.ToString().Should().Be("Button > IconLabel > Label"); }
public void Font_SetGet() { var builder = new StyleBuilder(); builder.Font = SystemFonts.SmallCaptionFont; Assert.AreEqual(SystemFonts.SmallCaptionFont, builder.Font.Value); Assert.Throws <ArgumentNullException>(() => builder.Font = null); }
public void ToStringTest1() { StyleBuilder.StyleKeys Key = StyleBuilder.StyleKeys.background_color; // TODO: Passenden Wert initialisieren string expected = "background-color"; // TODO: Passenden Wert initialisieren string actual; actual = StyleBuilder.ToString(Key); Assert.AreEqual(expected, actual); }
public void TestBuildSimple() { var b = new StyleBuilder(LayoutTestStyle.CreateStyleSystem()); var step2 = b.SelectForType <Button>().WithDirectChild(b.SelectForType <IconLabel>()); step2.Should().BeAssignableTo <DescendantSelector>().Which.Selector.ToString().Should().Be("IconLabel"); step2.Should().BeAssignableTo <DescendantSelector>().Which.AnchestorSelector.ToString().Should().Be("Button"); step2.ToString().Should().Be("Button > IconLabel"); }
public void TabStopRuler_SetGet() { var builder = new StyleBuilder(); var ruler = new PixelTabStopRuler(30, 10); builder.TabStopRuler = ruler; Assert.AreEqual(ruler, builder.TabStopRuler.Value); Assert.Throws <ArgumentNullException>(() => builder.TabStopRuler = null); }
protected virtual IEnumerable <IStyleRule> CreateStyleForNotebook(StyleBuilder b) { var widgetStyles = b.StyleSystem.StylesFor <WidgetStyleDefinition>(); var notebookStyles = b.StyleSystem.StylesFor <NotebookStyleDefinition>(); return(new List <IStyleRule> { b.CreateRule(b.SelectForType <Notebook>(), b.CreateStyle().WithValue(notebookStyles.NotebookTabOverlapY, 15)), b.CreateRule( b.SelectForType <Notebook>().WithDirectChild(b.SelectForType <ScrollPanel>()), b.CreateStyle().WithBox(widgetStyles.FrameTexture, "UI/Notebook/NotebookFrame", new Insets(15)).WithValue(notebookStyles.NotebookTabOverlapY, 5)), b.CreateRule( b.SelectForType <NotebookTabList>(), b.CreateStyle().WithValue(widgetStyles.Padding, new Insets(0, 20, 0, 20)).WithValue(notebookStyles.NotebookTabOverlapX, 15)), b.CreateRule( b.SelectForType <NotebookTab>(), b.CreateStyle() .WithValue(widgetStyles.Padding, new Insets(0, 20, 0, 20)) .WithBox(widgetStyles.FrameTexture, "UI/Notebook/Tab", new Insets(15)) .WithBox(widgetStyles.HoverOverlayTexture, "UI/Notebook/TabHover", new Insets(15))), b.CreateRule( b.SelectForType <NotebookTab>().WithCondition(StyleBuilderExtensions.HasAttribute(nameof(NotebookTab.IsActive), "true")), b.CreateStyle().WithBox(widgetStyles.FrameTexture, "UI/Notebook/ActiveTab", new Insets(15))), b.CreateRule( b.SelectForType <NotebookTab>().WithCondition(StyleBuilderExtensions.HasPseudoClass(WidgetPseudoClasses.FocusedPseudoClass)), b.CreateStyle().WithBox(widgetStyles.FocusedOverlayTexture, "UI/Notebook/TabFocus", new Insets(15))), b.CreateRule( b.SelectForType <NotebookTab>() .WithCondition( StyleBuilderExtensions.HasAttribute(nameof(NotebookTab.IsActive), "true") .And(StyleBuilderExtensions.HasPseudoClass(WidgetPseudoClasses.FocusedPseudoClass))), b.CreateStyle().WithBox(widgetStyles.FocusedOverlayTexture, "UI/Notebook/ActiveTabFocused", new Insets(15))), b.CreateRule( b.SelectForType <Button>().WithCondition(StyleBuilderExtensions.HasClass(NotebookTab.CloseButtonStyleClass)), b.CreateStyle() .WithValue(widgetStyles.Padding, new Insets(0, 20, 0, 20)) .WithBox(widgetStyles.FrameTexture, "UI/Notebook/TabClose", new Insets(15))), b.CreateRule( b.SelectForType <Button>() .WithCondition( StyleBuilderExtensions.HasClass(NotebookTab.CloseButtonStyleClass) .And(StyleBuilderExtensions.HasPseudoClass(WidgetPseudoClasses.HoveredPseudoClass))), b.CreateStyle() .WithValue(widgetStyles.Padding, new Insets(0, 20, 0, 20)) .WithBox(widgetStyles.HoverOverlayTexture, "UI/Notebook/TabCloseHover", new Insets(15))), b.CreateRule( b.SelectForType <Button>() .WithCondition( StyleBuilderExtensions.HasClass(NotebookTab.CloseButtonStyleClass) .And(StyleBuilderExtensions.HasPseudoClass(ButtonPseudoClasses.DownPseudoClass))), b.CreateStyle() .WithValue(widgetStyles.Padding, new Insets(0, 20, 0, 20)) .WithBox(widgetStyles.HoverOverlayTexture, "UI/Notebook/TabCloseDown", new Insets(15))) }); }
public void DefaultConstructor_InheritsAllProperties() { var builder = new StyleBuilder(); Assert.Multiple(() => { Assert.IsTrue(builder.Font.Inherited); Assert.IsTrue(builder.Color.Inherited); Assert.IsTrue(builder.TabStopRuler.Inherited); Assert.IsTrue(builder.WordWrap.Inherited); Assert.IsTrue(builder.LeftMargin.Inherited); Assert.IsTrue(builder.RightMargin.Inherited); Assert.IsTrue(builder.FirstLineIndent.Inherited); }); }
public void StyleBuilderCopyConstructor_WhenStyleIsNotNull_CopiesTheStyle() { var builder1 = new StyleBuilder(Style.Default); var builder2 = new StyleBuilder(builder1); Assert.AreEqual(builder1, builder2, new StructuralEqualityComparer<StyleBuilder>() { x => x.Font, x => x.Color, x => x.TabStopRuler, x => x.WordWrap, x => x.LeftMargin, x => x.RightMargin, x => x.FirstLineIndent }); }
public void StyleCopyConstructor_WhenStyleIsNotNull_CopiesTheStyle() { var style = Style.Default; var builder = new StyleBuilder(style); Assert.Multiple(() => { Assert.AreEqual(style.Font, builder.Font); Assert.AreEqual(style.Color, builder.Color); Assert.AreEqual(style.TabStopRuler, builder.TabStopRuler); Assert.AreEqual(style.WordWrap, builder.WordWrap); Assert.AreEqual(style.LeftMargin, builder.LeftMargin); Assert.AreEqual(style.RightMargin, builder.RightMargin); Assert.AreEqual(style.FirstLineIndent, builder.FirstLineIndent); }); }
public void TabStopRuler_SetGet() { var builder = new StyleBuilder(); var ruler = new PixelTabStopRuler(30, 10); builder.TabStopRuler = ruler; Assert.AreEqual(ruler, builder.TabStopRuler.Value); Assert.Throws<ArgumentNullException>(() => builder.TabStopRuler = null); }
public void BeginStyle_CoalescesEqualStyles() { var document = new SplashDocument(); var style = new StyleBuilder().ToStyle(); // equal to default style document.BeginStyle(style); Assert.AreSame(Style.Default, document.CurrentStyle); document.EndStyle(); Assert.AreSame(Style.Default, document.CurrentStyle); }
public void ToStyle_WhenInheritedStyleIsNotNullAndAllPropertiesAreInherited_ReturnsStyleEqualToInherited() { var builder = new StyleBuilder(); Assert.AreEqual(Style.Default, builder.ToStyle(Style.Default)); }
private void AddPostBodyBlockElementStyle(IHTMLElement parentElement, string elementName, string selectorPrefix, StyleBuilder styleBuilder, string defaultFontSize) { IHTMLElement blockElement = AddPostBodyElementStyle(parentElement, elementName, selectorPrefix, styleBuilder, defaultFontSize, false); string inlineSelector = selectorPrefix != "" ? selectorPrefix + " " + elementName : elementName; AddInlineElementStyles(blockElement, inlineSelector + " ", styleBuilder, defaultFontSize); }
private void AppendBackgroundStyles(IHTMLElement e, StyleBuilder styleBuilder, bool allowImages) { IHTMLElement2 e2 = (IHTMLElement2)e; try { Color c = GetBackgroundColorFromPixel(e); string defaultBackgroundColor = ColorHelper.ColorToString(c); styleBuilder.Append("background-color", defaultBackgroundColor); } catch (Exception) { while (e2 != null) { string bgColor = (string)e2.currentStyle.backgroundColor; if (bgColor != "transparent") { styleBuilder.Append("background-color", bgColor); return; } e2 = (IHTMLElement2)((IHTMLElement)e2).parentElement; } } }
private void AddInlineElementStyles(IHTMLElement parentElement, string selectorPrefix, StyleBuilder styleBuilder, string defaultFontSize) { AddPostBodyElementStyle(parentElement, "a", selectorPrefix, styleBuilder, defaultFontSize, true); AddPostBodyElementStyle(parentElement, "b", selectorPrefix, styleBuilder, defaultFontSize, true); AddPostBodyElementStyle(parentElement, "i", selectorPrefix, styleBuilder, defaultFontSize, true); AddPostBodyElementStyle(parentElement, "strong", selectorPrefix, styleBuilder, defaultFontSize, true); AddPostBodyElementStyle(parentElement, "em", selectorPrefix, styleBuilder, defaultFontSize, true); AddPostBodyElementStyle(parentElement, "span", selectorPrefix, styleBuilder, defaultFontSize, true); AddPostBodyElementStyle(parentElement, "strike", selectorPrefix, styleBuilder, defaultFontSize, true); AddPostBodyElementStyle(parentElement, "u", selectorPrefix, styleBuilder, defaultFontSize, true); AddPostBodyElementStyle(parentElement, "img", selectorPrefix, styleBuilder, defaultFontSize, true); }
private IHTMLElement AddPostBodyElementStyle(IHTMLElement parentElement, string elementName, string selectorPrefix, StyleBuilder styleBuilder, string defaultFontSize, bool includeBorders) { IHTMLDocument2 doc2 = (parentElement.document as IHTMLDocument2); IHTMLElement newElement = doc2.createElement(elementName); (parentElement as IHTMLDOMNode).appendChild((IHTMLDOMNode)newElement); IHTMLElement2 newElement2 = (IHTMLElement2)newElement; try { newElement.innerText = "Hello"; } catch (Exception) { } // some tags don't allow inner text, so just ignore //bug fix: anchors will not properly set their current styles if they do not have an href attribute if (newElement.tagName == "A") newElement.setAttribute("href", "http://www.notarealdomain.com", 0); string fontSize = (string)newElement2.currentStyle.fontSize; if (fontSize == defaultFontSize) { //if the fontSize is the same as the default font, then don't set the font size as //this would cause the font to get reduced/increased by an unexpected %. //This fixes a bug where template editing styles get mucked up by //% values that IE returns as the font size if no explicit font-size is set. //WARNING Be very careful about changing font-size logic in this //class as it needs to be tested against many blog templates. fontSize = null; } AddStyles(newElement, selectorPrefix + elementName.ToLower(CultureInfo.InvariantCulture), styleBuilder, false, true, includeBorders, fontSize); return newElement; }
public unsafe void AppendStuff() { var style1 = new StyleBuilder() { Color = Color.Red }.ToStyle(); var style2 = new StyleBuilder() { LeftMargin = 10, RightMargin = 10 }.ToStyle(); var style3 = new StyleBuilder() { Font = SystemFonts.SmallCaptionFont, Color = Color.Blue }.ToStyle(); var embeddedObject = new EmbeddedImage(new Bitmap(16, 16)); var document = new SplashDocument(); var changedParagraphIndices = new List<int>(); document.ParagraphChanged += (sender, e) => changedParagraphIndices.Add(e.ParagraphIndex); using (document.BeginStyle(style1)) document.AppendText("Some text, lalala.\nMore text."); using (document.BeginStyle(style2)) { document.AppendText("Tab\t.\n"); document.AppendText("\0\r"); // these control characters will be discarded using (document.BeginStyle(style3)) { document.AppendLine(); document.AppendText(""); // to verify that no change event is raised for empty text } document.AppendText("("); document.AppendObject(embeddedObject); document.AppendText(")"); } Assert.Multiple(() => { // Check char content. Assert.AreEqual("Some text, lalala.\nMore text.Tab\t.\n\n( )", document.ToString()); // Check style table. Assert.AreEqual(4, document.StyleCount); Assert.AreEqual(Style.Default, document.LookupStyle(0)); Assert.AreEqual(style1, document.LookupStyle(1)); Assert.AreEqual(style2, document.LookupStyle(2)); Assert.AreEqual(style3, document.LookupStyle(3)); // Check object table. Assert.AreEqual(1, document.ObjectCount); Assert.AreEqual(embeddedObject, document.LookupObject(0)); // Check paragraph table. Assert.AreEqual(4, document.ParagraphCount); Paragraph* paragraphs = document.GetParagraphZero(); Assert.AreEqual(0, paragraphs[0].CharIndex); // "Some text, lalala.\n" Assert.AreEqual(19, paragraphs[0].CharCount); Assert.AreEqual(0, paragraphs[0].RunIndex); Assert.AreEqual(1, paragraphs[0].RunCount); Assert.AreEqual(19, paragraphs[1].CharIndex); // "More text.Tab\t.\n" Assert.AreEqual(16, paragraphs[1].CharCount); Assert.AreEqual(1, paragraphs[1].RunIndex); Assert.AreEqual(4, paragraphs[1].RunCount); Assert.AreEqual(35, paragraphs[2].CharIndex); // "\n" Assert.AreEqual(1, paragraphs[2].CharCount); Assert.AreEqual(5, paragraphs[2].RunIndex); Assert.AreEqual(1, paragraphs[2].RunCount); Assert.AreEqual(36, paragraphs[3].CharIndex); // "( )" Assert.AreEqual(3, paragraphs[3].CharCount); Assert.AreEqual(6, paragraphs[3].RunIndex); Assert.AreEqual(3, paragraphs[3].RunCount); // Check run table. Assert.AreEqual(9, document.RunCount); Run* runs = document.GetRunZero(); Assert.AreEqual(RunKind.Text, runs[0].RunKind); // "Some text, lalala.\n" Assert.AreEqual(19, runs[0].CharCount); Assert.AreEqual(1, runs[0].StyleIndex); Assert.AreEqual(RunKind.Text, runs[1].RunKind); // "More text." Assert.AreEqual(10, runs[1].CharCount); Assert.AreEqual(1, runs[1].StyleIndex); Assert.AreEqual(RunKind.Text, runs[2].RunKind); // "Tab" Assert.AreEqual(3, runs[2].CharCount); Assert.AreEqual(2, runs[2].StyleIndex); Assert.AreEqual(RunKind.Tab, runs[3].RunKind); // "\t" Assert.AreEqual(1, runs[3].CharCount); Assert.AreEqual(2, runs[3].StyleIndex); Assert.AreEqual(RunKind.Text, runs[4].RunKind); // ".\n" Assert.AreEqual(2, runs[4].CharCount); Assert.AreEqual(2, runs[4].StyleIndex); Assert.AreEqual(RunKind.Text, runs[5].RunKind); // "\n" Assert.AreEqual(1, runs[5].CharCount); Assert.AreEqual(3, runs[5].StyleIndex); Assert.AreEqual(RunKind.Text, runs[6].RunKind); // "(" Assert.AreEqual(1, runs[6].CharCount); Assert.AreEqual(2, runs[6].StyleIndex); Assert.AreEqual(RunKind.Object, runs[7].RunKind); // "(" Assert.AreEqual(1, runs[7].CharCount); Assert.AreEqual(2, runs[7].StyleIndex); Assert.AreEqual(0, runs[7].ObjectIndex); Assert.AreEqual(RunKind.Text, runs[8].RunKind); // ")" Assert.AreEqual(1, runs[8].CharCount); Assert.AreEqual(2, runs[8].StyleIndex); // Check that paragraph changed notifications were raised as needed. Assert.AreElementsEqual(new[] { 0, 1, 2, 2, 3, 3, 3 }, changedParagraphIndices); }); }
public void GetStyleAtIndex_WhenIndexValid_ReturnsStyleAtIndex() { var document = new SplashDocument(); var style = new StyleBuilder() { Color = Color.Red }.ToStyle(); document.AppendText("some "); using (document.BeginStyle(style)) document.AppendText("text"); document.AppendText("..."); Assert.Multiple(() => { for (int i = 0; i < 5; i++) Assert.AreEqual(Style.Default, document.GetStyleAtIndex(i)); for (int i = 5; i < 9; i++) Assert.AreEqual(style, document.GetStyleAtIndex(i)); for (int i = 9; i < 12; i++) Assert.AreEqual(Style.Default, document.GetStyleAtIndex(i)); }); }
public void Font_SetGet() { var builder = new StyleBuilder(); builder.Font = SystemFonts.SmallCaptionFont; Assert.AreEqual(SystemFonts.SmallCaptionFont, builder.Font.Value); Assert.Throws<ArgumentNullException>(() => builder.Font = null); }
protected internal override BlogEditingTemplate GenerateBlogTemplate(IHTMLDocument3 doc, IHTMLElement titleElement, IHTMLElement[] allTitleElements, IHTMLElement bodyElement) { CleanupContainingAnchorTag(titleElement); StyleBuilder styleBuilder = new StyleBuilder(); string templateHtml; using (styleBuilder) { string titleTemplateText = WrapInStyledDiv(postTitleClass, BlogEditingTemplate.POST_TITLE_MARKER); AddTitleStyles(titleElement, styleBuilder); string bodyTemplateText = WrapInStyledDiv(postBodyClass, BlogEditingTemplate.POST_BODY_MARKER); AddBodyStyles(bodyElement, styleBuilder); templateHtml = titleTemplateText + bodyTemplateText; } string headHtml = String.Format(CultureInfo.InvariantCulture, "<head><style>{0}</style></head>", styleBuilder.ToString()); templateHtml = String.Format(CultureInfo.InvariantCulture, "<html>{0}<body>{1}</body></html>", headHtml, templateHtml); //prepend the doctype of the document - this prevents styles in the document from rendering improperly string docType = HTMLDocumentHelper.GetSpecialHeaders((IHTMLDocument2)doc).DocType; if (docType != null) templateHtml = docType + "\r\n" + templateHtml; return new BlogEditingTemplate(templateHtml); }
public void ToStyle_WhenInheritedStyleIsNull_Throws() { var builder = new StyleBuilder(); Assert.Throws<ArgumentNullException>(() => builder.ToStyle(null)); }
protected void AddStyles(IHTMLElement e, string selector, StyleBuilder styleBuilder, bool invisible, bool includeBackgroundColor, bool includeBorders, string fontSize) { IHTMLElement2 e2 = (IHTMLElement2)e; IHTMLCurrentStyle currStyle = e2.currentStyle; styleBuilder.Selector = selector; if (fontSize != null) styleBuilder.Append("font-size", fontSize); styleBuilder.Append("font-family", currStyle.fontFamily); styleBuilder.Append("font-weight", currStyle.fontWeight); styleBuilder.Append("font-variant", currStyle.fontVariant); styleBuilder.Append("line-height", currStyle.lineHeight); styleBuilder.Append("text-transform", currStyle.textTransform); styleBuilder.Append("text-decoration", currStyle.textDecoration); styleBuilder.Append("color", currStyle.color); if (includeBackgroundColor) styleBuilder.Append("background-color", currStyle.backgroundColor); styleBuilder.Append("display", currStyle.display); string padding = e2.currentStyle.padding; if (invisible || padding != "auto") styleBuilder.Append("padding", invisible ? "0px" : padding); string margin = e2.currentStyle.margin; if (invisible || margin != "auto") styleBuilder.Append("margin", invisible ? "0px" : margin); if (includeBorders) { styleBuilder.Append("border-top", CreateBorderStyle(currStyle.borderTopWidth, currStyle.borderTopStyle, currStyle.borderTopColor)); styleBuilder.Append("border-right", CreateBorderStyle(currStyle.borderRightWidth, currStyle.borderRightStyle, currStyle.borderRightColor)); styleBuilder.Append("border-bottom", CreateBorderStyle(currStyle.borderBottomWidth, currStyle.borderBottomStyle, currStyle.borderBottomColor)); styleBuilder.Append("border-left", CreateBorderStyle(currStyle.borderLeftWidth, currStyle.borderLeftStyle, currStyle.borderLeftColor)); } }
public void ToStyleNoArguments_WhenAllPropertiesAreInherited_ReturnsStyleEqualToDefault() { var builder = new StyleBuilder(); Assert.AreEqual(Style.Default, builder.ToStyle()); }
protected void AddBodyStyles(IHTMLElement postBodyElement, StyleBuilder styleBuilder) { string selector = "." + postBodyClass; styleBuilder.Selector = selector; string fontSize = (string)((IHTMLElement2)postBodyElement).currentStyle.fontSize; AddStyles(postBodyElement, selector, styleBuilder, false, false, false, fontSize); //set the background color of the post body at the background of the entire body styleBuilder.Selector = "body"; AppendBackgroundStyles(postBodyElement, styleBuilder, false); //set the default font size since this is the size that all %-based font-sizes are rooted from IHTMLElement2 bodyElement2 = (IHTMLElement2)((IHTMLDocument2)postBodyElement.document).body; styleBuilder.Append("font-size", bodyElement2.currentStyle.fontSize); //set the default styles for inline elements for the post body AddInlineElementStyles(postBodyElement, "." + postBodyClass + " ", styleBuilder, fontSize); AddPostBodyBlockElementStyle(postBodyElement, "p", "", styleBuilder, fontSize); AddPostBodyBlockElementStyle(postBodyElement, "h1", "", styleBuilder, fontSize); AddPostBodyBlockElementStyle(postBodyElement, "h2", "", styleBuilder, fontSize); AddPostBodyBlockElementStyle(postBodyElement, "h3", "", styleBuilder, fontSize); AddPostBodyBlockElementStyle(postBodyElement, "h4", "", styleBuilder, fontSize); AddPostBodyBlockElementStyle(postBodyElement, "h5", "", styleBuilder, fontSize); AddPostBodyBlockElementStyle(postBodyElement, "h6", "", styleBuilder, fontSize); AddPostBodyBlockElementStyle(postBodyElement, "blockquote", "", styleBuilder, fontSize); AddPostBodyImageElementStyle(postBodyElement, "", styleBuilder, fontSize); AddPostBodyListStyles(postBodyElement, "ol", "", styleBuilder, fontSize, 3); AddPostBodyListStyles(postBodyElement, "ul", "", styleBuilder, fontSize, 3); }
protected internal override BlogEditingTemplate GenerateBlogTemplate(IHTMLDocument3 doc, IHTMLElement titleElement, IHTMLElement[] allTitleElements, IHTMLElement bodyElement) { // if title is containing with a link then strip the link CleanupContainingAnchorTag(titleElement); string templateHtml = ""; StyleBuilder styleBuilder = new StyleBuilder(); IMarkupServicesRaw rawMarkupServices = doc as IMarkupServicesRaw; MshtmlMarkupServices markupServices = new MshtmlMarkupServices(rawMarkupServices); MarkupPointer startPointer = markupServices.CreateMarkupPointer(titleElement, _ELEMENT_ADJACENCY.ELEM_ADJ_AfterBegin); MarkupPointer endPointer = markupServices.CreateMarkupPointer(bodyElement, _ELEMENT_ADJACENCY.ELEM_ADJ_AfterEnd); MarkupRange range = markupServices.CreateMarkupRange(startPointer, endPointer); IHTMLElement stopElement = range.ParentElement(); IHTMLElement currElement; string titleTemplateText = WrapInHiddenHtml(postTitleClass, BlogEditingTemplate.POST_TITLE_MARKER); AddTitleStyles(titleElement, styleBuilder); currElement = titleElement; while (currElement != null && currElement.sourceIndex != stopElement.sourceIndex) { string className = currElement.tagName + currElement.sourceIndex; titleTemplateText = WriteStartTag(currElement, className) + titleTemplateText + WriteEndTag(currElement); AddFrameStyles(currElement, "." + className, styleBuilder); currElement = currElement.parentElement; } string bodyTemplateText = WrapInHiddenHtml(postBodyClass, BlogEditingTemplate.POST_BODY_MARKER); AddBodyStyles(bodyElement, styleBuilder); currElement = bodyElement; while (currElement != null && currElement.sourceIndex != stopElement.sourceIndex) { string className = currElement.tagName + currElement.sourceIndex; bodyTemplateText = WriteStartTag(currElement, className) + bodyTemplateText + WriteEndTag(currElement); AddFrameStyles(currElement, "." + className, styleBuilder); currElement = currElement.parentElement; } templateHtml = titleTemplateText + bodyTemplateText; currElement = range.ParentElement(); while (currElement != null) { string className = null; if (currElement.tagName == "HTML") { MarkupPointer bodyPointer = markupServices.CreateMarkupPointer(((IHTMLDocument2)doc).body, _ELEMENT_ADJACENCY.ELEM_ADJ_BeforeBegin); MarkupPointer docPointer = markupServices.CreateMarkupPointer(currElement, _ELEMENT_ADJACENCY.ELEM_ADJ_AfterBegin); MarkupRange headRange = markupServices.CreateMarkupRange(docPointer, bodyPointer); IHTMLElement[] elements = headRange.GetTopLevelElements(new IHTMLElementFilter(IsHeadElement)); if (elements.Length > 0) { //string head = elements[0].innerHTML; string head = ""; //string defaultStyles = "<style>p, h1, h2, h3, h4, h5, h6, blockquote, pre{ padding-top: 1px; }</style>"; styleBuilder.Dispose(); head = String.Format(CultureInfo.InvariantCulture, "<head>{0}<style>{1}</style></head>", head, styleBuilder.ToString()); templateHtml = head + templateHtml; } } else { className = currElement.tagName + currElement.sourceIndex; AddFrameStyles(currElement, "." + className, styleBuilder); } templateHtml = WriteStartTag(currElement, className) + templateHtml + WriteEndTag(currElement); currElement = currElement.parentElement; } //prepend the doctype of the document - this prevents styles in the document from rendering improperly string docType = HTMLDocumentHelper.GetSpecialHeaders((IHTMLDocument2)doc).DocType; //string docType = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"[]>"; if (docType != null) templateHtml = docType + "\r\n" + templateHtml; return new BlogEditingTemplate(templateHtml); }
protected void AddTitleStyles(IHTMLElement titleElement, StyleBuilder styleBuilder) { string fontSize = (string)((IHTMLElement2)titleElement).currentStyle.fontSize; AddStyles(titleElement, "." + postTitleClass, styleBuilder, true, false, false, fontSize); //explicitly preserve the background color of the title element just in case the title has //a different background than the postBody element. If we don't do this, we open ourselves //to the possibility of having a title font color that is the same as the body background color, //in which case the title would be invisible while editing. //styleBuilder.Selector = "." + postTitleClass; //AppendBackgroundStyles(titleElement, styleBuilder, false); }
private void AddPostBodyListStyles(IHTMLElement parentElement, string listTag, string selectorPrefix, StyleBuilder styleBuilder, string defaultFontSize, int stopDepth) { IHTMLDocument2 doc2 = (parentElement.document as IHTMLDocument2); IHTMLElement listElement = doc2.createElement(listTag); (parentElement as IHTMLDOMNode).appendChild((IHTMLDOMNode)listElement); styleBuilder.Selector = selectorPrefix + " " + listTag; IHTMLCurrentStyle currStyle = ((IHTMLElement2)listElement).currentStyle; styleBuilder.Append("display", currStyle.display); styleBuilder.Append("padding", currStyle.padding); styleBuilder.Append("margin", currStyle.margin); IHTMLElement listItem = AddPostBodyElementStyle(listElement, "li", selectorPrefix + " " + listTag + " ", styleBuilder, defaultFontSize, false); currStyle = (listItem as IHTMLElement2).currentStyle; styleBuilder.Append("list-style", currStyle.listStyleType); styleBuilder.Append("list-style-image", currStyle.listStyleImage); styleBuilder.Append("list-style-position", currStyle.listStylePosition); if (stopDepth > 1) AddPostBodyListStyles(listItem, listTag, selectorPrefix + " " + listTag + " ", styleBuilder, defaultFontSize, stopDepth - 1); }
public void BeginStyleAndEndStyle_PushAndPopStylesOnStack() { var document = new SplashDocument(); var style1 = new StyleBuilder() { Color = Color.Red }.ToStyle(); var style2 = new StyleBuilder() { Color = Color.Green }.ToStyle(); var style3 = new StyleBuilder() { Color = Color.Blue }.ToStyle(); Assert.AreEqual(Style.Default, document.CurrentStyle); document.BeginStyle(style1); Assert.AreEqual(style1, document.CurrentStyle); document.EndStyle(); Assert.AreEqual(Style.Default, document.CurrentStyle); using (document.BeginStyle(style2)) { Assert.AreEqual(style2, document.CurrentStyle); using (document.BeginStyle(style3)) { Assert.AreEqual(style3, document.CurrentStyle); } Assert.AreEqual(style2, document.CurrentStyle); } Assert.AreEqual(Style.Default, document.CurrentStyle); }
private void AddFrameStyles(IHTMLElement e, string selector, StyleBuilder styleBuilder) { IHTMLElement2 e2 = (IHTMLElement2)e; IHTMLCurrentStyle currStyle = e2.currentStyle; styleBuilder.Selector = selector; //styleBuilder.Append("font-size", currStyle.fontSize); styleBuilder.Append("display", currStyle.display); styleBuilder.Append("padding", currStyle.padding); styleBuilder.Append("margin", currStyle.margin); styleBuilder.Append("width", currStyle.width); styleBuilder.Append("height", currStyle.height); styleBuilder.Append("display", currStyle.display); styleBuilder.Append("background-color", currStyle.backgroundColor); styleBuilder.Append("background-repeat", currStyle.backgroundRepeat); styleBuilder.Append("background-image", currStyle.backgroundImage); styleBuilder.Append("background-position", currStyle.backgroundPositionY + " " + currStyle.backgroundPositionX); styleBuilder.Append("border-top", CreateBorderStyle(currStyle.borderTopWidth, currStyle.borderTopStyle, currStyle.borderTopColor)); styleBuilder.Append("border-right", CreateBorderStyle(currStyle.borderRightWidth, currStyle.borderRightStyle, currStyle.borderRightColor)); styleBuilder.Append("border-bottom", CreateBorderStyle(currStyle.borderBottomWidth, currStyle.borderBottomStyle, currStyle.borderBottomColor)); styleBuilder.Append("border-left", CreateBorderStyle(currStyle.borderLeftWidth, currStyle.borderLeftStyle, currStyle.borderLeftColor)); }
private void AddPostBodyImageElementStyle(IHTMLElement parentElement, string selectorPrefix, StyleBuilder styleBuilder, string defaultFontSize) { IHTMLDocument2 doc2 = (parentElement.document as IHTMLDocument2); IHTMLElement newElement = doc2.createElement("img"); (parentElement as IHTMLDOMNode).appendChild((IHTMLDOMNode)newElement); IHTMLElement2 e2 = (IHTMLElement2)newElement; styleBuilder.Selector = selectorPrefix + " img"; IHTMLCurrentStyle currStyle = e2.currentStyle; styleBuilder.Append("display", currStyle.display); styleBuilder.Append("padding", currStyle.padding); styleBuilder.Append("margin", currStyle.margin); styleBuilder.Append("border-top", CreateBorderStyle(currStyle.borderTopWidth, currStyle.borderTopStyle, currStyle.borderTopColor)); styleBuilder.Append("border-right", CreateBorderStyle(currStyle.borderRightWidth, currStyle.borderRightStyle, currStyle.borderRightColor)); styleBuilder.Append("border-bottom", CreateBorderStyle(currStyle.borderBottomWidth, currStyle.borderBottomStyle, currStyle.borderBottomColor)); styleBuilder.Append("border-left", CreateBorderStyle(currStyle.borderLeftWidth, currStyle.borderLeftStyle, currStyle.borderLeftColor)); }