Drawing a line with arrow in web application with C# and silverlight

1467
6
Jump to solution
01-14-2012 11:47 PM
HusseinSayed
New Contributor
Is there any way to draw a line with arrow at the end or the middle in a web application using C# and Silverlight?
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
You need either to include the ???ExtendedSymbols??? project in your project or just to reference the ExtendedSymbols dll (others projects are not useful)

Then you can create a line symbol that has an arrow at the end with XAML code like:

<extendedSymbols:ExtendedLineSymbol x:Key="arrowLineSymbol" Fill="Red" >   <extendedSymbols:ExtendedLineSymbol.GeometryTransformer>     <extendedSymbols:ArrowPatternTransformer AtEnd="True" />   </extendedSymbols:ExtendedLineSymbol.GeometryTransformer> </extendedSymbols:ExtendedLineSymbol>

(with xmlns:extendedSymbols="clr-namespace:ExtendedSymbols;assembly=ExtendedSymbols")

Then the symbol can be used in replacement of any line symbol.
For example:
 <esri:GraphicsLayer>     <esri:GraphicsLayer.Renderer>         <esri:SimpleRenderer Symbol="{StaticResource arrowLineSymbol}"/>     </esri:GraphicsLayer.Renderer>       <esri:GraphicsLayer.Graphics >          <esri:Graphic>             <esri:Polyline >                 <esri:Polyline.Paths>                     <esri:PointCollection>                         <esri:MapPoint X="0" Y="51.399" />                         <esri:MapPoint X="2.637" Y="48.865" />                         <esri:MapPoint X="12.568" Y="41.706" />                         <esri:MapPoint X="13.447" Y="52.483" />                         <esri:MapPoint X="21.357" Y="52.160" />                         <esri:MapPoint X="30.322" Y="59.845" />                     </esri:PointCollection>                 </esri:Polyline.Paths>             </esri:Polyline>         </esri:Graphic>     </esri:GraphicsLayer.Graphics> </esri:GraphicsLayer>

View solution in original post

0 Kudos
6 Replies
DominiqueBroux
Esri Frequent Contributor
This sample is done for you.
0 Kudos
HusseinSayed
New Contributor
This sample is done for you.


thanx for your help,but i already found this example and trying to find how to use it using points coordinates not by the event handled by the user ,i will be grateful if you can help me
i need to draw lines given their coordinated and i need to keep them on the graphic layer.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
You need either to include the ???ExtendedSymbols??? project in your project or just to reference the ExtendedSymbols dll (others projects are not useful)

Then you can create a line symbol that has an arrow at the end with XAML code like:

<extendedSymbols:ExtendedLineSymbol x:Key="arrowLineSymbol" Fill="Red" >   <extendedSymbols:ExtendedLineSymbol.GeometryTransformer>     <extendedSymbols:ArrowPatternTransformer AtEnd="True" />   </extendedSymbols:ExtendedLineSymbol.GeometryTransformer> </extendedSymbols:ExtendedLineSymbol>

(with xmlns:extendedSymbols="clr-namespace:ExtendedSymbols;assembly=ExtendedSymbols")

Then the symbol can be used in replacement of any line symbol.
For example:
 <esri:GraphicsLayer>     <esri:GraphicsLayer.Renderer>         <esri:SimpleRenderer Symbol="{StaticResource arrowLineSymbol}"/>     </esri:GraphicsLayer.Renderer>       <esri:GraphicsLayer.Graphics >          <esri:Graphic>             <esri:Polyline >                 <esri:Polyline.Paths>                     <esri:PointCollection>                         <esri:MapPoint X="0" Y="51.399" />                         <esri:MapPoint X="2.637" Y="48.865" />                         <esri:MapPoint X="12.568" Y="41.706" />                         <esri:MapPoint X="13.447" Y="52.483" />                         <esri:MapPoint X="21.357" Y="52.160" />                         <esri:MapPoint X="30.322" Y="59.845" />                     </esri:PointCollection>                 </esri:Polyline.Paths>             </esri:Polyline>         </esri:Graphic>     </esri:GraphicsLayer.Graphics> </esri:GraphicsLayer>
0 Kudos
HusseinSayed
New Contributor
You need either to include the �??ExtendedSymbols�?? project in your project or just to reference the ExtendedSymbols dll (others projects are not useful)

Then you can create a line symbol that has an arrow at the end with XAML code like:

<extendedSymbols:ExtendedLineSymbol x:Key="arrowLineSymbol" Fill="Red" >
  <extendedSymbols:ExtendedLineSymbol.GeometryTransformer>
    <extendedSymbols:ArrowPatternTransformer AtEnd="True" />
  </extendedSymbols:ExtendedLineSymbol.GeometryTransformer>
</extendedSymbols:ExtendedLineSymbol>

(with xmlns:extendedSymbols="clr-namespace:ExtendedSymbols;assembly=ExtendedSymbols")

Then the symbol can be used in replacement of any line symbol.
For example:

<esri:GraphicsLayer>
    <esri:GraphicsLayer.Renderer>
        <esri:SimpleRenderer Symbol="{StaticResource arrowLineSymbol}"/>
    </esri:GraphicsLayer.Renderer>
 
    <esri:GraphicsLayer.Graphics > 
        <esri:Graphic>
            <esri:Polyline >
                <esri:Polyline.Paths>
                    <esri:PointCollection>
                        <esri:MapPoint X="0" Y="51.399" />
                        <esri:MapPoint X="2.637" Y="48.865" />
                        <esri:MapPoint X="12.568" Y="41.706" />
                        <esri:MapPoint X="13.447" Y="52.483" />
                        <esri:MapPoint X="21.357" Y="52.160" />
                        <esri:MapPoint X="30.322" Y="59.845" />
                    </esri:PointCollection>
                </esri:Polyline.Paths>
            </esri:Polyline>
        </esri:Graphic>
    </esri:GraphicsLayer.Graphics>
</esri:GraphicsLayer>


Thank you, it works.
0 Kudos
MaximPetroshenko
New Contributor
Sorry, I did not find where I can download this library... could you give me a link?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Humm, it seems the portal item was corrupted at some point. I repaired it so now it should work.
0 Kudos