コード例 #1
0
 public Grid25GeographicDisplayHelper(MapLayersHandler mapLayersHandler, AxMap mapControl)
 {
     _mapcontrol           = mapControl;
     MapLayersHandler      = mapLayersHandler;
     _minorGridThickness   = 1;
     _subGridLineThickness = 1;
     _majorGridLabelColor  = new Utils().ColorByName(tkMapColor.Red);
     _majorGridLineColor   = new Utils().ColorByName(tkMapColor.Red);
     _minorGridLabelColor  = new Utils().ColorByName(tkMapColor.Black);
     _subGridLineColor     = new Utils().ColorByName(tkMapColor.Gray);
     _borderColor          = new Utils().ColorByName(tkMapColor.Black);
     HasGrid = false;
     _minorGridOffsetDistance = 0;
 }
コード例 #2
0
        private void OnMenuChecked(object sender, RoutedEventArgs e)
        {
            var menuItem = (WindowMenuItem)sender;

            switch (menuItem.Name)
            {
            case "menuMapCoastlineVisible":

                var coast = MapLayersHandler.get_MapLayer("Coastline");
                if (coast == null)
                {
                    MapWindowManager.LoadCoastline(MapWindowManager.CoastLineFile);
                    coast = MapLayersHandler.get_MapLayer("Coastline");
                }
                if (coast != null)
                {
                    MapLayersHandler.EditLayer(coast.Handle, coast.Name, menuItem.IsChecked);
                }
                else
                {
                    if (File.Exists(MapWindowManager.CoastLineFile))
                    {
                        System.Windows.MessageBox.Show("Coastline file could not be loaded as a GIS Shapefile", "GPX Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        System.Windows.MessageBox.Show("Coastline file could not be found", "GPX Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }

                break;

            case "menuMapTilesVisible":
                if (menuItem.IsChecked)
                {
                    menuMapTilesSelectProvider.IsEnabled = true;
                    if (MapControl.TileProvider == tkTileProvider.ProviderNone)
                    {
                        SelectTileProvider();
                    }
                }
                else
                {
                    MapControl.TileProvider = tkTileProvider.ProviderNone;
                    menuMapTilesSelectProvider.IsEnabled = false;
                }
                break;
            }
        }
コード例 #3
0
 private void OnCurrentLayer(MapLayersHandler s, LayerEventArg e)
 {
     if (rbtnUseSelectedLayer.Checked)
     {
         if (_layersHandler.CurrentMapLayer?.LayerType == "ShapefileClass")
         {
             var shp = _layersHandler.CurrentMapLayer.LayerObject as Shapefile;
             var ext = shp.Extents;
             txtMaxLat.Text = ext.yMax.ToString();
             txtMaxLon.Text = ext.xMax.ToString();
             txtMinLat.Text = ext.yMin.ToString();
             txtMinLon.Text = ext.xMin.ToString();
         }
     }
 }
コード例 #4
0
 public LayersForm(MapLayersHandler mapLayers, MainWindowForm parent)
 {
     InitializeComponent();
     _parent                               = parent;
     _mapLayersHandler                     = mapLayers;
     _mapLayersHandler.LayerRead          += OnLayerRead;
     _mapLayersHandler.LayerRemoved       += OnLayerDeleted;
     _mapLayersHandler.OnLayerNameUpdate  += OnLayerNameUpdated;
     _mapLayersHandler.LayerRefreshNeeded += OnLayerRefreshRequest;
     layerGrid.CellClick                  += OnCellClick;
     layerGrid.CellMouseDown              += OnCellMouseDown;
     layerGrid.CellDoubleClick            += OnCellDoubleClick;
     layerGrid.DragDrop                   += OnLayerGrid_DragDrop;
     layerGrid.DragOver                   += OnLayerGrid_DragOver;
     layerGrid.MouseDown                  += OnLayerGrid_MouseDown;
     layerGrid.MouseMove                  += OnLayerGrid_MouseMove;
 }
コード例 #5
0
 private void DataGridLayers_LayoutUpdated(object sender, EventArgs e)
 {
     if (_isDragDropDone)
     {
         List <MapLayerSequence> layersSequence = new List <MapLayerSequence>();
         int sequence = dataGridLayers.Items.Count - 1;
         foreach (MapLayer ly in dataGridLayers.Items)
         {
             layersSequence.Add(new MapLayerSequence {
                 MapLayer = ly, Sequence = sequence
             });
             sequence--;
         }
         MapLayersHandler.LayersSequence(layersSequence);
         _isDragDropDone = false;
     }
 }
コード例 #6
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            global.LoadFormSettings(this, true);

            _layersHandler = global.MappingForm.MapLayersHandler;
            _layersHandler.CurrentLayer += OnCurrentLayer;

            lvERDDAP.Visible = false;

            lvERDDAP.Columns.Clear();
            lvERDDAP.Columns.Add("Title");
            lvERDDAP.Columns.Add("Data start");
            lvERDDAP.Columns.Add("Data end");
            lvERDDAP.Columns.Add("Frequency");
            lvERDDAP.Columns.Add("Cell size");
            lvERDDAP.ShowItemToolTips = true;
            SizeColumns(lvERDDAP);

            //ERDDAP data download
            ERDDAPMetadataFiles.OnMetadataRead += OnERDDAPMetadataRead;
            _ERDDAPMetadataFolder      = ERDDAPMetadataFiles.GetMetadataDirectorySetting();
            txtMetadataFolderPath.Text = _ERDDAPMetadataFolder;

            if (_ERDDAPMetadataFolder.Length > 0)
            {
                //the xml metadatafiles in the metadata folder determines what FAD3 can download from ERDDAP
                ERDDAPMetadataFiles.MetadataDirectory = _ERDDAPMetadataFolder;

                //read xml metadata for ERDDAP download
                ERDDAPMetadataFiles.ReadISO9115Metadata();
            }

            lvERDDAP.Visible = true;

            MakeGridFromPoints.MapLayersHandler = global.MappingForm.MapLayersHandler;
            MakeGridFromPoints.OnExtentDefined += OnExtentDefined;
            Text = "Download gridded, oceanographic, spatio-temporal data using ERDDAP";
            UpdateDataSetCount();
            SetupTooltips();
        }
コード例 #7
0
        private void OnWindowLoaded(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();

            MapControl = new AxMapWinGIS.AxMap();
            host.Child = MapControl;
            MapGrid.Children.Add(host);

            MapLayersHandler        = new MapLayersHandler(MapControl);
            MapInterActionHandler   = new MapInterActionHandler(MapControl, MapLayersHandler);
            MapControl.ZoomBehavior = tkZoomBehavior.zbDefault;

            if (MapWindowManager.MapStateFileExists)
            {
                MapWindowManager.RestoreMapState(this);
                menuMapTilesVisible.IsChecked        = MapControl.TileProvider != tkTileProvider.ProviderNone;
                menuMapTilesSelectProvider.IsEnabled = MapControl.TileProvider != tkTileProvider.ProviderNone;
            }
            else
            {
                menuMapTilesSelectProvider.IsEnabled = false;
            }

            if (MapLayersHandler.get_MapLayer("Coastline") != null)
            {
                menuMapCoastlineVisible.IsChecked = MapLayersHandler.get_MapLayer("Coastline").Visible;
            }


            MapWindowManager.ResetCursor();

            MapInterActionHandler.ShapesSelected      += OnMapShapeSelected;
            MapLayersHandler.CurrentLayer             += OnMapCurrentLayer;
            MapLayersHandler.OnLayerVisibilityChanged += MapLayersHandler_OnLayerVisibilityChanged;
            GPXMappingManager.MapInteractionHandler    = MapInterActionHandler;
            TripMappingManager.MapInteractionHandler   = MapInterActionHandler;

            SetButtonEnabled();
        }
コード例 #8
0
 private void OnMapCurrentLayer(MapLayersHandler s, LayerEventArg e)
 {
     CurrentLayer = s.CurrentMapLayer;
     SetButtonEnabled();
 }
コード例 #9
0
 private void OnMapLayerRead(MapLayersHandler s, LayerEventArg e)
 {
     DrawLegendLayers();
 }
コード例 #10
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;
        }
