示例#1
0
        public override void Deserialize(Version documentVersion, XmlElement node)
        {
            base.Deserialize(documentVersion, node);

            BackColor     = ST.DeserializeColor(node, "back_color", BackColor);
            ForeColor     = ST.DeserializeColor(node, "fore_color", ForeColor);
            LineColor     = ST.DeserializeColor(node, "line_color", LineColor);
            BorderColor   = ST.DeserializeColor(node, "border_color", BorderColor);
            Shape         = ST.GetTopicShape(ST.ReadTextNode(node, "shape"), TopicShape.Default);
            RoundRadius   = ST.GetInt(ST.ReadTextNode(node, "round_radius"), TopicStyle.DefaultRoundRadius);
            TextAlignment = ST.GetEnumValue(ST.ReadTextNode(node, "text_align"), HorizontalAlignment.Center);
            FillType      = ST.ReadTextNode(node, "fill_type");

            Padding?padding = ST.GetPadding(ST.ReadTextNode(node, "padding"));

            if (padding.HasValue)
            {
                Padding = padding.Value;
            }
            else
            {
                Padding = new Padding(TopicStyle.DefaultNodePadding);
            }

            XmlElement fontNode = node.SelectSingleNode("font") as XmlElement;

            if (fontNode != null)
            {
                Font = ST.ReadFontNode(fontNode);
            }
        }
示例#2
0
文件: Widget.cs 项目: namit3/BlueMind
        public override void Deserialize(Version documentVersion, XmlElement node)
        {
            //
            if (documentVersion >= Document.DV_3) // 新
            {
                this.Bounds = new Rectangle(
                    ST.GetIntDefault(node.GetAttribute("x")),
                    ST.GetIntDefault(node.GetAttribute("y")),
                    ST.GetIntDefault(node.GetAttribute("width")),
                    ST.GetIntDefault(node.GetAttribute("height")));

                CustomWidth  = ST.GetInt(node.GetAttribute("custom_width"));
                CustomHeight = ST.GetInt(node.GetAttribute("custom_height"));
            }
            else
            {
                CustomWidth  = ST.GetInt(node.GetAttribute("width"));
                CustomHeight = ST.GetInt(node.GetAttribute("height"));
            }

            if (node.HasAttribute("align"))
            {
                Alignment = ST.GetEnumValue <WidgetAlignment>(node.GetAttribute("align"), Alignment);
            }
            Hyperlink    = node.GetAttribute("hyperlink");
            DisplayIndex = ST.GetIntDefault(node.GetAttribute("display_index"));
            Padding      = ST.GetIntDefault(node.GetAttribute("padding"));
            Text         = ST.ReadTextNode(node, "text");
        }
示例#3
0
        public override void Deserialize(Version documentVersion, XmlElement node)
        {
            base.Deserialize(documentVersion, node);

            //FromID = node.GetAttribute("from");
            TargetID = node.GetAttribute("target");
            //LayoutData.CPLength1 = ST.GetInt(node.GetAttribute("cp1_length"), 0);
            //LayoutData.CPAngle1 = ST.GetInt(node.GetAttribute("cp1_angle"), 0);
            LayoutData.CP1 = new BezierControlPoint(
                ST.GetInt(node.GetAttribute("cp1_angle"), 0),
                ST.GetInt(node.GetAttribute("cp1_length"), 0));
            //LayoutData.CPLength2 = ST.GetInt(node.GetAttribute("cp2_length"), 0);
            //LayoutData.CPAngle2 = ST.GetInt(node.GetAttribute("cp2_angle"), 0);
            LayoutData.CP2 = new BezierControlPoint(
                ST.GetInt(node.GetAttribute("cp2_angle"), 0),
                ST.GetInt(node.GetAttribute("cp2_length"), 0));
            Color     = ST.GetColor(node.GetAttribute("color"), Color);
            LineWidth = ST.GetInt(node.GetAttribute("width"), LineWidth);
            LineStyle = ST.GetEnumValue(node.GetAttribute("line_style"), LineStyle);
            Text      = node.GetAttribute("text");
            Hyperlink = node.GetAttribute("hyperlink");

            if (node.HasAttribute("start_cap"))
            {
                int c;
                if (int.TryParse(node.GetAttribute("start_cap"), out c))
                {
                    StartCap = ((LineCap)c).ToLineAnchor();
                }
                else if (documentVersion >= Document.DV_3)
                {
                    StartCap = LineAnchorExtensions.Parse(node.GetAttribute("start_cap"));
                }
            }

            if (node.HasAttribute("end_cap"))
            {
                int c;
                if (int.TryParse(node.GetAttribute("end_cap"), out c))
                {
                    EndCap = ((LineCap)c).ToLineAnchor();
                }
                else if (documentVersion >= Document.DV_3)
                {
                    EndCap = LineAnchorExtensions.Parse(node.GetAttribute("end_cap"));
                }
            }

            if (documentVersion >= Document.DV_3)
            {
                Remark = ST.ReadTextNode(node, "remark");
            }
            else
            {
                Remark = ST.ReadTextNode(node, "description");
            }
        }
