Select to view content in your preferred language

disabling draw surface

724
3
07-28-2010 02:55 PM
AgatinoLa_Rosa
Emerging Contributor
I am using the Draw Surface example to generate graphics on a silverlight application. The example says "To disable the Draw surface, set the DrawMode to None and IsEnabled property to false." I have tried the following lines

private void myDrawObject_OnDrawComplete(object sender, DrawEventArgs args)
{
myDrawObject.IsEnabled = false;
myDrawObject.IsEnabled = (myDrawObject.DrawMode == DrawMode.None);
}

I know that myDrawObject.IsEnabled = (myDrawObject.DrawMode != DrawMode.None) sets the bool to true. How can I set back to false?
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
After you've added the graphics to the layer in the DrawComplete event handler, you can disable the draw object explicitly setting its IsEnabled property to false or flipping its value like and setting DrawMode property to None if it is not already None.
myDrawObject.IsEnabled = !myDrawObject.IsEnabled;
if (myDrawObject.DrawMode != DrawMode.None)
    myDrawObject = DrawMode.None;

Jennifer
0 Kudos
AgatinoLa_Rosa
Emerging Contributor
I am not able to stop drawing even with your suggestions. The surface is still receiving drawings. I have a button event that triggers the draw surface. I would like to stop drawing at the end of the first polygon. This is my code. Anything wrong?

        private void StartPolygon_Click(object sender, RoutedEventArgs e)
        {
            Draw myDrawObject = new Draw(this.baseMap)
            {
                LineSymbol = this.layoutMap.Resources["DrawLineSymbol"] as LineSymbol,
                FillSymbol = this.layoutMap.Resources["DrawFillSymbol"] as FillSymbol
            };
            myDrawObject.DrawMode = DrawMode.Polygon;
            myDrawObject.DrawComplete += myDrawObject_OnDrawComplete;
            myDrawObject.IsEnabled = (myDrawObject.DrawMode != DrawMode.None);
           
        }

       private void myDrawObject_OnDrawComplete(object sender, DrawEventArgs args)
        {
           //here I save the graphics and then to stop drawing I say
            Draw myDrawObject = new Draw(this.baseMap)
            myDrawObject.DrawMode = DrawMode.None
        }
0 Kudos
AgatinoLa_Rosa
Emerging Contributor
My fault. I had a different draw definition in the constructor. It works now. Thanks.
0 Kudos