/// <summary>Handles the respons from the user.</summary>
        private void handleConnection(object sender, string e)
        {
            Dispatcher.BeginInvoke((Action) delegate
            {
                if (e == "Ok")                                                                          // If the user confirms the establishment a progressbar is presented and a establish connection process is initialized
                {
                    progDialog       = new ProgressDialog("Forbinder...");
                    progDialog.Owner = this;
                    this.IsEnabled   = false;
                    progDialog.Show();

                    Logic.OnException -= new Logic.LogicExceptionEventHandler(ShowException);
                    Logic.OnException += new Logic.LogicExceptionEventHandler(ShowException);
                    Connection.OnConnectionCompleted -= new Connection.ConnectionCompletedEventHandler(ConnectionCompleted);
                    Connection.OnConnectionCompleted += new Connection.ConnectionCompletedEventHandler(ConnectionCompleted);

                    Thread connThread = new Thread(() =>                                                // Calls the establish connection in a thread so the progressbar isnt blocked
                    {
                        logic.EstablishConnection();
                    });
                    connThread.IsBackground = true;
                    connThread.Start();
                }

                else if (e == "Annuller")                                                               // The user cancels the establishment and the window is closed
                {
                    infoDlg.Close();
                    infoDlg        = null;
                    this.IsEnabled = true;
                }
            });
        }
        /// <summary>Opens a window showing the error, when the robot is in the wrong mode for movement.</summary>
        /// <param name="error">Error message.</param>
        private void URNotRunning(string error)
        {
            Dispatcher.BeginInvoke((Action) delegate
            {
                if (infoDlg == null)
                {
                    infoDlg = new InfoAndErrorWindow("Fejlmeddelelse", error, "Luk program");

                    infoDlg.OnDialogFinished -= infoDlg_DialogFinished;
                    infoDlg.OnDialogFinished += infoDlg_DialogFinished;
                    infoDlg.OnDialogFinished -= handleURNOTRUNNING;
                    infoDlg.OnDialogFinished += handleURNOTRUNNING;
                    infoDlg.Owner             = this;
                    infoDlg.Show();

                    Thread NotRunning = new Thread(() =>                                                               // Wait until the robots modes fulfill the right conditions
                    {
                        while (true)
                        {
                            if (connection.robotMode == "ROBOT_MODE_RUNNING" && connection.safetyMode == "SAFETY_MODE_NORMAL")
                            {
                                break;
                            }
                        }
                        Dispatcher.BeginInvoke((Action) delegate
                        {
                            infoDlg.Close();
                            infoDlg = null;
                        });
                    });
                    NotRunning.IsBackground = true;
                    NotRunning.Start();
                }
            });
        }
Ejemplo n.º 3
0
        /// <summary>DialogFinished event that closes the window.</summary>
        private void infoDlg_DialogFinished(object sender, string e)
        {
            InfoAndErrorWindow dlg = sender as InfoAndErrorWindow;

            dlg.Close();
        }
 /// <summary>DialogFinished event that closes the window.</summary>
 void infoDlg_DialogFinished(object sender, string e)
 {
     infoDlg.Close();
     infoDlg = null;
 }
 /// <summary>DialogFinished event that closes the window.</summary>
 void infoDlg_Error_DialogFinished(object sender, string e)
 {
     errorDlg.Close();
     errorDlg = null;
 }