Example #1
0
 private void GetState()
 {
     var stateRequest = new GetStateRequest();
     stateRequest.ProcessSuccessfully += data =>
         Dispatcher.BeginInvoke((Action)delegate
         {
             Cursor = Cursors.Arrow;
             UpdateButtonState();
             OnUpdateParentControl(null);
         });
     stateRequest.ProcessError += (errorCode, msg) =>
     {
         Dispatcher.BeginInvoke((Action)delegate
         {
             Cursor = Cursors.Arrow;
             switch (errorCode)
             {
                 case RobotRequest.ErrorCode.SetupConnection:
                 case RobotRequest.ErrorCode.WrongSessionID:
                     OnUpdateParentControl("MustReconnect");
                     break;
             }
         });
         Debug.Fail(msg, Enum.GetName(typeof(RobotRequest.ErrorCode), errorCode));
     };
     GlobalVariables.RobotWorker.AddJob(stateRequest);
 }
        private void GetState()
        {
            var stateRequest = new GetStateRequest();
            stateRequest.ProcessSuccessfully += data => Dispatcher.BeginInvoke((Action)delegate
            {
                UpdateRemoteControl();
                Cursor = Cursors.Arrow;
            });
            stateRequest.ProcessError += (errorCode, msg) =>
            {
                Dispatcher.BeginInvoke((Action)delegate
                {
                    Cursor = Cursors.Arrow;
                    switch (errorCode)
                    {
                        case RobotRequest.ErrorCode.SetupConnection:
                        case RobotRequest.ErrorCode.WrongSessionID:
                            var titleError = (string)TryFindResource("RobotConnectionLostText");
                            var msgError = (string)TryFindResource("WantReconnectRobotText");
                            var result = WPFMessageBox.Show(StaticMainWindow.Window, msgError,
                                                     titleError, 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(RobotRequest.ErrorCode)), errorCode));
            };
            GlobalVariables.RobotWorker.AddJob(stateRequest);
        }
Example #3
0
 private void GetState()
 {
     var stateRequest = new GetStateRequest();
     stateRequest.ProcessSuccessfully += data =>
     {
         OnProcessSuccessfully(data);
         OnUpdateParentControl(null);
     };
     stateRequest.ProcessError += (errorCode, msg) =>
     {
         Debug.Fail(msg);
         switch (errorCode)
         {
             case RobotRequest.ErrorCode.SetupConnection:
             case RobotRequest.ErrorCode.WrongSessionID:
                 OnUpdateParentControl("MustReconnect");
                 break;
         }
         OnProcessError();
     };
     GlobalVariables.RobotWorker.AddJob(stateRequest);
 }