示例#4
0
        public override void Deserialize(Version documentVersion, XmlElement node)
        {
            base.Deserialize(documentVersion, node);

            Maximum         = ST.GetInt(node.GetAttribute("max"), Maximum);
            Minimum         = ST.GetInt(node.GetAttribute("min"), Minimum);
            Value           = ST.GetFloat(node.GetAttribute("value"), Value);
            AutoCalculation = ST.GetBool(node.GetAttribute("auto_calculation"), AutoCalculation);
            //Visible = ST.GetBoolean(node.GetAttribute("visible"), Visible);
            ShowText  = ST.GetBool(node.GetAttribute("show_text"), ShowText);
            Color     = ST.GetColor(node.GetAttribute("color"), Color);
            BackColor = ST.GetColor(node.GetAttribute("back_color"), BackColor);
            ForeColor = ST.GetColor(node.GetAttribute("fore_color"), ForeColor);
        }
示例#5
0
 static void ParseInclination(string inclination, out int angle, out int length)
 {
     string[] strs = inclination.Split(';');
     if (strs.Length >= 2)
     {
         angle  = ST.GetInt(strs[0], 0);
         length = ST.GetInt(strs[1], 0);
     }
     else
     {
         angle  = 0;
         length = 0;
     }
 }
示例#6
0
        void NudHour_KeyDown(object sender, KeyEventArgs e)
        {
            if (Status != TimerStatus.Standby || !(sender is NumericUpDown) || e.KeyCode != Keys.Enter)
            {
                return;
            }

            NumericUpDown nud  = (NumericUpDown)sender;
            string        text = nud.Text.Trim();

            if (text == string.Empty)
            {
                nud.Value = 0;
            }
            else
            {
                nud.Value = Math.Max(nud.Minimum, Math.Min(nud.Maximum, ST.GetInt(text, (int)nud.Value)));
            }
            e.SuppressKeyPress = true;
        }
示例#7
0
文件: MindMap.cs 项目: yfarm/Blumind
        void DeserializeMapStyle(XmlElement node)
        {
            BackColor        = ST.DeserializeColor(node, "back_color", BackColor);
            ForeColor        = ST.DeserializeColor(node, "fore_color", ForeColor);
            LineColor        = ST.DeserializeColor(node, "line_color", LineColor);
            BorderColor      = ST.DeserializeColor(node, "border_color", BorderColor);
            NodeBackColor    = ST.DeserializeColor(node, "node_back_color", NodeBackColor);
            NodeForeColor    = ST.DeserializeColor(node, "node_fore_color", NodeForeColor);
            SelectColor      = ST.DeserializeColor(node, "select_color", SelectColor);
            HoverColor       = ST.DeserializeColor(node, "hover_color", HoverColor);
            LinkLineColor    = ST.DeserializeColor(node, "link_line_color", LinkLineColor);
            LayerSpace       = ST.GetInt(ST.ReadTextNode(node, "layer_space"), MindMapStyle.DefaultLayerSpace);
            ItemsSpace       = ST.GetInt(ST.ReadTextNode(node, "items_space"), MindMapStyle.DefaultItemsSpace);
            WidgetMargin     = ST.GetInt(ST.ReadTextNode(node, "widget_margin"), WidgetMargin);
            PictureThumbSize = ST.GetSize(ST.ReadTextNode(node, "picture_thumb_size"), PictureThumbSize);

            var fontNode = node.SelectSingleNode("font") as XmlElement;

            if (fontNode != null)
            {
                Font = ST.ReadFontNode(fontNode);
            }
        }
