Пример #1
0
        public override AbstractStyleElement Clone()
        {
            AbstractStyleElement clone = new StyleElementLineEnding(value);

            clone.Bind(this);
            return(clone);
        }
Пример #2
0
        public void ReadXml(XmlReader _xmlReader)
        {
            m_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 "Arrows":
                    styleElement = new StyleElementLineEnding(_xmlReader);
                    break;

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

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

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

            _xmlReader.ReadEndElement();
        }
        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");
                }
            }
        }