protected override void OnActivate() { try { UID dockWinID = new UIDClass(); dockWinID.Value = ThisAddIn.IDs.EditForm; IDockableWindow dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID); if (!dockWindow.IsVisible()) { dockWindow.Show(true); } activeLayer = Editor.ActiveLayer; IRasterLayer rasterLayer = (IRasterLayer)activeLayer; IRasterProps rasterProp = (IRasterProps)rasterLayer.Raster; maxIndex = new Position(rasterProp.Width - 1, rasterProp.Height - 1); EditForm editForm = AddIn.FromID <EditForm.AddinImpl>(ThisAddIn.IDs.EditForm).UI; editForm.SetLayer(activeLayer.Name); System.Array noDataValue = (System.Array)rasterProp.NoDataValue; editForm.RasterGridView.NoDataValue = Convert.ToDouble(noDataValue.GetValue(0)); editForm.SetNoDataValue(editForm.RasterGridView.NoDataValue); } catch (Exception ex) { MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error"); } base.OnActivate(); }
/// <summary> /// Stop editing. /// </summary> public static void StopEditing() { Editor.activeLayer = null; Editor.isEditing = false; Display.ClearElement(Editor.Edits.GetAllGraphicElements()); Editor.Edits.Clear(); Display.ClearElement(Editor.Selections.GetAllGraphicElements()); Editor.Selections.Clear(); StopEditingButton stopEditingButton = AddIn.FromID <StopEditingButton>(ThisAddIn.IDs.StopEditingButton); stopEditingButton.IsEnabled = false; StartEditingButton startEditionButton = AddIn.FromID <StartEditingButton>(ThisAddIn.IDs.StartEditingButton); startEditionButton.IsEnabled = true; SaveEditsButton saveEditsButton = AddIn.FromID <SaveEditsButton>(ThisAddIn.IDs.SaveEditsButton); saveEditsButton.IsEnabled = false; SaveEditsAsButton saveEditsAsButton = AddIn.FromID <SaveEditsAsButton>(ThisAddIn.IDs.SaveEditsAsButton); saveEditsAsButton.IsEnabled = false; EditTool selectTool = AddIn.FromID <EditTool>(ThisAddIn.IDs.EditTool); selectTool.IsEnabled = false; ShowEditsButton showEditsButton = AddIn.FromID <ShowEditsButton>(ThisAddIn.IDs.ShowEditsButton); showEditsButton.IsEnabled = false; EditForm editForm = AddIn.FromID <EditForm.AddinImpl>(ThisAddIn.IDs.EditForm).UI; editForm.ClearValues(); editForm.SetLayer(""); }