public override void FinalFixup(List <GraphicElement> elements, ElementPropertyBag epb) { base.FinalFixup(elements, epb); StartConnectedShape = elements.SingleOrDefault(e => e.Id == epb.StartConnectedShapeId); EndConnectedShape = elements.SingleOrDefault(e => e.Id == epb.EndConnectedShapeId); base.FinalFixup(elements, epb); }
public virtual void Deserialize(ElementPropertyBag epb) { Id = epb.Id; if (!String.IsNullOrEmpty(epb.Json)) { Json = JsonConvert.DeserializeObject <Dictionary <string, string> >(epb.Json); } DisplayRectangle = epb.DisplayRectangle; BorderPen.Dispose(); BorderPen = new Pen(epb.BorderPenColor, epb.BorderPenWidth); FillBrush.Dispose(); FillBrush = new SolidBrush(epb.FillBrushColor); Text = epb.Text; TextColor = epb.TextColor; // If missing (backwards compatibility) middle-center align. TextAlign = epb.TextAlign == 0 ? ContentAlignment.MiddleCenter : epb.TextAlign; TextFont.Dispose(); FontStyle fontStyle = (epb.TextFontUnderline ? FontStyle.Underline : FontStyle.Regular) | (epb.TextFontItalic ? FontStyle.Italic : FontStyle.Regular) | (epb.TextFontStrikeout ? FontStyle.Strikeout : FontStyle.Regular); TextFont = new Font(epb.TextFontFamily, epb.TextFontSize, fontStyle); HasCornerAnchors = epb.HasCornerAnchors; HasCenterAnchors = epb.HasCenterAnchors; HasLeftRightAnchors = epb.HasLeftRightAnchors; HasTopBottomAnchors = epb.HasTopBottomAnchors; HasCornerConnections = epb.HasCornerConnections; HasCenterConnections = epb.HasCenterConnections; HasLeftRightConnections = epb.HasLeftRightConnections; HasTopBottomConnections = epb.HasTopBottomConnections; }
public virtual void Serialize(ElementPropertyBag epb) { epb.ElementName = GetType().AssemblyQualifiedName; epb.Id = Id; epb.DisplayRectangle = DisplayRectangle; epb.BorderPenColor = BorderPen.Color; epb.BorderPenWidth = (int)BorderPen.Width; epb.FillBrushColor = FillBrush.Color; epb.Text = Text; epb.TextColor = TextColor; epb.TextFontFamily = TextFont.FontFamily.Name; epb.TextFontSize = TextFont.Size; epb.TextFontUnderline = TextFont.Underline; epb.TextFontStrikeout = TextFont.Strikeout; epb.TextFontItalic = TextFont.Italic; epb.HasCornerAnchors = HasCornerAnchors; epb.HasCenterAnchors = HasCenterAnchors; epb.HasLeftRightAnchors = HasLeftRightAnchors; epb.HasTopBottomAnchors = HasTopBottomAnchors; epb.HasCornerConnections = HasCornerConnections; epb.HasCenterConnections = HasCenterConnections; epb.HasLeftRightConnections = HasLeftRightConnections; epb.HasTopBottomConnections = HasTopBottomConnections; Connections.ForEach(c => c.Serialize(epb)); }
public virtual void Deserialize(ElementPropertyBag epb) { Id = epb.Id; DisplayRectangle = epb.DisplayRectangle; BorderPen.Dispose(); BorderPen = new Pen(epb.BorderPenColor, epb.BorderPenWidth); FillBrush.Dispose(); FillBrush = new SolidBrush(epb.FillBrushColor); Text = epb.Text; TextColor = epb.TextColor; TextFont.Dispose(); FontStyle fontStyle = (epb.TextFontUnderline ? FontStyle.Underline : FontStyle.Regular) | (epb.TextFontItalic ? FontStyle.Italic : FontStyle.Regular) | (epb.TextFontStrikeout ? FontStyle.Strikeout : FontStyle.Regular); TextFont = new Font(epb.TextFontFamily, epb.TextFontSize, fontStyle); HasCornerAnchors = epb.HasCornerAnchors; HasCenterAnchors = epb.HasCenterAnchors; HasLeftRightAnchors = epb.HasLeftRightAnchors; HasTopBottomAnchors = epb.HasTopBottomAnchors; HasCornerConnections = epb.HasCornerConnections; HasCenterConnections = epb.HasCenterConnections; HasLeftRightConnections = epb.HasLeftRightConnections; HasTopBottomConnections = epb.HasTopBottomConnections; }
public virtual void Serialize(ElementPropertyBag epb, IEnumerable <GraphicElement> elementsBeingSerialized) { epb.ElementName = GetType().AssemblyQualifiedName; epb.Id = Id; epb.Json = JsonConvert.SerializeObject(Json); epb.DisplayRectangle = DisplayRectangle; epb.BorderPenColor = BorderPen.Color; epb.BorderPenWidth = (int)BorderPen.Width; epb.FillBrushColor = FillBrush.Color; epb.Text = Text; epb.TextColor = TextColor; epb.TextAlign = TextAlign; epb.TextFontFamily = TextFont.FontFamily.Name; epb.TextFontSize = TextFont.Size; epb.TextFontUnderline = TextFont.Underline; epb.TextFontStrikeout = TextFont.Strikeout; epb.TextFontItalic = TextFont.Italic; epb.HasCornerAnchors = HasCornerAnchors; epb.HasCenterAnchors = HasCenterAnchors; epb.HasLeftRightAnchors = HasLeftRightAnchors; epb.HasTopBottomAnchors = HasTopBottomAnchors; epb.HasCornerConnections = HasCornerConnections; epb.HasCenterConnections = HasCenterConnections; epb.HasLeftRightConnections = HasLeftRightConnections; epb.HasTopBottomConnections = HasTopBottomConnections; Connections.ForEach(c => c.Serialize(epb, elementsBeingSerialized)); GroupChildren.ForEach(c => epb.Children.Add(new ChildPropertyBag() { ChildId = c.Id })); }
public override void Serialize(ElementPropertyBag epb) { base.Serialize(epb); epb.StartCap = StartCap; epb.EndCap = EndCap; epb.StartConnectedShapeId = StartConnectedShape?.Id ?? Guid.Empty; epb.EndConnectedShapeId = EndConnectedShape?.Id ?? Guid.Empty; }
public override void Serialize(ElementPropertyBag epb, IEnumerable <GraphicElement> elementsBeingSerialized) { base.Serialize(epb, elementsBeingSerialized); epb.StartPoint = StartPoint; epb.EndPoint = EndPoint; epb.HyAdjust = hyAdjust; epb.VxAdjust = vxAdjust; }
public override void Deserialize(ElementPropertyBag epb) { base.Deserialize(epb); StartPoint = epb.StartPoint; EndPoint = epb.EndPoint; hyAdjust = epb.HyAdjust; vxAdjust = epb.VxAdjust; }
public void Serialize(ElementPropertyBag epb) { ConnectionPropertyBag cpb = new ConnectionPropertyBag(); cpb.ToElementId = ToElement.Id; cpb.ToConnectionPoint = ToConnectionPoint; cpb.ElementConnectionPoint = ElementConnectionPoint; epb.Connections.Add(cpb); }
public override void Deserialize(ElementPropertyBag epb) { base.Deserialize(epb); string truePath; if (Json.TryGetValue("TruePath", out truePath)) { TruePath = (TruePath)Enum.Parse(typeof(TruePath), truePath); } }
public void Serialize(ElementPropertyBag epb, IEnumerable <GraphicElement> elementsBeingSerialized) { // If partial serialization (like copying a subset of shapes, don't include unselected connectors.) if (elementsBeingSerialized.Contains(ToElement)) { ConnectionPropertyBag cpb = new ConnectionPropertyBag(); cpb.ToElementId = ToElement.Id; cpb.ToConnectionPoint = ToConnectionPoint; cpb.ElementConnectionPoint = ElementConnectionPoint; epb.Connections.Add(cpb); } }
public static string Serialize(GraphicElement el) { ElementPropertyBag epb = new ElementPropertyBag(); el.Serialize(epb); XmlSerializer xs = new XmlSerializer(typeof(ElementPropertyBag)); StringBuilder sb = new StringBuilder(); TextWriter tw = new StringWriter(sb); xs.Serialize(tw, epb); return(sb.ToString()); }
public static GraphicElement DeserializeElement(Canvas canvas, string data) { XmlSerializer xs = new XmlSerializer(typeof(ElementPropertyBag)); TextReader tr = new StringReader(data); ElementPropertyBag epb = (ElementPropertyBag)xs.Deserialize(tr); Type t = Type.GetType(epb.ElementName); GraphicElement el = (GraphicElement)Activator.CreateInstance(t, new object[] { canvas }); el.Deserialize(epb); // A specific deserialization does not preserve connections. el.Id = Guid.NewGuid(); // We get a new GUID when deserializing a specific element. return(el); }
public override void FinalFixup(List <GraphicElement> elements, ElementPropertyBag epb, Dictionary <Guid, Guid> oldNewGuidMap) { base.FinalFixup(elements, epb, oldNewGuidMap); if (epb.StartConnectedShapeId != Guid.Empty) { StartConnectedShape = elements.SingleOrDefault(e => e.Id == oldNewGuidMap[epb.StartConnectedShapeId]); } if (epb.EndConnectedShapeId != Guid.Empty) { EndConnectedShape = elements.SingleOrDefault(e => e.Id == oldNewGuidMap[epb.EndConnectedShapeId]); } }
public override void Deserialize(ElementPropertyBag epb) { base.Deserialize(epb); string state; if (Json.TryGetValue("State", out state)) { State = (CollapseState)Enum.Parse(typeof(CollapseState), state); } string size; if (Json.TryGetValue("ExpandedSize", out size)) { TypeConverter tc = TypeDescriptor.GetConverter(typeof(Size)); ExpandedSize = (Size)tc.ConvertFromString(size); } }
public override void Serialize(ElementPropertyBag epb, IEnumerable <GraphicElement> elementsBeingSerialized) { base.Serialize(epb, elementsBeingSerialized); epb.StartCap = StartCap; epb.EndCap = EndCap; // Don't assign connected shape ID to partial copy and paste selection where target is not in elements being serialized. if (elementsBeingSerialized.Contains(StartConnectedShape)) { epb.StartConnectedShapeId = StartConnectedShape?.Id ?? Guid.Empty; } if (elementsBeingSerialized.Contains(EndConnectedShape)) { epb.EndConnectedShapeId = EndConnectedShape?.Id ?? Guid.Empty; } }
public static string Serialize(List <GraphicElement> elements) { List <ElementPropertyBag> sps = new List <ElementPropertyBag>(); elements.ForEach(el => { ElementPropertyBag epb = new ElementPropertyBag(); el.Serialize(epb); sps.Add(epb); }); XmlSerializer xs = new XmlSerializer(sps.GetType()); StringBuilder sb = new StringBuilder(); TextWriter tw = new StringWriter(sb); xs.Serialize(tw, sps); return(sb.ToString()); }
public override void Serialize(ElementPropertyBag epb) { base.Serialize(epb); epb.StartPoint = startPoint; epb.EndPoint = endPoint; }
public virtual void FinalFixup(List <GraphicElement> elements, ElementPropertyBag epb, Dictionary <Guid, Guid> oldNewGuidMap) { elements.ForEach(el => el.UpdateProperties()); }
public override void Serialize(ElementPropertyBag epb, IEnumerable <GraphicElement> elementsBeingSerialized) { Json["State"] = State.ToString(); Json["ExpandedSize"] = ExpandedSize.Width + "," + ExpandedSize.Height; base.Serialize(epb, elementsBeingSerialized); }
public override void Serialize(ElementPropertyBag epb, IEnumerable <GraphicElement> elementsBeingSerialized) { Json["TruePath"] = TruePath.ToString(); base.Serialize(epb, elementsBeingSerialized); }
public override void Serialize(ElementPropertyBag epb, IEnumerable <GraphicElement> elementsBeingSerialized) { base.Serialize(epb, elementsBeingSerialized); epb.StartPoint = startPoint; epb.EndPoint = endPoint; }
public override void Deserialize(ElementPropertyBag epb) { base.Deserialize(epb); StartCap = epb.StartCap; EndCap = epb.EndCap; }
public override void Deserialize(ElementPropertyBag epb) { base.Deserialize(epb); startPoint = epb.StartPoint; endPoint = epb.EndPoint; }
public virtual void FinalFixup(List <GraphicElement> elements, ElementPropertyBag epb) { elements.ForEach(el => el.UpdateProperties()); }