Exemple #1
0
        void _UpdateDPad(DirectInputDPad dPad, DPadGaugeUC gauge, int dPadIndex)
        {
            gauge.Vector.Text = dPad.Vector.ToStringF4();
            gauge.Lenght.Text = dPad.Vector.Length().ToString("F4");
#if DEBUG
            gauge.VectorRaw.Text =
                //dPad.ParentDevice.RawDPadsStates[dPadIndex].ToString();
                dPad.AngleRad.ToString();
#endif
            _X            = Cmn.RangeConversion(-1, 0, DPadGaugeUC.RatioX, dPad.Vector.X);
            _Y            = Cmn.RangeConversion(1, 0, DPadGaugeUC.RatioY, dPad.Vector.Y);
            gauge.Line.X2 = _X;
            gauge.Line.Y2 = _Y;

            gauge.Thumb.Margin = new Thickness(_X - 10d, _Y - 10d, 0d, 0d);

            if (dPad.Up == ButtonState.Pressed)
            {
                gauge.ButtonUp.Background = Brushes.YellowGreen;
            }
            else
            {
                gauge.ButtonUp.Background = null;
            }

            _UpdateButtonIndicator(gauge.ButtonUp, dPad.Up);
            _UpdateButtonIndicator(gauge.ButtonDown, dPad.Down);
            _UpdateButtonIndicator(gauge.ButtonLeft, dPad.Left);
            _UpdateButtonIndicator(gauge.ButtonRight, dPad.Right);
        }
Exemple #2
0
        void _UpdateThumbStick(
            Vector2 thumbStickVector, ThumbStickGaugeUC gauge
#if DEBUG
            , Vector2 thumbStickVectorRaw
#endif
            )
        {
            gauge.Vector.Text = thumbStickVector.ToStringF4(); // F4
            gauge.Lenght.Text = thumbStickVector.Length().ToString("F4");
#if DEBUG
            gauge.VectorRaw.Text = thumbStickVectorRaw.ToString();
#endif
            // Vector: 0,0 = center
            // Line: 100,100 = center
            // Vector: -1,-1 = bottom left
            // Line: 0,200 = bottom left
            // Vector: 1,1 = top right
            // Line: 200,0 = top right

            _X            = Cmn.RangeConversion(-1, 0, ThumbStickGaugeUC.RatioX, thumbStickVector.X);
            _Y            = Cmn.RangeConversion(1, 0, ThumbStickGaugeUC.RatioY, thumbStickVector.Y);
            gauge.Line.X2 = _X;
            gauge.Line.Y2 = _Y;

            gauge.Thumb.Margin = new Thickness(_X - 15d, _Y - 15d, 0d, 0d);
        }