public static FrameworkElement LoadPathFrom(string pathResourcePattern, string resourceDictionaryName, Color fillColor = default(Color))
        {
            PathLoader.PreloadIconsFrom(resourceDictionaryName);

            var paths = PathLoader.GetPathNamesForIconSet(resourceDictionaryName);

            if (string.IsNullOrWhiteSpace(pathResourcePattern))
                pathResourcePattern = PathLoader.NoPathName;

            pathResourcePattern = PathLoader.GetGlobalPathName(resourceDictionaryName, pathResourcePattern);

            var matchingPaths =
                (from p in paths
                 where string.Equals(p, pathResourcePattern, StringComparison.OrdinalIgnoreCase)
                 orderby GetPathPartSequence(p)
                 select PathLoader.LoadFrom(p, fillColor))
                .ToList();

            //just return the path if there is only one
            if (matchingPaths.Count() == 1)
            {
                return matchingPaths.First();
            }

            //if we have multiple paths, create a grid out of it and return that
            var grid = new Windows.UI.Xaml.Controls.Grid();
            foreach (var path in matchingPaths)
            {
                grid.Children.Add(path);
            }

            return grid;
        }
        private void RenderHud()
        {
            var hudContainer = new Windows.UI.Xaml.Controls.Grid();

            hudContainer.Width  = 640;
            hudContainer.Height = 480;



            _artificialHorizon = new Controls.ArtificialHorizon();
            hudContainer.Children.Add(_artificialHorizon);

            _video = new Controls.VideoControl();
            hudContainer.Children.Add(_video);

            _pitchTransform = new TranslateTransform()
            {
                Y = 0
            };
            _rollTransform = new RotateTransform()
            {
                Angle = 0, CenterX = 240, CenterY = 240,
            };

            _compass = new Controls.Compass();
            _compass.VerticalAlignment = VerticalAlignment.Top;
            hudContainer.Children.Add(_compass);

            _altitudeIndicator = new Controls.AltitudeIndicator();
            _altitudeIndicator.HorizontalAlignment = HorizontalAlignment.Right;
            _altitudeIndicator.VerticalAlignment   = VerticalAlignment.Center;
            hudContainer.Children.Add(_altitudeIndicator);

            _systemStatus                     = new Controls.SystemStatus();
            _systemStatus.Margin              = new Thickness(0, 0, 0, 60);
            _systemStatus.VerticalAlignment   = VerticalAlignment.Bottom;
            _systemStatus.HorizontalAlignment = HorizontalAlignment.Left;
            hudContainer.Children.Add(_systemStatus);

            _aoaCircle = new Controls.AoACircle();
            hudContainer.Children.Add(_aoaCircle);

            _gpsStatus = new Controls.GPSStatus
            {
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            hudContainer.Children.Add(_gpsStatus);

            hudContainer.SetValue(Windows.UI.Xaml.Controls.Grid.RowProperty, 0);
            hudContainer.SetValue(Windows.UI.Xaml.Controls.Grid.ColumnProperty, 1);

            Children.Add(hudContainer);
        }
Example #3
0
        public void When_PrivateProperty_And_Binding()
        {
            var source = new PrivateProperty(42);
            var SUT    = new Windows.UI.Xaml.Controls.Grid();

            SUT.SetBinding(
                Windows.UI.Xaml.Controls.Grid.TagProperty,
                new Binding()
            {
                Path = "MyProperty"
            }
                );

            SUT.DataContext = source;

            Assert.IsNull(SUT.Tag);
        }
Example #4
0
        public void When_PrivateProperty_And_XBind()
        {
            var source = new PrivateProperty(42);
            var SUT    = new Windows.UI.Xaml.Controls.Grid();

            SUT.SetBinding(
                Windows.UI.Xaml.Controls.Grid.TagProperty,
                new Binding()
            {
                Path           = "MyProperty",
                CompiledSource = source
            }
                );

            SUT.ApplyCompiledBindings();

            Assert.AreEqual(42, SUT.Tag);
        }
Example #5
0
        private void WindowsXamlHost_ChildChanged(object sender, EventArgs e)
        {
            var grid = (sender as WindowsXamlHost).Child as Windows.UI.Xaml.Controls.Grid;

            if (grid == null)
            {
                return;
            }

            var gridInkCanvas = new Windows.UI.Xaml.Controls.Grid();

            gridInkCanvas.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.White);
            var inkCanvas = new Windows.UI.Xaml.Controls.InkCanvas();

            gridInkCanvas.Children.Add(inkCanvas);
            gridInkCanvas.SetValue(Windows.UI.Xaml.Controls.Grid.RowProperty, 1);
            inkCanvas.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Touch;


            var inkToolbar = new Windows.UI.Xaml.Controls.InkToolbar();

            inkToolbar.TargetInkCanvas = inkCanvas;
            inkToolbar.SetValue(Windows.UI.Xaml.Controls.Grid.RowProperty, 0);

            var firstRow = new Windows.UI.Xaml.Controls.RowDefinition();

            firstRow.Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
            var secondRow = new Windows.UI.Xaml.Controls.RowDefinition();

            secondRow.Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Star);
            grid.RowDefinitions.Add(firstRow);
            grid.RowDefinitions.Add(secondRow);

            grid.Children.Add(gridInkCanvas);
            grid.Children.Add(inkToolbar);
        }