コード例 #11
0
 private void OnCurrentMapLayer(MapLayersHandler s, LayerEventArg e)
 {
     _currentMapLayer = _mapLayersHandler.get_MapLayer(e.LayerHandle);
 }
コード例 #12
0
 private void OnFormLoad(object sender, EventArgs e)
 {
     _mapLayersHandler = new MapLayersHandler(mapControl);
     _mapLayersHandler.TilesVisible = false;
     _mapInterActionHandler         = new MapInterActionHandler(mapControl, _mapLayersHandler);
 }
コード例 #13
0
 public InventoryMapping(AxMap mapControl, MapLayersHandler layersHandler)
 {
     _mapControl    = mapControl;
     _layersHandler = layersHandler;
 }
コード例 #14
0
 private void MapLayersHandler_OnLayerVisibilityChanged(MapLayersHandler s, LayerEventArg e)
 {
     RefreshLayerGrid();
 }
コード例 #15
0
        private bool SpeciesOccurenceMapping()
        {
            string sql = "";

            if (Aggregate)
            {
                if (MapInSelectedTargetArea)
                {
                    sql = $@"SELECT tblAOI.AOIName,
                                tblSampling.FishingGround,
                                Count(tblSampling.SamplingGUID) AS n,
                                tblAOI.UTMZone
                            FROM (tblSampling INNER JOIN
                                tblAOI ON
                                tblSampling.AOI = tblAOI.AOIGuid) INNER JOIN
                                tblCatchComp ON tblSampling.SamplingGUID = tblCatchComp.SamplingGUID
                            WHERE tblCatchComp.NameGUID = {{{ItemToMapGuid}}} AND
                                Year([SamplingDate]) In ({YearsToCSV()}) AND
                                tblSampling.FishingGround Is Not Null AND
                                tblAOI.UTMZone Is Not Null AND
                                tblAOI.AOIGuid={{{SelectedTargetAreaGuid}}}
                            GROUP BY tblAOI.AOIName,
                                tblSampling.FishingGround,
                                tblAOI.UTMZone";
                }
                else
                {
                    sql = $@"SELECT tblAOI.AOIName,
                              tblSampling.FishingGround,
                              Count(tblSampling.SamplingGUID) AS n,
                              tblAOI.UTMZone
                            FROM (tblSampling INNER JOIN
                              tblCatchComp ON
                              tblSampling.SamplingGUID = tblCatchComp.SamplingGUID) INNER JOIN
                              tblAOI ON tblSampling.AOI = tblAOI.AOIGuid
                            WHERE Year([SamplingDate]) In ({YearsToCSV()}) AND
                              tblSampling.FishingGround Is Not Null AND
                              tblAOI.UTMZone Is Not Null AND
                              tblCatchComp.NameGUID={{{ItemToMapGuid}}}
                            GROUP BY tblAOI.AOIName,
                              tblSampling.FishingGround,
                              tblAOI.UTMZone";
                }
            }
            else
            {
                if (MapInSelectedTargetArea)
                {
                    sql = $@"SELECT tblAOI.AOIName,
                                tblEnumerators.EnumeratorName,
                                tblSampling.*,
                                tblLandingSites.LSName,
                                tblGearClass.GearClassName,
                                tblGearVariations.Variation,
                                tblAOI.UTMZone
                            FROM tblEnumerators
                                RIGHT JOIN ((tblAOI INNER JOIN tblLandingSites ON
                                tblAOI.AOIGuid = tblLandingSites.AOIGuid) INNER JOIN
                                ((tblGearClass INNER JOIN tblGearVariations ON
                                tblGearClass.GearClass = tblGearVariations.GearClass) INNER JOIN
                                (tblSampling INNER JOIN tblCatchComp ON
                                tblSampling.SamplingGUID = tblCatchComp.SamplingGUID) ON
                                tblGearVariations.GearVarGUID = tblSampling.GearVarGUID) ON
                                tblLandingSites.LSGUID = tblSampling.LSGUID) ON
                                tblEnumerators.EnumeratorID = tblSampling.Enumerator
                            WHERE tblSampling.AOI={{{SelectedTargetAreaGuid}}} AND
                                tblAOI.UTMZone Is Not Null AND
                                tblCatchComp.NameGUID={{{ItemToMapGuid}}} AND
                                Year([SamplingDate]) In ({YearsToCSV()}) AND
                                tblSampling.FishingGround Is Not Null
                            ORDER BY tblAOI.AOIName,
                                tblGearClass.GearClassName,
                                tblGearVariations.Variation,
                                tblSampling.SamplingDate";
                }
                else
                {
                    sql = $@"SELECT tblAOI.AOIName,
                                tblEnumerators.EnumeratorName,
                                tblSampling.*,
                                tblLandingSites.LSName,
                                tblGearClass.GearClassName,
                                tblGearVariations.Variation,
                                tblAOI.UTMZone
                            FROM tblEnumerators
                                RIGHT JOIN ((tblAOI INNER JOIN tblLandingSites ON
                                tblAOI.AOIGuid = tblLandingSites.AOIGuid) INNER JOIN
                                ((tblGearClass INNER JOIN tblGearVariations ON
                                tblGearClass.GearClass = tblGearVariations.GearClass) INNER JOIN
                                (tblSampling INNER JOIN tblCatchComp ON
                                tblSampling.SamplingGUID = tblCatchComp.SamplingGUID) ON
                                tblGearVariations.GearVarGUID = tblSampling.GearVarGUID) ON
                                tblLandingSites.LSGUID = tblSampling.LSGUID) ON
                                tblEnumerators.EnumeratorID = tblSampling.Enumerator
                            WHERE tblCatchComp.NameGUID={{{ItemToMapGuid}}} AND
                                Year([SamplingDate]) In ({YearsToCSV()}) AND
                                tblSampling.FishingGround Is Not Null AND
                                tblAOI.UTMZone Is Not Null
                            ORDER BY tblAOI.AOIName,
                                tblGearClass.GearClassName,
                                tblGearVariations.Variation,
                                tblSampling.SamplingDate";
                }
            }
            try
            {
                var sf = new Shapefile();
                if (sf.CreateNew("", ShpfileType.SHP_POINT))
                {
                    sf.GeoProjection = MapControl.GeoProjection;
                    var ifldTargetArea      = -1;
                    var ifldCount           = -1;
                    var ifldFishingGround   = -1;
                    var ifldSpeciesName     = -1;
                    var ifldGearClass       = -1;
                    var ifldGearVariation   = -1;
                    var ifldCatchWt         = -1;
                    var ifldReferenceNumber = -1;
                    var ifldSamplingDate    = -1;
                    var ifldVesselType      = -1;
                    var ifldLandindSite     = -1;
                    var ifldEnumerator      = -1;
                    if (Aggregate)
                    {
                        ifldTargetArea    = sf.EditAddField("TargetArea", FieldType.STRING_FIELD, 1, 100);
                        ifldFishingGround = sf.EditAddField("FG", FieldType.STRING_FIELD, 1, 8);
                        ifldSpeciesName   = sf.EditAddField("Species", FieldType.STRING_FIELD, 1, 100);
                        ifldCount         = sf.EditAddField("n", FieldType.INTEGER_FIELD, 1, 4);
                    }
                    else
                    {
                        ifldReferenceNumber = sf.EditAddField("RefNo", FieldType.STRING_FIELD, 1, 20);
                        ifldEnumerator      = sf.EditAddField("Enumerator", FieldType.STRING_FIELD, 1, 30);
                        ifldSpeciesName     = sf.EditAddField("Species", FieldType.STRING_FIELD, 1, 100);
                        ifldTargetArea      = sf.EditAddField("TargetArea", FieldType.STRING_FIELD, 1, 100);
                        ifldLandindSite     = sf.EditAddField("LandingSite", FieldType.STRING_FIELD, 1, 50);
                        ifldSamplingDate    = sf.EditAddField("SamplingDate", FieldType.DATE_FIELD, 1, 1);
                        ifldGearClass       = sf.EditAddField("GearClass", FieldType.STRING_FIELD, 1, 25);
                        ifldGearVariation   = sf.EditAddField("GearVariation", FieldType.STRING_FIELD, 1, 35);
                        ifldFishingGround   = sf.EditAddField("FishingGround", FieldType.STRING_FIELD, 1, 8);
                        ifldCatchWt         = sf.EditAddField("CatchWeight", FieldType.DATE_FIELD, 2, 10);
                        ifldVesselType      = sf.EditAddField("Vessel", FieldType.STRING_FIELD, 1, 25);
                    }

                    using (OleDbConnection conn = new OleDbConnection(global.ConnectionString))
                    {
                        conn.Open();
                        var       adapter = new OleDbDataAdapter(sql, conn);
                        DataTable dt      = new DataTable();
                        adapter.Fill(dt);
                        if (dt.Rows.Count > 0)
                        {
                            for (int n = 0; n < dt.Rows.Count; n++)
                            {
                                DataRow    dr      = dt.Rows[n];
                                var        fg      = dr["FishingGround"].ToString();
                                var        zone    = dr["UTMZone"].ToString();
                                fadUTMZone utmZone = FishingGrid.ZoneFromZoneName(zone);
                                FishingGrid.UTMZone = utmZone;
                                var latlong = FishingGrid.Grid25ToLatLong(fg, utmZone);
                                var shp     = new Shape();
                                if (shp.Create(ShpfileType.SHP_POINT) && shp.AddPoint(latlong.longitude, latlong.latitude) >= 0)
                                {
                                    var iShp = sf.EditAddShape(shp);
                                    if (Aggregate)
                                    {
                                        if (sf.EditCellValue(ifldTargetArea, iShp, dr["AOIName"].ToString()))
                                        {
                                            sf.EditCellValue(ifldCount, iShp, (int)dr["n"]);
                                            sf.EditCellValue(ifldSpeciesName, iShp, ItemName);
                                            sf.EditCellValue(ifldFishingGround, iShp, fg);
                                        }
                                    }
                                    else
                                    {
                                        sf.EditCellValue(ifldSpeciesName, iShp, ItemName);
                                        sf.EditCellValue(ifldEnumerator, iShp, dr["EnumeratorName"].ToString());
                                        sf.EditCellValue(ifldTargetArea, iShp, dr["AOIName"].ToString());
                                        sf.EditCellValue(ifldFishingGround, iShp, fg);
                                        sf.EditCellValue(ifldGearClass, iShp, dr["GearClassName"].ToString());
                                        sf.EditCellValue(ifldGearVariation, iShp, dr["Variation"].ToString());
                                        sf.EditCellValue(ifldReferenceNumber, iShp, dr["RefNo"].ToString());
                                        sf.EditCellValue(ifldSamplingDate, iShp, string.Format("{0:MMM-dd-yyyy}", (DateTime)dr["SamplingDate"]));
                                        sf.EditCellValue(ifldCatchWt, iShp, (double)dr["WtCatch"]);
                                        sf.EditCellValue(ifldVesselType, iShp, FishingVessel.VesselTypeFromVesselTypeNumber((int)dr["VesType"]));
                                        sf.EditCellValue(ifldLandindSite, iShp, dr["LSName"].ToString());
                                    }
                                }
                            }
                        }
                    }
                    sf.DefaultDrawingOptions.PointShape = tkPointShapeType.ptShapeCircle;
                    ClassificationType classificationType = ClassificationType.None;
                    if (Aggregate)
                    {
                        ShapefileLayerHelper.CategorizeNumericPointLayer(sf, ifldCount);
                        sf.DefaultDrawingOptions.LineVisible = true;
                        sf.DefaultDrawingOptions.LineColor   = new Utils().ColorByName(tkMapColor.White);
                        sf.CollisionMode   = tkCollisionMode.AllowCollisions;
                        classificationType = ClassificationType.JenksFisher;
                    }
                    else
                    {
                        sf.DefaultDrawingOptions.PointSize = 8;
                    }

                    var h = MapLayersHandler.AddLayer(sf, $"Species mapping: {ItemName} ({YearsToCSV()})", mappingMode: fad3MappingMode.occurenceMappingSpeciesAggregated);
                    MapLayersHandler[h].ClassificationType = classificationType;
                    MapControl.Redraw();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message, "OcuurenceMapping", "SpeciesOccurence");
            }
            return(true);
        }
