Esempio n. 1
0
        private void OnButtonClick(object sender, RoutedEventArgs e)
        {
            switch (((Button)sender).Name)
            {
            case "buttonCancel":
                MapWindowManager.MapLayersHandler.RemoveLayer(AOIManager._hAOI);
                Close();
                break;

            case "buttonOk":
                if (textBoxAOIName.Text.Length > 0)
                {
                    _aoi = AOIManager.SaveAOI(textBoxAOIName.Text);

                    if (_aoi != null)
                    {
                        Close();
                    }
                }
                else if (_editingAOI)
                {
                    _aoi = AOIManager.SaveAOI(_aoi.Name, true);
                    buttonOk.IsEnabled = _aoi == null;
                }
                break;
            }
        }
Esempio n. 2
0
        private void OnMenuClick(object sender, RoutedEventArgs e)
        {
            switch (((MenuItem)sender).Name)
            {
            case "menuAOIZoom":
                if (_aoi != null)
                {
                    MapWindowManager.ZoomToShapeFileExtent(_aoi.ShapeFile);
                }
                break;

            case "menuAOIEditExtent":
                if (_aoi != null)
                {
                    _editingAOI = true;
                    AOIManager.Edit(_aoi);
                    buttonOk.IsEnabled = true;
                }
                break;

            case "menuAOIRemove":
                if (_aoi != null)
                {
                    MapWindowManager.MapLayersHandler.RemoveLayer(_aoi.MapLayerHandle);
                }
                break;
            }
        }
