コード例 #1
0
        protected override void OnMouseEnter(MouseEventArgs e)
        {
            //this.UpdateZone(this.GetZone(e.GetPosition(this)));
            BookZone bz = ZoneDetector.GetZone(this.RenderSize, this.FoldSize, e.GetPosition(this), this.Orientation);

            this.UpdateZone(bz);
        }
コード例 #2
0
        private static void FoldAnimation_CalculateStartAndTargetPoint(BookZone zone, double FoldSize, Size RenderSize, ref Vector2 start, ref Vector2 target)
        {
            Vector2 vector3 = new Vector2(FoldSize / RenderSize.Width, FoldSize / RenderSize.Height);

            switch (zone)
            {
            case BookZone.BottomLeft:
                start  = new Vector2(0.0, 1.0);
                target = new Vector2(vector3.X, 1.0 - vector3.Y);
                break;

            case BookZone.TopLeft:
                start  = new Vector2();
                target = vector3;
                break;

            case BookZone.TopRight:
                start  = new Vector2(1.0, 0.0);
                target = new Vector2(1.0 - vector3.X, vector3.Y);
                break;

            case BookZone.BottomRight:
                start  = new Vector2(1.0, 1.0);
                target = new Vector2(1.0, 1.0) - vector3;
                break;
            }
        }
コード例 #3
0
        private void CircleTransition(BookItem item, BookZone zone)
        {
            Vector2  center;
            Vector2  start;
            Vector2  target;
            double   radius;
            BookItem item2 = this.Back(item);

            if (item2 != null)
            {
                //<>c__DisplayClass6 class2;
                center = new Vector2();
                if (this.Orientation == System.Windows.Controls.Orientation.Horizontal)
                {
                    center = ((zone == BookZone.TopLeft) || (zone == BookZone.TopRight)) ? new Vector2(0.5, -0.5) : new Vector2(0.5, 1.5);
                }
                else
                {
                    center = ((zone == BookZone.TopLeft) || (zone == BookZone.BottomLeft)) ? new Vector2(-0.5, 0.5) : new Vector2(1.5, 0.5);
                }
                start = new Vector2();
                switch (zone)
                {
                case BookZone.BottomLeft:
                    start = new Vector2(0.0, 1.0);
                    break;

                case BookZone.TopRight:
                    start = new Vector2(1.0, 0.0);
                    break;

                case BookZone.BottomRight:
                    start = new Vector2(1.0, 1.0);
                    break;
                }
                target = VectorHelper.Flip(new Size(1.0, 1.0), item.Direction, start);
                Vector2 vector = center - start;
                radius                = vector.Length;
                item2.DragCurrent     = item.DragCurrent = item2.DragStart = item.DragStart = start;
                item2.TransitionFront = true;
                item.TransitionFront  = false;
                item2.Time            = item.Time = 0.0;
                item2.Path            = item.Path = (double t) =>
                {
                    if (t != 1.0)
                    {
                        Vector2 vector2 = ((Vector2)((target * t) + (start * (1.0 - t)))) - center;
                        return(((Vector2)(vector2.Normalized * radius)) + center);
                    }
                    return(target);
                };

                this.BeginRendering();
            }
        }
コード例 #4
0
 private void UpdateZone(BookZone zone)
 {
     if ((this.ShowPageFold == PageFoldVisibility.OnMouseOver) && ((this.CurrentZone != zone) || (this._fold == null)))
     {
         this.UndoFold();
         if (((this._dragged == null) && (zone != BookZone.Center)) && (zone != BookZone.Out))
         {
             this.Fold(zone);
         }
     }
     this.CurrentZone = zone;
 }
