public override AbstractStyleElement Clone()
        {
            AbstractStyleElement clone = new StyleElementLineShape(value);

            clone.Bind(this);
            return(clone);
        }
        private static string GetPolyLineStyleVariant(DrawingPolyline drawing)
        {
            // Style variants of DrawingPolyline: polyline, curve, arrow curve, arrow polyline, arrow polyline dash, arrow polyline squiggly.
            if (!drawing.DrawingStyle.Elements.ContainsKey("arrows") || !drawing.DrawingStyle.Elements.ContainsKey("line shape") || !drawing.DrawingStyle.Elements.ContainsKey("curved"))
            {
                return("Polyline");
            }

            StyleElementLineEnding elementLineEnding = drawing.DrawingStyle.Elements["arrows"] as StyleElementLineEnding;
            StyleElementLineShape  elementLineShape  = drawing.DrawingStyle.Elements["line shape"] as StyleElementLineShape;
            StyleElementToggle     elementCurved     = drawing.DrawingStyle.Elements["curved"] as StyleElementToggle;

            if (elementLineEnding == null || elementLineShape == null || elementCurved == null)
            {
                return("Polyline");
            }

            LineEnding valueLineEnding = (LineEnding)elementLineEnding.Value;
            LineShape  valueLineShape  = (LineShape)elementLineShape.Value;
            bool       valueCurved     = (bool)elementCurved.Value;

            if (valueLineEnding == LineEnding.None)
            {
                if (!valueCurved)
                {
                    return("Polyline");
                }
                else
                {
                    return("Curve");
                }
            }
            else
            {
                switch (valueLineShape)
                {
                case LineShape.Solid: return("ArrowPolyline");

                case LineShape.Dash: return("ArrowPolylineDash");

                case LineShape.Squiggle: return("ArrowPolylineSquiggly");

                default: return("Polyline");
                }
            }
        }
        private static string GetLineStyleVariant(DrawingLine drawing)
        {
            // Style variants of DrawingLine: line, arrow, arrow dash, arrow squiggly.
            if (!drawing.DrawingStyle.Elements.ContainsKey("arrows") || !drawing.DrawingStyle.Elements.ContainsKey("line shape"))
            {
                return("Line");
            }

            StyleElementLineEnding elementLineEnding = drawing.DrawingStyle.Elements["arrows"] as StyleElementLineEnding;
            StyleElementLineShape  elementLineShape  = drawing.DrawingStyle.Elements["line shape"] as StyleElementLineShape;

            if (elementLineEnding == null || elementLineShape == null)
            {
                return("Line");
            }

            LineEnding valueLineEnding = (LineEnding)elementLineEnding.Value;
            LineShape  valueLineShape  = (LineShape)elementLineShape.Value;

            if (valueLineEnding == LineEnding.None)
            {
                return("Line");
            }
            else
            {
                switch (valueLineShape)
                {
                case LineShape.Solid: return("Arrow");

                case LineShape.Dash: return("ArrowDash");

                case LineShape.Squiggle: return("ArrowSquiggly");

                default: return("Line");
                }
            }
        }
Beispiel #4
0
        public void ReadXml(XmlReader xmlReader)
        {
            styleElements.Clear();

            xmlReader.ReadStartElement();       // <ToolPreset Key="ToolName"> or <DrawingStyle>
            while (xmlReader.NodeType == XmlNodeType.Element)
            {
                AbstractStyleElement styleElement = null;
                string key = xmlReader.GetAttribute("Key");

                switch (xmlReader.Name)
                {
                case "Color":
                    styleElement = new StyleElementColor(xmlReader);
                    break;

                case "FontSize":
                    styleElement = new StyleElementFontSize(xmlReader);
                    break;

                case "PenSize":
                    styleElement = new StyleElementPenSize(xmlReader);
                    break;

                case "LineSize":
                    styleElement = new StyleElementLineSize(xmlReader);
                    break;

                case "LineShape":
                    styleElement = new StyleElementLineShape(xmlReader);
                    break;

                case "Arrows":
                    styleElement = new StyleElementLineEnding(xmlReader);
                    break;

                case "TrackShape":
                    styleElement = new StyleElementTrackShape(xmlReader);
                    break;

                case "GridDivisions":
                    styleElement = new StyleElementGridDivisions(xmlReader);
                    break;

                case "Curved":
                    styleElement = new StyleElementCurved(xmlReader);
                    break;

                default:
                    log.ErrorFormat("Could not import style element \"{0}\"", xmlReader.Name);
                    log.ErrorFormat("Content was: {0}", xmlReader.ReadOuterXml());
                    break;
                }

                if (styleElement != null)
                {
                    styleElements.Add(key, styleElement);
                }
            }

            xmlReader.ReadEndElement();
        }