Пример #1
0
 void tcpClient_OnConnectionStatusChanged(object sender, TCPSlamClient.ClientStatusArgs e)
 {
     if (e.Status == TCPSlamClient.ClientStatus.Connected)
     {
         txtIP.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { txtIP.IsEnabled = false; }));
         btnConnect.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { btnConnect.Content = "Disconnect"; }));
         lblStatus.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { lblStatus.Content = "Status: Connected"; }));
         groupCommunication.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { groupCommunication.IsEnabled = true; }));
         groupArduino.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { groupArduino.IsEnabled = true; }));
     }
     else if (e.Status == TCPSlamClient.ClientStatus.Connecting)
     {
         txtIP.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { txtIP.IsEnabled = false; }));
         btnConnect.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { btnConnect.Content = "Disconnect"; }));
         lblStatus.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { lblStatus.Content = "Status: Connecting..."; }));
         groupCommunication.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { groupCommunication.IsEnabled = false; }));
         groupArduino.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { groupArduino.IsEnabled = false; }));
     }
     else if (e.Status == TCPSlamClient.ClientStatus.Disconnected)
     {
         txtIP.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { txtIP.IsEnabled = true; }));
         btnConnect.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { btnConnect.Content = "Connect"; }));
         lblStatus.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { lblStatus.Content = "Status: Disconnected"; }));
         groupCommunication.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { groupCommunication.IsEnabled = false; }));
         btnArduinoConnect.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { btnArduinoConnect.Content = "Connect"; }));
         lblArduinoStatus.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { lblArduinoStatus.Content = "Disconnected"; }));
         groupArduino.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { groupArduino.IsEnabled = false; }));
         ArduinoStatus = ArduinoSlam.ArduinoStatus.NotConnected;
         cmbKinect.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { cmbKinect.Items.Clear(); }));
     }
 }
Пример #2
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     controller = new ControllerSlam();
     controller.OnButtonsChanged += new EventHandler<ControllerSlam.ButtonArgs>(controller_OnButtonsChanged);
     tcpClient = new TCPSlamClient();
     tcpClient.Port = 9988;
     tcpClient.OnConnectionStatusChanged += new EventHandler<TCPSlamClient.ClientStatusArgs>(tcpClient_OnConnectionStatusChanged);
     tcpClient.OnDataReceived += new EventHandler<TCPSlamBase.MessageArgs>(tcpClient_OnDataReceived);
     txtIP.Text = Common.GetIP();
 }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     skeleton = new SkeletonSlam();
     skeleton.onHandHeightChanged += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onHandHeightChanged);
     skeleton.onRightAngleTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onRightAngleTurn);
     skeleton.onLeftQuarterTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onLeftQuarterTurn);
     skeleton.onRightQuarterTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onRightQuarterTurn);
     skeleton.onLeftHalfTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onLeftHalfTurn);
     skeleton.onLeftFullTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onLeftFullTurn);
     skeleton.onRightHalfTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onRightHalfTurn);
     skeleton.onRightFullTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onRightFullTurn);
     controller = new ControllerSlam();
     controller.OnButtonsChanged += new EventHandler<ControllerSlam.ButtonArgs>(controller_OnButtonsChanged);
     tcpClient = new TCPSlamClient();
     tcpClient.Port = 9988;
     tcpClient.OnConnectionStatusChanged += new EventHandler<TCPSlamClient.ClientStatusArgs>(tcpClient_OnConnectionStatusChanged);
     tcpClient.OnDataReceived += new EventHandler<TCPSlamBase.MessageArgs>(tcpClient_OnDataReceived);
     txtIP.Text = Common.GetIP();
 }