Ejemplo n.º 1
0
        private void RenderUI()
        {
            // try to get layoutroot
            _layoutRoot = (Grid)this.GetTemplateChild("LayoutRoot");

            if (null == _layoutRoot)
            {
                return;
            }

            // generic, but doesn't work for "best of list". Will have to be set seperate in the bestof case below
            double ColumnSpacing = StyleHelper.GetApplicationDouble(LayoutSizes.ListColumnSpacerWidth);
            double RowSpacing    = StyleHelper.GetApplicationDouble(LayoutSizes.ListRowSpacerHeight);

            // configure grid
            _layoutRoot.Name   = "ListGrid";
            _layoutRoot.Margin = new Thickness(0);

            // based on liststyle, do we need a list header and list panel?
            switch (this.ListStyle)
            {
            case ListStyles.LedeOnly:     // used for interactive pages with header followed by list of items
            {
                // add columns
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    });
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(ColumnSpacing)
                    });
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    });

                // create a counter to know when we reach the end of list
                int Index      = 0;
                int ListLength = _listItems.Count() - 1;

                // create the list items and add to the grid
                foreach (ListItem item in _listItems)
                {
                    // get correct row to add content, don't want to add to a spacer row
                    int RowToAdd = Index == 0 ? item.Order : item.Order + Index;

                    // create the row for content
                    _layoutRoot.RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });

                    // if it's not the last row, create a spacer row
                    if (Index < ListLength)
                    {
                        _layoutRoot.RowDefinitions.Add(new RowDefinition()
                            {
                                Height = new GridLength(RowSpacing)
                            });
                    }

                    // create icon image and add to grid
                    ImageEx icon = new ImageEx()
                    {
                        Name                     = String.Format("Icon_{0}", item.Order),
                        ImageSource              = item.IconPath,
                        ImageWidth               = item.IconWidth,
                        VerticalAlignment        = VerticalAlignment.Center,        // center items when it's just a lede
                        VerticalContentAlignment = VerticalAlignment.Center,
                        PageEntranceDirection    = this.PageEntranceDirection
                    };
                    Grid.SetColumn(icon, 0);
                    Grid.SetRow(icon, RowToAdd);
                    _layoutRoot.Children.Add(icon);

                    // create the lede and add to grid
                    Header lede = new Header()
                    {
                        LedeStyle             = TextStyles.ListItemLedePenTouch,
                        Lede                  = item.Lede,
                        Width                 = StyleHelper.GetApplicationDouble("AccessoriesPenListTextWidth"),
                        HeaderAlignment       = TextAlignment.Left,
                        HorizontalAlignment   = HorizontalAlignment.Left,
                        VerticalAlignment     = VerticalAlignment.Center,
                        HeadlineOpacity       = 0,
                        LedeOpacity           = 0,
                        PageEntranceDirection = this.PageEntranceDirection
                    };
                    Grid.SetColumn(lede, 2);
                    Grid.SetRow(lede, RowToAdd);
                    _layoutRoot.Children.Add(lede);

                    // increment the counter
                    Index++;
                }
            }
            break;

            case ListStyles.HeadlineAndLede:     // Used for product highlights page wherein each item has its own lede-headline
            {
                // add columns
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    });
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(ColumnSpacing)
                    });
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    });

                // create a counter to know when we reach the end of list
                int Index      = 0;
                int ListLength = _listItems.Count() - 1;

                // create the list items and add to the grid
                foreach (ListItem item in _listItems)
                {
                    // get correct row to add content, don't want to add to a spacer row
                    int RowToAdd = Index == 0 ? item.Order : item.Order + Index;

                    // create the row for content
                    _layoutRoot.RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });

                    // if it's not the last row, create a spacer row
                    if (Index < ListLength)
                    {
                        _layoutRoot.RowDefinitions.Add(new RowDefinition()
                            {
                                Height = new GridLength(RowSpacing)
                            });
                    }

                    GridLength ledeHeadlineRowHeight = (item.Headline == null) ? new GridLength(0) : GridLength.Auto;

                    // create icon image
                    ImageEx icon = new ImageEx()
                    {
                        Name                     = String.Format("Icon_{0}", item.Order),
                        ImageSource              = item.IconPath,
                        ImageWidth               = item.IconWidth,
                        VerticalAlignment        = VerticalAlignment.Top,   // items align to top when there's a header
                        VerticalContentAlignment = VerticalAlignment.Top,
                        PageEntranceDirection    = this.PageEntranceDirection
                    };

                    Grid.SetColumn(icon, 0);
                    Grid.SetRow(icon, RowToAdd);

                    _layoutRoot.Children.Add(icon);

                    // create the headline (bold text) if one is provided
                    Header headline = new Header()
                    {
                        HeadlineStyle         = TextStyles.ListHeadline,
                        Headline              = item.Headline,
                        LedeStyle             = TextStyles.ListLede,
                        Lede                  = item.Lede,
                        Width                 = this.Width,
                        CTAText               = item.CTAText,
                        CTAUri                = String.IsNullOrWhiteSpace(item.CTAUri) ? null : new Uri(item.CTAUri),
                        HeaderAlignment       = TextAlignment.Left,
                        HorizontalAlignment   = HorizontalAlignment.Left,
                        VerticalAlignment     = VerticalAlignment.Top,
                        HeadlineOpacity       = 0,
                        LedeOpacity           = 0,
                        PageEntranceDirection = this.PageEntranceDirection
                    };
                    Grid.SetColumn(headline, 2);
                    Grid.SetRow(headline, RowToAdd);

                    _layoutRoot.Children.Add(headline);

                    // increment index
                    Index++;
                }
            }
            break;

            case ListStyles.BestOf:     // Used for product highlights page wherein each item has its own lede-headline
            {
                // create a grid of grids. 2 columns and 2 or 3 rows base don # of units. star space them
                // and each inner grid handles its icon/text/spacer
                double rowPercent = (_listItems.Count > 4 ? 0.333 : 0.5);
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(0.5, GridUnitType.Star)
                    });
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(0.5, GridUnitType.Star)
                    });
                _layoutRoot.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(rowPercent, GridUnitType.Star)
                    });
                _layoutRoot.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(rowPercent, GridUnitType.Star)
                    });
                if (_listItems.Count > 4)
                {        //5th item handling
                    _layoutRoot.RowDefinitions.Add(new RowDefinition()
                        {
                            Height = new GridLength(rowPercent, GridUnitType.Star)
                        });
                }
                // create a counter to know when we reach the end of list
                int    Index         = 0;
                int    ListLength    = _listItems.Count() - 1;
                int    rowPos        = 0;
                int    colPos        = 0;
                double ListTextWidth = StyleHelper.GetApplicationDouble("BestOfMicrosoftListTextWidth");

                // create the list items and add to the grid
                foreach (ListItem item in _listItems)
                {
                    // get correct row to add content, don't want to add to a spacer row
                    Grid grid = new Grid();
                    grid.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = GridLength.Auto
                        });
                    grid.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = new GridLength(StyleHelper.GetApplicationDouble(LayoutSizes.BestOfMicrosoftColumnSpacerWidth))
                        });
                    grid.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = GridLength.Auto
                        });
                    int RowToAdd = Index == 0 ? item.Order : item.Order + Index;

                    // create the row for content
                    grid.RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });

                    // create icon image
                    ImageEx icon = new ImageEx()
                    {
                        Name                     = String.Format("Icon_{0}", item.Order),
                        ImageSource              = item.IconPath,
                        ImageWidth               = item.IconWidth,
                        VerticalAlignment        = VerticalAlignment.Top,   // items align to top when there's a header
                        VerticalContentAlignment = VerticalAlignment.Top,
                        PageEntranceDirection    = this.PageEntranceDirection,
                        Opacity                  = 0.0
                    };

                    Grid.SetColumn(icon, 0);
                    Grid.SetRow(icon, RowToAdd);
                    grid.Children.Add(icon);

                    // create the headline (bold text) if one is provided
                    Header headline = new Header()
                    {
                        HeadlineStyle         = TextStyles.ListItemHeadlineBestOf,
                        Headline              = item.Headline,
                        LedeStyle             = TextStyles.ListItemLedeBestOf,
                        Lede                  = item.Lede,
                        CTAText               = item.CTAText,
                        CTAUri                = String.IsNullOrWhiteSpace(item.CTAUri) ? null : new Uri(item.CTAUri),
                        Width                 = ListTextWidth,
                        HeaderAlignment       = TextAlignment.Left,
                        HorizontalAlignment   = HorizontalAlignment.Left,
                        VerticalAlignment     = VerticalAlignment.Top,
                        PageEntranceDirection = this.PageEntranceDirection,
                        HeadlineOpacity       = 0,
                        LedeOpacity           = 0
                    };
                    Grid.SetColumn(headline, 2);
                    Grid.SetRow(headline, RowToAdd);

                    grid.Children.Add(headline);
                    Grid.SetRow(grid, rowPos);
                    Grid.SetColumn(grid, colPos);
                    _layoutRoot.Children.Add(grid);
                    // increment index
                    Index++;
                    rowPos = (Index < 2 ? 0 : (Index < 4 ? 1 : 2));
                    colPos = (colPos > 0 ? 0 : 1);
                }
            }
            break;

            case ListStyles.Compare:     // Used for product highlights page wherein each item has its own lede-headline
            {
                // add columns
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    });
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(StyleHelper.GetApplicationDouble("CompareColumnSpacerWidth"))
                    });
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    });

                // create a counter to know when we reach the end of list
                int Index      = 0;
                int ListLength = _listItems.Count() - 1;

                double ListTextWidth = StyleHelper.GetApplicationDouble("CompareListTextWidth");

                // create the list items and add to the grid
                foreach (ListItem item in _listItems)
                {
                    // get correct row to add content, don't want to add to a spacer row
                    int RowToAdd = Index == 0 ? item.Order : item.Order + Index;

                    // set row spacing
                    double rowSpacing = StyleHelper.GetApplicationDouble("CompareRowSpacerHeight");

                    // create the row for content
                    _layoutRoot.RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });

                    // if it's not the last row, create a spacer row
                    if (Index < ListLength)
                    {
                        _layoutRoot.RowDefinitions.Add(new RowDefinition()
                            {
                                Height = new GridLength(rowSpacing)
                            });
                    }

                    GridLength ledeHeadlineRowHeight = (item.Headline == null) ? new GridLength(0) : GridLength.Auto;

                    // create icon image
                    ImageEx icon = new ImageEx()
                    {
                        Name                     = String.Format("Icon_{0}", item.Order),
                        ImageSource              = item.IconPath,
                        ImageWidth               = item.IconWidth,
                        VerticalAlignment        = VerticalAlignment.Top,   // items align to top when there's a header
                        VerticalContentAlignment = VerticalAlignment.Top,
                    };

                    Grid.SetColumn(icon, 0);
                    Grid.SetRow(icon, RowToAdd);
                    _layoutRoot.Children.Add(icon);

                    // create the headline (bold text) if one is provided
                    Header headline = new Header()
                    {
                        HeadlineStyle       = TextStyles.ListItemHeadlineCompare,
                        Headline            = item.Headline,
                        LedeStyle           = TextStyles.ListItemLedeCompare,
                        Lede                = item.Lede,
                        CTAText             = item.CTAText,
                        CTAUri              = String.IsNullOrWhiteSpace(item.CTAUri) ? null : new Uri(item.CTAUri),
                        Width               = ListTextWidth,
                        HeaderAlignment     = TextAlignment.Left,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Top
                    };
                    Grid.SetColumn(headline, 2);
                    Grid.SetRow(headline, RowToAdd);

                    _layoutRoot.Children.Add(headline);

                    // increment index
                    Index++;
                }
            }
            break;

            case ListStyles.Specs:
            {
                _layoutRoot.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    });

                // set row spacing
                double rowSpacing = StyleHelper.GetApplicationDouble("CompareRowSpacerHeight");

                // create a counter to know when we reach the end of list
                int Index = 0;

                int ListLength       = _listItems.Count() - 1;
                var ListContentCount = new List <int> {
                    4, 2, 3
                };
                double ListTextWidth = StyleHelper.GetApplicationDouble("SpecsListTextWidth");
                for (int col = 0; col < 3; col++)
                {
                    int rowIndex = 0;
                    ColGrid = new Grid()
                    {
                        Name = "ColumnGrid",
                    };

                    _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = new GridLength(1, GridUnitType.Star)
                        });
                    // create the list items and add to the grid
                    for (int row = 0; row < ListContentCount[col]; row++)
                    {
                        ColGrid.RowDefinitions.Add(new RowDefinition()
                            {
                                Height = GridLength.Auto
                            });

                        if (Index < ListLength)
                        {
                            ColGrid.RowDefinitions.Add(new RowDefinition()
                                {
                                    Height = new GridLength(rowSpacing)
                                });
                        }

                        RowGrid = new Grid()
                        {
                            Name = "RowGrid"
                        };

                        ListItem item = _listItems[Index];

                        int RowToAdd = rowIndex == 0 ? 0 : row + rowIndex;
                        // get correct row to add content, don't want to add to a spacer row

                        RowGrid.ColumnDefinitions.Add(new ColumnDefinition()
                            {
                                Width = GridLength.Auto
                            });

                        RowGrid.ColumnDefinitions.Add(new ColumnDefinition()
                            {
                                Width = new GridLength(StyleHelper.GetApplicationDouble("SpecsListColumnSpacerWidth"))
                            });

                        RowGrid.ColumnDefinitions.Add(new ColumnDefinition()
                            {
                                Width = GridLength.Auto
                            });

                        RowGrid.RowDefinitions.Add(new RowDefinition()
                            {
                                Height = GridLength.Auto
                            });

                        // create icon image
                        ImageEx icon = new ImageEx()
                        {
                            Name                     = String.Format("Icon_{0}", item.Order),
                            ImageSource              = item.IconPath,
                            ImageWidth               = item.IconWidth,
                            VerticalAlignment        = VerticalAlignment.Top,   // items align to top when there's a header
                            VerticalContentAlignment = VerticalAlignment.Top,
                            PageEntranceDirection    = this.PageEntranceDirection,
                            Opacity                  = 1
                        };

                        Grid.SetColumn(icon, 0);
                        Grid.SetRow(icon, 0);
                        RowGrid.Children.Add(icon);

                        // create the headline (bold text) if one is provided
                        Header headline = new Header()
                        {
                            HeadlineStyle         = TextStyles.SpecItemHeadline,
                            Headline              = item.Headline,
                            LedeStyle             = TextStyles.SpecItemLede,
                            Lede                  = item.Lede,
                            IsRowSpacingActive    = false,
                            CTAText               = item.CTAText,
                            CTAUri                = String.IsNullOrWhiteSpace(item.CTAUri) ? null : new Uri(item.CTAUri),
                            Width                 = ListTextWidth,
                            HeaderAlignment       = TextAlignment.Left,
                            HorizontalAlignment   = HorizontalAlignment.Left,
                            VerticalAlignment     = VerticalAlignment.Top,
                            PageEntranceDirection = this.PageEntranceDirection,
                            Opacity               = 1
                        };

                        Grid.SetColumn(headline, 2);
                        Grid.SetRow(headline, 0);
                        RowGrid.Children.Add(headline);

                        _specListElements.Add(RowGrid);

                        Grid.SetColumn(RowGrid, col);
                        Grid.SetRow(RowGrid, RowToAdd);
                        ColGrid.Children.Add(RowGrid);

                        // increment index
                        Index++;
                        rowIndex++;
                    }
                    Grid.SetColumn(ColGrid, col);
                    Grid.SetRow(ColGrid, 0);
                    _layoutRoot.Children.Add(ColGrid);

                    rowIndex = 0;
                }
            }
            break;
            }
        }
