private static void UpdateStyle(this Pen pen, Word.BorderValues borderValue) { switch (borderValue) { case Word.BorderValues.Nil: case Word.BorderValues.None: pen.Color = Color.Transparent; pen.Width = 0; break; case Word.BorderValues.Single: case Word.BorderValues.Thick: pen.DashStyle = DashStyle.Solid; break; case Word.BorderValues.Dotted: pen.DashStyle = DashStyle.Dot; break; case Word.BorderValues.DashSmallGap: case Word.BorderValues.Dashed: pen.DashStyle = DashStyle.Dash; break; case Word.BorderValues.DotDash: pen.DashStyle = DashStyle.DashDot; break; case Word.BorderValues.DotDotDash: pen.DashStyle = DashStyle.DashDotDot; break; } }
internal static void TestBorder <T>(T border, Word.BorderValues val, string color, UInt32 width) where T : Word.BorderType { Assert.AreEqual(border.Val.Value, val); Assert.AreEqual(border.Color.Value, color); Assert.AreEqual(border.Size, width); }
public static SideBorder Parse(String str) { if (str == null) { return(SideBorder.Empty); } // The properties of a border that can be set, are (in order): border-width, border-style, and border-color. // It does not matter if one of the values above are missing, e.g. border:solid #ff0000; is allowed. // The main problem for parsing this attribute is that the browsers allow any permutation of the values... meaning more coding :( // http://www.w3schools.com/cssref/pr_border.asp List <String> borderParts = new List <String>(str.Split(HttpUtility.WhiteSpaces, StringSplitOptions.RemoveEmptyEntries)); if (borderParts.Count == 0) { return(SideBorder.Empty); } // Initialize default values Unit borderWidth = Unit.Empty; HtmlColor borderColor = HtmlColor.Empty; w.BorderValues borderStyle = w.BorderValues.Nil; // Now try to guess the values with their permutation // handle border style for (int i = 0; i < borderParts.Count; i++) { borderStyle = Converter.ToBorderStyle(borderParts[i]); if (borderStyle != w.BorderValues.Nil) { borderParts.RemoveAt(i); // no need to process this part anymore break; } } for (int i = 0; i < borderParts.Count; i++) { borderWidth = ParseWidth(borderParts[i]); if (borderWidth.IsValid) { borderParts.RemoveAt(i); // no need to process this part anymore break; } } // find width if (borderParts.Count > 0) { borderColor = HtmlColor.Parse(borderParts[0]); } // returns the instance with default value if needed. // These value are the ones used by the browser, i.e: solid 3px black return(new SideBorder( borderStyle == w.BorderValues.Nil? w.BorderValues.Single : borderStyle, borderColor.IsEmpty? HtmlColor.Black : borderColor, borderWidth.IsFixed? borderWidth : new Unit(UnitMetric.Pixel, 4))); }
public SideBorder(w.BorderValues style, HtmlColor color, Unit size) { this.style = style; this.color = color; this.size = size; }
public SideBorder(w.BorderValues style, Color color, Unit size) { this.style = style; this.color = color; this.size = size; }