示例#1
0
        public MainWindow()
        {
            //Init XAML
            InitializeComponent();
            //Create note list
            _razer = Provider.Razer;
            _notes = new Dictionary<Rectangle,Pitch>();
            _notes.Add(NoteCS,Pitch.CSharp4);
            _notes.Add(NoteDS,Pitch.DSharp4);
            _notes.Add(NoteFS,Pitch.FSharp4);
            _notes.Add(NoteGS,Pitch.GSharp4);
            _notes.Add(NoteAS,Pitch.ASharp4);
            _notes.Add(NoteC,Pitch.C4);
            _notes.Add(NoteD,Pitch.D4);
            _notes.Add(NoteE,Pitch.E4);
            _notes.Add(NoteF,Pitch.F4);
            _notes.Add(NoteG,Pitch.G4);
            _notes.Add(NoteA,Pitch.A4);
            _notes.Add(NoteB,Pitch.B4);

            //sound device
            if (OutputDevice.InstalledDevices.Count > 0)
            {
                _outputDevice = OutputDevice.InstalledDevices[0];
                _outputDevice.Open();
                _outputDevice.SendProgramChange(Channel.Channel1, Instrument.AcousticGrandPiano);
            }
            else
                Application.Current.Shutdown();

            _overlayHelper = new OverlayHelper(NewMessageOverlay, NewMessageOverlayLabel);
            

            /* This sends the current window to the SBUI
             * We give it the Polling RenderMethod which updates
             * SBUI every 42ms (about 24FPS)
             */
            _razer.Touchpad.SetWindow(this, Touchpad.RenderMethod.Polling);

            _razer.EnableDynamicKey(RazerAPI.DynamicKeyType.DK1, OnPressPiano, @"Default\Images\Piano.png");
            _razer.EnableDynamicKey(RazerAPI.DynamicKeyType.DK2, OnPressGuitar, @"Default\Images\Guitar.png");
            _razer.EnableDynamicKey(RazerAPI.DynamicKeyType.DK3, OnPressEPiano, @"Default\Images\EPiano.png");
            _razer.EnableDynamicKey(RazerAPI.DynamicKeyType.DK4, OnPressXylophone, @"Default\Images\Xylo.png");
            _razer.EnableDynamicKey(RazerAPI.DynamicKeyType.DK5, OnPressSteelDrums, @"Default\Images\Drums.png");
            _razer.Touchpad.Gesture += TouchpadOnGesture;
            //_razer.Touchpad.EnableGesture(RazerAPI.GestureType.Press);
            _razer.Touchpad.EnableGesture(RazerAPI.GestureType.Move);
            _razer.Touchpad.EnableGesture(RazerAPI.GestureType.Tap);
            //_overlayHelper.Show("Ready to touch");

        }