ArcGISRuntime.UWP.Viewer.SamplePage.CoreWindow_KeyDown C# (CSharp) Метод

CoreWindow_KeyDown() приватный Метод

private CoreWindow_KeyDown ( global sender, global args ) : void
sender global
args global
Результат void
        private async void CoreWindow_KeyDown(global::Windows.UI.Core.CoreWindow sender, global::Windows.UI.Core.KeyEventArgs args)
        {
            var ctrl = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control);
            if (ctrl.HasFlag(CoreVirtualKeyStates.Down) && args.VirtualKey == VirtualKey.T)
            {
                if (!isResized)
                {
                    originalHeight = SampleContainer.ActualHeight;
                    originalWidth = SampleContainer.ActualWidth;
                    SampleContainer.Height = 600;
                    SampleContainer.Width = 800;
                    isResized = true;
                    return;
                }

                var layoutRoot = new Grid();
                var mapViewImage = new Image() { VerticalAlignment = VerticalAlignment.Top };
                var uiImage = new Image();

                // Create image from the non-map UI
                var uiLayerImage = await CreateBitmapFromElement(SampleContainer.Content as UIElement);

                // Find mapview from the sample. This expects that we use the same name in all samples
                var mapview = (SampleContainer.Content as UserControl).FindName("MyMapView") as MapView;

                // Retrieve general transform 
                var tranform = mapview.TransformToVisual((SampleContainer.Content as UIElement));
                // Retrieve the point value relative to the child.
                var currentPoint = tranform.TransformPoint(new Point(0, 0));
                // Setup the location where the mapview was in the view to respect the ui layout
                mapViewImage.Margin = new Thickness(currentPoint.X, currentPoint.Y, 0, 0);

                // Create snapshot from MapView
                var exportImage = await mapview.ExportImageAsync();

                // Set sources to the images and add them to the layout
                uiImage.Source = uiLayerImage;
                mapViewImage.Source = await esriUI.RuntimeImageExtensions.ToImageSourceAsync(exportImage);
                layoutRoot.Children.Add(mapViewImage);
                layoutRoot.Children.Add(uiImage);

                // Add layout to the view
                var sample = SampleContainer.Content;
                SampleContainer.Content = layoutRoot;

                // Wait that images are rendered
                await Task.Delay(TimeSpan.FromSeconds(1));

                // Save image to the disk
                var combinedImage = await CreateBitmapFromElement(SampleContainer.Content as UIElement);
                await SaveBitmapToFileAsync(combinedImage, SampleManager.Current.SelectedSample.SampleName);

                // Reset view
                SampleContainer.Content = sample;
                SampleContainer.Height = originalHeight;
                SampleContainer.Width = originalWidth;
                isResized = false;
            }
        }