コード例 #1
0
ファイル: SNode.cs プロジェクト: Daoting/dt
        /// <summary>
        /// 综合动画
        /// </summary>
        /// <param name="direction"></param>
        /// <returns></returns>
        Timeline BuildAnimation(PointerDirection direction)
        {
            DoubleAnimationUsingKeyFrames timeline = new DoubleAnimationUsingKeyFrames();

            Storyboard.SetTarget(timeline, this);
            if (direction != PointerDirection.Center)
            {
                PlaneProjection projection2 = new PlaneProjection();
                projection2.CenterOfRotationZ = 0.0;
                PlaneProjection      projection = projection2;
                EasingDoubleKeyFrame frame3     = new EasingDoubleKeyFrame();
                frame3.KeyTime = (KeyTime)TimeSpan.FromSeconds(0.0);
                frame3.Value   = 0.0;
                EasingDoubleKeyFrame frame  = frame3;
                EasingDoubleKeyFrame frame4 = new EasingDoubleKeyFrame();
                frame4.KeyTime = _tilePressDuration;
                EasingDoubleKeyFrame frame2 = frame4;
                timeline.KeyFrames.Add(frame);
                timeline.KeyFrames.Add(frame2);
                if ((direction == PointerDirection.Left) || (direction == PointerDirection.Bottom))
                {
                    frame2.Value = _rotationDepth;
                }
                else if ((direction == PointerDirection.Top) || (direction == PointerDirection.Right))
                {
                    frame2.Value = -_rotationDepth;
                }
                if ((direction == PointerDirection.Top) || (direction == PointerDirection.Bottom))
                {
                    Storyboard.SetTargetProperty(timeline, "(UIElement.Projection).(PlaneProjection.RotationX)");
                }
                else if ((direction == PointerDirection.Left) || (direction == PointerDirection.Right))
                {
                    Storyboard.SetTargetProperty(timeline, "(UIElement.Projection).(PlaneProjection.RotationY)");
                }
                if (direction == PointerDirection.Bottom)
                {
                    projection.CenterOfRotationX = 0.5;
                    projection.CenterOfRotationY = 0.0;
                }
                else if (direction == PointerDirection.Top)
                {
                    projection.CenterOfRotationX = 0.5;
                    projection.CenterOfRotationY = 1.0;
                }
                else if (direction == PointerDirection.Left)
                {
                    projection.CenterOfRotationX = 1.0;
                    projection.CenterOfRotationY = 0.5;
                }
                else if (direction == PointerDirection.Right)
                {
                    projection.CenterOfRotationX = 0.0;
                    projection.CenterOfRotationY = 0.5;
                }
                Projection = projection;
            }
            return(timeline);
        }
コード例 #2
0
        /// <summary>
        /// The Tooltip constructor
        /// </summary>
        /// <param name="host">Host control (of the TreeView) in which the tooltip will be shown</param>
        /// <param name="width">Tooltip width</param>
        /// <param name="height">Tooltip height</param>
        /// <param name="direction">The pointer direction of the tooltip</param>
        public Tooltip(HostControlInfo host, double width, double height, PointerDirection direction, double verticalTooltipOffset)
            : base(host, width, height)
        {
            SetPointerDirection(direction);

            //The offset represent the distance vertically from the top/bottom for showing the tooltip pointer (a triangle)
            PointerVerticalOffset   = (Height / 8) + verticalTooltipOffset;
            PointerHorizontalOffset = (Width / 8);
            DrawPointerDirection(direction);
        }
コード例 #3
0
        private void updatePointerPosition(PointerDirection pointerDirection)
        {
            pointer.IsVisible        = true;
            pointer.TimeCheckElapsed = 0;

            switch (pointerDirection)
            {
            case PointerDirection.Right:
            {
                string shownText = textBoxText.CurrentText.Substring(textBoxText.CurrentSubstringIndex);

                if (pointer.Position < textBoxText.CurrentText.Length)
                {
                    pointer.Position++;
                }

                Vector2 newPosition = pointer.StartTopLeftCorner;

                newPosition.X += text.MeasureText(shownText.Substring(0, pointer.Position -
                                                                      textBoxText.CurrentSubstringIndex).Replace(" ", "["), textBoxText.FontSize).X - 6f;

                pointer.Rect.MoveLeftTopCorner(newPosition, pointer.Size);

                break;
            }

            case PointerDirection.Left:
            {
                if (pointer.Position > 0)
                {
                    pointer.Position--;
                }

                string shownText = textBoxText.CurrentText.Substring(textBoxText.CurrentSubstringIndex);

                Vector2 newPosition = pointer.StartTopLeftCorner;

                if (pointer.Position > textBoxText.CurrentSubstringIndex)
                {
                    newPosition.X += text.MeasureText(shownText.Substring(0, pointer.Position -
                                                                          textBoxText.CurrentSubstringIndex).Replace(" ", "["), textBoxText.FontSize).X - 6f;
                }

                pointer.Rect.MoveLeftTopCorner(newPosition, pointer.Size);

                break;
            }
            }
        }
