Esempio n. 1
0
        private void ApplySettingsButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Grid grid;

            // First, update the grid based on the type selected.
            switch (gridTypeCombo.SelectedValue.ToString())
            {
            case "LatLong":
                grid = new LatitudeLongitudeGrid();
                // Apply the label format setting.
                string selectedFormatString = labelFormatCombo.SelectedValue.ToString();
                ((LatitudeLongitudeGrid)grid).LabelFormat =
                    (LatitudeLongitudeGridLabelFormat)Enum.Parse(typeof(LatitudeLongitudeGridLabelFormat), selectedFormatString);
                break;

            case "MGRS":
                grid = new MgrsGrid();
                break;

            case "UTM":
                grid = new UtmGrid();
                break;

            case "USNG":
            default:
                grid = new UsngGrid();
                break;
            }

            // Next, apply the label visibility setting.
            grid.IsLabelVisible = labelVisibilityCheckbox.IsChecked.Value;

            // Next, apply the grid visibility setting.
            grid.IsVisible = gridVisibilityCheckbox.IsChecked.Value;

            // Next, apply the grid color and label color settings for each zoom level.
            for (long level = 0; level < grid.LevelCount; level++)
            {
                // Set the line symbol.
                Symbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.FromName(gridColorCombo.SelectedItem.ToString()), 2);
                grid.SetLineSymbol(level, lineSymbol);

                // Set the text symbol.
                Symbol textSymbol = new TextSymbol
                {
                    Color        = Colors.FromName(labelColorCombo.SelectedItem.ToString()),
                    OutlineColor = Colors.FromName(haloColorCombo.SelectedItem.ToString()),
                    Size         = 16,
                    HaloColor    = Colors.FromName(haloColorCombo.SelectedItem.ToString()),
                    HaloWidth    = 3
                };
                grid.SetTextSymbol(level, textSymbol);
            }

            // Next, apply the label position setting.
            grid.LabelPosition = (GridLabelPosition)Enum.Parse(typeof(GridLabelPosition), labelPositionCombo.SelectedValue.ToString());

            // Apply the updated grid.
            MyMapView.Grid = grid;
        }
        private void _applySettingsButton_Click(object sender, EventArgs e)
        {
            Grid grid;

            // First, update the grid based on the type selected.
            switch (_gridTypeSpinner.SelectedItem.ToString())
            {
            case "LatLong":
                grid = new LatitudeLongitudeGrid();
                // Apply the label format setting.
                string selectedFormatString = _labelFormatSpinner.SelectedItem.ToString();
                ((LatitudeLongitudeGrid)grid).LabelFormat =
                    (LatitudeLongitudeGridLabelFormat)Enum.Parse(typeof(LatitudeLongitudeGridLabelFormat), selectedFormatString);
                break;

            case "MGRS":
                grid = new MgrsGrid();
                break;

            case "UTM":
                grid = new UtmGrid();
                break;

            case "USNG":
            default:
                grid = new UsngGrid();
                break;
            }

            // Next, apply the label visibility setting.
            grid.IsLabelVisible = _labelVisibilitySwitch.Checked;

            // Next, apply the grid visibility setting.
            grid.IsVisible = _gridVisibilitySwitch.Checked;

            // Next, apply the grid color and label color settings for each zoom level.
            for (long level = 0; level < grid.LevelCount; level++)
            {
                // Set the line symbol.
                string lineColor  = ((ArrayAdapter <string>)_gridColorSpinner.Adapter).GetItem(_gridColorSpinner.SelectedItemPosition);
                Symbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.FromName(lineColor), 2);
                grid.SetLineSymbol(level, lineSymbol);

                // Set the text symbol.
                string labelColor = ((ArrayAdapter <String>)_labelColorSpinner.Adapter).GetItem(_labelColorSpinner.SelectedItemPosition);
                Symbol textSymbol = new TextSymbol
                {
                    Color      = Colors.FromName(labelColor),
                    Size       = 16,
                    FontWeight = FontWeight.Bold
                };
                grid.SetTextSymbol(level, textSymbol);
            }

            // Next, apply the label position setting.
            grid.LabelPosition = (GridLabelPosition)Enum.Parse(typeof(GridLabelPosition), _labelPositionSpinner.SelectedItem.ToString());

            // Apply the updated grid.
            _myMapView.Grid = grid;
        }
Esempio n. 3
0
        /// <summary>
        /// Display a Latitude / Longitude grid with labels over the map
        /// Would like to change the symbol properties for the lines and labels
        /// </summary>
        private void DisplayLatLongGrid()
        {
            //Create a new grid
            LatitudeLongitudeGrid gridLatLong        = new Esri.ArcGISRuntime.UI.LatitudeLongitudeGrid();
            LatitudeLongitudeGrid gridLatLongDefault = new LatitudeLongitudeGrid();

            //Configure grid
            gridLatLong.LabelFormat   = LatitudeLongitudeGridLabelFormat.DegreesMinutesSeconds;
            gridLatLong.LabelPosition = GridLabelPosition.TopRight;
            gridLatLong.LabelOffset   = 50;
            if (localSetting.GetSettingValue(ApplicationLiterals.KeywordMapViewGrid) != null)
            {
                gridLatLong.IsVisible = (bool)localSetting.GetSettingValue(ApplicationLiterals.KeywordMapViewGrid);
            }
            else
            {
                gridLatLong.IsVisible = true;
            }
            gridLatLong.IsLabelVisible = true;

            try
            {
                myMapView.Grid = gridLatLong;
            }
            catch (Exception)
            {
                myMapView.Grid = gridLatLongDefault;
            }

            myMapView.UpdateLayout();
        }
        private void ApplyCurrentSettings()
        {
            Grid grid;

            // First, update the grid based on the type selected.
            switch (_selectedGridType)
            {
            case "LatLong":
                grid = new LatitudeLongitudeGrid();
                break;

            case "MGRS":
                grid = new MgrsGrid();
                break;

            case "UTM":
                grid = new UtmGrid();
                break;

            case "USNG":
            default:
                grid = new UsngGrid();
                break;
            }

            // Next, apply the label position setting.
            grid.LabelPosition = _selectedLabelPosition;

            // Next, apply the grid color and label color settings for each zoom level.
            for (long level = 0; level < grid.LevelCount; level++)
            {
                // Set the grid color if the grid is selected for display.
                if (_selectedGridColor != null)
                {
                    // Set the line symbol.
                    Symbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, _selectedGridColor.Value, 2);
                    grid.SetLineSymbol(level, lineSymbol);
                }

                // Set the label color if labels are enabled for display.
                if (_selectedLabelColor != null)
                {
                    // Set the text symbol.
                    Symbol textSymbol = new TextSymbol
                    {
                        Color      = _selectedLabelColor.Value,
                        Size       = 16,
                        FontWeight = FontWeight.Bold
                    };
                    grid.SetTextSymbol(level, textSymbol);
                }
            }

            // Next, hide the grid if it has been hidden.
            if (_selectedGridColor == null)
            {
                grid.IsVisible = false;
            }

            // Next, hide the labels if they have been hidden.
            if (_selectedLabelColor == null)
            {
                grid.IsLabelVisible = false;
            }

            // Apply the updated grid.
            _myMapView.Grid = grid;
        }