Esempio n. 1
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;
        }
Esempio 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 "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;
        }