private static string GetChronoStyleVariant(DrawingChrono drawing) { // Style variants of DrawingChrono: Chrono, Clock. if (!drawing.DrawingStyle.Elements.ContainsKey("clock")) { return("Chrono"); } StyleElementToggle elementToggle = drawing.DrawingStyle.Elements["clock"] as StyleElementToggle; if (elementToggle == null) { return("Chrono"); } bool valueClock = (bool)elementToggle.Value; if (valueClock) { return("Clock"); } else { return("Chrono"); } }
private static string GetPlaneStyleVariant(DrawingPlane drawing) { // Style variants of DrawingPlane: Plane, Grid. if (!drawing.DrawingStyle.Elements.ContainsKey("perspective")) { return("Plane"); } StyleElementToggle elementPerspective = drawing.DrawingStyle.Elements["perspective"] as StyleElementToggle; if (elementPerspective == null) { return("Plane"); } bool valuePerspective = (bool)elementPerspective.Value; if (valuePerspective) { return("Plane"); } else { return("Grid"); } }
public override AbstractStyleElement Clone() { StyleElementToggle clone = new StyleElementToggle(value, variant); clone.icon = icon; clone.displayName = displayName; clone.variant = variant; 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"); } } }
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 "PenShape": styleElement = new StyleElementPenShape(xmlReader); break; case "GridDivisions": styleElement = new StyleElementGridDivisions(xmlReader); break; case "Toggle": styleElement = new StyleElementToggle(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(); }