コード例 #4
0
ファイル: Step.cs プロジェクト: reddyashish/Dynamo
 /// <summary>
 /// This method will be used to update the pointer direction if is needed
 /// </summary>
 /// <param name="direction"></param>
 public void SetPointerDirection(PointerDirection direction)
 {
     TooltipPointerDirection = direction;
 }
コード例 #5
0
        public void Execute(char c)
        {
            if (c == ' ')
            {
                if (stringMode) { stack.Push(Convert.ToInt32(c)); }
                return;
            }
            if (stringMode && c != '"') { stack.Push(Convert.ToInt32(c)); return; }
            if (Char.IsNumber(c)) { stack.Push(int.Parse(c.ToString())); return; }

            int a, b, x;

            switch (c)
            {
                case '+':
                    a = stack.Pop();
                    b = stack.Pop();
                    stack.Push(a + b);
                    break;
                case '-':
                    a = stack.Pop();
                    b = stack.Pop();
                    stack.Push(b - a);
                    break;
                case '*':
                    a = stack.Pop();
                    b = stack.Pop();
                    stack.Push(a * b);
                    break;
                case '/':
                    a = stack.Pop();
                    b = stack.Pop();
                    if (a == 0)
                    {
                        Console.Write("Division by zero found. What result do you want?");
                        stack.Push(GetNumber());
                    }
                    else
                    {
                        stack.Push(b / a);
                    }
                    break;
                case '%':
                    a = stack.Pop();
                    b = stack.Pop();
                    if (a == 0)
                    {
                        Console.Write("Division by zero found. What result do you want?");
                        stack.Push(GetNumber());
                    }
                    else
                    {
                        stack.Push(b % a);
                    }
                    break;
                case '!':
                    a = stack.Pop();
                    stack.Push((a == 0) ? 1 : 0);
                    break;
                case '`':
                    a = stack.Pop();
                    b = stack.Pop();
                    stack.Push((b > a) ? 1 : 0);
                    break;
                case '>':
                    pointerDirection = PointerDirection.right;
                    break;
                case '<':
                    pointerDirection = PointerDirection.left;
                    break;
                case '^':
                    pointerDirection = PointerDirection.up;
                    break;
                case 'v':
                    pointerDirection = PointerDirection.down;
                    break;
                case '?':
                    Random r = new Random(DateTime.Now.Millisecond);
                    pointerDirection = (PointerDirection)r.Next(4);
                    break;
                case '_':
                    a = stack.Pop();
                    pointerDirection = ( a == 0 ) ? PointerDirection.right : PointerDirection.left;
                    break;
                case '|':
                    a = stack.Pop();
                    pointerDirection = ( a == 0 ) ? PointerDirection.down : PointerDirection.up;;
                    break;
                case '"':
                    stringMode = !stringMode;
                    break;
                case ':':
                    stack.Push((stack.Count > 0) ? stack.Peek() : 0);
                    break;
                case '\\':
                    a = stack.Pop();
                    b = stack.Pop();
                    stack.Push(a);
                    stack.Push(b);
                    break;
                case '$':
                    if (stack.Count > 0) { stack.Pop(); }
                    break;
                case '.':
                    Console.Write(stack.Pop());
                    break;
                case ',':
                    Console.Write(Convert.ToChar(stack.Pop()));
                    break;
                case '#':
                    MoveInstructionPointer();
                    break;
                case 'p':
                    a = stack.Pop();
                    b = stack.Pop();
                    x = stack.Pop();
                    program[b, a] = Convert.ToChar(x);
                    break;
                case 'g':
                    a = stack.Pop();
                    b = stack.Pop();
                    stack.Push(program[b, a]);
                    break;
                case '&':
                    Console.Write("Enter number:");
                    stack.Push(GetNumber());
                    break;
                case '~':
                    Console.Write("Enter character:");
                    stack.Push(GetCharacter());
                    break;
            }
        }
