/// <summary>
        /// I got really sick of XAML layout here and decided to absolute position everything
        /// in calculated positions.  I guess this is probably considered bad, but
        /// it takes a lot less time than fooling with 500 different controls to achieve
        /// simple layout tasks in a static screen size.
        /// </summary>
        private void adjustLayoutToAccomodateRealRes()
        {
            // Top bar is always 135
            // Bottom buttons are 122
            double availableHeight = GlobalConfiguration.currentScreenH - 80;

            // We know the photo button needs 254
            double availableWidth = GlobalConfiguration.currentScreenW - 254;
            double fullW = availableWidth;

            masterParent.Width = GlobalConfiguration.currentScreenW;
            masterParent.Height = availableHeight;

            camFlash.Width = GlobalConfiguration.currentScreenW;
            camFlash.Height = availableHeight;

            // Absolute position all of our elements
            // Dead center the photo area
            Canvas.SetTop(contentBorder, 50);
            Canvas.SetLeft(contentBorder, (GlobalConfiguration.currentScreenW / 2 - contentBorder.ActualWidth / 2));
            
            // Center the countdown number in the photo area
            Canvas.SetTop(countDown, 50 + (contentBorder.ActualHeight / 2 - countDown.DesiredSize.Height / 2));
            Canvas.SetLeft(countDown, Canvas.GetLeft(contentBorder) + (contentBorder.ActualWidth / 2 - countDown.DesiredSize.Width / 2));

            // Position the take photo stack to the right of the photo area
            Canvas.SetTop(takePhotoStack, 50);
            Canvas.SetLeft(takePhotoStack, Canvas.GetLeft(contentBorder) + contentBorder.ActualWidth + 50);

            // Dynamically insert any photos into the background selection area
            if (_chromaKImages != null)
            {
                if(_chromaKImages.Count > 0) {
                    // Remove the placeholders
                    bg1B.Child = null;
                    bg2B.Child = null;
                    bg3B.Child = null;

                    stackBGs.Children.Remove(bg1B);
                    stackBGs.Children.Remove(bg2B);
                    stackBGs.Children.Remove(bg3B);
                }

                for(int i = 0; i < _chromaKImages.Count; i++) {
                    WrappedBGThumb myImage = new WrappedBGThumb();
                    myImage.Width = 203;
                    myImage.Height = 152;
                    myImage.Stretch = Stretch.Fill;
                    myImage.Source = _chromaKImages[i].BackgroundImageBM;
                    // This is used in main to swap the backgrounds on hit testing
                    myImage.SetValue(FrameworkElement.TagProperty, _chromaKImages[i]);

                    Border myBorder = new Border();
                    myBorder.BorderThickness = new Thickness(5);
                    myBorder.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E62923"));
                    myBorder.Margin = new Thickness(20, 0, 20, 0);
                    myBorder.Opacity = 1;
                    myBorder.Child = myImage;

                    stackBGs.Children.Add(myBorder);
                }
            }

            // Force the stackBGs to re-render quickly so we get the correct width
            stackBGs.Measure(new Size(GlobalConfiguration.currentScreenW, GlobalConfiguration.currentScreenH));
            // Dead center the background selection under the photo area
            Canvas.SetTop(stackBGs, Canvas.GetTop(contentBorder) + contentBorder.ActualHeight + 50);
            Canvas.SetLeft(stackBGs, GlobalConfiguration.currentScreenW / 2 - stackBGs.DesiredSize.Width / 2);

            // Position the Yes No buttons dead center but offscreen to the bottom
            Canvas.SetLeft(btnStack, GlobalConfiguration.currentScreenW / 2 - btnStack.DesiredSize.Width / 2);
            Canvas.SetTop(btnStack, GlobalConfiguration.currentScreenH + btnStack.DesiredSize.Height + 30);

        }
Ejemplo n.º 2
0
        /// <summary>
        /// I got really sick of XAML layout here and decided to absolute position everything
        /// in calculated positions.  I guess this is probably considered bad, but
        /// it takes a lot less time than fooling with 500 different controls to achieve
        /// simple layout tasks in a static screen size.
        /// </summary>
        private void adjustLayoutToAccomodateRealRes()
        {
            // Top bar is always 135
            // Bottom buttons are 122
            double availableHeight = GlobalConfiguration.currentScreenH - 80;

            // We know the photo button needs 254
            double availableWidth = GlobalConfiguration.currentScreenW - 254;
            double fullW          = availableWidth;

            masterParent.Width  = GlobalConfiguration.currentScreenW;
            masterParent.Height = availableHeight;

            camFlash.Width  = GlobalConfiguration.currentScreenW;
            camFlash.Height = availableHeight;

            // Absolute position all of our elements
            // Dead center the photo area
            Canvas.SetTop(contentBorder, 50);
            Canvas.SetLeft(contentBorder, (GlobalConfiguration.currentScreenW / 2 - contentBorder.ActualWidth / 2));

            // Center the countdown number in the photo area
            Canvas.SetTop(countDown, 50 + (contentBorder.ActualHeight / 2 - countDown.DesiredSize.Height / 2));
            Canvas.SetLeft(countDown, Canvas.GetLeft(contentBorder) + (contentBorder.ActualWidth / 2 - countDown.DesiredSize.Width / 2));

            // Position the take photo stack to the right of the photo area
            Canvas.SetTop(takePhotoStack, 50);
            Canvas.SetLeft(takePhotoStack, Canvas.GetLeft(contentBorder) + contentBorder.ActualWidth + 50);

            // Dynamically insert any photos into the background selection area
            if (_chromaKImages != null)
            {
                if (_chromaKImages.Count > 0)
                {
                    // Remove the placeholders
                    bg1B.Child = null;
                    bg2B.Child = null;
                    bg3B.Child = null;

                    stackBGs.Children.Remove(bg1B);
                    stackBGs.Children.Remove(bg2B);
                    stackBGs.Children.Remove(bg3B);
                }

                for (int i = 0; i < _chromaKImages.Count; i++)
                {
                    WrappedBGThumb myImage = new WrappedBGThumb();
                    myImage.Width   = 203;
                    myImage.Height  = 152;
                    myImage.Stretch = Stretch.Fill;
                    myImage.Source  = _chromaKImages[i].BackgroundImageBM;
                    // This is used in main to swap the backgrounds on hit testing
                    myImage.SetValue(FrameworkElement.TagProperty, _chromaKImages[i]);

                    Border myBorder = new Border();
                    myBorder.BorderThickness = new Thickness(5);
                    myBorder.BorderBrush     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E62923"));
                    myBorder.Margin          = new Thickness(20, 0, 20, 0);
                    myBorder.Opacity         = 1;
                    myBorder.Child           = myImage;

                    stackBGs.Children.Add(myBorder);
                }
            }

            // Force the stackBGs to re-render quickly so we get the correct width
            stackBGs.Measure(new Size(GlobalConfiguration.currentScreenW, GlobalConfiguration.currentScreenH));
            // Dead center the background selection under the photo area
            Canvas.SetTop(stackBGs, Canvas.GetTop(contentBorder) + contentBorder.ActualHeight + 50);
            Canvas.SetLeft(stackBGs, GlobalConfiguration.currentScreenW / 2 - stackBGs.DesiredSize.Width / 2);

            // Position the Yes No buttons dead center but offscreen to the bottom
            Canvas.SetLeft(btnStack, GlobalConfiguration.currentScreenW / 2 - btnStack.DesiredSize.Width / 2);
            Canvas.SetTop(btnStack, GlobalConfiguration.currentScreenH + btnStack.DesiredSize.Height + 30);
        }