//private string GetFontFamily() { // var fontname = WpfHelper.IdToText( // NodeBehind.HasAttribute("fontname", true) // ? NodeBehind.GetAttribute("fontname", true) // : "Times-Roman"); // return null; //} private string GetFontColor() { return(WpfHelper.IdToText( NodeBehind.HasAttribute("fontcolor", true) ? NodeBehind.GetAttribute("fontcolor", true) : "black")); }
private string GetNodeStrokeColor() { var color = WpfHelper.IdToText( NodeBehind.HasAttribute("color", true) ? NodeBehind.GetAttribute("color", true) : null); return(color ?? "black"); }
private double GetFontSize() { var sizeStr = WpfHelper.IdToText( NodeBehind.HasAttribute("fontsize", true) ? NodeBehind.GetAttribute("fontsize", true) : null); if (!string.IsNullOrEmpty(sizeStr)) { return(double.Parse(sizeStr, CultureInfo.InvariantCulture)); } return(14.0); }
private double GetNodeStrokeThickness() { if (NodeShapeData.Name == "None") { return(0); } var thicknessStr = WpfHelper.IdToText( NodeBehind.HasAttribute("penwidth", true) ? NodeBehind.GetAttribute("penwidth", true) + "pt" : "1"); return(WpfHelper.StringToPixel(thicknessStr)); }
private void UpdatePropertyValues() { Id = NodeBehind.Id; Label = WpfHelper.IdToText( NodeBehind.HasAttribute("label") ? NodeBehind.GetAttribute("label") : NodeBehind.Id); Styles = WpfHelper.IdToStyles( NodeBehind.HasAttribute("style", true) ? NodeBehind.GetAttribute("style", true) : null); NodeShapeData = WpfHelper.ConvertToShapeData( NodeBehind.HasAttribute("shape", true) ? NodeBehind.GetAttribute("shape", true) : "ellipse", NodeBehind.HasAttribute("sides", true) ? NodeBehind.GetAttribute("sides", true) : "4", Styles.Contains("diagonals")); //Dot extends the border in both directions but wpf only inwards //so we compensate this by increasing the Width/Height by StrokeThickness. //Side note: Thickness is set to 0 in case of a plain shape StrokeThickness = GetNodeStrokeThickness(); CenterX = WpfHelper.StringToPixel(WpfHelper.IdToText( NodeBehind.GetAttribute("pos")).Split(',')[0] + "pt"); CenterY = WpfHelper.StringToPixel(WpfHelper.IdToText( NodeBehind.GetAttribute("pos")).Split(',')[1] + "pt"); Width = WpfHelper.StringToPixel(WpfHelper.IdToText( NodeBehind.GetAttribute("width", true)) + "in") + StrokeThickness; Height = WpfHelper.StringToPixel(WpfHelper.IdToText( NodeBehind.GetAttribute("height", true)) + "in") + StrokeThickness; X = CenterX - Width / 2; Y = CenterY - Height / 2; Margin = FormattableString.Invariant($"{X},{Y},0,0"); FillColor = GetNodeFillColor(); StrokeColor = GetNodeStrokeColor(); StrokeDashList = WpfHelper.AbsoluteStrokeDash(Styles, StrokeThickness); //FontFamily = GetFontFamily(); FontColor = GetFontColor(); FontSize = GetFontSize(); }
private string GetNodeFillColor() { if (Styles.Contains("filled")) { var color = WpfHelper.IdToText( NodeBehind.HasAttribute("color", true) ? NodeBehind.GetAttribute("color", true) : null); var fillcolor = WpfHelper.IdToText( NodeBehind.HasAttribute("fillcolor", true) ? NodeBehind.GetAttribute("fillcolor", true) : null); return(fillcolor ?? color ?? "lightgray"); } return("Transparent"); }