예제 #1
0
        static Link DeserializeLink(XmlElement node)
        {
            if (node == null)
            {
                throw new ArgumentNullException();
            }

            Link link = new Link();

            link.ID = node.GetAttribute("ID");
            //line.FromID = node.GetAttribute("from");
            link.TargetID  = node.GetAttribute("DESTINATION");
            link.Color     = ST.GetColor(node.GetAttribute("COLOR"), Color.Black);
            link.LineStyle = DashStyle.Solid;
            link.LineWidth = 1;

            int angle, length;

            ParseInclination(node.GetAttribute("STARTINCLINATION"), out angle, out length);
            link.LayoutData.CP1 = new BezierControlPoint(angle, length);
            ParseInclination(node.GetAttribute("ENDINCLINATION"), out angle, out length);
            link.LayoutData.CP2 = new BezierControlPoint(angle, length);

            link.StartCap = ParseLineCap(node.GetAttribute("STARTARROW"));
            link.EndCap   = ParseLineCap(node.GetAttribute("ENDARROW"));

            //link.Layout.CPLength1 = ST.GetInteger(node.GetAttribute("cp1_length"), 0);
            //link.Layout.CPAngle1 = ST.GetInteger(node.GetAttribute("cp1_angle"), 0);
            //link.Layout.CPLength2 = ST.GetInteger(node.GetAttribute("cp2_length"), 0);
            //link.Layout.CPAngle2 = ST.GetInteger(node.GetAttribute("cp2_angle"), 0);
            //link.Width = ST.GetInteger(node.GetAttribute("width"), link.Width);
            //link.LineStyle = (DashStyle)ST.GetInteger(node.GetAttribute("line_style"), (int)link.LineStyle);
            return(link);
        }
예제 #2
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");
            }
        }
예제 #3
0
        public static UIColorTheme Load(XmlDocument dom)
        {
            if (dom == null || dom.DocumentElement == null)
            {
                return(null);
            }

            var root = dom.DocumentElement;

            if (!StringComparer.OrdinalIgnoreCase.Equals(root.GetAttribute("type"), FileType))
            {
                return(null);
            }

            var t = new UIColorTheme();

            t.Name        = root.GetAttribute("name");
            t.Description = ST.ReadTextNode(root, "description");

            var colors = root.SelectSingleNode("colors");

            if (colors != null)
            {
                foreach (XmlElement cn in colors.ChildNodes)
                {
                    switch (cn.GetAttribute("name").ToLower())
                    {
                    case "dark":
                        t.Dark = ST.GetColor(cn.GetAttribute("value"), t.Dark);
                        break;

                    case "light":
                        t.Light = ST.GetColor(cn.GetAttribute("value"), t.Light);
                        break;

                    case "sharp":
                        t.Sharp = ST.GetColor(cn.GetAttribute("value"), t.Sharp);
                        break;

                    case "mediumdark":
                        t.MediumDark = ST.GetColor(cn.GetAttribute("value"), t.MediumDark);
                        break;

                    case "mediumlight":
                        t.MediumLight = ST.GetColor(cn.GetAttribute("value"), t.MediumLight);
                        break;

                    case "workspace":
                        t.Workspace = ST.GetColor(cn.GetAttribute("value"), t.Workspace);
                        break;
                    }
                }
            }

            return(t);
        }
예제 #4
0
 public UIColorTheme(string name, string dark, string light, string sharp, string mediumDark, string mediumLight, string workSpace, string description)
 {
     Name        = name;
     Dark        = ST.GetColor(dark);
     Light       = ST.GetColor(light);
     Sharp       = ST.GetColor(sharp);
     MediumDark  = ST.GetColor(mediumDark);
     MediumLight = ST.GetColor(mediumLight);
     Workspace   = ST.GetColor(workSpace);
     Description = description;
 }
예제 #5
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);
        }
예제 #6
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.KeyCode == Keys.Escape && Picker != null && Picker.IsDroped)
            {
                Picker.EndDropDown();
            }
            else if (e.KeyCode == Keys.Enter && (Picker == null || !Picker.IsDroped))
            {
                ColorValue         = ST.GetColor(Text);
                e.SuppressKeyPress = true;
            }
        }
예제 #7
0
        public override void Deserialize(Version documentVersion, XmlElement node)
        {
            base.Deserialize(documentVersion, node);

            if (documentVersion < Document.DV_3) // 向后兼容
            {
                Text = ST.ReadTextNode(node, "description");
            }
            else
            {
                Remark = ST.ReadTextNode(node, "text");
            }

            BackColor = ST.GetColor(node.GetAttribute("back_color"), BackColor);
            ForeColor = ST.GetColor(node.GetAttribute("fore_color"), ForeColor);
        }
예제 #8
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);
        }