Пример #1
0
        private AnimationScenario PlayExpandAnimation(ViewStatus viewStatus, ColumnViewModel columnViewModel)
        {
            AnimationHint hint = null;// stashedViewStatus.AnimationHint;
            IEnumerable <RowViewModel> previousRowViewModels = (stashedViewStatus.TableViewState == TableViewState.AllRow) ? SheetViewModel.AllRowViewModels : stashedViewStatus.GroupedRowViewModels;
            IEnumerable <RowViewModel> currentRowViewModels  = viewStatus.IsAllRowViewModelVisible ? SheetViewModel.AllRowViewModels : viewStatus.GroupedRowViewModels;
            Double     beforeX    = hint.ColumnViewModelPosition[columnViewModel];
            Double     afterX     = columnViewModel.X;
            Int32      index      = 0;
            Storyboard storyboard = new Storyboard();
            Double     horizontalAnimationDuration = 0;

            Canvas canvas = view.TableView.AnimatingRowCanvas;

            canvas.Children.Clear();

            RowViewModel               rootGroupedRowViewModel = stashedViewStatus.GroupedRowViewModels[0];
            Int32                      rootIndex = 0;
            IEnumerable <Row>          rows      = rootGroupedRowViewModel.Rows;
            IEnumerable <RowViewModel> expandingRowViewModels =
                currentRowViewModels
                .Where(rvm => (rvm.Row == null ? rows.Intersect(rvm.Rows).Count() > 0 : rows.Contains(rvm.Row)) && rvm.Y < mainPageViewModel.Bounds.Height)
                .OrderBy(rvm => rvm.Y)
                .Take(50);

            if (expandingRowViewModels.Count() < 5)
            {
                index = 0;
                foreach (GroupedRows groupedRows in stashedViewStatus.GroupedRows)
                {
                    IEnumerable <RowViewModel> candidate =
                        currentRowViewModels
                        .Where(rvm => (rvm.Row == null ? groupedRows.Rows.Intersect(rvm.Rows).Count() > 0 : groupedRows.Rows.Contains(rvm.Row)) && rvm.Y < mainPageViewModel.Bounds.Height)
                        .OrderBy(rvm => rvm.Y)
                        .Take(50);

                    if (candidate.Count() >= 5)
                    {
                        rootGroupedRowViewModel = stashedViewStatus.GroupedRowViewModels[index];
                        rows = groupedRows.Rows;
                        expandingRowViewModels = candidate;
                        rootIndex = index;
                        break;
                    }
                    index++;
                }
            }

            viewStatus.ColorRowViewModels(allRowViewModels, viewStatus.GroupedRowViewModels, viewStatus.GroupedRows);


            if (viewStatus.IsAllRowViewModelVisible)
            {
                // root
                {
                    AnimatingRowViewModel arvm = new AnimatingRowViewModel()
                    {
                        RowViewModel    = rootGroupedRowViewModel,
                        X               = beforeX,
                        ColumnViewModel = columnViewModel
                    };

                    AnimatingRowPresenter arp = new AnimatingRowPresenter()
                    {
                        AnimatingRowViewModel = arvm
                    };

                    arp.Opacity = 1;
                    arp.Update();
                    canvas.Children.Add(arp);
                    Canvas.SetTop(arp, rootGroupedRowViewModel.StashedY);
                    arp.CellPresenter.Foreground = new SolidColorBrush(rootGroupedRowViewModel.Color);

                    storyboard.Children.Add(Util.Animator.Generate(arp, "Opacity", 0, UnitAnimationDuration, DelayBeforeAnimation));
                }

                index = 0;
                foreach (RowViewModel rvm in expandingRowViewModels)
                {
                    AnimatingRowViewModel arvm = new AnimatingRowViewModel()
                    {
                        RowViewModel    = rvm,
                        X               = beforeX,
                        ColumnViewModel = columnViewModel
                    };

                    AnimatingRowPresenter arp = new AnimatingRowPresenter()
                    {
                        AnimatingRowViewModel = arvm
                    };

                    arp.Opacity = 0;
                    arp.Update();
                    canvas.Children.Add(arp);

                    Canvas.SetTop(arp, rootGroupedRowViewModel.StashedY);
                    arp.CellPresenter.Foreground = new SolidColorBrush(rootGroupedRowViewModel.Color);

                    storyboard.Children.Add(Util.Animator.Generate(arp, "(Canvas.Top)", rvm.Y, UnitAnimationDuration, DelayBeforeAnimation));
                    storyboard.Children.Add(Util.Animator.Generate(arp, "Opacity", 1, UnitAnimationDuration, DelayBeforeAnimation));

                    storyboard.Children.Add(
                        Util.Animator.GenerateColorAnimation(arp.CellPresenter, "(TextBlock.Foreground).(SolidColorBrush.Color)", rvm.Color, UnitAnimationDuration, DelayBeforeAnimation)
                        );

                    if (beforeX != afterX)
                    {
                        storyboard.Children.Add(Util.Animator.Generate(arp.CellPresenter, "(Canvas.Left)", afterX, UnitAnimationDuration, DelayBeforeAnimation + UnitAnimationDuration));
                        horizontalAnimationDuration = UnitAnimationDuration;
                    }
                    index++;
                }
            }
            else // grouped row visible
            {
            }

            stashedViewStatus = null;
            return(new AnimationScenario()
            {
                TotalAnimationDuration = DelayBeforeAnimation + UnitAnimationDuration + horizontalAnimationDuration,
                TableHeaderUpdateTime = DelayBeforeAnimation + UnitAnimationDuration,
                AnimationStoryboard = storyboard
            });
        }