コード例 #6
0
        /// <summary>
        /// This method will create the X,Y points (3 sets) for drawing a triangle that represents the Tooltip pointer direction
        /// </summary>
        /// <param name="direction"></param>
        private void DrawPointerDirection(PointerDirection direction)
        {
            //The Default pointer direction is PointerDirection.TOP_LEFT

            //First X,Y coordinate
            double pointX1 = PointerWidth;
            double pointY1 = 0;

            //Second X,Y coordinate
            double pointX2 = PointerWidth;
            double pointY2 = PointerHeight;

            //Third X,Y coordinate
            double pointX3 = 0;
            double pointY3 = PointerHeight / 2;

            //Due that we are drawing the 2 direction pointers we need to add 20 to the current width (Width + PointerWidth*2 - PointerTooltipOverlap*2)
            double realWidth  = Width + PointerWidth * 2 - PointerTooltipOverlap * 2;
            double realHeight = Height + PointerHeight * 2 - PointerTooltipOverlap * 2;

            //For each Y coordinate we add the Vertical offset otherwise the pointer will be always at the top or the botton
            if (direction == PointerDirection.TOP_LEFT)
            {
                pointX1 = PointerWidth;
                pointY1 = 0 + PointerVerticalOffset;

                pointX2 = PointerWidth;
                pointY2 = PointerHeight + PointerVerticalOffset;

                pointX3 = 0;
                pointY3 = PointerHeight / 2 + PointerVerticalOffset;
            }
            else if (direction == PointerDirection.BOTTOM_LEFT)
            {
                pointX1 = PointerWidth;
                pointY1 = Height - PointerVerticalOffset;

                pointX2 = PointerWidth;
                pointY2 = Height - PointerHeight - PointerVerticalOffset;

                pointX3 = 0;
                pointY3 = Height - PointerHeight / 2 - PointerVerticalOffset;
            }
            else if (direction == PointerDirection.TOP_RIGHT)
            {
                pointX1 = realWidth - PointerWidth;
                pointY1 = 0 + PointerVerticalOffset;

                pointX2 = realWidth - PointerWidth;
                pointY2 = PointerHeight + PointerVerticalOffset;

                pointX3 = realWidth;
                pointY3 = PointerHeight / 2 + PointerVerticalOffset;
            }
            else if (direction == PointerDirection.BOTTOM_RIGHT)
            {
                pointX1 = realWidth - PointerWidth;
                pointY1 = Height - PointerVerticalOffset;

                pointX2 = realWidth - PointerWidth;
                pointY2 = Height - PointerHeight - PointerVerticalOffset;

                pointX3 = realWidth;
                pointY3 = Height - PointerHeight / 2 - PointerVerticalOffset;
            }
            else if (direction == PointerDirection.BOTTOM_DOWN)
            {
                pointX1 = PointerHorizontalOffset;
                pointY1 = Height + PointerDownHeight;

                pointX2 = PointerDownWidth + PointerHorizontalOffset;
                pointY2 = Height + PointerDownHeight;

                pointX3 = PointerDownWidth / 2 + PointerHorizontalOffset;
                pointY3 = realHeight - PointerHeight;
            }

            TooltipPointerPoints = new PointCollection(new[] { new Point(pointX1, pointY1),
                                                               new Point(pointX2, pointY2),
                                                               new Point(pointX3, pointY3), });
        }
コード例 #7
0
 /// <summary>
 /// Determines if a pointer is allowed to down.
 /// </summary>
 /// <returns><c>true</c>, if allowed was downed, <c>false</c> otherwise.</returns>
 /// <param name="dir">Dir.</param>
 public static bool DownAllowed(this PointerDirection dir)
 {
     return((dir & PointerDirection.Down) != 0);
 }
コード例 #8
0
 /// <summary>
 /// Determines if a pointer is allowed to point up.
 /// </summary>
 /// <returns><c>true</c>, if allowed was uped, <c>false</c> otherwise.</returns>
 /// <param name="dir">Dir.</param>
 public static bool UpAllowed(this PointerDirection dir)
 {
     return((dir & PointerDirection.Up) != 0);
 }
コード例 #9
0
 /// <summary>
 /// Determines if a pointer is allowed to point right.
 /// </summary>
 /// <returns><c>true</c>, if allowed was righted, <c>false</c> otherwise.</returns>
 /// <param name="dir">Dir.</param>
 public static bool RightAllowed(this PointerDirection dir)
 {
     return((dir & PointerDirection.Right) != 0);
 }
コード例 #10
0
 /// <summary>
 /// Determines if a pointer is allowed to point left.
 /// </summary>
 /// <returns><c>true</c>, if allowed was lefted, <c>false</c> otherwise.</returns>
 /// <param name="dir">Dir.</param>
 public static bool LeftAllowed(this PointerDirection dir)
 {
     return((dir & PointerDirection.Left) != 0);
 }
コード例 #11
0
 /// <summary>
 /// Determines if pointer direction is horizontal.
 /// </summary>
 /// <returns><c>true</c> if is horizontal the specified dir; otherwise, <c>false</c>.</returns>
 /// <param name="dir">Dir.</param>
 public static bool IsHorizontal(this PointerDirection dir)
 {
     return(dir == PointerDirection.Left || dir == PointerDirection.Right);
 }