示例#8
0
        static ChartTheme DeserializeTheme(XmlElement node)
        {
            var theme = new ChartTheme();

            //DeserializeMapStyle(node, theme);
            theme.BackColor     = ST.DeserializeColor(node, "back_color", theme.BackColor);
            theme.ForeColor     = ST.DeserializeColor(node, "fore_color", theme.ForeColor);
            theme.LineColor     = ST.DeserializeColor(node, "line_color", theme.LineColor);
            theme.BorderColor   = ST.DeserializeColor(node, "border_color", theme.BorderColor);
            theme.NodeBackColor = ST.DeserializeColor(node, "node_back_color", theme.NodeBackColor);
            theme.NodeForeColor = ST.DeserializeColor(node, "node_fore_color", theme.NodeForeColor);
            theme.SelectColor   = ST.DeserializeColor(node, "select_color", theme.SelectColor);
            theme.HoverColor    = ST.DeserializeColor(node, "hover_color", theme.HoverColor);
            theme.LinkLineColor = ST.DeserializeColor(node, "link_line_color", theme.LinkLineColor);
            theme.LayerSpace    = ST.GetInt(ST.ReadTextNode(node, "layer_space"), MindMapStyle.DefaultLayerSpace);
            theme.ItemsSpace    = ST.GetInt(ST.ReadTextNode(node, "items_space"), MindMapStyle.DefaultItemsSpace);

            XmlElement fontNode = node.SelectSingleNode("font") as XmlElement;

            if (fontNode != null)
            {
                theme.Font = ST.ReadFontNode(fontNode);
            }

            theme.Name            = node.GetAttribute("name");
            theme.RootBackColor   = ST.DeserializeColor(node, "root_back_color", theme.RootBackColor);
            theme.RootForeColor   = ST.DeserializeColor(node, "root_fore_color", theme.RootForeColor);
            theme.RootBorderColor = ST.DeserializeColor(node, "root_border_color", theme.RootBorderColor);
            theme.Description     = ST.ReadCDataNode(node, "description");
            if (theme.Description == string.Empty)
            {
                theme.Description = ST.ReadTextNode(node, "description");
            }


            return(theme);
        }
