I have converted the DrawGraphics tool http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#DrawGraphics to a Viewer addin. Everything works fine except for the editor check box. I have tried a ton of different things but the edit geometry box is not functional. It has something to do with the MouseLeftButtonUp event. I'm not sure whats going on. Code is below.
C# namespace DrawGraphics.AddIns { public partial class DrawGraphicsDialog : UserControl { private Draw MyDrawObject; private Symbol _activeSymbol = null; GraphicsLayer graphicsLayer;
public Map MyMap { get { return MapApplication.Current.Map; } }
public GraphicsLayer MyGraphicsLayer { get { return MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; } }
public DrawGraphicsDialog() { InitializeComponent();
graphicsLayer = MyGraphicsLayer;
if (graphicsLayer == null) { graphicsLayer = createGraphicsLayer(); MapApplication.Current.Map.Layers.Add(graphicsLayer); }
MyDrawObject = new Draw(MyMap) { LineSymbol = LayoutRoot.Resources["DrawLineSymbol"] as LineSymbol, FillSymbol = LayoutRoot.Resources["DrawFillSymbol"] as FillSymbol }; MyDrawObject.DrawComplete += MyDrawObject_DrawComplete; }
private void GraphicsLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e) { if (EnableEditVerticesScaleRotate.IsChecked.Value) { MyDrawObject.DrawMode = DrawMode.None; UnSelectTools(); Editor editor = LayoutRoot.Resources["MyEditor"] as Editor; if (e.Graphic != null && !(e.Graphic.Geometry is ESRI.ArcGIS.Client.Geometry.MapPoint)) { editor.EditVertices.Execute(e.Graphic); } } }
private void UnSelectTools() { foreach (UIElement element in MyStackPanel.Children) if (element is Button) VisualStateManager.GoToState((element as Button), "UnSelected", false); }