void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { InitMenu(); var sf = App.SelectedShapefile; ctxSelectByRectangle.Enabled = true; ctxSelectByRectangle.Checked = App.Map.CursorMode == tkCursorMode.cmSelection; ctxMoveShapes.Checked = App.Map.CursorMode == tkCursorMode.cmMoveShapes; ctxRotateShapes.Checked = App.Map.CursorMode == tkCursorMode.cmRotateShapes; if (sf != null && sf.InteractiveEditing) { int selectedCount = sf.NumSelected; ctxMergeShapes.Enabled = selectedCount > 1; ctxSplitShapes.Enabled = selectedCount > 0; ctxMoveShapes.Enabled = selectedCount > 0; ctxRemoveShapes.Enabled = selectedCount > 0; ctxRotateShapes.Enabled = selectedCount > 0; ctxClearSelection.Enabled = selectedCount > 0; } var list = new[] { ctxCopy, ctxCut, ctxPaste }; foreach (var item in list) { item.Enabled = StateHelper.GetEnabled(item); } }
void mnuShapeEditor_DropDownOpening(object sender, EventArgs e) { mnuEditorVertices.Checked = Map.ShapeEditor.VerticesVisible; var list = new[] { mnuCopy, mnuPaste, mnuCut, mnuUndo, mnuRedo }; foreach (var item in list) { item.Enabled = StateHelper.GetEnabled(item); } }
public void RefreshUI() { int layerHandle = App.Instance.Legend.SelectedLayer; bool hasLayer = layerHandle != -1; var sf = App.Instance.Map.get_Shapefile(layerHandle); bool hasShapefile = sf != null; toolEditLayer.Checked = false; toolSplitShapes.Enabled = false; toolMergeShapes.Enabled = false; toolRotateShapes.Enabled = false; bool editing = false; if (hasShapefile) { editing = sf.InteractiveEditing; int numSelected = sf.NumSelected; toolSplitShapes.Enabled = numSelected > 0; toolMergeShapes.Enabled = numSelected > 1; toolRotateShapes.Enabled = numSelected > 0; } foreach (var item in _editToolStrip.Items.OfType <ToolStripItem>(). Where(item => item != toolEditLayer)) { item.Enabled = editing; } toolEditLayer.Enabled = hasShapefile; toolEditLayer.Image = editing ? Resources.save1 : Resources.edit; // save toolEditLayer.Text = editing ? "Save Changes" : "Edit Layer"; var map = App.Instance.Map; toolAddShape.Checked = map.CursorMode == tkCursorMode.cmAddShape; toolEditShape.Checked = map.CursorMode == tkCursorMode.cmEditShape; toolMoveShapes.Checked = map.CursorMode == tkCursorMode.cmMoveShapes; toolRotateShapes.Checked = map.CursorMode == tkCursorMode.cmRotateShapes; toolSplitByPolyline.Checked = map.CursorMode == tkCursorMode.cmSplitByPolyline; toolEraseByPolygon.Checked = map.CursorMode == tkCursorMode.cmEraseByPolygon; toolClipByPolygon.Checked = map.CursorMode == tkCursorMode.cmClipByPolygon; toolSplitByPolygon.Checked = map.CursorMode == tkCursorMode.cmSplitByPolygon; toolUndoCount.Text = string.Format("{0}\\{1}", map.UndoList.UndoCount, map.UndoList.TotalLength); toolMergeShapes.Enabled = false; toolSplitShapes.Enabled = false; if (sf != null && sf.InteractiveEditing) { int selectedCount = sf.NumSelected; toolMergeShapes.Enabled = selectedCount > 1; toolSplitShapes.Enabled = selectedCount > 0; toolMoveShapes.Enabled = selectedCount > 0; toolRotateShapes.Enabled = selectedCount > 0; } var list = new[] { toolCopy, toolPaste, toolCut, toolUndo, toolRedo }; foreach (var item in list) { item.Enabled = StateHelper.GetEnabled(item); } }