示例#9
0
        public override void Deserialize(Version documentVersion, System.Xml.XmlElement node)
        {
            base.Deserialize(documentVersion, node);

            Hyperlink = node.GetAttribute("hyperlink");
            Folded    = ST.GetBoolDefault(node.GetAttribute("folded"));

            //
            if (documentVersion >= Document.DV_3) // 新
            {
                CustomWidth  = ST.GetInt(node.GetAttribute("custom_width"));
                CustomHeight = ST.GetInt(node.GetAttribute("custom_height"));
            }
            else
            {
                CustomWidth  = ST.GetInt(node.GetAttribute("width"));
                CustomHeight = ST.GetInt(node.GetAttribute("height"));
            }

            TextBounds       = ST.GetRectangle(node.GetAttribute("text_b"), TextBounds);
            RemarkIconBounds = ST.GetRectangle(node.GetAttribute("remark_b"), RemarkIconBounds);
            FoldingButton    = ST.GetRectangle(node.GetAttribute("fold_btn_b"), FoldingButton);

            XmlElement styleNode = node.SelectSingleNode("style") as XmlElement;

            if (styleNode != null)
            {
                Style.Deserialize(documentVersion, styleNode);
            }

            //
            var linkNodes = node.SelectNodes("links/link");

            foreach (XmlElement linkNode in linkNodes)
            {
                Link link = new Link();
                link.Deserialize(documentVersion, linkNode);
                Links.Add(link);
            }

            //
            var widgetNodes = node.SelectNodes("widgets/widget");

            foreach (XmlElement widgetNode in widgetNodes)
            {
                var widget = Widget.DeserializeWidget(documentVersion, widgetNode);
                if (widget != null)
                {
                    Widgets.Add(widget);
                }
            }

            //
            XmlNodeList nodes = node.SelectNodes("nodes/node");

            foreach (XmlElement subNode in nodes)
            {
                Topic subTopic = new Topic();
                subTopic.Deserialize(documentVersion, subNode);
                Children.Add(subTopic);
            }

            //
            if (!Children.IsNullOrEmpty())
            {
                XmlNodeList lines = node.SelectNodes("lines/line");
                foreach (XmlElement lineNode in lines)
                {
                    var line = new TopicLine();
                    line.Deserialize(documentVersion, lineNode);

                    var targetID = lineNode.GetAttribute("target");
                    var target   = Children.Find(c => StringComparer.OrdinalIgnoreCase.Equals(c.ID, targetID));
                    if (target != null)
                    {
                        line.SetTarget(target);
                        Lines.Add(line);
                    }
                }
            }

            //
        }
示例#10
0
        static Topic LoadNodes(XmlElement xmlNode)
        {
            if (xmlNode == null || xmlNode.Name != "node")
            {
                return(null);
            }

            // topic
            Topic topic = new Topic();

            topic.Text      = xmlNode.GetAttribute("TEXT");
            topic.ID        = xmlNode.GetAttribute("ID");
            topic.BackColor = ST.GetColor(xmlNode.GetAttribute("BACKGROUND_COLOR"), topic.BackColor);
            topic.ForeColor = ST.GetColor(xmlNode.GetAttribute("COLOR"), topic.BackColor);
            topic.Folded    = ST.GetBool(xmlNode.GetAttribute("FOLDED"), topic.Folded);
            topic.Padding   = new Padding(ST.GetInt(xmlNode.GetAttribute("HGAP"), 0),
                                          ST.GetInt(xmlNode.GetAttribute("VGAP"), 0),
                                          ST.GetInt(xmlNode.GetAttribute("HGAP"), 0),
                                          ST.GetInt(xmlNode.GetAttribute("VGAP"), 0));

            // font
            XmlElement node = xmlNode.SelectSingleNode("font") as XmlElement;

            if (node != null)
            {
                FontStyle fs = FontStyle.Regular;
                if (ST.GetBoolDefault(node.GetAttribute("BOLD")))
                {
                    fs |= FontStyle.Bold;
                }
                if (ST.GetBoolDefault(node.GetAttribute("ITALIC")))
                {
                    fs |= FontStyle.Italic;
                }
                topic.Font = new Font(node.GetAttribute("NAME"), ST.GetFloat(node.GetAttribute("SIZE"), 0), fs);
            }

            // note
            XmlElement noteNode = xmlNode.SelectSingleNode("richcontent[@TYPE='NOTE']") as XmlElement;

            if (noteNode != null)
            {
                topic.Remark = DeserializeRemark(noteNode);
            }

            // arrowlink
            XmlNodeList links = xmlNode.SelectNodes("arrowlink");

            foreach (XmlElement linkNode in links)
            {
                Link link = DeserializeLink(linkNode);
                topic.Links.Add(link);
            }

            // children
            XmlNodeList list = xmlNode.SelectNodes("node");

            foreach (XmlElement element in list)
            {
                Topic subTopic = LoadNodes(element);
                if (subTopic != null)
                {
                    topic.Children.Add(subTopic);
                }
            }

            return(topic);
        }