Esempio n. 1
0
        private void OnToolbarClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            axMap.UDCursorHandle = -1;
            ToolStripItem tsi = e.ClickedItem;

            switch (tsi.Name)
            {
            case "tsButtonSave":
                _mapLayersHandler.SaveMapState();
                break;

            case "tsButtonLayers":
                var mlf = MapLayersForm.GetInstance(_mapLayersHandler, this);
                if (!mlf.Visible)
                {
                    mlf.Show(this);
                }
                else
                {
                    mlf.BringToFront();
                    mlf.Focus();
                }

                break;

            case "tsButtonLayerAdd":
                OpenFileDialog();
                break;

            case "tsButtonAttributes":

                if (MapLayersHandler.CurrentMapLayer != null)
                {
                    EditShapeAttributeForm esaf = EditShapeAttributeForm.GetInstance(this, _mapInterActionHandler);
                    if (esaf.Visible)
                    {
                        esaf.BringToFront();
                    }
                    else
                    {
                        esaf.Show(this);
                    }
                }
                else
                {
                    MessageBox.Show("Please select a layer", "No selected layer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;

            case "tsButtonZoomIn":
                axMap.MapCursor      = tkCursor.crsrUserDefined;
                axMap.UDCursorHandle = (int)((Bitmap)e.ClickedItem.Image).GetHicon();
                axMap.CursorMode     = tkCursorMode.cmZoomIn;
                break;

            case "tsButtonZoomOut":
                axMap.MapCursor      = tkCursor.crsrUserDefined;
                axMap.UDCursorHandle = (int)((Bitmap)e.ClickedItem.Image).GetHicon();
                axMap.CursorMode     = tkCursorMode.cmZoomOut;
                break;

            case "tsButtonZoomAll":
                axMap.ZoomToMaxExtents();
                break;

            case "tsButtonFitMap":
                break;

            case "tsButtonZoomPrevious":
                axMap.ZoomToPrev();
                break;

            case "tsButtonPan":
                SetCursor(tkCursorMode.cmPan);
                break;

            case "tsButtonBlackArrow":
                SetCursor(tkCursorMode.cmSelection);
                break;

            case "tsButtonMeasure":
                axMap.CursorMode = tkCursorMode.cmMeasure;
                axMap.MapCursor  = tkCursor.crsrMapDefault;
                break;

            case "tsButtonClearSelection":
                if (_currentMapLayer != null && _currentMapLayer.LayerType == "ShapefileClass")
                {
                    _mapLayersHandler.ClearSelection(_currentMapLayer.Handle);
                }
                break;

            case "tsButtonClearAllSelection":
                _mapLayersHandler.ClearAllSelections();
                break;

            case "tsButtonGraticule":
                ShowGraticuleForm();
                break;

            case "tsButtonSaveImage":
                var saveForm = new SaveMapForm();
                saveForm.SaveType(SaveAsShapefile: false);
                saveForm.ShowDialog(this);
                break;

            case "tsButtonCloseMap":
                Close();
                return;
            }

            switch (axMap.CursorMode)
            {
            case tkCursorMode.cmSelection:
                SetCursor(tkCursorMode.cmSelection);
                break;

            case tkCursorMode.cmPan:
                SetCursor(tkCursorMode.cmPan);
                break;

            default:

                break;
            }
        }