コード例 #5
0
        private void Fold(BookZone zone)
        {
            int     index   = this.CurrentPage - this.PagePosition(this.CurrentPage);
            Vector2 start   = new Vector2();
            Vector2 target  = new Vector2();
            Vector2 vector3 = new Vector2(this.FoldSize / base.RenderSize.Width, this.FoldSize / base.RenderSize.Height);

            switch (zone)
            {
            case BookZone.BottomLeft:
                index += (this.Orientation == System.Windows.Controls.Orientation.Horizontal) ? 0 : 1;
                start  = new Vector2(0.0, 1.0);
                target = new Vector2(vector3.X, 1.0 - vector3.Y);
                break;

            case BookZone.TopLeft:
                start  = new Vector2();
                target = vector3;
                break;

            case BookZone.TopRight:
                index += (this.Orientation == System.Windows.Controls.Orientation.Horizontal) ? 1 : 0;
                start  = new Vector2(1.0, 0.0);
                target = new Vector2(1.0 - vector3.X, vector3.Y);
                break;

            case BookZone.BottomRight:
                index++;
                start  = new Vector2(1.0, 1.0);
                target = new Vector2(1.0, 1.0) - vector3;
                break;
            }
            this.SortPages(this.PagePosition(index) == 1);
            this._fold = base.ItemContainerGenerator.ContainerFromIndex(index) as BookItem;
            if (this._fold != null)
            {
                if (this._fold.DragStart != start)
                {
                    this.LinearTransition(this._fold, start, target);
                }
                else
                {
                    if (this._fold.Time == 1.0)
                    {
                        this._fold.Time = 0.0;
                    }
                    this.LinearTransition(this._fold, this._fold.Time, target);
                }
            }
        }
コード例 #6
0
        private bool TurnPage(BookZone zone)
        {
            bool     forward = ((this.Orientation == System.Windows.Controls.Orientation.Horizontal) && ((zone == BookZone.BottomRight) || (zone == BookZone.TopRight))) || ((this.Orientation == null) && ((zone == BookZone.BottomLeft) || (zone == BookZone.BottomRight)));
            int      num     = (this.CurrentPage - this.PagePosition(this.CurrentPage)) + (forward ? 1 : 0);
            BookItem item    = base.ItemContainerGenerator.ContainerFromIndex(num) as BookItem;

            if ((this.Back(item) != null) && (this._dragged == null))
            {
                this.InstantUndoFold();
                this.SortPages(forward);
                this.CircleTransition(item, zone);
                this.SetCurrentPage(this.CurrentPage + (forward ? 2 : -2));
                return(true);
            }
            return(false);
        }
コード例 #7
0
        void Fold(BookZone zone)
        //int index, BookZone zone, double FoldSize, Size RenderSize, System.Windows.Controls.Orientation Orientation)
        {
            int index = this.CurrentPage - this.PagePosition(this.CurrentPage);

            if (_bIsLayout1Page)
            {
                ///re-layout zindex and find fold page
                switch (zone)
                {
                case BookZone.BottomLeft:
                    index += (Orientation == System.Windows.Controls.Orientation.Horizontal) ? 0 : 1;
                    break;

                case BookZone.TopLeft:
                    break;

                case BookZone.TopRight:
                    index += (Orientation == System.Windows.Controls.Orientation.Horizontal) ? 1 : 0;
                    break;

                case BookZone.BottomRight:
                    index++;
                    break;
                }
                this.SortPages(this.PagePosition(index) == 1);
            }
            else
            {
                this.SortPages(zone == BookZone.BottomRight || zone == BookZone.TopRight);
            }
            //create fold page for animation
            this._fold = BookItemFromIndex(index);

            BookItem back_fold = null;

            if (_bIsLayout1Page)
            {
                back_fold = this.Back(this._fold);
            }
            else
            {//not tested
                int back_fold_index = -1;
                switch (zone)
                {
                case BookZone.BottomLeft:
                case BookZone.TopLeft:
                    back_fold_index = index - 1;
                    break;

                case BookZone.TopRight:
                case BookZone.BottomRight:
                    back_fold_index = index + 1;
                    break;
                }
                if ((index >= 0) && (index < base.Items.Count))
                {
                    back_fold = BookItemFromIndex(back_fold_index);
                }
            }

            ///calculate start and target point
            Vector2 start  = new Vector2();
            Vector2 target = new Vector2();

            FoldAnimation_CalculateStartAndTargetPoint(zone, FoldSize, base.RenderSize, ref start, ref target);

            if (CreateFoldAnimation(ref this._fold, back_fold, start, target))
            {
                this.BeginRendering();
            }
        }