Example #6
0
        // TODO: To add this sample's url when it is available.
        //public override string      SampleCodeUri            { get { return ""; } }

        private async void Page_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            double paramHeight;
            double paramWidth;

            GetParamSize(out paramWidth, out paramHeight);

            LeftWallGrid.Width   = 0.02 * paramWidth;
            LeftWallGrid.Height  = paramHeight;
            RightWallGrid.Width  = paramWidth;
            RightWallGrid.Height = paramHeight;

            _roomVisual = ElementCompositionPreview.GetElementVisual(RoomGrid);
            _compositor = _roomVisual.Compositor;

            float scale = GetFullScale();

            if (_roomVisual != null)
            {
                _roomVisual.Scale = new Vector3(scale, scale, 1.0f);
            }

            await LoadImages();

            float   flAngle             = (float)(Math.PI / -64.0f);
            float   perspectiveDistance = (float)RoomGrid.Width * 3;
            Vector3 centerPt            = new Vector3(
                (float)(RoomGrid.Width * 0.5f),
                (float)(RoomGrid.Height * 0.5f),
                0);
            Matrix4x4 transformMatrix =
                Matrix4x4.CreateTranslation(-centerPt) *
                Matrix4x4.CreateRotationY(flAngle) *
                new Matrix4x4(
                    1, 0, 0, 0,
                    0, 1, 0, 0,
                    0, 0, 1, -1 / perspectiveDistance,
                    0, 0, 0, 1) *
                Matrix4x4.CreateTranslation(centerPt);
            Vector3 offset = new Vector3(transformMatrix.M41 - 8, transformMatrix.M42 - 8, 0);

            _roomVisual.TransformMatrix = transformMatrix * Matrix4x4.CreateTranslation(-offset);

            // Create three categories of panels, each panel has three contents.
            // Each category has a layer visual which contains three layer visual from its contents.
            // Effect on a category and all its sub tree contents works when hit-testing a category.
            // And effect on a content works when hit-testing a content.
            Visual rightWallVisual = ElementCompositionPreview.GetElementVisual(RightWallGrid);

            flAngle = (float)(Math.PI / 64.0f);
            rightWallVisual.TransformMatrix = Matrix4x4.CreateRotationY(flAngle);

            double sectionGridWidthRatio = 1 / 3.0;

            for (int i = 0; i < _fColumnCount; ++i)
            {
                _sectionContentParams[i] = new EffectParameters[_fColumnCount];
            }

            EffectType[] sectionEffectTypes =
            {
                EffectType.Saturation,
                EffectType.HueRotation,
                EffectType.Sepia
            };

            float[] sectionPropertyValues = { 1.0f, 0.0f, 0.0f };
            Color[] sectionColors         = { Colors.Linen, Colors.Linen, Colors.Linen };
            double  sectionWidthRatio     = 0.9;
            double  delatSectionWidth     = RightWallGrid.Width * sectionGridWidthRatio * (1 - sectionWidthRatio) * 0.5;

            for (int j = 0; j < _fColumnCount; ++j)
            {
                Windows.UI.Xaml.Controls.Grid section = (Windows.UI.Xaml.Controls.Grid)RightWallGrid.Children[j];
                section.Width  = sectionGridWidthRatio * RightWallGrid.Width * sectionWidthRatio;
                section.Height = RightWallGrid.Height * 0.9;
                section.Margin = new Windows.UI.Xaml.Thickness(
                    (1.5 - j * 0.5) * delatSectionWidth,
                    0.05 * paramHeight,
                    (0.5 + j * 0.5) * delatSectionWidth,
                    0.05 * paramHeight);

                double contentGridHeightRatio = 1 / 3.0;
                double contentWidthRatio      = 0.8;
                double contentHeightRatio     = 0.8;
                double deltaWidth             = (1 - contentWidthRatio) * 0.5 * section.Width;
                double deltaHeight            = contentGridHeightRatio * section.Height * (1.0 - contentHeightRatio) * 0.5;

                _sectionParams[j] = new EffectParameters(this, sectionEffectTypes[j], sectionPropertyValues[j], 1.1f);
                _sectionParams[j].InitializeEffectBrush();

                Vector2 sectionSize = new Vector2((float)section.Width, (float)section.Height);
                _sectionParams[j].VisualInstance = AddLayerVisual(
                    _sectionParams[j].EffectInstance,
                    sectionSize,
                    RightWallGrid.Children[j]);
                _sectionParams[j].UpdatePropertyValue();

                _sectionParams[j].VisualInstance.CenterPoint = new Vector3(sectionSize.X * 0.5f, sectionSize.Y * 0.5f, 0);
                AddColorSpriteVisual(sectionColors[j], _sectionParams[j].VisualInstance.Size, _sectionParams[j].VisualInstance);

                for (int i = 0; i < _fColumnCount; ++i)
                {
                    Windows.UI.Xaml.Shapes.Rectangle content = (Windows.UI.Xaml.Shapes.Rectangle)section.Children[i];
                    content.Width  = section.Width * contentWidthRatio;
                    content.Height = contentGridHeightRatio * section.Height * contentHeightRatio;

                    content.Margin = new Windows.UI.Xaml.Thickness(deltaWidth,
                                                                   (1.5 - i * 0.5) * deltaHeight,
                                                                   deltaWidth,
                                                                   (0.5 + i * 0.5) * deltaHeight);

                    _sectionContentParams[i][j] = new EffectParameters(this,
                                                                       sectionEffectTypes[j], sectionPropertyValues[j]);
                    _sectionContentParams[i][j].InitializeEffectBrush();

                    Vector2 contentASize = new Vector2((float)content.Width, (float)content.Height);

                    _sectionContentParams[i][j].VisualInstance = AddLayerVisual(
                        _sectionContentParams[i][j].EffectInstance,
                        contentASize,
                        new Vector3((float)section.Width * (0.5f - (float)contentWidthRatio * 0.5f),
                                    (float)content.Height * i + 1.5f * (float)deltaHeight * (i + 1), 0),
                        _sectionParams[j].VisualInstance);
                    _sectionContentParams[i][j].UpdatePropertyValue();

                    _sectionContentParams[i][j].VisualInstance.CenterPoint =
                        new Vector3(contentASize.X * 0.5f, contentASize.Y * 0.5f, 0);
                    AddImageSpriteVisual(_imageSurfaces[j * _fColumnCount + i].Brush,
                                         _sectionContentParams[i][j].VisualInstance.Size, _sectionContentParams[i][j].VisualInstance);
                }
            }

            for (int j = 0; j < RightWallGrid.Children.Count; ++j)
            {
                Windows.UI.Xaml.Controls.Grid section = (Windows.UI.Xaml.Controls.Grid)RightWallGrid.Children[j];
                EffectParameters sectionPara          = _sectionParams[j];

                section.PointerEntered += (s, v) =>
                {
                    sectionPara.OnPointerEntered();
                };
                section.PointerExited += (s, v) =>
                {
                    sectionPara.OnPointerExited();
                };

                for (int i = 0; i < section.Children.Count; ++i)
                {
                    Windows.UI.Xaml.Shapes.Rectangle content = (Windows.UI.Xaml.Shapes.Rectangle)section.Children[i];
                    EffectParameters contentPara             = _sectionContentParams[i][j];

                    content.PointerEntered += (s, v) =>
                    {
                        sectionPara.OnPointerExited();
                        contentPara.OnPointerEntered();
                    };
                    content.PointerExited += (s, v) =>
                    {
                        sectionPara.OnPointerEntered();
                        contentPara.OnPointerExited();
                    };
                    content.PointerMoved += (s, V) =>
                    {
                        sectionPara.OnPointerExited();
                    };
                }
            }
        }
            public GesturePage() :
                base(
                    "SemanticZoom",
                    "Pinch to semantic zoom",
                    "Semantic zoom is a new concept in our touch language. It’s designed to make it fast and fluid to jump within a list of content. Pinch two or more fingers on the screen  to change to an overview view.  Then tap or stretch the region or item you want to see more details for. For example, in People, pinch your contact list to see alphabet tiles (A, B, etc.), and then tap the desired letter to get back to the individual contact level (J for Jan).",
                    "Similar to when you use a mouse and click the “-” button, usually found in the lower-right corner.",
                    "Assets/pinch_sezo.png")
            {
                // Configure the app bar items for this page
                // GesturePageBase.Selected uses this._nonContextualItems to populate the global app bar when the page is selected.

                // Links button
                this._links["Doc: Guidelines for semantic zoom"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/hh465319.aspx");
                this._nonContextualItems.Add(GesturePageBase.CreateLinksAppBarButton(this._links));

                // Create the play area for this page
                var grid = new Windows.UI.Xaml.Controls.Grid();

                var row = new Windows.UI.Xaml.Controls.RowDefinition();

                row.Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Star);
                grid.RowDefinitions.Add(row);

                row        = new Windows.UI.Xaml.Controls.RowDefinition();
                row.Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                grid.RowDefinitions.Add(row);

                var col = new Windows.UI.Xaml.Controls.ColumnDefinition();

                col.Width = new Windows.UI.Xaml.GridLength(2, Windows.UI.Xaml.GridUnitType.Star);
                grid.ColumnDefinitions.Add(col);

                col       = new Windows.UI.Xaml.Controls.ColumnDefinition();
                col.Width = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Star);
                grid.ColumnDefinitions.Add(col);

                var image = new Windows.UI.Xaml.Controls.Image
                {
                    Margin  = new Windows.UI.Xaml.Thickness(30, 30, 30, 30),
                    Source  = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/semantic_zoom.png")),
                    Stretch = Windows.UI.Xaml.Media.Stretch.Uniform
                };

                grid.Children.Add(image);
                Windows.UI.Xaml.Controls.Grid.SetColumn(image, 0);
                Windows.UI.Xaml.Controls.Grid.SetRow(image, 0);

                var textBlock = new Windows.UI.Xaml.Controls.TextBlock
                {
                    Style = App.Current.Resources["AppSubtitleTextStyle"] as Windows.UI.Xaml.Style,
                    Text  = "Pinch anywhere in this app to zoom out",
                    HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center,
                    VerticalAlignment   = Windows.UI.Xaml.VerticalAlignment.Center,
                    TextWrapping        = Windows.UI.Xaml.TextWrapping.Wrap,
                    TextAlignment       = Windows.UI.Xaml.TextAlignment.Center
                };

                grid.Children.Add(textBlock);
                Windows.UI.Xaml.Controls.Grid.SetColumn(textBlock, 1);
                Windows.UI.Xaml.Controls.Grid.SetRow(textBlock, 0);

                this.Content = grid;
            }
        private void WindowsXamlHost_Loaded(object sender, RoutedEventArgs e)
        {
            windows.UI.Xaml.Controls.StackPanel stackPanel = new windows.UI.Xaml.Controls.StackPanel()
            {
                Background = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Black),
            };

            stackPanel.Children.Add(new windows.UI.Xaml.Shapes.Rectangle()
            {
                Width  = 50,
                Height = 75,
                Fill   = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Blue),
            });

            stackPanel.Children.Add(new windows.UI.Xaml.Shapes.Rectangle()
            {
                Width  = 200,
                Height = 30,
                Fill   = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Red),
            });

            var button = new windows.UI.Xaml.Controls.Button()
            {
                Width  = 160,
                Height = 60,
                HorizontalAlignment = windows.UI.Xaml.HorizontalAlignment.Center,
                Content             = "ContentDialog UWP Button",
            };

            button.Tapped += Button_Tapped;
            stackPanel.Children.Add(button);

            stackPanel.Children.Add(new windows.UI.Xaml.Shapes.Rectangle()
            {
                Width  = 25,
                Height = 100,
                Fill   = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Green),
            });

            windows.UI.Xaml.Controls.Flyout flyout = new windows.UI.Xaml.Controls.Flyout();
            flyout.Content = new windows.UI.Xaml.Controls.TextBlock()
            {
                Text = "Flyout content",
            };

            var button2 = new windows.UI.Xaml.Controls.Button()
            {
                Width  = 300,
                Height = 40,
                HorizontalAlignment = windows.UI.Xaml.HorizontalAlignment.Center,
                Content             = "Long UWP Button with Flyout",
                Flyout = flyout,
            };

            stackPanel.Children.Add(button2);

            var comboBox = new windows.UI.Xaml.Controls.ComboBox()
            {
                HorizontalAlignment = windows.UI.Xaml.HorizontalAlignment.Center,
            };

            comboBox.Items.Add("One");
            comboBox.Items.Add("Two");
            comboBox.Items.Add("Three");
            comboBox.Items.Add("Four");
            stackPanel.Children.Add(comboBox);

            windows.UI.Xaml.Controls.Grid grid = new windows.UI.Xaml.Controls.Grid();
            stackPanel.Children.Add(grid);

            _contentDialog         = new windows.UI.Xaml.Controls.ContentDialog();
            _contentDialog.Content = new windows.UI.Xaml.Controls.TextBlock()
            {
                Text = "ContentDialog content",
            };
            stackPanel.Children.Add(_contentDialog);

            var popup = new windows.UI.Xaml.Controls.Primitives.Popup()
            {
                Width  = 50,
                Height = 50,
                ShouldConstrainToRootBounds = false,
                Child = new windows.UI.Xaml.Controls.TextBlock()
                {
                    Text = "Popup child",
                },
            };

            grid.Children.Add(popup);

            windowsXamlHost.Child = stackPanel;
            popup.IsOpen          = true;
        }