Ejemplo n.º 2
0
        private void RenderUI()
        {
            // get the layoutroot
            _layoutRoot = (Grid)this.GetTemplateChild("LayoutRoot");

            //_layoutRoot.Opacity = 0;
            double AppSelectorMarginRight = StyleHelper.GetApplicationDouble("AppSelectorMarginRight");

            if (null == _layoutRoot)
            {
                return;
            }

            _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(.95, GridUnitType.Star)
            });
            _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(.05, GridUnitType.Star)
            });

            // create touch here canvas
            _touchHereCanvas = new Canvas()
            {
                Name             = "ColoringBookCanvasControls",
                Margin           = new Thickness(0),
                ManipulationMode = ManipulationModes.None
            };
            Grid.SetRow(_touchHereCanvas, 0);
            Grid.SetColumn(_touchHereCanvas, 0);
            _layoutRoot.Children.Add(_touchHereCanvas);

            // create the button grid
            _penTouchPointGrid = new Grid()
            {
                Name    = "AccessoriesPenButtonGrid",
                Margin  = new Thickness(0),
                Padding = new Thickness(0),
                Opacity = 0.0
            };
            _penTouchPointGrid.ColumnDefinitions.Add(new ColumnDefinition());
            _penTouchPointGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1.0, GridUnitType.Auto)
            });
            _penTouchPointGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(GRID_ROWSPACING)
            });
            _penTouchPointGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1.0, GridUnitType.Auto)
            });
            Canvas.SetLeft(_penTouchPointGrid, GRID_X);
            Canvas.SetTop(_penTouchPointGrid, GRID_Y);
            Canvas.SetZIndex(_penTouchPointGrid, Z_ORDER_CONTROLS);
            _touchHereCanvas.Children.Add(_penTouchPointGrid);

            // create the ink canvas
            _inkCanvas = new InkCanvas()
            {
                Name   = "InkCanvas",
                Margin = new Thickness(0),
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch
            };

            // add events to inkpresenter
            _inkCanvas.InkPresenter.StrokeInput.StrokeStarted   += InkPresenter_StrokeStarted;
            _inkCanvas.InkPresenter.StrokeInput.StrokeContinued += InkPresenter_StrokeContinued;
            _inkCanvas.InkPresenter.StrokeInput.StrokeEnded     += InkPresenter_StrokeEnded;

            Grid.SetRow(_inkCanvas, 0);
            Grid.SetColumnSpan(_inkCanvas, this.ImageColumnSpan);
            Grid.SetColumn(_inkCanvas, 0);
            _layoutRoot.Children.Add(_inkCanvas);

            // please dont not have a URI or an SVGURI or the image below will error
            _ColoringImage = new ImageEx()
            {
                Name                = "ColoringImage",
                BitmapImage         = BMIMAGE_COLORING_BOOK,
                ImageWidth          = DOUBLE_COLORING_BOOK_IMAGE_WIDTH,
                Width               = DOUBLE_COLORING_BOOK_IMAGE_WIDTH,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Center,

                Opacity          = .1,
                IsHitTestVisible = false
            };

            Canvas.SetZIndex(_ColoringImage, 101);
            Grid.SetColumnSpan(_ColoringImage, this.ImageColumnSpan);
            Grid.SetRow(_ColoringImage, 0);
            Grid.SetColumn(_ColoringImage, 0);
            _layoutRoot.Children.Add(_ColoringImage);

            this.Colors.Add(COLOR_COLORING_BOOK_RED);
            this.Colors.Add(COLOR_COLORING_BOOK_BLUE);
            this.Colors.Add(COLOR_COLORING_BOOK_TEAL);
            this.Colors.Add(COLOR_COLORING_BOOK_ORANGE);
            this.Colors.Add(COLOR_COLORING_BOOK_PURPLE);

            this._ImagePairs.Add(0, new ImagePair()
            {
                NotSelected = new Image()
                {
                    Source = BMIMAGE_COLOR_RED,
                    Width  = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                },
                Selected = new Image()
                {
                    Source = BMIMAGE_COLOR_RED_SELECTED,
                    Width  = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                }
            });

            this._ImagePairs.Add(1, new ImagePair()
            {
                NotSelected = new Image()
                {
                    Source = BMIMAGE_COLOR_BLUE,
                    Width  = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                },
                Selected = new Image()
                {
                    Source = BMIMAGE_COLOR_BLUE_SELECTED,
                    Width  = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                }
            });

            this._ImagePairs.Add(2, new ImagePair()
            {
                NotSelected = new Image()
                {
                    Source = BMIMAGE_COLOR_TEAL,
                    Width  = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                },
                Selected = new Image()
                {
                    Source = BMIMAGE_COLOR_TEAL_SELECTED,
                    Width  = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                }
            });

            this._ImagePairs.Add(3, new ImagePair()
            {
                NotSelected = new Image()
                {
                    Source = BMIMAGE_COLOR_ORANGE,
                    Width  = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                },
                Selected = new Image()
                {
                    Source = BMIMAGE_COLOR_ORANGE_SELECTED,
                    Width  = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                }
            });

            this._ImagePairs.Add(4, new ImagePair()
            {
                NotSelected = new Image()
                {
                    Source = BMIMAGE_COLOR_PURPLE,
                    Width  = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                },
                Selected = new Image()
                {
                    Source = BMIMAGE_COLOR_PURPLE_SELECTED,
                    Width  = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                }
            });

            this._AppSelector = new AppSelector()
            {
                //TelemetryId = TelemetryService.TELEMETRY_KEYBOARDVIEWCOLOR,
                IsPenOnly           = true,
                AppSelectorMode     = SelectorMode.Color,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Center,
                Margin               = new Thickness(0, 0, AppSelectorMarginRight, 0),
                MainOrientation      = Orientation.Vertical,
                ButtonHeight         = DOUBLE_COLORING_BOOK_BUTTON_HEIGHT,
                ButtonWidth          = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                Opacity              = 1,
                ImagePairs           = this._ImagePairs,
                ClearButtonImagePair = new ImagePair()
                {
                    NotSelected = new Image()
                    {
                        Source = BMIMAGE_CLEARBUTTON,
                        Width  = DOUBLE_COLORING_BOOK_BUTTON_WIDTH,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment   = VerticalAlignment.Center,
                        Opacity             = 1.0
                    },
                    IsClearButton = true
                },
                SelectedID = 0
            };
            _AppSelector.SelectedIDChanged += _AppSelector_SelectedIDChanged;
            _AppSelector.OnClearClicked    += _AppSelector_ClearClickedChanged;
            Canvas.SetZIndex(_AppSelector, 101);
            Grid.SetRow(_AppSelector, 0);
            Grid.SetColumn(_AppSelector, 1);
            this._layoutRoot.Children.Add(_AppSelector);
            this._SelectedColor = this.Colors[0];
            SetupBrush();
        }
