Ejemplo n.º 1
0
        public static MapWindowForm OpenMapWindow(MainWindow ownerWindow, bool showCoastline = false)
        {
            MapWindowForm mwf = MapWindowForm.GetInstance();

            if (mwf.Visibility == Visibility.Visible)
            {
                MapWindowForm.BringIntoView();
            }
            else
            {
                MapWindowForm = mwf;
                MapWindowForm.LocationChanged += MapWindowForm_LocationChanged;
                MapWindowForm.Closing         += MapWindowForm_Closing;
                MapWindowForm.Owner            = ownerWindow;
                MapWindowForm.ParentWindow     = ownerWindow;
                MapWindowForm.Show();

                MapLayersHandler      = MapWindowForm.MapLayersHandler;
                MapInterActionHandler = MapWindowForm.MapInterActionHandler;
                ShapefileAttributeTableManager.MapInterActionHandler = MapInterActionHandler;
                AOIManager.Setup();
                MapControl = MapWindowForm.MapControl;
                if (!MapStateFileExists)
                {
                    LoadCoastline(CoastLineFile);
                    MapControl.TileProvider = tkTileProvider.ProviderNone;
                }
                else if (Coastline == null && showCoastline)
                {
                    LoadCoastline(CoastLineFile);
                }
            }


            if (MapLayersWindow != null)
            {
                MapLayersWindow.Visibility = Visibility.Visible;
                MapLayersWindow.BringIntoView();
            }

            if (ShapeFileAttributesWindow != null)
            {
                ShapeFileAttributesWindow.Visibility = Visibility.Visible;
                ShapeFileAttributesWindow.BringIntoView();
            }
            MapLayersViewModel = new MapLayersViewModel(MapLayersHandler);

            return(mwf);
        }
