private static void BuildNames() { foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type type in a.GetTypes()) { if (type.Namespace != null) { if (IsStyleType(type)) { string s = type.Name.ToLower(); object[] attr = type.GetCustomAttributes(typeof(SynonymAttribute), false); if (attr.Length == 1) { s = ((SynonymAttribute)attr[0]).Name; } StyleNames.Add(s, type); } var markupElementAttribute = type.GetCustomAttribute <MarkupElementAttribute>(false); if (markupElementAttribute != null && type.GetInterfaces().Contains(typeof(IStyledObject))) { string s = type.Name.ToLower(); object[] attr = type.GetCustomAttributes(typeof(SynonymAttribute), false); if (attr.Length == 1) { s = ((SynonymAttribute)attr[0]).Name; } TagNames.Add(s, type); } } } } }
private Paragraph CreateParagraph(Document doc, StyleNames styleName = StyleNames.None) { var section = new Section(doc); _ = doc.AppendChild(section); var body = new Body(doc); _ = section.AppendChild(body); var paragraph = new Paragraph(doc); _ = body.AppendChild(paragraph); switch (styleName) { case StyleNames.Heading1: _ = paragraph.ParagraphFormat.StyleName = "Heading 1"; break; case StyleNames.Quote: _ = paragraph.ParagraphFormat.StyleName = "Quote"; break; case StyleNames.Heading2: _ = paragraph.ParagraphFormat.StyleName = "Heading 2"; break; default: break; } return(paragraph); }
private void StyleSelectionChanged(string name) { Logger.Info("Selection changed to {0}", name); if (StyleNames.Contains(name)) { LoadStyleButton.IsEnabled = true; DeleteStyleButton.IsEnabled = true; } else { LoadStyleButton.IsEnabled = false; DeleteStyleButton.IsEnabled = false; } }
/// <summary> /// Change style /// </summary> /// <param name="styleName">Style name</param> private void ChangeStyle(StyleNames styleName) { switch (styleName) { case StyleNames.Default: ResourcesChanger.ChangeResource(DefaultStyle); break; case StyleNames.Dark: ResourcesChanger.ChangeResource(DarkStyle); break; case StyleNames.Animated: ResourcesChanger.ChangeResource(AnimatedStyle); break; default: throw new ArgumentOutOfRangeException(nameof(styleName), styleName, null); } }