Esempio n. 3
0
        private void OnMenuClick(object sender, RoutedEventArgs e)
        {
            switch (((WindowMenuItem)sender).Name)
            {
            case "menuEdit":
                break;

            case "menuAddLayerBoundaryLGU":
                string feedfBack = "";
                MapWindowManager.AddLGUBoundary(out feedfBack);
                if (feedfBack.Length > 0)
                {
                    System.Windows.MessageBox.Show(feedfBack, "GPX Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                break;

            case "menuMapTilesSelectProvider":
                SelectTileProvider();
                break;

            case "menuClose":
                Close();
                break;

            case "menuSaveMapState":
                SaveMapState();
                break;

            case "menuAOICreate":
                var aoiw = new AOIWindow();
                aoiw.Owner = this;
                aoiw.AddNewAOI();
                aoiw.Show();
                AOIManager.AddNew();
                break;

            case "menuAOIList":
                aoiw = new AOIWindow();
                aoiw.ShowAOIList();
                aoiw.Owner = this;
                aoiw.Show();
                break;

            case "menuIslandLabels":
                break;
            }
        }
Esempio n. 4
0
        private void OnMenuClick(object sender, RoutedEventArgs e)
        {
            switch (((WindowMenuItem)sender).Name)
            {
            case "menuCleanExtractedtracks":
                if (MapWindowManager.ExtractedTracksShapefile != null && MapWindowManager.BSCBoundaryShapefile != null)
                {
                    var result = Entities.ExtractedFishingTrackViewModel.CleanupUsingBoundary(MapWindowManager.BSCBoundaryShapefile);

                    string message = "No tracks were removed during the cleanup";
                    if (result > 0)
                    {
                        message = $"Cleanup resulted in {result} tracks removed";
                    }

                    System.Windows.Forms.MessageBox.Show(message, "GPX Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    System.Windows.MessageBox.Show("Extracted track and boundary must be loaded", "GPX Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                break;

            case "menuAddExtractedTracks":
                if (!MapWindowManager.AddExtractedTracksLayer())
                {
                    System.Windows.MessageBox.Show("Extracted tracks not found", "GPX Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                break;

            case "menuAddBSCBoundary":
                string feedfBack = "";

                if (!MapWindowManager.SetBoundaryShapefile())
                {
                    if (MapWindowManager.BSCBoundaryShapefile == null)
                    {
                        MapWindowManager.AddBSCBoundaryLineShapefile(FileOpenDialogForShapefile(), out feedfBack);
                    }
                    if (feedfBack.Length > 0)
                    {
                        System.Windows.MessageBox.Show(feedfBack, "GPX Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }

                break;

            case "menuEdit":
                break;

            case "menuAddLayerBoundaryLGU":
                feedfBack = "";
                MapWindowManager.AddLGUBoundary(out feedfBack);
                if (feedfBack.Length > 0)
                {
                    System.Windows.MessageBox.Show(feedfBack, "GPX Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                break;

            case "menuMapTilesSelectProvider":
                SelectTileProvider();
                break;

            case "menuClose":
                Close();
                break;

            case "menuSaveMapState":
                SaveMapState();
                break;

            case "menuAOICreate":
                var aoiw = new AOIWindow();
                aoiw.Owner = this;
                aoiw.AddNewAOI();
                aoiw.Show();
                AOIManager.AddNew();
                break;

            case "menuAOIList":
                ShowAOIList();
                break;

            case "menuIslandLabels":
                break;
            }
        }
        private void OnMenuClick(object sender, RoutedEventArgs e)
        {
            switch (((MenuItem)sender).Name)
            {
            case "menuAOIDelete":
                break;

            case "menuFormatMap":
                bool proceed = false;
                foreach (var aoi in Entities.AOIViewModel.GetAllAOI())
                {
                    if (aoi.GridIsLoaded && aoi.GridMapping.HasGriddedData)
                    {
                        proceed = true;
                        break;
                    }
                }


                if (!proceed)
                {
                    MessageBox.Show("There is no gridded map", "GPXC Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    FormatGridMapWindow fmw = FormatGridMapWindow.GetInstance(_aoi);
                    if (fmw.Visibility == Visibility.Visible)
                    {
                        fmw.BringIntoView();
                    }
                    else
                    {
                        fmw.Owner = this;
                        fmw.Show();
                    }
                }

                break;

            case "menuEditGrid":
                MakeGrid();
                menuEditGrid.IsEnabled   = false;
                menuShowGrid.IsEnabled   = false;
                menuRemoveGrid.IsEnabled = true;
                break;

            case "menuGridMapping":
                ShowGridMappingWindow();
                break;

            case "menuAOIZoom":
                if (_aoi != null)
                {
                    MapWindowManager.ZoomToShapeFileExtent(_aoi.ShapeFile);
                }
                break;

            case "menuAOIEditExtent":
                if (_aoi != null)
                {
                    _editingAOI = true;
                    AOIManager.Edit(_aoi);
                    buttonOk.IsEnabled = true;
                }
                break;

            case "menuRemoveGrid":
                if (_aoi != null)
                {
                    //MapWindowManager.MapLayersHandler.RemoveLayer(_aoi.MapLayerHandle);
                    MapWindowManager.MapLayersHandler.RemoveLayer(_aoi.GridLayerName);
                    _aoi.GridIsLoaded        = false;
                    menuRemoveGrid.IsEnabled = false;
                    menuShowGrid.IsEnabled   = !_aoi.GridIsLoaded;
                    menuEditGrid.IsEnabled   = !_aoi.GridIsLoaded;
                    SetDataGridContext();
                }
                break;

            case "menuShowGrid":

                if (_aoi.GridFileName != null && _aoi.GridFileName.Length > 0 && File.Exists(_aoi.GridFileName))
                {
                    var files = Entities.AOIViewModel.GetAOISubGridFileNames(_aoi);
                    if (files.Count > 1)
                    {
                        var selectedFile         = "";
                        SelectGridFileWindow sgw = new SelectGridFileWindow();
                        sgw.GridFiles = files;
                        if ((bool)sgw.ShowDialog())
                        {
                            selectedFile = sgw.SelectedFile;
                            menuGridMapping.IsEnabled = _aoi.CreateGridFromFileName(selectedFile);
                        }
                    }
                    else
                    {
                        menuGridMapping.IsEnabled = _aoi.CreateGridFromFileName(_aoi.GridFileName);
                    }
                }
                else
                {
                    MakeGrid();
                }
                SetDataGridContext();
                menuShowGrid.IsEnabled   = !_aoi.GridIsLoaded;
                menuEditGrid.IsEnabled   = menuShowGrid.IsEnabled;
                menuRemoveGrid.IsEnabled = _aoi.GridIsLoaded;
                break;
            }
        }
        private void OnButtonClick(object sender, RoutedEventArgs e)
        {
            Button btn = (Button)sender;

            switch (btn.Name)
            {
            case "buttonProcessGrid":
            case "buttonShowGrid":
            case "buttonFormatMaps":
                if (Entities.AOIViewModel.CountSelected() > 0)
                {
                    switch (btn.Name)
                    {
                    case "buttonShowGrid":
                        Entities.AOIViewModel.SetGridFilenamesOfCommonSize();
                        if (Entities.AOIViewModel.CommonGridSizes.Count > 1)
                        {
                            SelectGridFileWindow sgw = new SelectGridFileWindow();
                            sgw.CommonGridSizes = Entities.AOIViewModel.CommonGridSizes;
                            if ((bool)sgw.ShowDialog())
                            {
                                //Entities.AOIViewModel.CommonGridSizeSelectedSize = sgw.SelectedGridSize;
                                foreach (var aoi in Entities.AOIViewModel.GetSelectedAOIs())
                                {
                                    var file = aoi.GetGridFileNameOfGridSize(((int)sgw.SelectedGridSize).ToString());
                                    aoi.CreateGridFromFileName(file);
                                }
                            }
                        }
                        else if (Entities.AOIViewModel.CommonGridSizes.Count == 1)
                        {
                            foreach (var aoi in Entities.AOIViewModel.GetSelectedAOIs())
                            {
                                var file = aoi.GetGridFileNameOfGridSize(Entities.AOIViewModel.CommonGridSizes[0]);
                                aoi.CreateGridFromFileName(file);
                            }
                        }
                        SetDataGridContext();
                        break;

                    case "buttonProcessGrid":
                        var griddedAOICount = Entities.AOIViewModel.GetSelectedAOIs().Count(t => t.SubGrids != null);
                        if (griddedAOICount == Entities.AOIViewModel.CountSelected())
                        {
                            ShowGridMappingWindow(mulitpleAOIs: true);
                        }
                        else
                        {
                            MessageBox.Show("All selected AOIs must have a grid", "GPX Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        break;

                    case "buttonFormatMaps":
                        FormatGridMapWindow fmw = FormatGridMapWindow.GetInstance(_aoi);
                        if (fmw.Visibility == Visibility.Visible)
                        {
                            fmw.BringIntoView();
                        }
                        else
                        {
                            fmw.Owner = this;
                            fmw.Show();
                        }
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("At least one AOI must be selected", "GPX Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                break;

            case "buttonCancel":
                MapWindowManager.MapLayersHandler.RemoveLayer(AOIManager._hAOI);
                Close();
                break;

            case "buttonOk":
                if (textBoxAOIName.Text.Length > 0)
                {
                    _aoi = AOIManager.SaveAOI(textBoxAOIName.Text);

                    if (_aoi != null)
                    {
                        Close();
                    }
                }
                else if (_editingAOI)
                {
                    _aoi = AOIManager.SaveAOI(_aoi.Name, true);
                    buttonOk.IsEnabled = _aoi == null;
                }
                break;
            }
        }