private void ExportMap_Click(object sender, RoutedEventArgs e)
        {
            if (printTask == null || Formats.SelectedIndex < 0 || printTask.IsBusy)
            {
                return;
            }

            PrintParameters printParameters = new PrintParameters(MyMap)
            {
                ExportOptions = new ExportOptions()
                {
                    Dpi = 96, OutputSize = new Size(MyMap.ActualWidth, MyMap.ActualHeight)
                },
                LayoutTemplate = (string)LayoutTemplates.SelectedItem ?? string.Empty,
                Format         = (string)Formats.SelectedItem,
            };

            printTask.ExecuteAsync(printParameters);
        }
        private void ExportMapButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            this.IsBusy = true;
            linkExportResult.Visibility = System.Windows.Visibility.Collapsed;
            PrintParameters printParams = new PrintParameters(this.MapControl);

            printParams.Format = (string)boxExportFormats.SelectedItem;

            ExportOptions expOptions = new ExportOptions()
            {
                Dpi = 96
            };

            expOptions.OutputSize = new Size(this.MapControl.ActualWidth, this.MapControl.ActualHeight);

            LegendOptions      legendOptions = new LegendOptions();
            List <LegendLayer> legendLayers  = new List <LegendLayer>();

            foreach (LivingMapLayer layer in this.AppConfig.MapConfig.LivingMaps)
            {
                if (this.MapControl.Layers[layer.ID] is ArcGISDynamicMapServiceLayer)
                {
                    int[]         visibleLayers = (this.MapControl.Layers[layer.ID] as ArcGISDynamicMapServiceLayer).VisibleLayers;
                    List <object> layerIDs      = new List <object>();
                    foreach (int lyrID in visibleLayers)
                    {
                        layerIDs.Add(lyrID);
                    }
                    legendLayers.Add(new LegendLayer()
                    {
                        LayerId = layer.ID, SubLayerIds = layerIDs
                    });
                }
                else
                {
                    legendLayers.Add(new LegendLayer()
                    {
                        LayerId = layer.ID
                    });
                }
            }

            legendOptions.LegendLayers = legendLayers;
            ScaleBarOptions scaleOptions   = new ScaleBarOptions();
            string          metricUnits    = (boxMetricUnits.SelectedItem as ComboBoxItem).Content as string;
            string          nonmetricUnits = (boxNonmetricUnits.SelectedItem as ComboBoxItem).Content as string;

            scaleOptions.MetricUnit     = (ScaleBarOptions.MetricUnits)Enum.Parse(typeof(ScaleBarOptions.MetricUnits), metricUnits, true);
            scaleOptions.MetricLabel    = txtMetricLabel.Text;
            scaleOptions.NonMetricUnit  = (ScaleBarOptions.NonMetricUnits)Enum.Parse(typeof(ScaleBarOptions.NonMetricUnits), nonmetricUnits, true);
            scaleOptions.NonMetricLabel = txtNonmetricLabel.Text;

            LayoutOptions layoutOptions = new LayoutOptions()
            {
                LegendOptions = legendOptions, ScaleBarOptions = scaleOptions
            };

            layoutOptions.Title     = txtExportMapTitle.Text;
            layoutOptions.Copyright = txtCopyright.Text;

            printParams.ExportOptions  = expOptions;
            printParams.LayoutOptions  = layoutOptions;
            printParams.LayoutTemplate = (string)boxLayoutTemplates.SelectedItem;

            if (isAsynPrintService)
            {
                printTask.SubmitJobAsync(printParams);
            }
            else
            {
                printTask.ExecuteAsync(printParams);
            }
        }