// Get list motion in robot private void GetListMotion() { var listAllMotionRequest = new ListAllMotionRobotRequest(); viewModel.NoRobotMotionVisibility = false; if (GlobalVariables.CurrentListMotion.Count > 0) { viewModel.RemoteItemsList.Clear(); GlobalVariables.CurrentListMotion.Clear(); } listAllMotionRequest.ProcessSuccessfully += (listMotionInfo) => Dispatcher.BeginInvoke((Action) delegate { if (listMotionInfo.Count == 0) { viewModel.NoRobotMotionVisibility = true; } listMotionInfo.Sort((x, y) => String.CompareOrdinal(x.Title, y.Title)); // Sort title foreach (MotionInfo info in listMotionInfo) { //if (info.MType != MotionInfo.MotionType.Dance) continue; var motionTitleItem = new MotionTitleItem(); motionTitleItem.MotionID = info.MotionID; motionTitleItem.ViewModel.Title = info.Title; motionTitleItem.ViewModel.Duration = info.Duration; motionTitleItem.DeleteMotion += MotionTitleItem_DeleteMotion; viewModel.RemoteItemsList.Add(motionTitleItem); GlobalVariables.CurrentListMotion.Add(info); } //Dispatcher.BeginInvoke((Action)delegate // { // Cursor = Cursors.Arrow; // }); }); listAllMotionRequest.ProcessError += (e, msg) => { Dispatcher.BeginInvoke((Action) delegate { Cursor = Cursors.Arrow; switch (e) { case ListAllMotionRobotRequest.ErrorCode.SetupConnection: case ListAllMotionRobotRequest.ErrorCode.WrongSessionID: var titleReconnect = (string)TryFindResource("RobotConnectionLostText"); var msgReconnect = (string)TryFindResource("WantReconnectRobotText"); var result = WPFMessageBox.Show(StaticMainWindow.Window, titleReconnect, msgReconnect, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (result == MessageBoxResult.Yes) { ConnectMrobo(); } else { GlobalVariables.RoboOnline = false; UnconnectedTextBox.Visibility = Visibility.Visible; } break; } Debug.Fail(msg, Enum.GetName((typeof(ListAllMotionRobotRequest.ErrorCode)), e)); }); }; GlobalVariables.RobotWorker.AddJob(listAllMotionRequest); }
// Get list motion in robot private void GetListMotion() { var listAllMotionRequest = new ListAllMotionRobotRequest(); viewModel.NoRobotMotionVisibility = false; if (GlobalVariables.CurrentListMotion.Count > 0) { viewModel.RemoteItemsList.Clear(); GlobalVariables.CurrentListMotion.Clear(); } listAllMotionRequest.ProcessSuccessfully += (listMotionInfo) => Dispatcher.BeginInvoke((Action)delegate { if (listMotionInfo.Count == 0) viewModel.NoRobotMotionVisibility = true; listMotionInfo.Sort((x, y) => String.CompareOrdinal(x.Title, y.Title)); // Sort title foreach (MotionInfo info in listMotionInfo) { //if (info.MType != MotionInfo.MotionType.Dance) continue; var motionTitleItem = new MotionTitleItem(); motionTitleItem.MotionID = info.MotionID; motionTitleItem.ViewModel.Title = info.Title; motionTitleItem.ViewModel.Duration = info.Duration; motionTitleItem.DeleteMotion += MotionTitleItem_DeleteMotion; viewModel.RemoteItemsList.Add(motionTitleItem); GlobalVariables.CurrentListMotion.Add(info); } //Dispatcher.BeginInvoke((Action)delegate // { // Cursor = Cursors.Arrow; // }); }); listAllMotionRequest.ProcessError += (e, msg) => { Dispatcher.BeginInvoke((Action)delegate { Cursor = Cursors.Arrow; switch (e) { case ListAllMotionRobotRequest.ErrorCode.SetupConnection: case ListAllMotionRobotRequest.ErrorCode.WrongSessionID: var titleReconnect = (string)TryFindResource("RobotConnectionLostText"); var msgReconnect = (string)TryFindResource("WantReconnectRobotText"); var result = WPFMessageBox.Show(StaticMainWindow.Window, titleReconnect, msgReconnect, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (result == MessageBoxResult.Yes) { ConnectMrobo(); } else { GlobalVariables.RoboOnline = false; UnconnectedTextBox.Visibility = Visibility.Visible; } break; } Debug.Fail(msg, Enum.GetName((typeof(ListAllMotionRobotRequest.ErrorCode)), e)); }); }; GlobalVariables.RobotWorker.AddJob(listAllMotionRequest); }