arrow caption...

Jul 12, 2010 at 1:57 PM

How can we add caption (show text above than arrow line) to arrows/edge, drawing from source to target node... 

 

 

Jul 12, 2010 at 2:02 PM

You can do that by changing the template, then bind to a vertex/edge property.

Jul 12, 2010 at 2:05 PM

Thanks for  your help, can you please help with code or tell where is its template is defined. 

 

Thanks again. please reply

Jul 13, 2010 at 11:53 AM
Generic.xaml in Themes. Behaves like normal WPF, so if you have trouble, please read upon WPF.
Jul 14, 2010 at 7:20 AM
Thanks for your help. I found its template. Edge template is defined below.. <Style TargetType="{x:Type Controls:EdgeControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Controls:EdgeControl}"> <Path Stroke="{TemplateBinding Foreground}" StrokeThickness="{TemplateBinding StrokeThickness}" MinWidth="1" MinHeight="1" ToolTip="{TemplateBinding ToolTip}" x:Name="edgePath"> <Path.Data> <PathGeometry> <PathGeometry.Figures> <MultiBinding Converter="{StaticResource routeToPathConverter}"> <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Source.(Controls:GraphCanvas.X)" /> <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Source.(Controls:GraphCanvas.Y)" /> <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Source.ActualWidth" /> <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Source.ActualHeight" /> <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Target.(Controls:GraphCanvas.X)" /> <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Target.(Controls:GraphCanvas.Y)" /> <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Target.ActualWidth" /> <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Target.ActualHeight" /> <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="RoutePoints" /> </MultiBinding> </PathGeometry.Figures> </PathGeometry> </Path.Data> </Path> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="Controls:GraphElementBehaviour.HighlightTrigger" Value="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" /> <Setter Property="MinWidth" Value="1" /> <Setter Property="MinHeight" Value="1" /> <Setter Property="Background" Value="Red" /> <Setter Property="Foreground" Value="Silver" /> <Setter Property="Opacity" Value="0.5" /> <Style.Triggers> <Trigger Property="Controls:GraphElementBehaviour.IsHighlighted" Value="True"> <Setter Property="Foreground" Value="Black" /> </Trigger> <Trigger Property="Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"> <Setter Property="Foreground" Value="Yellow" /> </Trigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True" /> <Condition Property="Controls:GraphElementBehaviour.SemiHighlightInfo" Value="InEdge" /> </MultiTrigger.Conditions> <Setter Property="Foreground" Value="Red" /> </MultiTrigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True" /> <Condition Property="Controls:GraphElementBehaviour.SemiHighlightInfo" Value="OutEdge" /> </MultiTrigger.Conditions> <Setter Property="Foreground" Value="Blue" /> </MultiTrigger> </Style.Triggers> </Style> and it is getting shape of Path FIgure by this converter code... public class EdgeRouteToPathConverter : IMultiValueConverter { public object Convert( object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture ) { Debug.Assert( values != null && values.Length == 9, "EdgeRouteToPathConverter should have 9 parameters: pos (1,2), size (3,4) of source; pos (5,6), size (7,8) of target; routeInformation (9)." ); #region Get the inputs //get the position of the source Point sourcePos = new Point() { X = ( values[0] != DependencyProperty.UnsetValue ? (double)values[0] : 0.0 ), Y = ( values[1] != DependencyProperty.UnsetValue ? (double)values[1] : 0.0 ) }; //get the size of the source Size sourceSize = new Size() { Width = ( values[2] != DependencyProperty.UnsetValue ? (double)values[2] : 0.0 ), Height = ( values[3] != DependencyProperty.UnsetValue ? (double)values[3] : 0.0 ) }; //get the position of the target Point targetPos = new Point() { X = ( values[4] != DependencyProperty.UnsetValue ? (double)values[4] : 0.0 ), Y = ( values[5] != DependencyProperty.UnsetValue ? (double)values[5] : 0.0 ) }; //get the size of the target Size targetSize = new Size() { Width = ( values[6] != DependencyProperty.UnsetValue ? (double)values[6] : 0.0 ), Height = ( values[7] != DependencyProperty.UnsetValue ? (double)values[7] : 0.0 ) }; //get the route informations Point[] routeInformation = ( values[8] != DependencyProperty.UnsetValue ? (Point[])values[8] : null ); #endregion bool hasRouteInfo = routeInformation != null && routeInformation.Length > 0; // // Create the path // Point p1 = GraphConverterHelper.CalculateAttachPoint( sourcePos, sourceSize, ( hasRouteInfo ? routeInformation[0] : targetPos ) ); Point p2 = GraphConverterHelper.CalculateAttachPoint( targetPos, targetSize, ( hasRouteInfo ? routeInformation[routeInformation.Length - 1] : sourcePos ) ); PathSegment[] segments = new PathSegment[1 + ( hasRouteInfo ? routeInformation.Length : 0 )]; if ( hasRouteInfo ) //append route points for ( int i = 0; i < routeInformation.Length; i++ ) segments[i] = new LineSegment( routeInformation[i], true ); Point pLast = ( hasRouteInfo ? routeInformation[routeInformation.Length - 1] : p1 ); Vector v = pLast - p2; v = v / v.Length * 5; Vector n = new Vector( -v.Y, v.X ) * 0.3; segments[segments.Length - 1] = new LineSegment( p2 + v, true ); PathFigureCollection pfc = new PathFigureCollection(2); pfc.Add(new PathFigure( p1, segments, false ) ); pfc.Add(new PathFigure( p2, new PathSegment[] { new LineSegment(p2 + v - n, true), new LineSegment(p2 + v + n, true)}, true ) ); return pfc; } public object[] ConvertBack( object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture ) { throw new NotImplementedException(); } } JUST WONDERING HOW I CAN EMBED MY DESIRED TEXT HERE......PLZ SUGGEST
Jul 14, 2010 at 7:51 AM

See this post for a starter: http://graphsharp.codeplex.com/Thread/View.aspx?ThreadId=72119