public void RollAngleChange(bool Flag)
    {
        if (!RollerFlag)
        {
            if (Flag)
            {
                switch (rollAngle)
                {
                case RollAngle.Ten:
                    rollAngle = RollAngle.Fifteen;
                    break;

                case RollAngle.Fifteen:
                    rollAngle = RollAngle.Twenty;
                    break;

                case RollAngle.Twenty:
                    rollAngle = RollAngle.Ten;
                    break;
                }
                audio.PlayOneShot(aclip_rotchange);
            }
            else
            {
                switch (rollAngle)
                {
                case RollAngle.Ten:
                    rollAngle = RollAngle.Twenty;
                    break;

                case RollAngle.Fifteen:
                    rollAngle = RollAngle.Ten;
                    break;

                case RollAngle.Twenty:
                    rollAngle = RollAngle.Fifteen;
                    break;
                }
                audio.PlayOneShot(aclip_rotchange2);
            }
        }
    }
示例#2
0
        private void DrawRollPitchCycle()
        {
            Canvas_ViewPortMiddle.Children.Clear();
            bool isLargeArc = MaxRollAngle > 90;
            //double cycleR = Grid_Virwport.ActualWidth / 4;
            double cycleR     = 115;
            Point  startPoint = new Point(-cycleR * Math.Sin(MaxRollAngle * Math.PI / 180), -cycleR * Math.Cos(MaxRollAngle * Math.PI / 180));
            Point  endPoint   = new Point(cycleR * Math.Sin(MaxRollAngle * Math.PI / 180), -cycleR * Math.Cos(MaxRollAngle * Math.PI / 180));

            if (MaxRollAngle == 180)
            {
                startPoint = new Point(-0.1, cycleR);
                endPoint   = new Point(0.1, cycleR);
            }
            ArcSegment   arcpath   = new ArcSegment(endPoint, new Size(cycleR, cycleR), 0, isLargeArc, SweepDirection.Clockwise, true);
            PathGeometry geometry  = new PathGeometry(new PathFigure[] { new PathFigure(startPoint, new PathSegment[] { arcpath }, false) });
            Path         cyclepath = new Path();

            cyclepath.Data            = geometry;
            cyclepath.Stroke          = Brushes.LimeGreen;
            cyclepath.StrokeThickness = 2;
            int tickangle = 10;

            DrawRollTick(cycleR, 0);
            for (int angle = tickangle; angle <= MaxRollAngle; angle += tickangle)
            {
                if (angle == 180)
                {
                    break;
                }
                DrawRollTick(cycleR, angle);
                DrawRollTick(cycleR, -angle);
            }
            if (MaxRollAngle == 180)
            {
                DrawRollTick(cycleR, MaxRollAngle);
            }
            Canvas_ViewPortMiddle.Children.Add(cyclepath);

            #region 俯仰角
            int pitch      = (((int)PitchAngle) / 10) * 10;
            int pitchcount = 3;
            int pitchspace = 5;
            DrawPitchTick(pitch, 0);
            for (int i = 1; i < pitchcount; i++)
            {
                DrawPitchTick(pitch + i * pitchspace, -cycleR * i / pitchcount);
                for (int j = 1; j < pitchspace; j++)
                {
                    DrawShortPitchTick(pitch + (i - 1) * pitchspace + j, -cycleR * ((i - 1) + (float)j / pitchspace) / pitchcount);
                }
                DrawPitchTick(pitch - i * pitchspace, cycleR * i / pitchcount);
                for (int j = 1; j < pitchspace; j++)
                {
                    DrawShortPitchTick(pitch + (i - 1) * pitchspace + j, cycleR * ((i - 1) + (float)j / pitchspace) / pitchcount);
                }
            }
            DrawPitchValue(PitchAngle, -(PitchAngle - pitch) * cycleR / (pitchspace * pitchcount));
            #endregion

            Canvas_ViewPortMiddle.RenderTransform = new RotateTransform(-RollAngle);

            Canvas.SetTop(Canvas_RollCursor, -cycleR - Canvas_RollCursor.Height);
            Canvas.SetLeft(Canvas_RollCursor, -Canvas_RollCursor.Width / 2);
            Text_RollStaff_Value.Text = RollAngle.ToString("0.#");
        }