Esempio n. 1
0
 public static SaveMapForm GetInstance(Grid25GenerateForm Parent)
 {
     if (_instance == null)
     {
         _instance = new SaveMapForm(Parent);
     }
     return(_instance);
 }
        private void OnToolbar_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            switch (e.ClickedItem.Name)
            {
            case "tsButtonXY":
                var g25MouseCoordForm = Grid25CoordinateForm.GetInstance(global.MappingForm.MapControl, _grid25MajorGrid);
                if (g25MouseCoordForm.Visible)
                {
                    g25MouseCoordForm.BringToFront();
                }
                else
                {
                    g25MouseCoordForm.Show(this);
                }
                break;

            case "tsButtonMBRs":
                break;

            //retrieve fishing grid boundaries and shows them on the map form
            case "tsButtonRetrieve":
                var folderBrowser = new FolderBrowserDialog();
                folderBrowser.ShowNewFolderButton = true;
                folderBrowser.SelectedPath        = SaveMapForm.GetSavedMapsFolder();
                folderBrowser.Description         = "Locate folder containing saved fishing ground grid maps";
                DialogResult result = FolderBrowserLauncher.ShowFolderBrowser(folderBrowser);
                if (result == DialogResult.OK)
                {
                    SaveMapForm.SetSavedMapsFolder(folderBrowser.SelectedPath);
                    SetupDictionary();
                    _grid25MajorGrid.ShowGridBoundaries(folderBrowser.SelectedPath, _utmZone, _labelAndGridProperties);
                }
                break;

            //Saves fishing grids either as shapefile or image file
            case "tsButtonSaveImage":
            case "tsButtonSaveShapefile":
                if (txtMapTitle.Text.Length > 0 && _grid25MajorGrid.HasGrid)
                {
                    RedoGridLabel();
                    using (var saveForm = new SaveMapForm(this))
                    {
                        saveForm.SaveType(SaveAsShapefile: e.ClickedItem.Name == "tsButtonSaveShapefile");
                        saveForm.MapTitle = txtMapTitle.Text;
                        saveForm.ShowDialog(this);
                        if (saveForm.DialogResult == DialogResult.OK)
                        {
                            _hasUnsavedMap = false;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please provide map title and fishing grid", "Validation error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;

            case "tsButtonFitMap":
                _grid25MajorGrid.FitGridToMap();
                break;

            case "tsButtonExit":
                if (!_hasUnsavedMap)
                {
                    Close();
                }
                else
                {
                    if (MessageBox.Show("You have not saved the map. Are you sure you still want to close?",
                                        "Close this window", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        Close();
                    }
                }
                break;
            }
        }
Esempio n. 3
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;
            }
        }
Esempio n. 4
0
 private void OnGrid25SaveForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     _instance = null;
 }