Solved! Go to Solution.
<!-- Selectable Tools Window-->
<userControls:DraggableWindow IsOpen="False" x:Name="DrawGraphicToolbar" IsDraggable="True" VerticalAlignment="Top"
HorizontalAlignment="Left" Margin="450,110,0,15"
Effect="{StaticResource dropShadow}"
Background="Black" Title="DRAW GRAPHIC TOOLS">
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" Width="Auto" Height="Auto" >
<Border Effect="{StaticResource miniDropShadow}" Style="{StaticResource RibbonElementBorder}" Padding="15" Margin="10">
<!--<Grid Margin="10" Background="White">-->
<StackPanel Orientation="Vertical" Margin="3">
<StackPanel x:Name="MyStackPanel" Orientation="Horizontal">
<Button Tag="DrawPoint" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a point">
<Image Source="images/DrawPoint.png" Margin="2" />
</Button>
<Button Tag="DrawPolyline" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a polyline">
<Image Source="images/DrawPolyline.png" Margin="2" />
</Button>
<Button Tag="DrawPolygon" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a polygon">
<Image Source="images/DrawPolygon.png" Margin="2" />
</Button>
<Button Tag="DrawRectangle" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a rectangle">
<Image Source="images/DrawRectangle.png" Margin="2" />
</Button>
<Button Tag="DrawFreehand" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a freehand line">
<Image Source="images/DrawFreehand.png" Margin="2" />
</Button>
<Button Tag="DrawArrow" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add an arrow">
<Image Source="images/DrawArrow2.png" Margin="2" />
</Button>
<Button Tag="DrawTriangle" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a triangle">
<Image Source="images/DrawTriangle2.png" Margin="2" />
</Button>
<Button Tag="DrawCircle" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a circle">
<Image Source="images/DrawCircle2.png" Margin="2" />
</Button>
<Button Tag="DrawEllipse" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add an ellipse">
<Image Source="images/DrawEllipse2.png" Margin="2" />
</Button>
<Button Tag="EnterText" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add text">
<Image Source="images/text.png" Margin="2" />
</Button>
<Button Tag="DrawNothing" Margin="5" Click="Tool_Click"
Style="{x:Null}"
ToolTipService.ToolTip="Unselect Current Tool">
<Image Source="images/dismiss.png" Margin="2" />
</Button>
<Button Tag="ClearStopDraw" Margin="5" Click="Tool_Click"
Style="{x:Null}"
ToolTipService.ToolTip="Clear graphics">
<Image Source="images/StopDraw.png" Margin="2" />
</Button>
</StackPanel>
<CheckBox x:Name="EnableEditVerticesScaleRotate" Content="Click on geometry to edit"
IsChecked="False" Foreground="Black" FontWeight="Bold" Margin="10,5,5,5" />
<TextBox x:Name="txtText" Text="test" />
</StackPanel>
<!--</Grid>-->
</Border>
</Grid>
</userControls:DraggableWindow>
private void MyDrawObjectGraphic_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args)
{
if (_bolText) //if user selected text from drawing options
{
//MessageBox.Show(txtText.Text);
//_activeSymbol = LayoutRoot.Resources["DefaultGraphicMarkerSymbol"] as Symbol;
//string test = txtText.Text;
//(_activeSymbol as TextSymbol).Text = test;
//MessageBox.Show(test);
(_activeSymbol as TextSymbol).Text = txtText.Text;
txtText.Text = string.Empty;
// spText.Visibility = Visibility.Collapsed;
}
ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
{
Geometry = args.Geometry,
Symbol = _activeSymbol,
};
graphicsLayer.Graphics.Add(graphic);
graphicsLayer.Refresh();
}
private void Tool_Click(object sender, RoutedEventArgs e)
{
UnSelectTools();
VisualStateManager.GoToState(sender as Button, "Selected", false);
_bolText = false;
switch ((sender as Button).Tag as string)
{
case "DrawPoint":
MyDrawObjectGraphic.DrawMode = DrawMode.Point;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicMarkerSymbol"] as Symbol;
break;
case "DrawPolyline":
MyDrawObjectGraphic.DrawMode = DrawMode.Polyline;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicLineSymbol"] as Symbol;
break;
case "DrawPolygon":
MyDrawObjectGraphic.DrawMode = DrawMode.Polygon;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "DrawRectangle":
MyDrawObjectGraphic.DrawMode = DrawMode.Rectangle;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "DrawFreehand":
MyDrawObjectGraphic.DrawMode = DrawMode.Freehand;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicLineSymbol"] as Symbol;
break;
case "DrawArrow":
MyDrawObjectGraphic.DrawMode = DrawMode.Arrow;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "DrawTriangle":
MyDrawObjectGraphic.DrawMode = DrawMode.Triangle;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "DrawCircle":
MyDrawObjectGraphic.DrawMode = DrawMode.Circle;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "DrawEllipse":
MyDrawObjectGraphic.DrawMode = DrawMode.Ellipse;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "EnterText":
MyDrawObjectGraphic.DrawMode = DrawMode.Point;
//_activeSymbol = LayoutRoot.Resources["DefaultGraphicMarkerSymbol"] as Symbol;
_activeSymbol = new TextSymbol()
{
Text = "",
FontSize = 12,
// Foreground = new SolidColorBrush(clr),
FontFamily = new FontFamily("Arial"),
};
_bolText = true;
break;
case "DrawNothing":
MyDrawObjectGraphic.DrawMode = DrawMode.None;
break;
default:
MyDrawObjectGraphic.DrawMode = DrawMode.None;
graphicsLayer.ClearGraphics();
break;
}
MyDrawObjectGraphic.IsEnabled = (MyDrawObjectGraphic.DrawMode != DrawMode.None);
}_Draw.IsEnabled = false; _Draw.DrawMode = DrawMode.None;
(_activesymbol as TextSymbol).Text = txtText.Text;