Example #9
0
        public static void SetGridColumnByBreakpoints(Windows.UI.Xaml.Controls.Grid grid, double width)
        {
            // 不同窗口宽度有不同的列数,Breakpoints.Small 为一列,Breakpoints.Medium 为两列,Breakpoints.Large 为三列
            switch (GetBreakpoints(width))
            {
            case Breakpoints.Small:
                if (grid.ColumnDefinitions.Count == 1)
                {
                    // 不做任何处理
                }
                else if (grid.ColumnDefinitions.Count == 2)
                {
                    grid.ColumnDefinitions.Remove(grid.ColumnDefinitions.Last());
                }
                else if (grid.ColumnDefinitions.Count == 3)
                {
                    grid.ColumnDefinitions.Remove(grid.ColumnDefinitions.Last());
                    grid.ColumnDefinitions.Remove(grid.ColumnDefinitions.Last());
                }
                else
                {
                    throw new Exception($"发生未知错误,grid.ColumnDefinitions.Count: {grid.ColumnDefinitions.Count}");
                }
                break;

            case Breakpoints.Medium:
                if (grid.ColumnDefinitions.Count == 1)
                {
                    grid.ColumnDefinitions.Add(new Windows.UI.Xaml.Controls.ColumnDefinition());
                }
                else if (grid.ColumnDefinitions.Count == 2)
                {
                    // 不做任何处理
                }
                else if (grid.ColumnDefinitions.Count == 3)
                {
                    grid.ColumnDefinitions.Remove(grid.ColumnDefinitions.Last());
                }
                else
                {
                    throw new Exception($"发生未知错误,grid.ColumnDefinitions.Count: {grid.ColumnDefinitions.Count}");
                }
                break;

            case Breakpoints.Large:
                if (grid.ColumnDefinitions.Count == 1)
                {
                    grid.ColumnDefinitions.Add(new Windows.UI.Xaml.Controls.ColumnDefinition());
                    grid.ColumnDefinitions.Add(new Windows.UI.Xaml.Controls.ColumnDefinition());
                }
                else if (grid.ColumnDefinitions.Count == 2)
                {
                    grid.ColumnDefinitions.Add(new Windows.UI.Xaml.Controls.ColumnDefinition());
                }
                else if (grid.ColumnDefinitions.Count == 3)
                {
                    // 不做任何处理
                }
                else
                {
                    throw new Exception($"发生未知错误,grid.ColumnDefinitions.Count: {grid.ColumnDefinitions.Count}");
                }
                break;

            default:
                throw new Exception($"发生未知错误,width: {width}");
            }
        }
 public void ConfigureDialogs(Windows.UI.Xaml.Controls.Grid dxSwapChainPanel)
 {
     _dxSwapChainPanel = dxSwapChainPanel;
 }
