private async void _printButton_Click(object sender, RoutedEventArgs e)
        {
            // ダイアログのインスタンスを生成
            var dialog = new SaveFileDialog();

            dialog.Title        = "JPEGファイルの保存";
            dialog.AddExtension = true;
            dialog.Filter       = "jpg画像|*.jpg;*.jpeg";

            // ダイアログを表示する
            if (dialog.ShowDialog() == true)
            {
                try
                {
                    // マップの現在の状態をJPEG画像として出力して、指定のパスに保存する
                    ImageSource image = await RuntimeImageExtensions.ToImageSourceAsync(await _mainMapView.ExportImageAsync());

                    JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create((BitmapSource)image));
                    FileStream stream = new FileStream(dialog.FileName, FileMode.Create);
                    encoder.Save(stream);
                    stream.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
        }
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap
            Map streetMap = new Map(Basemap.CreateStreetsVector());

            // Get the path to the downloaded shapefile
            string filepath = GetShapefilePath();

            try
            {
                // Open the shapefile
                ShapefileFeatureTable myShapefile = await ShapefileFeatureTable.OpenAsync(filepath);

                // Read metadata about the shapefile and display it in the UI
                ShapefileInfo fileInfo = myShapefile.Info;
                InfoPanel.DataContext = fileInfo;

                // Display the shapefile thumbnail in an image control
                ShapefileThumbnailImage.Source = await RuntimeImageExtensions.ToImageSourceAsync(fileInfo.Thumbnail);

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

                // Zoom the map to the extent of the shapefile
                MyMapView.SpatialReferenceChanged += async(s, e) =>
                {
                    await MyMapView.SetViewpointGeometryAsync(newFeatureLayer.FullExtent);
                };

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

                // Show the map in the MapView
                MyMapView.Map = streetMap;
            }
            catch (Exception e)
            {
                await new MessageDialog(e.ToString(), "Error").ShowAsync();
            }
        }
Exemple #3
0
        public async void SetSymbol(Symbol symbol)
        {
            var swatch = await symbol.CreateSwatchAsync();

            Image = await RuntimeImageExtensions.ToImageSourceAsync(swatch);
        }