Beispiel #1
0
 public QuickStyleWrapper(QuickStyle model) : base(model)
 {
 }
Beispiel #2
0
        protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore)
        {
            var parentNode = (INode)parent;

            // required attributes

            uint   index    = uint.Parse(reader.GetAttribute(IndexAttributeName));
            string name     = reader.GetAttribute(NameAttributeName);
            string fontName = reader.GetAttribute(FontNameAttributeName);
            double fontSize = double.Parse(reader.GetAttribute(FontSizeAttributeName));

            var deserializedObject = new QuickStyle(
                index,
                name,
                fontName,
                fontSize,
                parentNode.Depth + 1,
                parentNode);

            // optional attributes

            string fontColor = reader.GetAttribute(FontColorAttributeName);

            if (!string.IsNullOrEmpty(fontColor))
            {
                deserializedObject.FontColor = fontColor;
            }

            string highlightColor = reader.GetAttribute(HighlightColorAttributeName);

            if (!string.IsNullOrEmpty(highlightColor))
            {
                deserializedObject.HighlightColor = highlightColor;
            }

            string fontSizeString = reader.GetAttribute(FontSizeAttributeName);

            if (!string.IsNullOrEmpty(fontSizeString))
            {
                deserializedObject.FontSize = double.Parse(fontSizeString);
            }

            string boldString = reader.GetAttribute(BoldAttributeName);

            if (!string.IsNullOrEmpty(boldString))
            {
                deserializedObject.Bold = bool.Parse(boldString);
            }

            string italicString = reader.GetAttribute(ItalicAttributeName);

            if (!string.IsNullOrEmpty(italicString))
            {
                deserializedObject.Italic = bool.Parse(italicString);
            }

            string underlineString = reader.GetAttribute(UnderlineAttributeName);

            if (!string.IsNullOrEmpty(underlineString))
            {
                deserializedObject.Underline = bool.Parse(underlineString);
            }

            string strikethroughString = reader.GetAttribute(StrikethroughAttributeName);

            if (!string.IsNullOrEmpty(strikethroughString))
            {
                deserializedObject.Strikethrough = bool.Parse(strikethroughString);
            }

            string superscriptString = reader.GetAttribute(SuperscriptAttributeName);

            if (!string.IsNullOrEmpty(superscriptString))
            {
                deserializedObject.Superscript = bool.Parse(superscriptString);
            }

            string subscriptString = reader.GetAttribute(SubscriptAttributeName);

            if (!string.IsNullOrEmpty(subscriptString))
            {
                deserializedObject.Subscript = bool.Parse(subscriptString);
            }

            string spaceBeforeString = reader.GetAttribute(SpaceBeforeAttributeName);

            if (!string.IsNullOrEmpty(spaceBeforeString))
            {
                deserializedObject.SpaceBefore = float.Parse(spaceBeforeString);
            }

            string spaceAfterString = reader.GetAttribute(SpaceAfterAttributeName);

            if (!string.IsNullOrEmpty(spaceAfterString))
            {
                deserializedObject.SpaceAfter = float.Parse(spaceAfterString);
            }

            parentNode.Children.Add(deserializedObject);

            patchStore.AddPatchOperation(node =>
            {
                var outlineElement = node as OutlineElement;
                if (outlineElement != null && outlineElement.QuickStyleIndex != -1 && outlineElement.QuickStyleIndex == index)
                {
                    outlineElement.QuickStyle      = deserializedObject;
                    outlineElement.QuickStyleIndex = -1;
                }
            });

            return(true);
        }