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. 2
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 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;
        }