Example #1
0
        private void OnMouseDown(object sender, MouseButtonEventArgs args)
        {
            if ((Status == PageStatus.DropAnimation) || (Status == PageStatus.TurnAnimation))
            {
                return;
            }

            UIElement source = sender as UIElement;
            Point     p      = args.GetPosition(source);

            CornerOrigin?tmp  = GetCorner(source, p);
            int?         side = GetSide(source, p);


            if (side.HasValue && side == 1)
            {
                TurnPage();
                return;
            }

            if (tmp.HasValue)
            {
                origin = tmp.Value;
                this.CaptureMouse();
            }
            else
            {
                return;
            }

            Status = PageStatus.Dragging;
        }
Example #2
0
        private CornerOrigin?GetCorner(UIElement source, Point position)
        {
            CornerOrigin?result = null;

            Rect topLeftRectangle     = new Rect(0, 0, gripSize, gripSize);
            Rect topRightRectangle    = new Rect(source.RenderSize.Width - gripSize, 0, gripSize, gripSize);
            Rect bottomLeftRectangle  = new Rect(0, source.RenderSize.Height - gripSize, gripSize, gripSize);
            Rect bottomRightRectangle = new Rect(source.RenderSize.Width - gripSize, source.RenderSize.Height - gripSize, gripSize, gripSize);

            if (IsTopLeftCornerEnabled && topLeftRectangle.Contains(position))
            {
                result = CornerOrigin.TopLeft;
            }
            else if (IsTopRightCornerEnabled && topRightRectangle.Contains(position))
            {
                result = CornerOrigin.TopRight;
            }
            else if (IsBottomLeftCornerEnabled && bottomLeftRectangle.Contains(position))
            {
                result = CornerOrigin.BottomLeft;
            }
            else if (IsBottomRightCornerEnabled && bottomRightRectangle.Contains(position))
            {
                result = CornerOrigin.BottomRight;
            }

            return(result);
        }
Example #3
0
        private void OnMouseMove(object sender, MouseEventArgs args)
        {
            UIElement source = sender as UIElement;
            Point     p      = args.GetPosition(source);

            DropPage(ComputeAnimationDuration(source, p, origin));
            if ((Status == PageStatus.DropAnimation) || (Status == PageStatus.TurnAnimation))
            {
                return;
            }

            //Application.Current.MainWindow.Title += "M";



            if (!(sender as UIElement).IsMouseCaptured)
            {
                CornerOrigin?tmp = GetCorner(source, p);

                if (tmp.HasValue)
                {
                    origin = tmp.Value;
                }
                else
                {
                    //if (Status == PageStatus.DraggingWithoutCapture)
                    //{
                    DropPage(ComputeAnimationDuration(source, p, origin));
                    //}
                    return;
                }
                Status = PageStatus.DraggingWithoutCapture;
            }

            PageParameters?parameters = ComputePage(source, p, origin);

            _cornerPoint = p;
            if (parameters != null)
            {
                ApplyParameters(parameters.Value);
            }
        }
Example #4
0
        public void GrabPage(UIElement source, Point p)
        {
            if ((Status == PageStatus.DropAnimation) || (Status == PageStatus.TurnAnimation))
            {
                return;
            }

            CornerOrigin?tmp = GetCorner(source, p);

            if (tmp.HasValue)
            {
                origin = tmp.Value;
                Status = PageStatus.Dragging;
            }
            else
            {
                Status = PageStatus.None;
                return;
            }
        }
Example #5
0
        private void ContentControl_GotStylusCapture(object sender, StylusEventArgs e)
        {
            if ((Status == PageStatus.DropAnimation) || (Status == PageStatus.TurnAnimation))
            {
                return;
            }

            UIElement source = sender as UIElement;
            Point     p      = e.GetPosition(source);

            CornerOrigin?tmp  = GetCorner(source, p);
            int?         side = GetSide(source, p);

            if (side.HasValue && side == 1 && IsBottomRightCornerEnabled)
            {
                AutoTurnPage(CornerOrigin.BottomRight, 500);
                return;
            }

            if (side.HasValue && side == 0 && IsBottomLeftCornerEnabled)
            {
                AutoTurnPage(CornerOrigin.BottomLeft, 500);
                return;
            }

            if (tmp.HasValue)
            {
                origin = tmp.Value;
                this.CaptureMouse();
            }
            else
            {
                return;
            }

            Status = PageStatus.Dragging;
        }