public static System.Windows.TextAlignment AttachmentPointToAlign(MTextAttachmentPoint Attach) { System.Windows.TextAlignment hAlign = new System.Windows.TextAlignment(); List <int> list = new List <int> { 2, 5, 8 }; if (list.Contains((int)Attach)) { hAlign = System.Windows.TextAlignment.Center; } list = new List <int> { 1, 4, 7 }; if (list.Contains((int)Attach)) { hAlign = System.Windows.TextAlignment.Left; } list = new List <int> { 3, 6, 9 }; if (list.Contains((int)Attach)) { hAlign = System.Windows.TextAlignment.Right; } return(hAlign); }
public static Alignment ToXwtAlignment(this SW.TextAlignment alignment) { switch (alignment) { case SW.TextAlignment.Left: return(Alignment.Start); case SW.TextAlignment.Center: return(Alignment.Center); default: return(Alignment.End); } }
public static TextAlignment ToEto(this sw.TextAlignment align) { switch (align) { case sw.TextAlignment.Left: return(TextAlignment.Left); case sw.TextAlignment.Right: return(TextAlignment.Right); case sw.TextAlignment.Center: return(TextAlignment.Center); case sw.TextAlignment.Justify: return(TextAlignment.Left); default: throw new NotSupportedException(); } }
public static TTextBlock TextAlignment <TTextBlock>(this TTextBlock @this, TA textAlignment) where TTextBlock : TextBlock { @this.TextAlignment = textAlignment; return(@this); }
internal static Style ToWPFStyle(this XElement elem) { Style style = new Style(); if (elem != null) { var setters = elem.Descendants().Select(elm => { Setter setter = null; if (elm.Name == w + "left" || elm.Name == w + "right" || elm.Name == w + "top" || elm.Name == w + "bottom") { ThicknessConverter tk = new ThicknessConverter(); Thickness thinkness = (Thickness)tk.ConvertFrom(elm.Attribute(w + "sz").Value); BrushConverter bc = new BrushConverter(); Brush color = (Brush)bc.ConvertFrom(string.Format("#{0}", elm.Attribute(w + "color").Value)); setter = new Setter(Block.BorderThicknessProperty, thinkness); //style.Setters.Add(new Setter(Block.BorderBrushProperty,color)); } else if (elm.Name == w + "rFonts") { FontFamilyConverter ffc = new FontFamilyConverter(); setter = new Setter(TextElement.FontFamilyProperty, ffc.ConvertFrom(elm.Attribute(w + "ascii").Value)); } else if (elm.Name == w + "b") { setter = new Setter(TextElement.FontWeightProperty, FontWeights.Bold); } else if (elm.Name == w + "color") { BrushConverter bc = new BrushConverter(); setter = new Setter(TextElement.ForegroundProperty, bc.ConvertFrom(string.Format("#{0}", elm.Attribute(w_val).Value))); } else if (elm.Name == w + "em" || elm.Name == w + "i") { setter = new Setter(TextElement.FontStyleProperty, FontStyles.Italic); } else if (elm.Name == w + "strike") { setter = new Setter(Inline.TextDecorationsProperty, TextDecorations.Strikethrough); } else if (elm.Name == w + "sz") { FontSizeConverter fsc = new FontSizeConverter(); setter = new Setter(TextElement.FontSizeProperty, fsc.ConvertFrom(elm.Attribute(w_val).Value)); } else if (elm.Name == w + "ilvl") { Console.WriteLine(elm.Attribute(w_val)); } else if (elm.Name == w + "numPr") { Console.WriteLine(elm.Value); } else if (elm.Name == w + "numId") { Console.WriteLine(elm.Attribute(w_val)); int value = int.Parse(elm.Attribute(w + "val").Value); if (value == 2) { setter = new Setter(List.MarkerStyleProperty, TextMarkerStyle.Decimal); } } else if (elm.Name == w + "u") { setter = new Setter(Inline.TextDecorationsProperty, TextDecorations.Underline); } else if (elm.Name == w + "jc") { TextAlignment textAlignment = new TextAlignment(); string value = elm.Attribute(w + "val").Value; switch (value) { case "left": textAlignment = TextAlignment.Left; break; case "center": textAlignment = TextAlignment.Center; break; case "right": textAlignment = TextAlignment.Right; break; case "justify": textAlignment = TextAlignment.Justify; break; } setter = new Setter(Block.TextAlignmentProperty, textAlignment); } else { Console.WriteLine(elm.Name); } return(setter); }); foreach (SetterBase setter in setters) { if (setter != null) { style.Setters.Add(setter); } } } return(style); }