Exemplo n.º 1
0
 static void Main(string[] args)
 {
     MainWindow Window = new MainWindow();
     MyoSoundControl Controller = new MyoSoundControl(Window);
     Controller.Run();
     Application.EnableVisualStyles();
     Application.Run(Window);
     Application.ApplicationExit += Controller.Quit;
 }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     MainWindow Window = new MainWindow(); //Forms intialisieren
     MyoSoundControl Controller = new MyoSoundControl(Window); //objekt der Klasse Myosoundcontrol
     Controller.Run();
     Application.EnableVisualStyles(); //zugriff auf steuerelemente, farben etc. aus der Forms (Windows)
     Application.Run(Window);
     Application.ApplicationExit += Controller.Quit;
 }
Exemplo n.º 3
0
        MainWindow Window; //Forms

        #endregion Fields

        #region Constructors

        public MyoSoundControl(MainWindow Gui)
        {
            this.Window = Gui;
            //Channel und Hub (Schnittstelle) erzeugen
            this.Channel = MyoSharp.Communication.Channel.Create(
                ChannelDriver.Create(ChannelBridge.Create(),
                MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
            this.Hub = MyoSharp.Device.Hub.Create(Channel);
            Hub.MyoConnected += (sender, e) =>
            {
                this.myo = e.Myo;
                e.Myo.Vibrate(VibrationType.Long);
                e.Myo.PoseChanged += Myo_PoseChanged;
                e.Myo.Locked += Myo_Locked;
                e.Myo.Unlocked += Myo_Unlocked;

                this.myo.Unlock(UnlockType.Hold);

                //Pose in Dictionary mit Sound verbinden (Soundplayerklasse extra)
                this.PoseToSound[Pose.Fist] = new SoundPlayer("./Sound/Mario.wav");
                this.PoseToSound[Pose.WaveIn] = new SoundPlayer("./Sound/Glass.wav");
                this.PoseToSound[Pose.WaveOut] = new SoundPlayer("./Sound/Slap.wav");

                //Sequence

                //IPoseSequence sequence0 = PoseSequence.Create(e.Myo, Pose.Fist, Pose.FingersSpread);
                //sequence0.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence0] = new SoundPlayer("./Sound/Mario.wav");

                //IPoseSequence sequence1 = PoseSequence.Create(e.Myo, Pose.WaveIn, Pose.WaveOut);
                //sequence1.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence1] = new SoundPlayer("./Sound/Slap.wav");

                //IPoseSequence sequence2 = PoseSequence.Create(e.Myo, Pose.WaveOut, Pose.WaveIn);
                //sequence2.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence2] = new SoundPlayer("./Sound/Glass.wav");
            };

            Hub.MyoDisconnected += (sender, e) =>
            {
                e.Myo.PoseChanged -= Myo_PoseChanged;
                e.Myo.Locked -= Myo_Locked;
                e.Myo.Unlocked -= Myo_Unlocked;
            };
        }