Ejemplo n.º 2
0
        private void OnToolbarButtonClick(object sender, RoutedEventArgs e)
        {
            tkCursorMode cursorMode = tkCursorMode.cmNone;
            tkCursor     cursor     = tkCursor.crsrArrow;


            switch (((System.Windows.Controls.Button)sender).Name)
            {
            case "buttonAOI":
                ShowAOIList();
                break;

            case "buttonDataScreen":
                Visibility = Visibility.Hidden;
                if (MapWindowManager.MapLayersWindow != null)
                {
                    MapWindowManager.MapLayersWindow.Visibility = Visibility.Hidden;
                }
                if (MapWindowManager.ShapeFileAttributesWindow != null)
                {
                    MapWindowManager.ShapeFileAttributesWindow.Visibility = Visibility.Hidden;
                }

                ParentWindow.Focus();
                break;

            case "buttonExit":
                Close();
                break;

            case "buttonRuler":
                cursorMode = tkCursorMode.cmMeasure;
                cursor     = tkCursor.crsrCross;
                break;

            case "buttonPan":
                cursorMode = tkCursorMode.cmPan;
                cursor     = tkCursor.crsrSizeAll;
                break;

            case "buttonZoomPlus":
                cursorMode = tkCursorMode.cmZoomIn;
                cursor     = tkCursor.crsrCross;
                MakeCursor("zoom_plus");
                break;

            case "buttonZoomMinus":
                cursorMode = tkCursorMode.cmZoomOut;
                cursor     = tkCursor.crsrCross;
                break;

            case "buttonSelect":
                cursorMode = tkCursorMode.cmSelection;
                cursor     = tkCursor.crsrHand;
                break;

            case "buttonSelectPolygon":
                cursorMode = tkCursorMode.cmSelectByPolygon;
                cursor     = tkCursor.crsrHand;
                MapLayersHandler.CurrentMapLayer.LayerIsSelectable = true;
                break;

            case "buttonSelectNone":
                MapLayersHandler.ClearAllSelections();
                break;

            case "buttonAttributes":
                if (MapLayersHandler.CurrentMapLayer != null)
                {
                    ShapeFileAttributesWindow sfw = ShapeFileAttributesWindow.GetInstance(MapWindowManager.MapInterActionHandler);
                    if (sfw.Visibility == Visibility.Visible)
                    {
                        sfw.BringIntoView();
                    }
                    else
                    {
                        sfw.Owner     = this;
                        sfw.ShapeFile = MapLayersHandler.CurrentMapLayer.LayerObject as Shapefile;
                        sfw.ShowShapeFileAttribute();
                        sfw.Show();
                    }
                    MapWindowManager.ShapeFileAttributesWindow = sfw;
                }
                break;

            case "buttonGears":
                ToBeImplemented("mapping options");
                break;

            case "buttonUploadCloud":
                ToBeImplemented("upload to cloud");
                break;

            case "buttonCalendar":
                ToBeImplemented("calendar");
                break;

            case "buttonTrack":
                ToBeImplemented("track");
                break;

            case "buttonGPS":
                ToBeImplemented("gps");
                break;

            case "buttonLayers":
                var mlw = MapLayersWindow.GetInstance();

                if (mlw.Visibility == Visibility.Visible)
                {
                    mlw.BringIntoView();
                    mlw.Focus();
                }
                else
                {
                    mlw.ParentForm       = this;
                    mlw.Owner            = this;
                    mlw.MapLayersHandler = MapWindowManager.MapLayersHandler;
                    mlw.Show();
                }

                break;

            case "buttonAddLayer":
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Title      = "Open shapefile";
                ofd.Filter     = "Shapefile (*.shp)|*.shp";
                ofd.DefaultExt = "*.shp";
                DialogResult dr = ofd.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK &&
                    ofd.FileName.Length > 0 &&
                    File.Exists(ofd.FileName))
                {
                    string feedBack = "";
                    if (!MapWindowManager.AddShapefileLayer(ofd.FileName, out feedBack))
                    {
                        System.Windows.MessageBox.Show(feedBack, "GPX Manager",
                                                       MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                break;
            }


            MapControl.CursorMode = cursorMode;
            MapControl.MapCursor  = cursor;
        }
Ejemplo n.º 3
0
        private void OnToolbarButtonClick(object sender, RoutedEventArgs e)
        {
            tkCursorMode cursorMode = tkCursorMode.cmNone;
            tkCursor     cursor     = tkCursor.crsrArrow;


            switch (((System.Windows.Controls.Button)sender).Name)
            {
            case "buttonDataScreen":
                Visibility = Visibility.Hidden;
                if (MapWindowManager.MapLayersWindow != null)
                {
                    MapWindowManager.MapLayersWindow.Visibility = Visibility.Hidden;
                }
                if (MapWindowManager.ShapeFileAttributesWindow != null)
                {
                    MapWindowManager.ShapeFileAttributesWindow.Visibility = Visibility.Hidden;
                }

                ParentWindow.Focus();
                break;

            case "buttonExit":
                Close();
                break;

            case "buttonRuler":
                cursorMode = tkCursorMode.cmMeasure;
                cursor     = tkCursor.crsrCross;
                break;

            case "buttonPan":
                cursorMode = tkCursorMode.cmPan;
                cursor     = tkCursor.crsrSizeAll;
                break;

            case "buttonZoomPlus":
                cursorMode = tkCursorMode.cmZoomIn;
                cursor     = tkCursor.crsrCross;
                MakeCursor("zoom_plus");
                break;

            case "buttonZoomMinus":
                cursorMode = tkCursorMode.cmZoomOut;
                cursor     = tkCursor.crsrCross;
                break;

            case "buttonSelect":
                cursorMode = tkCursorMode.cmSelection;
                cursor     = tkCursor.crsrHand;
                break;

            case "buttonSelectNone":
                MapLayersHandler.ClearAllSelections();
                break;

            case "buttonAttributes":
                ShapeFileAttributesWindow sfw = ShapeFileAttributesWindow.GetInstance(MapWindowManager.MapInterActionHandler);
                if (sfw.Visibility == Visibility.Visible)
                {
                    sfw.BringIntoView();
                }
                else
                {
                    sfw.Owner     = this;
                    sfw.ShapeFile = MapLayersHandler.CurrentMapLayer.LayerObject as Shapefile;
                    sfw.ShowShapeFileAttribute();
                    sfw.Show();
                }
                MapWindowManager.ShapeFileAttributesWindow = sfw;
                break;

            case "buttonGears":
                ToBeImplemented("mapping options");
                break;

            case "buttonUploadCloud":
                ToBeImplemented("upload to cloud");
                break;

            case "buttonCalendar":
                ToBeImplemented("calendar");
                break;

            case "buttonTrack":
                ToBeImplemented("track");
                break;

            case "buttonGPS":
                ToBeImplemented("gps");
                break;

            case "buttonLayers":
                var mlw = MapLayersWindow.GetInstance();

                if (mlw.Visibility == Visibility.Visible)
                {
                    mlw.BringIntoView();
                    mlw.Focus();
                }
                else
                {
                    mlw.ParentForm       = this;
                    mlw.Owner            = this;
                    mlw.MapLayersHandler = MapWindowManager.MapLayersHandler;
                    mlw.Show();
                }

                break;

            case "buttonAddLayer":
                ToBeImplemented("add a layer");
                break;
            }


            MapControl.CursorMode = cursorMode;
            MapControl.MapCursor  = cursor;
        }