Example #1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (sender == this.ConnectButton)
            {
                await MipRobotFinder.Instance.ScanForRobots();

                MipRobot mip = MipRobotFinder.Instance.FoundRobotList.FirstOrDefault();
                if (mip != null)
                {
                    if (await mip.Connect())
                    {
                        this.ConnectButton.Content = "Connected: " + mip.DeviceName;

                        this.ConnectButton.IsEnabled     = false;
                        this.DriveButton.IsEnabled       = true;
                        this.DriveCanvas.IsEnabled       = true;
                        this.PlaySoundButton.IsEnabled   = true;
                        this.ChangeChestButton.IsEnabled = true;
                        this.FalloverButton.IsEnabled    = true;
                    }
                }
                else
                {
                    await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-bluetooth:"));
                }
            }
            else if (sender == DriveButton)
            {
            }
            else if (sender == this.PlaySoundButton)
            {
                await MipRobotFinder.Instance.FirstConnectedRobot().SetMipVolumeLevel(7);

                await MipRobotFinder.Instance.FirstConnectedRobot().PlayMipSound(new MipRobotSound(MipRobotConstants.SOUND_FILE.MIP_IN_LOVE));
            }
            else if (sender == this.ChangeChestButton)
            {
                await MipRobotFinder.Instance.FirstConnectedRobot().SetMipChestLedWithColor(0xff, 0xff, 0xff, 1);
            }
            else if (sender == this.FalloverButton)
            {
                await MipRobotFinder.Instance.FirstConnectedRobot().MipFalloverWithSytle(MipRobotConstants.POSITION_VALUE.ON_BACK);
            }
        }
Example #2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            LogWindow.Text += "Connecting\n";
            if (sender == this.ConnectButton)
            {
                await MipRobotFinder.Instance.ScanForRobots();

                MipRobot mip = MipRobotFinder.Instance.FoundRobotList.FirstOrDefault();
                if (mip != null)
                {
                    if (await mip.Connect())
                    {
                        this.ConnectButton.Content = "Connected: " + mip.DeviceName;

                        this.ConnectButton.IsEnabled     = false;
                        this.DriveButton.IsEnabled       = true;
                        this.DriveCanvas.IsEnabled       = true;
                        this.PlaySoundButton.IsEnabled   = true;
                        this.ChangeChestButton.IsEnabled = true;
                        this.FalloverButton.IsEnabled    = true;

                        mip.MipPositionHandler            += Mip_MipPositionHandler;
                        mip.DidConnectedEvent             += Mip_DidConnectedEvent;
                        mip.DidDisconnectedEvent          += Mip_DidDisconnectedEvent;
                        mip.MipToyActivationStatusHandler += Mip_MipToyActivationStatusHandler;
                        mip.MipGameModeHandler            += Mip_MipGameModeHandler;
                        mip.MipVolumeLevelHandler         += Mip_MipVolumeLevelHandler;
                        mip.MipWeightLevelHandler         += Mip_MipWeightLevelHandler;
                        mip.MipLeaningForwardHandler      += Mip_MipLeaningForwardHandler;
                    }
                }
                else
                {
                    await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-bluetooth:"));
                }
            }
            else if (sender == DriveButton)
            {
            }
            else if (sender == this.FalloverButton)
            {
                await MipRobotFinder.Instance.FirstConnectedRobot().MipFalloverWithSytle(MipRobotConstants.POSITION_VALUE.ON_BACK);
            }
        }