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;
        }
Example #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;
        }
Example #3
0
        private void ColorToStringButton_OnClick(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = Color.FromName("#00110000");

            string colorString = System.Drawing.ColorTranslator.ToHtml(color);

            MessageBox.Show(colorString);
        }
Example #4
0
        public static DrawingColor ToColor(string value)
        {
            if (!value.Contains(","))
            {
                return(DrawingColor.FromName(value));
            }

            string[] colors = value.Split(',');
            _ = int.TryParse(colors.Length > 0 ? colors[0] : string.Empty, out int r);
            _ = int.TryParse(colors.Length > 1 ? colors[1] : string.Empty, out int g);
            _ = int.TryParse(colors.Length > 2 ? colors[2] : string.Empty, out int b);
            _ = int.TryParse(colors.Length > 3 ? colors[3] : string.Empty, out int a);

            return(DrawingColor.FromArgb(a, r, g, b));
        }