Ejemplo n.º 3
0
        private void RenderUI()
        {
            _layoutRoot = (Canvas)this.GetTemplateChild("LayoutRoot");
            if (null == _layoutRoot)
            {
                return;
            }

            // get sizes for everything
            double _canvasWidth  = StyleHelper.GetApplicationDouble("CanvasWidth");
            double _canvasHeight = StyleHelper.GetApplicationDouble("CanvasHeight");

            double _startImageWidth  = StyleHelper.GetApplicationDouble("PinchZoomImageWidth");
            double _startImageHeight = StyleHelper.GetApplicationDouble("PinchZoomImageHeight");

            double _radiatingButtonRadius   = StyleHelper.GetApplicationDouble(LayoutSizes.RadiatingButtonEllipseRadius);
            double _closeIconHeight         = StyleHelper.GetApplicationDouble(LayoutSizes.TryItIconHeight) / 2;
            double _closeEllipseTopMargin   = StyleHelper.GetApplicationDouble("PinchTopMargin");
            double _closeEllipseRightMargin = StyleHelper.GetApplicationDouble("PinchSideMargin");

            double _ellipseGridCanvasSetLeft = _canvasWidth - _closeEllipseRightMargin - _radiatingButtonRadius;

            // create the scroll viewer
            _viewer = new ScrollViewer
            {
                ZoomMode                      = ZoomMode.Enabled,
                Width                         = _canvasWidth,
                Height                        = _canvasHeight,
                MinZoomFactor                 = 1,
                MaxZoomFactor                 = 4,
                HorizontalScrollMode          = ScrollMode.Enabled,
                VerticalScrollMode            = ScrollMode.Enabled,
                HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden,
                VerticalScrollBarVisibility   = ScrollBarVisibility.Hidden
            };

            // create the image for zooming
            _pinch_image = new ImageEx
            {
                Name                = this.Name + "ZoomImage",
                ImageSource         = ImageUri,
                ImageWidth          = _startImageWidth, //account for left and right margins
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            };

            // add the image to the scroll viewer
            _viewer.Content = _pinch_image;

            // add manipulation events to viewer
            _viewer.ViewChanging += HandleZoomChanging;

            // add the scrollviewer to the root
            _layoutRoot.Children.Add(_viewer);

            // create grid for the close element if none exists
            if (null == _closeGrid)
            {
                _closeGrid = new Grid()
                {
                    Name       = this.Name + "closeGrid",
                    Visibility = Visibility.Collapsed
                };
            }

            // create the close button
            _closeEllipse = new Ellipse()
            {
                Name                = this.Name + "entranceEllipse",
                Width               = _radiatingButtonRadius,
                Height              = _radiatingButtonRadius,
                Fill                = new SolidColorBrush(Colors.White),
                Stroke              = RadiatingButton.GetSolidColorBrush("#FFD2D2D2"),
                StrokeThickness     = 2,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Margin              = new Thickness(0)
            };
            // add ellipse to the grid
            _closeGrid.Children.Add(_closeEllipse);

            // create the X image
            x_image = new ImageEx()
            {
                Name                = this.Name + "ImageX",
                ImageSource         = URI_X_IMAGE,
                ImageWidth          = _closeIconHeight,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Margin              = new Thickness(0)
            };

            // add the close image to the grid
            _closeGrid.Children.Add(x_image);

            // set canvas position for the close grid
            Canvas.SetLeft(_closeGrid, _ellipseGridCanvasSetLeft);
            Canvas.SetTop(_closeGrid, _closeEllipseTopMargin);

            // assign click handler
            _closeGrid.PointerPressed += HandleClick;

            // add the close button to the layout root
            _layoutRoot.Children.Add(_closeGrid);
        }
        private void RenderUI()
        {
            // get the layout base (a border here)
            _layoutRoot = (Canvas)this.GetTemplateChild("LayoutRoot");

            // if we can't get the layout root, we can't do anything
            if (null == _layoutRoot)
            {
                return;
            }

            double batteryHeight           = this.Width * .383;
            double chargeHeight            = batteryHeight - (2 * MARGIN_CHARGE_TOP);
            double batteryHorizontalCenter = this.Width / 2;
            double batteryVerticalCenter   = batteryHeight / 2;

            double TEXT_WIDTH      = 100d;
            double LEFT_HOURS      = batteryHorizontalCenter - TEXT_WIDTH - (MARGIN_CHARGE_LEFT / 2);
            double LEFT_HOURS_TEXT = batteryHorizontalCenter + (MARGIN_CHARGE_LEFT / 2);
            double TOP_TEXT        = batteryVerticalCenter - (chargeHeight / 2);

            // set up the canvas
            _layoutRoot.Width  = this.Width;
            _layoutRoot.Height = batteryHeight;

            // create the battery
            _imageBattery = new ImageEx()
            {
                Name        = "Battery",
                ImageSource = URI_IMAGE_BATTERY,
                ImageWidth  = this.Width
            };

            Canvas.SetLeft(_imageBattery, LEFT_BATTERY);
            Canvas.SetTop(_imageBattery, TOP_BATTERY);
            Canvas.SetZIndex(_imageBattery, Z_ORDER_BATTERY);
            _layoutRoot.Children.Add(_imageBattery);

            // create the charge
            _imageCharge = new Image()
            {
                Name    = "ChargeBar",
                Source  = new BitmapImage(new Uri(URI_IMAGE_CHARGE)),
                Stretch = Stretch.Fill,
                Width   = CHARGE_START_WIDTH,
                Height  = chargeHeight
            };

            Canvas.SetLeft(_imageCharge, LEFT_CHARGE);
            Canvas.SetTop(_imageCharge, TOP_CHARGE);
            Canvas.SetZIndex(_imageCharge, Z_ORDER_CHARGE);
            _layoutRoot.Children.Add(_imageCharge);

            // create the percent overlay
            _hours = new AnimatableInteger()
            {
                HourIntegerMax             = this.HourIntegerMax,
                Width                      = TEXT_WIDTH,
                Height                     = chargeHeight,
                VerticalAlignment          = VerticalAlignment.Center,
                DurationInMilliseconds     = this.DurationInMilliseconds,
                StaggerDelayInMilliseconds = this.StaggerDelayInMilliseconds
            };

            Canvas.SetLeft(_hours, LEFT_HOURS);
            Canvas.SetTop(_hours, TOP_TEXT);
            Canvas.SetZIndex(_hours, Z_ORDER_CONTROLS);
            _layoutRoot.Children.Add(_hours);

            double chargeEndWidth = this.Width - ((2 * MARGIN_CHARGE_LEFT) + CHARGE_START_WIDTH + 5);

            // create the charge animation
            _chargeStoryboard = SetupChargeAnimation(_imageCharge, CHARGE_START_WIDTH, chargeEndWidth, this.DurationInMilliseconds, this.StaggerDelayInMilliseconds);

            // create hour text overlay
            _hoursText = new TextBlockEx()
            {
                Text                = this.HourText,
                Width               = TEXT_WIDTH,
                Height              = chargeHeight,
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left,
                TextAlignment       = TextAlignment.Left,
                TextStyle           = TextStyles.PopupBatteryLife
            };

            Canvas.SetLeft(_hoursText, LEFT_HOURS_TEXT);
            Canvas.SetTop(_hoursText, TOP_TEXT);
            Canvas.SetZIndex(_hoursText, Z_ORDER_CONTROLS);
            _layoutRoot.Children.Add(_hoursText);
        }