//<< Fields protected override void Serialize(IDictionary <string, object> json) { //>> Serialization var stroke = Stroke.ToJson(); if (stroke.Any()) { json["stroke"] = stroke; } var hover = Hover.ToJson(); if (hover.Any()) { json["hover"] = hover; } if (StartCap.HasValue()) { json["startCap"] = StartCap; } if (EndCap.HasValue()) { json["endCap"] = EndCap; } //<< Serialization }
public override void Serialize(XmlDocument dom, XmlElement node) { base.Serialize(dom, node); node.SetAttribute("target", Target.ID); if (LayoutData != null) { node.SetAttribute("cp1_length", LayoutData.CP1.Length.ToString()); node.SetAttribute("cp1_angle", LayoutData.CP1.Angle.ToString()); node.SetAttribute("cp2_length", LayoutData.CP2.Length.ToString()); node.SetAttribute("cp2_angle", LayoutData.CP2.Angle.ToString()); } node.SetAttribute("width", LineWidth.ToString()); if (!Color.IsEmpty) { node.SetAttribute("color", ST.ToString(Color)); } node.SetAttribute("line_style", LineStyle.ToString()); node.SetAttribute("start_cap", StartCap.ToString()); node.SetAttribute("end_cap", EndCap.ToString()); node.SetAttribute("text", Text); node.SetAttribute("hyperlink", Hyperlink); if (!string.IsNullOrEmpty(Remark)) { ST.WriteTextNode(node, "remark", Remark); } }
/// <inheritdoc/> public override void Assign(Base source) { base.Assign(source); LineObject src = source as LineObject; Diagonal = src.Diagonal; StartCap.Assign(src.StartCap); EndCap.Assign(src.EndCap); }
/// <inheritdoc/> public override void Serialize(FRWriter writer) { Border.SimpleBorder = true; base.Serialize(writer); LineObject c = writer.DiffObject as LineObject; if (Diagonal != c.Diagonal) { writer.WriteBool("Diagonal", Diagonal); } StartCap.Serialize("StartCap", writer, c.StartCap); EndCap.Serialize("EndCap", writer, c.EndCap); }
public override JObject SaveToJsonObject(StiJsonSaveMode mode) { var jObject = base.SaveToJsonObject(mode); if (Brush != null) { jObject.Add(new JProperty("Brush", SaveBrushToJsonObject(Brush, mode))); } jObject.Add(new JProperty("Thickness", Thickness)); jObject.Add(new JProperty("PenStyle", PenStyle.ToString())); jObject.Add(new JProperty("Alignment", Alignment.ToString())); jObject.Add(new JProperty("StartCap", StartCap.ToString())); jObject.Add(new JProperty("EndCap", EndCap.ToString())); return(jObject); }
private Int32 computeHashCode() { return(Alignment.GetHashCode() ^ getSingleArrayHashCode(CompoundArray) ^ MiterLimit.GetHashCode() ^ BackgroundBrush.GetHashCode() ^ DashOffset.GetHashCode() ^ getSingleArrayHashCode(DashPattern) ^ getStyleBrushesArrayHashCode(DashBrushes) ^ DashStyle.GetHashCode() ^ StartCap.GetHashCode() ^ EndCap.GetHashCode() ^ DashCap.GetHashCode() ^ LineJoin.GetHashCode() ^ Transform.GetHashCode() ^ Width.GetHashCode() ^ -18133844); }
public override string ToString() { return ($"l:{_leftOffset:N1}, r:{_rightOffset:N1} S: {StartCap.GetType().Name}; E: {EndCap.GetType().Name}"); }
/// <inheritdoc/> public override void Draw(FRPaintEventArgs e) { IGraphics g = e.Graphics; // draw marker when inserting a line if (Width == 0 && Height == 0) { g.DrawLine(Pens.Black, AbsLeft * e.ScaleX - 6, AbsTop * e.ScaleY, AbsLeft * e.ScaleX + 6, AbsTop * e.ScaleY); g.DrawLine(Pens.Black, AbsLeft * e.ScaleX, AbsTop * e.ScaleY - 6, AbsLeft * e.ScaleX, AbsTop * e.ScaleY + 6); return; } Report report = Report; if (report != null && report.SmoothGraphics) { g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.SmoothingMode = SmoothingMode.AntiAlias; } Pen pen = e.Cache.GetPen(Border.Color, Border.Width * e.ScaleX, Border.DashStyle); float width = Width; float height = Height; if (!Diagonal) { if (Math.Abs(width) > Math.Abs(height)) { height = 0; } else { width = 0; } } float x1 = AbsLeft * e.ScaleX; float y1 = AbsTop * e.ScaleY; float x2 = (AbsLeft + width) * e.ScaleX; float y2 = (AbsTop + height) * e.ScaleY; if (StartCap.Style == CapStyle.None && EndCap.Style == CapStyle.None) { g.DrawLine(pen, x1, y1, x2, y2); } else { // draw line caps manually. It is necessary for correct svg rendering float angle = (float)(Math.Atan2(x2 - x1, y2 - y1) / Math.PI * 180); float len = (float)Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); float scale = Border.Width * e.ScaleX; IGraphicsState state = g.Save(); g.TranslateTransform(x1, y1); g.RotateTransform(-angle); float y = 0; GraphicsPath startCapPath = null; GraphicsPath endCapPath = null; float inset = 0; if (StartCap.Style != CapStyle.None) { StartCap.GetCustomCapPath(out startCapPath, out inset); y += inset * scale; } if (EndCap.Style != CapStyle.None) { EndCap.GetCustomCapPath(out endCapPath, out inset); len -= inset * scale; } g.DrawLine(pen, 0, y, 0, len); g.Restore(state); pen = e.Cache.GetPen(Border.Color, 1, Border.DashStyle); if (StartCap.Style != CapStyle.None) { state = g.Save(); g.TranslateTransform(x1, y1); g.RotateTransform(180 - angle); g.ScaleTransform(scale, scale); g.DrawPath(pen, startCapPath); g.Restore(state); } if (EndCap.Style != CapStyle.None) { state = g.Save(); g.TranslateTransform(x2, y2); g.RotateTransform(-angle); g.ScaleTransform(scale, scale); g.DrawPath(pen, endCapPath); g.Restore(state); } } if (report != null && report.SmoothGraphics && Diagonal) { g.InterpolationMode = InterpolationMode.Default; g.SmoothingMode = SmoothingMode.Default; } }
private bool ShouldSerializeStartCap() { return(!StartCap.Equals(new CapSettings())); }