I am trying to create a couple connectors automatically when a shape is dragged onto the diagram. I am formatting them to be green and red and have a label that says True and False, that's not an issue. I basically want the True connector to attach to the "Right" connecter at the source and NOT connect to a target but just have the connector go out to the right by 20 pixels or something. This is simply creating a "stub" for the user to route to their next target.
For this post, we can only talk about the True connector. The problem I'm having is that I want to set the connectors EndPoint just to the right of the "Right" Connector by 20 pixels BUT the connectors AbsolutePosition is returning 0,0. I'm using the ShapeDeserialized event which might be the problem, as the shape is probably not actually on the grid yet.
Here is the line of code I'm talking about:
Any suggestions are appreciated.
For this post, we can only talk about the True connector. The problem I'm having is that I want to set the connectors EndPoint just to the right of the "Right" Connector by 20 pixels BUT the connectors AbsolutePosition is returning 0,0. I'm using the ShapeDeserialized event which might be the problem, as the shape is probably not actually on the grid yet.
Here is the line of code I'm talking about:
tc.EndPoint =
new
Point(e.Shape.Connectors[
"Right"
].AbsolutePosition.X + 20, e.Shape.Connectors[
"Right"
].AbsolutePosition.Y);
Any suggestions are appreciated.
private
void
diagram_ShapeDeserialized_1(
object
sender, Telerik.Windows.Controls.Diagrams.ShapeSerializationRoutedEventArgs e)
{
if
(e.Shape.OutgoingLinks.Count() == 0)
{
CreateTrueConnection(e);
CreateFalseConnection(e);
}
if
(e.Shape
is
IFlowchartStepUI)
((IFlowchartStepUI)e.Shape).LoadStep(_stepsData, e.Shape.Id);
}
private
void
CreateTrueConnection(Telerik.Windows.Controls.Diagrams.ShapeSerializationRoutedEventArgs e)
{
RadDiagramConnection tc =
new
RadDiagramConnection();
tc.Stroke = Brushes.Green;
tc.StrokeThickness = 2;
// Add the "True" Label
var lbltrue =
new
System.Windows.Controls.Label();
lbltrue.Style =
this
.FindResource(
"TrueLabelStyle"
)
as
Style;
lbltrue.Content =
"True"
;
tc.Content = lbltrue;
//tc.Position = new Point(750, 150);
tc.SourceConnectorPosition = Telerik.Windows.Diagrams.Core.ConnectorPosition.Right;
//tc.TargetConnectorPosition = Telerik.Windows.Diagrams.Core.ConnectorPosition.Auto;
//tc.SourceCapSize = new System.Windows.Size(7, 7);
//tc.TargetCapSize = new System.Windows.Size(7, 7);
tc.ConnectionType = Telerik.Windows.Diagrams.Core.ConnectionType.Polyline;
//tc.StartPoint = new Point(750, 150);
Console.WriteLine(e.Shape.Connectors[
"Right"
].AbsolutePosition.X.ToString());
Console.WriteLine(e.Shape.Connectors[
"Right"
].AbsolutePosition.Y.ToString());
tc.EndPoint =
new
Point(e.Shape.Connectors[
"Right"
].AbsolutePosition.X + 20, e.Shape.Connectors[
"Right"
].AbsolutePosition.Y);
tc.TargetCapType = Telerik.Windows.Diagrams.Core.CapType.Arrow2Filled;
tc.Source = e.Shape;
this
.diagram.AddConnection(tc);
}