MATLABfromCSharp.MainControl.checkMatlab C# (CSharp) Method

checkMatlab() public method

Checks to see if Matlab is still open and asks to Reload the logged data and reopens matlab.
public checkMatlab ( bool showDialog ) : void
showDialog bool Whether to show a dialog with yes or no.
return void
        public void checkMatlab(bool showDialog)
        {
            if(showDialog)
               {
               bool hasMatlab = MatlabAccess.isMatlabOpen();
               if (!hasMatlab && !checkedMatlab)
               {
                   DialogResult result1 = MessageBox.Show(" Matlab has been closed. Do you want to reopen Matlab and load with Logged inputs? To start with an empty workspace, click No.", "Matlab has Closed", MessageBoxButtons.YesNoCancel);
                   if (result1 == DialogResult.Yes)
                   {
                       MatlabAccess.MatlabStartup();
                       LogSystem.SaveLog("temp.txt");
                       LogSystem.Clear();
                       importLog("temp.txt");
                       checkedMatlab = false;
                   }
                   else if(result1 == DialogResult.No)
                   {
                       MatlabAccess.MatlabStartup();
                   }
                   else
                       checkedMatlab = true;
               }
               }
               else
               {
               MatlabAccess.MatlabStartup();
               LogSystem.SaveLog("temp.txt");
               LogSystem.Clear();
               importLog("temp.txt");
               checkedMatlab = false;
               }
        }