/// <summary> /// Constructor /// </summary> /// <param name="up"></param> /// <param name="down"></param> /// <param name="left"></param> /// <param name="right"></param> /// <param name="button0"></param> /// <param name="button1"></param> /// <param name="button2"></param> /// <param name="button3"></param> /// <param name="button4"></param> /// <param name="button5"></param> /// <param name="button6"></param> /// <param name="button7"></param> /// <param name="button8"></param> /// <param name="button9"></param> public GamepadDevice(Key up, Key down, Key left, Key right, Key button0, Key button1, Key button2, Key button3, Key button4, Key button5, Key button6, Key button7, Key button8, Key button9) { Up = up; Down = down; Left = left; Right = right; Buttons = new Key[10]; Buttons[0] = button0; Buttons[1] = button1; Buttons[2] = button2; Buttons[3] = button3; Buttons[4] = button4; Buttons[5] = button5; Buttons[6] = button6; Buttons[7] = button7; Buttons[8] = button8; Buttons[9] = button9; Scanner = new BackgroundWorker(); Scanner.WorkerSupportsCancellation = true; Scanner.DoWork += Scan; }
/// <summary> /// Virtual button command mapping /// </summary> /// <param name="key">Virtual button</param> private void CommandMap(Key key) { bool result = true; if (!key.Click) { result = Bluetooth.SendCommand(0xAA); } else { int mode = 0; mode += (actL1.Click ? 1 : 0); mode += (actL2.Click ? 2 : 0); switch (key.Type) { // Action key case Key.Start: result = Bluetooth.SendCommand(Command.Start); break; case Key.Select: if (actL1.Click && !actL2.Click) { //read distance byte[] t = {0}; Bluetooth.ClearPreviousResponse(); result = Bluetooth.SendCommand(0xDD); System.Threading.Thread.Sleep(500); Bluetooth.ComPort.Read(t, 0, 1); MessageBox.Show(t[0].ToString()); break; } result = Bluetooth.SendCommand(Command.Stop); break; case Key.NavigationUp: result = Bluetooth.SendCommand(Command.Get(mode, 0)); break; case Key.NavigationDown: result = Bluetooth.SendCommand(Command.Get(mode, 1)); break; case Key.NavigationLeft: result = Bluetooth.SendCommand(Command.Get(mode, 2)); break; case Key.NavigationRight: result = Bluetooth.SendCommand(Command.Get(mode, 3)); break; case Key.Triangle: result = Bluetooth.SendCommand(Command.Get(mode, 4)); break; case Key.Cross: result = Bluetooth.SendCommand(Command.Get(mode, 5)); break; case Key.Square: result = Bluetooth.SendCommand(Command.Get(mode, 6)); break; case Key.Circle: result = Bluetooth.SendCommand(Command.Get(mode, 7)); break; case Key.R1: result = Bluetooth.SendCommand(Command.Get(mode, 8)); break; case Key.R2: result = Bluetooth.SendCommand(Command.Get(mode, 9)); break; } } if (!result) { MessageBox.Show("Connection Lost", "Error"); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: #line 12 "..\..\MainWindow.xaml" ((APOD_Controller.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.MetroWindow_Closing); #line default #line hidden return; case 2: this.menuLive = ((System.Windows.Controls.MenuItem)(target)); #line 18 "..\..\MainWindow.xaml" this.menuLive.Click += new System.Windows.RoutedEventHandler(this.menuLive_Click); #line default #line hidden return; case 3: this.menuPlayer = ((System.Windows.Controls.MenuItem)(target)); #line 19 "..\..\MainWindow.xaml" this.menuPlayer.Click += new System.Windows.RoutedEventHandler(this.menuPlayer_Click); #line default #line hidden return; case 4: this.menuConfig = ((System.Windows.Controls.MenuItem)(target)); #line 20 "..\..\MainWindow.xaml" this.menuConfig.Click += new System.Windows.RoutedEventHandler(this.menuConfig_Click); #line default #line hidden return; case 5: this.tabControl = ((System.Windows.Controls.TabControl)(target)); return; case 6: this.tabLiveControl = ((System.Windows.Controls.TabItem)(target)); return; case 7: this.gridLive = ((System.Windows.Controls.Grid)(target)); return; case 8: this.pnlNavigation = ((System.Windows.Controls.Border)(target)); return; case 9: this.navLeft = ((APOD_Keypad.Key)(target)); return; case 10: this.navRight = ((APOD_Keypad.Key)(target)); return; case 11: this.navUp = ((APOD_Keypad.Key)(target)); return; case 12: this.navDown = ((APOD_Keypad.Key)(target)); return; case 13: this.pnlAction = ((System.Windows.Controls.Border)(target)); return; case 14: this.actSquare = ((APOD_Keypad.Key)(target)); return; case 15: this.actCircle = ((APOD_Keypad.Key)(target)); return; case 16: this.actTriangle = ((APOD_Keypad.Key)(target)); return; case 17: this.actCross = ((APOD_Keypad.Key)(target)); return; case 18: this.pnlTriggers = ((System.Windows.Controls.Border)(target)); return; case 19: this.actL1 = ((APOD_Keypad.Key)(target)); return; case 20: this.actL2 = ((APOD_Keypad.Key)(target)); return; case 21: this.actR1 = ((APOD_Keypad.Key)(target)); return; case 22: this.actR2 = ((APOD_Keypad.Key)(target)); return; case 23: this.pnlFunction = ((System.Windows.Controls.Border)(target)); return; case 24: this.actStart = ((APOD_Keypad.Key)(target)); return; case 25: this.actSelect = ((APOD_Keypad.Key)(target)); return; case 26: #line 138 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_1); #line default #line hidden return; case 27: #line 139 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_2); #line default #line hidden return; case 28: this.imgSplash = ((System.Windows.Controls.Image)(target)); return; case 29: this.hostCam = ((System.Windows.Forms.Integration.WindowsFormsHost)(target)); return; case 30: this.viewCam = ((AForge.Controls.VideoSourcePlayer)(target)); return; case 31: this.rdModeNormal = ((System.Windows.Controls.RadioButton)(target)); #line 155 "..\..\MainWindow.xaml" this.rdModeNormal.Checked += new System.Windows.RoutedEventHandler(this.rdModeNormal_Checked); #line default #line hidden #line 155 "..\..\MainWindow.xaml" this.rdModeNormal.Unchecked += new System.Windows.RoutedEventHandler(this.rdModeNormal_Unchecked); #line default #line hidden return; case 32: this.rdModeKeypad = ((System.Windows.Controls.RadioButton)(target)); #line 158 "..\..\MainWindow.xaml" this.rdModeKeypad.Checked += new System.Windows.RoutedEventHandler(this.rdModeKeypad_Checked); #line default #line hidden #line 158 "..\..\MainWindow.xaml" this.rdModeKeypad.Unchecked += new System.Windows.RoutedEventHandler(this.rdModeKeypad_Unchecked); #line default #line hidden return; case 33: this.rdModeObjTracking = ((System.Windows.Controls.RadioButton)(target)); #line 161 "..\..\MainWindow.xaml" this.rdModeObjTracking.Checked += new System.Windows.RoutedEventHandler(this.rdModeObjTracking_Checked); #line default #line hidden #line 161 "..\..\MainWindow.xaml" this.rdModeObjTracking.Unchecked += new System.Windows.RoutedEventHandler(this.rdModeObjTracking_Unchecked); #line default #line hidden return; case 34: this.btnStream = ((System.Windows.Controls.Button)(target)); #line 162 "..\..\MainWindow.xaml" this.btnStream.Click += new System.Windows.RoutedEventHandler(this.Streaming_Trigger); #line default #line hidden return; case 35: this.pnlTrackingObject = ((System.Windows.Controls.Expander)(target)); return; case 36: this.cbTrackingMethod = ((System.Windows.Controls.ComboBox)(target)); #line 167 "..\..\MainWindow.xaml" this.cbTrackingMethod.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cbTrackingMethod_SelectionChanged); #line default #line hidden return; case 37: this.imgTrackingColor = ((System.Windows.Controls.Image)(target)); return; case 38: this.imgTrackingGlyph = ((System.Windows.Controls.Image)(target)); return; case 39: this.btnTrackingChangeTarget = ((System.Windows.Controls.Button)(target)); #line 173 "..\..\MainWindow.xaml" this.btnTrackingChangeTarget.Click += new System.Windows.RoutedEventHandler(this.btnTrackingChangeTarget_Click); #line default #line hidden return; case 40: this.btnTrackingLock = ((System.Windows.Controls.CheckBox)(target)); #line 175 "..\..\MainWindow.xaml" this.btnTrackingLock.Checked += new System.Windows.RoutedEventHandler(this.btnTrackingLock_Checked); #line default #line hidden #line 175 "..\..\MainWindow.xaml" this.btnTrackingLock.Unchecked += new System.Windows.RoutedEventHandler(this.btnTrackingLock_Unchecked); #line default #line hidden return; case 41: this.tabPlayer = ((System.Windows.Controls.TabItem)(target)); return; case 42: this.cbDirection = ((System.Windows.Controls.ComboBox)(target)); #line 199 "..\..\MainWindow.xaml" this.cbDirection.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cbDirection_SelectionChanged); #line default #line hidden return; case 43: this.txtInterval = ((System.Windows.Controls.TextBox)(target)); #line 205 "..\..\MainWindow.xaml" this.txtInterval.PreviewTextInput += new System.Windows.Input.TextCompositionEventHandler(this.txtInterval_PreviewTextInput); #line default #line hidden return; case 44: this.btnSequenceAdd = ((System.Windows.Controls.Button)(target)); #line 206 "..\..\MainWindow.xaml" this.btnSequenceAdd.Click += new System.Windows.RoutedEventHandler(this.btnSequenceAdd_Click); #line default #line hidden return; case 45: this.tblSequences = ((System.Windows.Controls.DataGrid)(target)); return; case 47: #line 232 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.StateRemove_Click); #line default #line hidden return; case 48: this.btnImport = ((System.Windows.Controls.Button)(target)); #line 237 "..\..\MainWindow.xaml" this.btnImport.Click += new System.Windows.RoutedEventHandler(this.btnImport_Click); #line default #line hidden return; case 49: this.btnExport = ((System.Windows.Controls.Button)(target)); #line 238 "..\..\MainWindow.xaml" this.btnExport.Click += new System.Windows.RoutedEventHandler(this.btnExport_Click); #line default #line hidden return; case 50: this.btnPlay = ((System.Windows.Controls.Button)(target)); #line 242 "..\..\MainWindow.xaml" this.btnPlay.Click += new System.Windows.RoutedEventHandler(this.btnPlay_Click); #line default #line hidden return; } this._contentLoaded = true; }