コード例 #16
0
 public VisibilityQueryForm(MapLayersHandler handler)
 {
     InitializeComponent();
     _layersHandler = handler;
     _shapeFile     = _layersHandler.CurrentMapLayer.LayerObject as Shapefile;
 }
コード例 #17
0
        private bool AddSelectedLayoutGrid(string layoutCellName)
        {
            _grid25Layers.Clear();
            _grid25Layers.Add("Minor grid", $"{layoutCellName}_gridlines.shp");
            _grid25Layers.Add("Major grid", $"{layoutCellName}_majorgrid.shp");
            _grid25Layers.Add("Labels", $"{layoutCellName}_gridlabels.shp");
            _grid25Layers.Add("MBR", $"{layoutCellName}_gridboundary.shp");

            string gridStateFile = $@"{SourceFolder}\{layoutCellName}_gridstate.xml";

            if (File.Exists(gridStateFile) && !_gridStateFinishedReading)
            {
                XmlTextReader xmlReader = new XmlTextReader(gridStateFile);
                while (xmlReader.Read())
                {
                    if (xmlReader.NodeType == XmlNodeType.Element)
                    {
                        switch (xmlReader.Name)
                        {
                        case "FishingGroundGridMap":
                            _minorGridLabelDistance = float.Parse(xmlReader.GetAttribute("minorGridLabelDistance")) / (60 * 1852);
                            _minorGridLabelFontBold = xmlReader.GetAttribute("minorGridLabelFontBold") != "0";
                            _minorGridThickness     = float.Parse(xmlReader.GetAttribute("minorGridThickness")) / 100;
                            _majorGridThickness     = float.Parse(xmlReader.GetAttribute("majorGridThickness")) / 100;
                            _majorGridLineColor     = uint.Parse(xmlReader.GetAttribute("majorGridLineColor"));
                            _minorGridLineColor     = uint.Parse(xmlReader.GetAttribute("minorGridLineColor"));
                            _minorGridLabelColor    = uint.Parse(xmlReader.GetAttribute("minorGridLabelColor"));
                            _borderColor            = uint.Parse(xmlReader.GetAttribute("borderColor"));
                            _borderThickness        = float.Parse(xmlReader.GetAttribute("borderThickness")) / 100;
                            _majorGridLabelSize     = int.Parse(xmlReader.GetAttribute("majorGridLabelSize"));
                            _majorGridLabelColor    = uint.Parse(xmlReader.GetAttribute("majorGridLabelColor"));
                            _minorGridLabelSize     = int.Parse(xmlReader.GetAttribute("minorGridLabelSize"));
                            _majorGridLabelFontBold = false;
                            _subGridLineColor       = uint.Parse(xmlReader.GetAttribute("subGridLineColor"));
                            _subGridLineThickness   = float.Parse(xmlReader.GetAttribute("subGridLineThickness")) / 100;
                            break;
                        }
                    }
                }
                _gridStateFinishedReading = true;
            }

            var    sf   = new Shapefile();
            string file = $@"{SourceFolder}\{_grid25Layers["Minor grid"]}";

            if (File.Exists(file) && sf.Open(file))
            {
                _hMinorGrid = MapLayersHandler.AddLayer(sf, "Minor grid", true, true);
                MapLayersHandler[_hMinorGrid].IsGrid25Layer = true;
                SetupShapefileLayerForPrinting(MapLayersHandler[_hMinorGrid]);

                sf   = new Shapefile();
                file = $@"{SourceFolder}\{_grid25Layers["Major grid"]}";
                if (File.Exists(file) && sf.Open(file))
                {
                    _hMajorGrid = MapLayersHandler.AddLayer(sf, "Major grid", true, true);
                    MapLayersHandler[_hMajorGrid].IsGrid25Layer = true;
                    SetupShapefileLayerForPrinting(MapLayersHandler[_hMajorGrid]);
                }

                sf   = new Shapefile();
                file = $@"{SourceFolder}\{_grid25Layers["Labels"]}";
                if (File.Exists(file) && sf.Open(file))
                {
                    _hGridLabels = MapLayersHandler.AddLayer(sf, "Labels", true, true);
                    MapLayersHandler[_hGridLabels].IsGrid25Layer = true;
                    SetupShapefileLayerForPrinting(MapLayersHandler[_hGridLabels]);
                    int reprojectedCount = 0;
                    MBR = sf.Reproject(_mapcontrol.GeoProjection, ref reprojectedCount);
                }

                sf   = new Shapefile();
                file = $@"{SourceFolder}\{_grid25Layers["MBR"]}";
                if (File.Exists(file) && sf.Open(file))
                {
                    _hMBR = MapLayersHandler.AddLayer(sf, "MBR", true, true);
                    MapLayersHandler[_hMBR].IsGrid25Layer = true;
                    SetupShapefileLayerForPrinting(MapLayersHandler[_hMBR]);
                }

                SymbolizeGrid();
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #18
0
 private void OnVisibilityExpression(MapLayersHandler s, LayerEventArg e)
 {
     txtVisibilityExpression.Text = e.VisibilityExpression;
 }
コード例 #19
0
 private void MapLayersHandler_CurrentLayer(MapLayersHandler s, LayerEventArg e)
 {
     ShapeFile = s.CurrentMapLayer.LayerObject as Shapefile;
     ShowShapeFileAttribute();
 }
コード例 #20
0
 private void OnLayerNameUpdated(MapLayersHandler s, LayerEventArg e)
 {
     layerGrid[_layerCol, _layerRow].Value = e.LayerName;
 }
コード例 #21
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;
        }
コード例 #22
0
 /// <summary>
 /// Event fired when a layer was selected in the layers form
 /// </summary>
 /// <param name="s"></param>
 /// <param name="e"></param>
 private void OnCurrentLayer(MapLayersHandler s, LayerEventArg e)
 {
     _currentMapLayer = MapInterActionHandler.MapLayersHandler.CurrentMapLayer;
     DisplayAttributes();
 }