コード例 #12
0
 /// <summary>
 /// Determines if pointer direction is vertical.
 /// </summary>
 /// <returns><c>true</c> if is vertical the specified dir; otherwise, <c>false</c>.</returns>
 /// <param name="dir">Dir.</param>
 public static bool IsVertical(this PointerDirection dir)
 {
     return(dir == PointerDirection.Up || dir == PointerDirection.Down);
 }
コード例 #13
0
ファイル: SNode.cs プロジェクト: Daoting/dt
        /// <summary>
        /// 鼠标点击
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPointerPressed(PointerRoutedEventArgs e)
        {
            base.OnPointerPressed(e);
            if (Click == null || !CapturePointer(e.Pointer))
            {
                return;
            }

            e.Handled  = true;
            _pointerID = e.Pointer.PointerId;

            Point  ptCurrent = e.GetCurrentPoint(this).Position;
            double width     = ActualWidth / 3.0;
            double height    = ActualHeight / 3.0;

            if (new Rect(0.0, 0.0, width, height).Contains(ptCurrent))
            {
                _ptDirection = PointerDirection.TopLeft;
            }
            else if (new Rect(width, 0.0, width, height).Contains(ptCurrent))
            {
                _ptDirection = PointerDirection.Top;
            }
            else if (new Rect(width * 2.0, 0.0, width, height).Contains(ptCurrent))
            {
                _ptDirection = PointerDirection.TopRight;
            }
            else if (new Rect(0.0, height, width, height).Contains(ptCurrent))
            {
                _ptDirection = PointerDirection.Left;
            }
            else if (new Rect(width * 2.0, 0.0, width, height).Contains(ptCurrent))
            {
                _ptDirection = PointerDirection.Center;
            }
            else if (new Rect(width * 2.0, height, width, height).Contains(ptCurrent))
            {
                _ptDirection = PointerDirection.Right;
            }
            else if (new Rect(0.0, height * 2.0, width, height).Contains(ptCurrent))
            {
                _ptDirection = PointerDirection.BottomLeft;
            }
            else if (new Rect(width, height * 2.0, width, height).Contains(ptCurrent))
            {
                _ptDirection = PointerDirection.Bottom;
            }
            else if (new Rect(width * 2.0, height * 2.0, width, height).Contains(ptCurrent))
            {
                _ptDirection = PointerDirection.BottomRight;
            }
            else
            {
                _ptDirection = PointerDirection.Center;
            }

            _storyboard = new Storyboard();
            if (_ptDirection <= PointerDirection.Center)
            {
                if (_ptDirection == PointerDirection.Center)
                {
                    Timeline timeline  = BuildScaleXAnimation();
                    Timeline timeline2 = BuildScaleYAnimation();
                    _storyboard.Children.Add(timeline);
                    _storyboard.Children.Add(timeline2);
                    _storyboard.Begin();
                }
                else
                {
                    Timeline timeline3 = BuildAnimation(_ptDirection);
                    _storyboard.Children.Add(timeline3);
                    _storyboard.Begin();
                }
            }
            else if (_ptDirection == PointerDirection.TopLeft)
            {
                if (ptCurrent.X > ptCurrent.Y)
                {
                    Timeline timeline4 = BuildAnimation(PointerDirection.Top);
                    _storyboard.Children.Add(timeline4);
                    _storyboard.Begin();
                }
                else
                {
                    Timeline timeline5 = BuildAnimation(PointerDirection.Left);
                    _storyboard.Children.Add(timeline5);
                    _storyboard.Begin();
                }
            }
            else if (_ptDirection == PointerDirection.TopRight)
            {
                if (ptCurrent.Y > (height - (ptCurrent.X - (width * 2.0))))
                {
                    Timeline timeline6 = BuildAnimation(PointerDirection.Right);
                    _storyboard.Children.Add(timeline6);
                    _storyboard.Begin();
                }
                else
                {
                    Timeline timeline7 = BuildAnimation(PointerDirection.Top);
                    _storyboard.Children.Add(timeline7);
                    _storyboard.Begin();
                }
            }
            else if (_ptDirection == PointerDirection.BottomLeft)
            {
                if ((ptCurrent.Y - (height * 2.0)) > (height - ptCurrent.X))
                {
                    Timeline timeline8 = BuildAnimation(PointerDirection.Bottom);
                    _storyboard.Children.Add(timeline8);
                    _storyboard.Begin();
                }
                else
                {
                    Timeline timeline9 = BuildAnimation(PointerDirection.Left);
                    _storyboard.Children.Add(timeline9);
                    _storyboard.Begin();
                }
            }
            else if (ptCurrent.X > ptCurrent.Y)
            {
                Timeline timeline10 = BuildAnimation(PointerDirection.Right);
                _storyboard.Children.Add(timeline10);
                _storyboard.Begin();
            }
            else
            {
                Timeline timeline11 = BuildAnimation(PointerDirection.Bottom);
                _storyboard.Children.Add(timeline11);
                _storyboard.Begin();
            }
        }