Пример #1
0
            /// <summary>
            /// Adds a page to the collection.
            /// </summary>
            /// <param name="element"></param>
            /// <returns></returns>
            public override int Add(UIElement element)
            {
                PanoramaPanelPage page = element as PanoramaPanelPage;

                if (page == null)
                {
                    throw new Exception("LauncherPanelPage expected!");
                }

                //parent.AddPage(page);
                // Set up the page's parent reference
                page.Parent = parent;

                // Add children of the page to the parent
                foreach (UIElement c in page)
                {
                    parent.Children.Add(c);
                }

                // Disable transitions and refresh layout
                parent.disableAnimation = true;
                parent.InvalidateVisual();

                return(base.Add(element));
            }
Пример #2
0
        protected void UpdateFluidLayout(Boolean ease)
        {
            if (disableAnimation)
            {
                InvalidateVisual();
            }
            else
            {
                for (int p = 0; p < pages.Count; p++)
                {
                    PanoramaPanelPage page = pages[p];
                    for (int i = 0; i < page.Count; i++)
                    {
                        Rect       cell       = GetCellRect(p, i);
                        Storyboard transition = CreateTransition(page[i], new Point(cell.X, cell.Y),
                                                                 TimeSpan.FromMilliseconds(DefaultTransitionDuration), Easing);

                        transition.Completed += (s, e) =>
                        {
                            if (dragging != null)
                            {
                                dragging.SetValue(ZIndexProperty, DragZ);
                            }
                        };

                        transition.Begin();
                    }
                }
            }
        }
Пример #3
0
            /// <summary>
            /// Removes a page from the collection.
            /// </summary>
            /// <param name="element"></param>
            public override void Remove(UIElement element)
            {
                PanoramaPanelPage page = element as PanoramaPanelPage;

                if (page == null)
                {
                    throw new Exception("LauncherPanelPage expected!");
                }

                //parent.RemovePage(page);

                // Remove children from the parent
                foreach (UIElement child in page)
                {
                    parent.Children.Remove(child);
                }

                // Refresh parent layout
                parent.disableAnimation = true;
                parent.InvalidateVisual();

                base.Remove(element);
            }
Пример #4
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            bool needEasing = !disableAnimation;

            // If animation is disabled, reinitialize the layout
            if (disableAnimation && Children.Count > 0)
            {
                for (int p = 0; p < pages.Count; p++)
                {
                    PanoramaPanelPage page = pages[p];
                    for (int i = 0; i < page.Count; i++)
                    {
                        // Get the cell position
                        Rect cell = GetCellRect(p, i);

                        // Arrange the element at (0, 0)...
                        page[i].Arrange(new Rect(0, 0, CellWidth, CellHeight));

                        // ...then move it to the correct location
                        page[i].RenderTransform = CreateTransform(cell.X, cell.Y, DefaultScale, DefaultScale);
                    }
                }

                if (!DesignerProperties.GetIsInDesignMode(this))
                {
                    disableAnimation = false;
                }
            }

            // Update the layout
            UpdateFluidLayout(needEasing);

            // Return parent panel size
            return(Orientation == Orientation.Horizontal
                ? new Size(PageWidth * PageCount, PageHeight)
                : new Size(PageWidth, PageHeight * PageCount));
        }