Пример #2
0
        private AnimationScenario PlayCollapseAnimation(List <RowViewModel> previousRowViewModels, List <RowViewModel> currentRowViewModels, ColumnViewModel columnViewModel)
        {
            Double beforeX = columnViewModel.StashedX;
            Double afterX  = columnViewModel.X;

            Storyboard storyboard = new Storyboard();

            Canvas canvas = view.TableView.AnimatingRowCanvas;

            RowViewModel               rootRowViewModel        = currentRowViewModels[0];
            IEnumerable <Row>          rows                    = rootRowViewModel.Rows;
            IEnumerable <RowViewModel> collapsingRowViewModels =
                previousRowViewModels
                .Where(rvm => (rvm.Row == null ? rows.Intersect(rvm.Rows).Count() > 0 : rows.Contains(rvm.Row)) && rvm.Y < mainPageViewModel.Bounds.Height)
                .OrderBy(rvm => rvm.Y)
                .Take(50);

            if (collapsingRowViewModels.Count() < 5)
            {
                foreach (RowViewModel groupedRowViewModel in currentRowViewModels)
                {
                    IEnumerable <RowViewModel> candidate =
                        previousRowViewModels
                        .Where(rvm => (rvm.Row == null ? groupedRowViewModel.Rows.Intersect(rvm.Rows).Count() > 0 : groupedRowViewModel.Rows.Contains(rvm.Row)) && rvm.Y < mainPageViewModel.Bounds.Height)
                        .OrderBy(rvm => rvm.Y)
                        .Take(50);

                    if (candidate.Count() >= 5)
                    {
                        rows = groupedRowViewModel.Rows;
                        collapsingRowViewModels = candidate;
                        rootRowViewModel        = groupedRowViewModel;
                        break;
                    }
                }
            }

            Double colorChangingAnimationDuration = 0;
            Double horizontalAnimationDuration    = 0;

            if (collapsingRowViewModels.Any(rvm => rvm.StashedColor != rootRowViewModel.Color))
            {
                colorChangingAnimationDuration = UnitAnimationDuration;
            }

            if (beforeX != afterX)
            {
                horizontalAnimationDuration = UnitAnimationDuration;
            }


            // root
            {
                AnimatingRowViewModel arvm = new AnimatingRowViewModel()
                {
                    RowViewModel    = rootRowViewModel,
                    X               = beforeX,
                    ColumnViewModel = columnViewModel
                };

                AnimatingRowPresenter arp = new AnimatingRowPresenter()
                {
                    AnimatingRowViewModel = arvm
                };

                arp.Opacity = 0;
                arp.Update();
                canvas.Children.Add(arp);
                arp.CellPresenter.Foreground = new SolidColorBrush(rootRowViewModel.Color);
                Canvas.SetTop(arp, rootRowViewModel.Y);

                storyboard.Children.Add(Util.Animator.Generate(arp, "Opacity", 1, UnitAnimationDuration, DelayBeforeAnimation + colorChangingAnimationDuration));

                if (beforeX != afterX)
                {
                    storyboard.Children.Add(Util.Animator.Generate(arp.CellPresenter, "(Canvas.Left)", afterX, UnitAnimationDuration, DelayBeforeAnimation + UnitAnimationDuration + colorChangingAnimationDuration));
                }
            }

            foreach (RowViewModel rvm in collapsingRowViewModels)
            {
                AnimatingRowViewModel arvm = new AnimatingRowViewModel()
                {
                    RowViewModel    = rvm,
                    X               = beforeX,
                    ColumnViewModel = columnViewModel
                };

                AnimatingRowPresenter arp = new AnimatingRowPresenter()
                {
                    AnimatingRowViewModel = arvm
                };

                arp.Opacity = 1;
                arp.Update();
                canvas.Children.Add(arp);

                Canvas.SetTop(arp, rvm.StashedY);
                arp.CellPresenter.Foreground = new SolidColorBrush(rvm.StashedColor);

                if (colorChangingAnimationDuration > 0)
                {
                    storyboard.Children.Add(
                        Util.Animator.GenerateColorAnimation(arp.CellPresenter, "(TextBlock.Foreground).(SolidColorBrush.Color)", rootRowViewModel.Color, UnitAnimationDuration, DelayBeforeAnimation)
                        );
                }

                // 그 다음 세로로 모음
                storyboard.Children.Add(Util.Animator.Generate(arp, "(Canvas.Top)", rootRowViewModel.Y, UnitAnimationDuration, DelayBeforeAnimation + colorChangingAnimationDuration));
                storyboard.Children.Add(Util.Animator.Generate(arp, "Opacity", 0, UnitAnimationDuration, DelayBeforeAnimation + colorChangingAnimationDuration));

                // 그 다음 가로로 이동
                if (beforeX != afterX)
                {
                    storyboard.Children.Add(Util.Animator.Generate(arp.CellPresenter, "(Canvas.Left)", afterX, UnitAnimationDuration, DelayBeforeAnimation + UnitAnimationDuration + colorChangingAnimationDuration));
                }
            }

            stashedViewStatus = null;

            return(new AnimationScenario()
            {
                TotalAnimationDuration = DelayBeforeAnimation + UnitAnimationDuration + horizontalAnimationDuration + colorChangingAnimationDuration,
                TableHeaderUpdateTime = DelayBeforeAnimation + UnitAnimationDuration + colorChangingAnimationDuration,
                AnimationStoryboard = storyboard,
                SpotlightColumnViewModel = columnViewModel
            });
        }