Beispiel #1
0
        // A function that reads all values in the dialog (selected layers, color, size) to build the multilayer point symbol.
        private async Task <MultilayerPointSymbol> GetCurrentSymbol()
        {
            // Create a list of keys that identify the selected symbol layers.
            List <string> symbolKeys = new List <string>
            {
                _baseSymbolKey,
                _symbolLayersPickerModel.SelectedSymbolKey1,
                _symbolLayersPickerModel.SelectedSymbolKey2,
                _symbolLayersPickerModel.SelectedSymbolKey3
            };

            // Use the list of keys to return symbols from the mobile style (they will be combined and returned as a multilayer point symbol).
            MultilayerPointSymbol faceSymbol = await _emojiStyle.GetSymbolAsync(symbolKeys) as MultilayerPointSymbol;

            // Loop through all symbol layers and lock the color (changing the color property on the symbol will not affect these layers).
            foreach (SymbolLayer lyr in faceSymbol.SymbolLayers)
            {
                lyr.IsColorLocked = true;
            }

            // Unlock the color for the base (first) layer. Changing the symbol color will change this layer's color.
            faceSymbol.SymbolLayers.First().IsColorLocked = false;

            // Get the System.Drawing.Color from the color list that corresponds to the selected segment in the color control.
            System.Drawing.Color selectedUIColor = _colorList[(int)_colorSegments.SelectedSegment];

            // Set the symbol color using the selected color.
            faceSymbol.Color = selectedUIColor;

            // Set the symbol size from the slider.
            faceSymbol.Size = _sizeSlider.Value;

            // Return the multilayer point symbol.
            return(faceSymbol);
        }
        private async Task <MultilayerPointSymbol> GetCurrentSymbol()
        {
            // If the style hasn't been opened, return.
            if (_emojiStyle == null)
            {
                return(null);
            }

            MultilayerPointSymbol faceSymbol = null;

            try
            {
                // Get the key that identifies the selected eye symbol (or an empty string if none selected).
                SymbolLayerInfo eyeLayerInfo = (SymbolLayerInfo)EyeSymbolList.SelectedItem;
                string          eyeLayerKey  = eyeLayerInfo != null ? eyeLayerInfo.Key : string.Empty;

                // Get the key that identifies the selected mouth symbol (or an empty string if none selected).
                SymbolLayerInfo mouthLayerInfo = (SymbolLayerInfo)MouthSymbolList.SelectedItem;
                string          mouthLayerKey  = mouthLayerInfo != null ? mouthLayerInfo.Key : string.Empty;

                // Get the key that identifies the selected hat symbol (or an empty string if none selected).
                SymbolLayerInfo hatLayerInfo = (SymbolLayerInfo)HatSymbolList.SelectedItem;
                string          hatLayerKey  = hatLayerInfo != null ? hatLayerInfo.Key : string.Empty;

                // Create a list of the symbol keys that identify the selected symbol layers, including the base (circle) symbol.
                List <string> symbolKeys = new List <string>
                {
                    _baseSymbolKey, eyeLayerKey, mouthLayerKey, hatLayerKey
                };

                // Get a multilayer point symbol from the style that contains the selected symbol layers.
                faceSymbol = await _emojiStyle.GetSymbolAsync(symbolKeys) as MultilayerPointSymbol;

                // Loop through all symbol layers and lock the color.
                foreach (SymbolLayer lyr in faceSymbol.SymbolLayers)
                {
                    // Changing the color of the symbol will not affect this layer.
                    lyr.IsColorLocked = true;
                }

                // Unlock the color for the base (first) layer. Changing the symbol color will change this layer's color.
                faceSymbol.SymbolLayers.First().IsColorLocked = false;

                // Set the symbol color from the combo box.
                if (FaceColorComboBox.SelectedItem != null)
                {
                    faceSymbol.Color = (Color)FaceColorComboBox.SelectedItem;
                }

                // Set the symbol size from the slider.
                faceSymbol.Size = SizeSlider.Value;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to create symbol: " + ex.Message, "Exception");
            }

            // Return the multilayer point symbol.
            return(faceSymbol);
        }
        // A function to get a multilayer point symbol that contains all selected symbol layers.
        private async Task <MultilayerPointSymbol> GetCurrentSymbol()
        {
            MultilayerPointSymbol faceSymbol = null;

            try
            {
                // Create a new list of strings with the key for the base (face) symbol and any additional selected layers.
                List <string> symbolKeys = new List <string>
                {
                    _baseSymbolKey, _selectedEyesKey, _selectedMouthKey, _selectedHatKey
                };

                // Use the keys to get the symbol layers as a multilayer symbol.
                faceSymbol = await _emojiStyle.GetSymbolAsync(symbolKeys) as MultilayerPointSymbol;

                // Loop through all symbol layers and lock the color.
                foreach (SymbolLayer lyr in faceSymbol.SymbolLayers)
                {
                    // Changing the color of the symbol will not affect this layer.
                    lyr.IsColorLocked = true;
                }

                // Unlock the color for the base (first) layer. Changing the symbol color will change this layer's color.
                faceSymbol.SymbolLayers.First().IsColorLocked = false;

                // Set the symbol color using the last selected color.
                System.Drawing.Color symbolColor = System.Drawing.Color.FromArgb(_faceColor.A, _faceColor.R, _faceColor.G, _faceColor.B);
                faceSymbol.Color = symbolColor;

                // Set the symbol size from the slider.
                faceSymbol.Size = _symbolSize;
            }
            catch (Exception ex)
            {
                // Show the exception message.
                AlertDialog.Builder alertBuilder = new AlertDialog.Builder(Activity);
                alertBuilder.SetTitle("Error creating symbol");
                alertBuilder.SetMessage(ex.Message);
                alertBuilder.Show();
            }

            // Return the constructed symbol.
            return(faceSymbol);
        }
Beispiel #4
0
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap

            Map myMap = new Map(Basemap.CreateStreets());

            string file_shapefile_location = parent.FullName + "\\Data\\Public_Art.shp";

            try
            {
                ShapefileFeatureTable myShapefile = await ShapefileFeatureTable.OpenAsync(file_shapefile_location);

                // Create a feature layer to display the shapefile
                FeatureLayer newFeatureLayer = new FeatureLayer(myShapefile);

                string file_to_stylx = parent.FullName + "\\Data\\style.stylx";
                symbolStyle = await SymbolStyle.OpenAsync(file_to_stylx);


                IList <String> stringList = new List <string>();
                stringList.Add("shoppingcenter01");
                stringList.Add("marker01");


                SimpleRenderer simpleRenderer = new SimpleRenderer(await symbolStyle.GetSymbolAsync(stringList));
                newFeatureLayer.Renderer = simpleRenderer;


                // Add the feature layer to the map
                myMap.OperationalLayers.Add(newFeatureLayer);

                // Zoom the map to the extent of the shapefile

                MyMapView.Map = myMap;
                await MyMapView.SetViewpointGeometryAsync(newFeatureLayer.FullExtent);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }