private static DiagramEdgeDto BuildDiagramEdgeDto(EdgeControl edgeControl) { if (edgeControl == null) { throw new ArgumentNullException(nameof(edgeControl)); } var outputEdge = new DiagramEdgeDto(); var edge = edgeControl.Edge as ArrowGraphEdge; if (edge != null) { outputEdge.Id = Convert.ToInt32(edge.ID); outputEdge.Name = edge.Name; outputEdge.SourceId = Convert.ToInt32(edge.Source.ID); outputEdge.TargetId = Convert.ToInt32(edge.Target.ID); Common.Project.EdgeDashStyle dashStyle = Common.Project.EdgeDashStyle.Normal; edge.DashStyle.ValueSwitchOn() .Case(GraphX.Controls.EdgeDashStyle.Solid, x => dashStyle = Common.Project.EdgeDashStyle.Normal) .Case(GraphX.Controls.EdgeDashStyle.Dash, x => dashStyle = Common.Project.EdgeDashStyle.Dashed) .Default(x => { throw new InvalidEnumArgumentException("Unknown EdgeDashStyle value"); }); outputEdge.DashStyle = dashStyle; Color foregroundColor = ((SolidColorBrush)edgeControl.Foreground).Color; outputEdge.ForegroundColorHexCode = DtoConverter.HexConverter(foregroundColor.R, foregroundColor.G, foregroundColor.B); outputEdge.StrokeThickness = edge.StrokeThickness; var labelText = new StringBuilder(); if (edge.IsDummy) { if (!edge.CanBeRemoved) { labelText.AppendFormat("{0}", edge.ID); if (!edge.IsCritical) { labelText.AppendLine(); labelText.AppendFormat("{0}|{1}", edge.FreeSlack, edge.TotalSlack); } outputEdge.ShowLabel = true; } else { if (!edge.IsCritical) { labelText.AppendFormat("{0}|{1}", edge.FreeSlack, edge.TotalSlack); outputEdge.ShowLabel = true; } } } else { labelText.AppendFormat("{0} ({1})", edge.ID, edge.Duration); if (!edge.IsCritical) { labelText.AppendLine(); labelText.AppendFormat("{0}|{1}", edge.FreeSlack, edge.TotalSlack); } outputEdge.ShowLabel = true; } outputEdge.Label = labelText.ToString(); } return(outputEdge); }
private static graphmlGraphEdge BuildArrowGraphEdge(DiagramEdgeDto diagramEdgeDto) { if (diagramEdgeDto == null) { throw new ArgumentNullException(nameof(diagramEdgeDto)); } var outputEdge = new graphmlGraphEdge { id = FormatArrowGraphEdgeId(diagramEdgeDto.Id), source = FormatArrowGraphNodeId(diagramEdgeDto.SourceId), target = FormatArrowGraphNodeId(diagramEdgeDto.TargetId) }; string dashStyle; switch (diagramEdgeDto.DashStyle) { case EdgeDashStyle.Normal: dashStyle = @"line"; break; case EdgeDashStyle.Dashed: dashStyle = @"dashed"; break; default: throw new InvalidOperationException("Unknown EdgeDashStyle value"); } outputEdge.data = new data { key = "d10", PolyLineEdge = new PolyLineEdge { Path = new PolyLineEdgePath { sx = "0.0", sy = "0.0", tx = "0.0", ty = "0.0" }, LineStyle = new PolyLineEdgeLineStyle { color = diagramEdgeDto.ForegroundColorHexCode, type = dashStyle, width = diagramEdgeDto.StrokeThickness.ToString(CultureInfo.InvariantCulture) }, Arrows = new PolyLineEdgeArrows { source = "none", target = "standard" }, EdgeLabel = new PolyLineEdgeEdgeLabel { alignment = "center", backgroundColor = "#FFFFFF", configuration = "AutoFlippingLabel", distance = "2.0", fontFamily = "Dialog", fontSize = "12", fontStyle = "plain", hasLineColor = "false", height = "18.701171875", modelName = "centered", modelPosition = "center", preferredPlacement = "on_edge", ratio = "0.5", textColor = "#000000", visible = diagramEdgeDto.ShowLabel ? "true" : "false", width = "10.673828125", x = "48.66937255859375", y = "-10.915985107421875", PreferredPlacementDescriptor = new PolyLineEdgeEdgeLabelPreferredPlacementDescriptor { angle = "0.0", angleOffsetOnRightSide = "0", angleReference = "absolute", angleRotationOnRightSide = "co", distance = "-1.0", placement = "anywhere", side = "on_edge", sideReference = "relative_to_edge_flow" }, hasText = "true", Text = diagramEdgeDto.Label }, BendStyle = new PolyLineEdgeBendStyle { smoothed = "false" } } }; return(outputEdge); }