Example #11
0
        // Create constructor public MainPage.
        public MainPage()
        {
            // Necessary to instantiate this Page, add a stackPanel to this Page, et cetera.
            this.InitializeComponent();

            // Find width of app in view pixels and height between bottom of app and bottom of title bar in view pixels.
            double widthOfAppInViewPixels = Windows.UI.ViewManagement.ApplicationView.PreferredLaunchViewSize.Width;
            double heightBetweenBottomOfAppAndBottomOfTitleBarInViewPixels = Windows.UI.ViewManagement.ApplicationView.PreferredLaunchViewSize.Height;

            // Create a stackPanel.
            Windows.UI.Xaml.Controls.StackPanel stackPanel = new Windows.UI.Xaml.Controls.StackPanel();

            // Create a toolbar with width equal to the width of the app, height equal to 50 view pixels, and background color of light blue that has one row and three columns.
            Windows.UI.Xaml.Controls.Grid toolbar = new Windows.UI.Xaml.Controls.Grid();
            toolbar.Width      = widthOfAppInViewPixels;
            toolbar.Height     = 50;
            toolbar.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.AliceBlue);
            Windows.UI.Xaml.Controls.RowDefinition row = new Windows.UI.Xaml.Controls.RowDefinition();
            toolbar.RowDefinitions.Add(row);
            Windows.UI.Xaml.Controls.ColumnDefinition columnForOpenImageButton         = new Windows.UI.Xaml.Controls.ColumnDefinition();
            Windows.UI.Xaml.Controls.ColumnDefinition columnForLoadBoundingBoxesButton = new Windows.UI.Xaml.Controls.ColumnDefinition();
            Windows.UI.Xaml.Controls.ColumnDefinition columnForTextboxForClassIndex    = new Windows.UI.Xaml.Controls.ColumnDefinition();
            Windows.UI.Xaml.Controls.ColumnDefinition columnForSaveLabeledImageButton  = new Windows.UI.Xaml.Controls.ColumnDefinition();
            Windows.UI.Xaml.Controls.ColumnDefinition columnForSaveLabelFileButton     = new Windows.UI.Xaml.Controls.ColumnDefinition();
            columnForOpenImageButton.Width         = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2);
            columnForLoadBoundingBoxesButton.Width = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2);
            columnForTextboxForClassIndex.Width    = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels / 7);
            columnForSaveLabeledImageButton.Width  = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2);
            columnForSaveLabelFileButton.Width     = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2);
            toolbar.ColumnDefinitions.Add(columnForOpenImageButton);
            toolbar.ColumnDefinitions.Add(columnForLoadBoundingBoxesButton);
            toolbar.ColumnDefinitions.Add(columnForTextboxForClassIndex);
            toolbar.ColumnDefinitions.Add(columnForSaveLabeledImageButton);
            toolbar.ColumnDefinitions.Add(columnForSaveLabelFileButton);

            // Add to toolbar's columnForOpenImageButton an "Open Image" button.
            Windows.UI.Xaml.Controls.Button openImageButton = new Windows.UI.Xaml.Controls.Button();
            openImageButton.Content = "Open Image";
            openImageButton.Height  = 40;
            Windows.UI.Xaml.Controls.Grid.SetRow(openImageButton, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(openImageButton, 0);
            openImageButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
            openImageButton.Click += OpenImageButton_Click;
            toolbar.Children.Add(openImageButton);

            // Add to the toolbar's columnForLoadBoundingBoxesButton a "Load Bounding Boxes" button.
            Windows.UI.Xaml.Controls.Button loadBoundingBoxesButton = new Windows.UI.Xaml.Controls.Button();
            loadBoundingBoxesButton.Content = "Load Bounding Boxes";
            loadBoundingBoxesButton.Height  = 40;
            Windows.UI.Xaml.Controls.Grid.SetRow(loadBoundingBoxesButton, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(loadBoundingBoxesButton, 1);
            loadBoundingBoxesButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
            loadBoundingBoxesButton.Click += LoadBoundingBoxesButton_Click;
            toolbar.Children.Add(loadBoundingBoxesButton);

            // Add to toolbar's columnForTextboxForClassIndex a labeled text box to store a user's choice of class index for an object they are about to bound.
            Windows.UI.Xaml.Controls.TextBlock textblockForClassIndex = new Windows.UI.Xaml.Controls.TextBlock();
            textblockForClassIndex.Text   = "Class Index: ";
            textblockForClassIndex.Height = 20;
            Windows.UI.Xaml.Controls.Grid.SetRow(textblockForClassIndex, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(textblockForClassIndex, 2);
            toolbar.Children.Add(textblockForClassIndex);
            this.TextBoxForClassIndex        = new Windows.UI.Xaml.Controls.TextBox();
            this.TextBoxForClassIndex.Text   = "0";
            this.TextBoxForClassIndex.Width  = 40;
            this.TextBoxForClassIndex.Height = 40;
            Windows.UI.Xaml.Controls.Grid.SetRow(this.TextBoxForClassIndex, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(this.TextBoxForClassIndex, 2);
            this.TextBoxForClassIndex.TextChanged += TextBoxForClassIndex_TextChanged;
            toolbar.Children.Add(this.TextBoxForClassIndex);

            // Add to toolbar's columnForSaveLabeledImageButton a "Save Labeled Image" button.
            Windows.UI.Xaml.Controls.Button saveLabeledImageButton = new Windows.UI.Xaml.Controls.Button();
            saveLabeledImageButton.Content = "Save Labeled Image";
            saveLabeledImageButton.Height  = 40;
            Windows.UI.Xaml.Controls.Grid.SetRow(saveLabeledImageButton, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(saveLabeledImageButton, 3);
            saveLabeledImageButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
            saveLabeledImageButton.Click += SaveLabeledImageButton_Click;
            toolbar.Children.Add(saveLabeledImageButton);

            // Add to toolbar's columnForSaveLabelFileButton a "Save Label File" button.
            Windows.UI.Xaml.Controls.Button saveLabelFileButton = new Windows.UI.Xaml.Controls.Button();
            saveLabelFileButton.Content = "Save Label File";
            saveLabelFileButton.Height  = 40;
            Windows.UI.Xaml.Controls.Grid.SetRow(saveLabelFileButton, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(saveLabelFileButton, 4);
            saveLabelFileButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
            saveLabelFileButton.Click += SaveLabelFileButton_Click;
            toolbar.Children.Add(saveLabelFileButton);

            // Add grid to the top of our stackPanel.
            stackPanel.Children.Add(toolbar);

            this.ImageCanvas                 = new Windows.UI.Xaml.Controls.Canvas();
            this.ImageCanvas.Width           = widthOfAppInViewPixels;
            this.ImageCanvas.Height          = heightBetweenBottomOfAppAndBottomOfTitleBarInViewPixels - toolbar.Height;
            this.ImageCanvas.PointerMoved   += new Windows.UI.Xaml.Input.PointerEventHandler(ImageCanvas_PointerMoved);
            this.ImageCanvas.PointerPressed += new Windows.UI.Xaml.Input.PointerEventHandler(ImageCanvas_PointerPressed);
            this.ImageCanvas.PointerExited  += new Windows.UI.Xaml.Input.PointerEventHandler(ImageCanvas_PointerExited);
            stackPanel.Children.Add(this.ImageCanvas);

            // Add stackPanel to the page defined in MainPage.xaml.
            page.Content = stackPanel;
        } // public MainPage