示例#1
0
        private async void MainWindow_OnKeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.W:
                UpKey.Background = new SolidColorBrush(Color.FromRgb(225, 225, 255));
                await BackendConnector.Move(GetSensitivity(), MovementType.Forward);

                break;

            case Key.A:
                LeftKey.Background = new SolidColorBrush(Color.FromRgb(225, 225, 255));
                await BackendConnector.Turn(GetSensitivity(), TurnType.Left);

                PositionDot.RenderTransform = new RotateTransform(90 - (await BackendConnector.GetPosition()).RotationDegrees);
                break;

            case Key.S:
                DownKey.Background = new SolidColorBrush(Color.FromRgb(225, 225, 255));
                await BackendConnector.Move(GetSensitivity(), MovementType.Backward);

                break;

            case Key.D:
                RightKey.Background = new SolidColorBrush(Color.FromRgb(225, 225, 255));
                await BackendConnector.Turn(GetSensitivity(), TurnType.Right);

                PositionDot.RenderTransform = new RotateTransform(90 - (await BackendConnector.GetPosition()).RotationDegrees);
                break;

            case Key.Space:
                if (e.IsRepeat)
                {
                    break;
                }
                SpaceKey.Background = new SolidColorBrush(Color.FromRgb(225, 225, 255));
                await BackendConnector.Blink();

                break;
            }

            var pos = await BackendConnector.GetPosition();

            PositionText.Text =
                $"Position (x: {pos.XPos}, y: {pos.YPos}, rotation: {pos.RotationDegrees})";

            var t = new Thickness((150 + pos.XPos) / multiplier, (110 - pos.YPos) / multiplier, 0, 0);

            if (t.Left >= 300 || t.Left <= 0 || t.Top <= 0 || t.Top >= 220)
            {
                PositionDot.Text = "";
            }
            else
            {
                PositionDot.Text = "^";
            }
            PositionDot.Margin   = t;
            PositionDot.FontSize = 10 / multiplier;
            e.Handled            = true;
        }
示例#2
0
        private async void MainWindow_OnInitialized(object?sender, EventArgs e)
        {
            await BackendConnector.Blink();

            await BackendConnector.Blink();

            await BackendConnector.Blink();

            var pos = await BackendConnector.GetPosition();

            multiplier        = 1;
            PositionText.Text =
                $"Position (x: {pos.XPos}, y: {pos.YPos}, rotation: {pos.RotationDegrees})";
            var t = new Thickness(150 + pos.XPos, 110 - pos.YPos, 0, 0);

            if (t.Left >= 300 || t.Left <= 0 || t.Top <= 0 || t.Top >= 220)
            {
                PositionDot.Text = "";
            }
            else
            {
                PositionDot.Text = "^";
            }
            PositionDot.Margin          = t;
            PositionDot.RenderTransform = new RotateTransform(90 - (await BackendConnector.GetPosition()).RotationDegrees);
        }
示例#3
0
        private async void Zoom_OnValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            var pos = await BackendConnector.GetPosition();

            multiplier = 1 / e.NewValue;
            var t = new Thickness((150 + pos.XPos) / multiplier, (110 - pos.YPos) / multiplier, 0, 0);

            if (t.Left >= 300 || t.Left <= 0 || t.Top <= 0 || t.Top >= 220)
            {
                PositionDot.Text = "";
            }
            else
            {
                PositionDot.Text = "^";
            }
            PositionDot.Margin   = t;
            PositionDot.FontSize = 10 / multiplier;
        }