Hiding the Arrow in edges for un-directed graph.

Mar 7, 2014 at 12:01 PM
Hi,

Can someone help me with that - I want to stick to Graph # and not use other library such as graphx (due to my project complexity).

How can hide this arrows for undirected graphs ?

Thanks,
Shimon
Mar 7, 2014 at 2:34 PM
Edited Mar 7, 2014 at 2:35 PM
Hi, you have to look in EdgeRouteToPathConverter.cs converter. There are routines for creating path objects including arrows. Optionaly, if you want to switch arrows on/off you can provide additional parameter into this converter (as it is multibinding).

If i'm correct this one is for arrow drawing:
pfc.Add( new PathFigure( p2,
    new PathSegment[] {
        new LineSegment(p2+v - n, true),
             new LineSegment(p2+v+n, true)}, true ) );
And this is an example for binding addditional value using custom bool value in DataEdge:
<Binding RelativeSource="{RelativeSource TemplatedParent}"
        Path="Edge.SomeBoolValue" />
Mar 7, 2014 at 5:53 PM
Thanks,

I found the function in the graph# source :
        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
            ......


            #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;__
        }
But I don't understand what are the parameters and what exactly to change ?
Another question, If i want to add this additional parameter to switch arrows on/off, than after I'm compiling the dlls and adding them to my project
Where I'm mentioning in the code this switch ?
Mar 7, 2014 at 6:11 PM
The code switch must be implemented in Generic.xaml template file. EdgeControl template. You'll see similar bindings there.

I've pointed where to look for arrows code in the previous post. You choose to add or not to add this code based on the input parameter.