// A function that reads a mobile style file and builds a list for each of three symbol categories. private async Task ReadMobileStyle() { // Open a mobile style file. _emojiStyle = await SymbolStyle.OpenAsync(_mobileStyleFilePath); // Get the default style search parameters. SymbolStyleSearchParameters searchParams = await _emojiStyle.GetDefaultSearchParametersAsync(); // Search the style with the default parameters to return all symbol results. IList <SymbolStyleSearchResult> styleResults = await _emojiStyle.SearchSymbolsAsync(searchParams); // Loop through the results and put symbols into the appropriate list according to category. foreach (SymbolStyleSearchResult result in styleResults) { // Get the symbol from the result. MultilayerPointSymbol multiLayerSym = result.Symbol as MultilayerPointSymbol; // Create an image from the symbol swatch. RuntimeImage swatch = await multiLayerSym.CreateSwatchAsync(); UIImage symbolImage = await swatch.ToImageSourceAsync(); // Create an instance of the custom SymbolLayerInfo class to store info about this symbol: name, swatch image, unique ID (key). SymbolLayerInfo symbolInfo = new SymbolLayerInfo(result.Name, symbolImage, result.Key); // Check the category for this result and place it into the correct list. switch (result.Category) { case "Eyes": { // _eyeSymbolInfos.Add(symbolInfo); break; } case "Mouth": { _mouthSymbolInfos.Add(symbolInfo); break; } case "Hat": { _hatSymbolInfos.Add(symbolInfo); break; } } } }
public async void LoadSymbols() { SymbolStylePicker.ItemsSource = symbols; if (symbols.Count == 0) { var pro2d = await SymbolStyle.OpenAsync("Resources/ArcGISRuntime2D_Pro25.stylx"); symbols.Add(new SymbolStyleItems() { Style = pro2d, Name = "2D Web Styles" }); //var pro3d = await SymbolStyle.OpenAsync("ArcGISRuntime3D_Pro25.stylx"); //symbols.Add(new SymbolStyleItems() { Style = pro3d, Name = "3D Web Styles" }); } SymbolStylePicker.SelectedIndex = 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); } }
private async Task ReadMobileStyle(string stylePath) { try { // Open the mobile style file at the provided path. _emojiStyle = await SymbolStyle.OpenAsync(stylePath); // Get the default style search parameters. SymbolStyleSearchParameters searchParams = await _emojiStyle.GetDefaultSearchParametersAsync(); // Search the style with the default parameters to return all symbol results. IList <SymbolStyleSearchResult> styleResults = await _emojiStyle.SearchSymbolsAsync(searchParams); // Create an empty placeholder image to represent "no symbol" for each category. ImageSource emptyImage = null; // Create lists to contain the available symbol layers for each category of symbol and add an empty entry as default. List <SymbolLayerInfo> eyeSymbolInfos = new List <SymbolLayerInfo> { new SymbolLayerInfo("", emptyImage, "") }; List <SymbolLayerInfo> mouthSymbolInfos = new List <SymbolLayerInfo> { new SymbolLayerInfo("", emptyImage, "") }; List <SymbolLayerInfo> hatSymbolInfos = new List <SymbolLayerInfo>() { new SymbolLayerInfo("", emptyImage, "") }; // Loop through the results and put symbols into the appropriate list according to category. foreach (SymbolStyleSearchResult result in styleResults) { // Get the symbol for this result. MultilayerPointSymbol multiLayerSym = await result.GetSymbolAsync() as MultilayerPointSymbol; // Create a swatch image from the symbol. RuntimeImage swatch = await multiLayerSym.CreateSwatchAsync(); ImageSource symbolImage = await swatch.ToImageSourceAsync(); // Create a symbol layer info object to represent the symbol in the list. // The symbol key will be used to retrieve the symbol from the style. SymbolLayerInfo symbolInfo = new SymbolLayerInfo(result.Name, symbolImage, result.Key); // Add the symbol layer info to the correct list for its category. switch (result.Category) { case "Eyes": { eyeSymbolInfos.Add(symbolInfo); break; } case "Mouth": { mouthSymbolInfos.Add(symbolInfo); break; } case "Hat": { hatSymbolInfos.Add(symbolInfo); break; } } } // Show the symbols in the category list boxes. EyeSymbolList.ItemsSource = eyeSymbolInfos; MouthSymbolList.ItemsSource = mouthSymbolInfos; HatSymbolList.ItemsSource = hatSymbolInfos; // Call a function to construct the current symbol (default yellow circle). Symbol faceSymbol = await GetCurrentSymbol(); // Call a function to show a preview image of the symbol. await UpdateSymbolPreview(faceSymbol); } catch (Exception ex) { // Report the exception. MessageDialog dialog = new MessageDialog("Error reading symbols from style: " + ex.Message); await dialog.ShowAsync(); } }
private async void ReadMobileStyle(string mobileStyleFilePath) { try { // Make sure the file exists. if (!System.IO.File.Exists(mobileStyleFilePath)) { throw new System.IO.FileNotFoundException("Mobile style file not found at " + mobileStyleFilePath); } // Open the mobile style file at the path provided. _emojiStyle = await SymbolStyle.OpenAsync(mobileStyleFilePath); // Get the default style search parameters. SymbolStyleSearchParameters searchParams = await _emojiStyle.GetDefaultSearchParametersAsync(); // Search the style with the default parameters to return a list of all symbol results. IList <SymbolStyleSearchResult> styleResults = await _emojiStyle.SearchSymbolsAsync(searchParams); // Loop through the results and put symbols into the appropriate list according to category (eyes, mouth, hat). foreach (SymbolStyleSearchResult result in styleResults) { // Get the result symbol as a multilayer point symbol. MultilayerPointSymbol multiLayerSym = result.Symbol as MultilayerPointSymbol; // Create a swatch for the symbol and use it to create a bitmap image. RuntimeImage swatch = await multiLayerSym.CreateSwatchAsync(); Bitmap symbolImage = await swatch.ToImageSourceAsync(); // Check the symbol category. switch (result.Category) { // Add a new SymbolLayerInfo to represent the symbol and add it to its category list. // SymbolLayerInfo is a custom class with properties for the symbol name, swatch image, and unique key. case "Eyes": { _eyeSymbolInfos.Add(new SymbolLayerInfo(result.Name, symbolImage, result.Key)); break; } case "Mouth": { _mouthSymbolInfos.Add(new SymbolLayerInfo(result.Name, symbolImage, result.Key)); break; } case "Hat": { _hatSymbolInfos.Add(new SymbolLayerInfo(result.Name, symbolImage, result.Key)); break; } case "Face": { break; } } } } catch (Exception ex) { // Show the exception message. AlertDialog.Builder alertBuilder = new AlertDialog.Builder(Activity); alertBuilder.SetTitle("Error reading style"); alertBuilder.SetMessage(ex.Message); alertBuilder.Show(); } }
private async Task ReadMobileStyle(string stylePath) { try { // Open the mobile style file at the provided path. _emojiStyle = await SymbolStyle.OpenAsync(stylePath); // Get the default style search parameters. SymbolStyleSearchParameters searchParams = await _emojiStyle.GetDefaultSearchParametersAsync(); // Search the style with the default parameters to return all symbol results. IList <SymbolStyleSearchResult> styleResults = await _emojiStyle.SearchSymbolsAsync(searchParams); // Create lists to contain the available symbol layers for each category of symbol and add an empty entry as default. List <SymbolLayerInfo> eyeSymbolInfos = new List <SymbolLayerInfo> { new SymbolLayerInfo("", null, "") }; List <SymbolLayerInfo> mouthSymbolInfos = new List <SymbolLayerInfo> { new SymbolLayerInfo("", null, "") }; List <SymbolLayerInfo> hatSymbolInfos = new List <SymbolLayerInfo>() { new SymbolLayerInfo("", null, "") }; // Loop through the results and put symbols into the appropriate list according to category. foreach (SymbolStyleSearchResult result in styleResults) { // Get the symbol for this result. MultilayerPointSymbol multiLayerSym = result.Symbol as MultilayerPointSymbol; // Create a swatch image from the symbol. RuntimeImage swatch = await multiLayerSym.CreateSwatchAsync(30, 30, 96, Color.White); // Create an image source from the swatch. Stream imageBuffer = await swatch.GetEncodedBufferAsync(); byte[] imageData = new byte[imageBuffer.Length]; imageBuffer.Read(imageData, 0, imageData.Length); ImageSource symbolImage = ImageSource.FromStream(() => new MemoryStream(imageData)); // Create a symbol layer info object to represent the symbol in the list. // The symbol key will be used to retrieve the symbol from the style. SymbolLayerInfo symbolInfo = new SymbolLayerInfo(result.Name, symbolImage, result.Key); // Add the symbol layer info to the correct list for its category. switch (result.Category) { case "Eyes": { eyeSymbolInfos.Add(symbolInfo); break; } case "Mouth": { mouthSymbolInfos.Add(symbolInfo); break; } case "Hat": { hatSymbolInfos.Add(symbolInfo); break; } } } // Show the symbols in the category list boxes. EyesListView.ItemsSource = eyeSymbolInfos; MouthListView.ItemsSource = mouthSymbolInfos; HatListView.ItemsSource = hatSymbolInfos; // Call a function to construct the current symbol (default yellow circle). Symbol faceSymbol = await GetCurrentSymbol(); // Call a function to show a preview image of the symbol. await UpdateSymbolPreview(faceSymbol); } catch (Exception ex) { // Report the exception. await DisplayAlert("Error reading style", ex.Message, "OK"); } }