Beispiel #1
0
        private void InitializeFile(string logPath)
        {
            string header1 = "RoboSep UI Log File";
            string header2 = "Created: " + LogTime();

            try
            {
                // write log line to current log file
                using (StreamWriter sw = File.CreateText(logPath))
                {
                    sw.WriteLine(header1);
                    sw.WriteLine(header2);
                    sw.WriteLine("");
                }
            }
            catch
            {
                // get prompt message
                string msg = GUI_Controls.UserDetails.getValue("GUI", "msgLogWriteFail");
                msg  = msg == null ? "Unable to write to log file '" : msg;
                msg += logPath + "'";

                string title = "File Write Error";

                RoboMessagePanel err = new RoboMessagePanel(Application.OpenForms[0], MessageIcon.MBICON_ERROR, msg, title);
                err.ShowDialog();
                err.Dispose();
            }
        }
Beispiel #2
0
        private List <string> AskUserToInsertUSBDrive()
        {
            List <string> lstUSBDrives = Utilities.GetUSBDrives();

            if (lstUSBDrives == null)
            {
                return(null);
            }

            if (lstUSBDrives.Count > 0)
            {
                return(lstUSBDrives);
            }

            // show dialog prompting user to insert USB key
            string msg = LanguageINI.GetString("SaveReport");

            GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(
                RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_INFORMATION, msg, LanguageINI.GetString("headerSaveReport"),
                LanguageINI.GetString("Yes"), LanguageINI.GetString("Cancel"));
            RoboSep_UserConsole.showOverlay();
            prompt.ShowDialog();
            RoboSep_UserConsole.hideOverlay();

            if (prompt.DialogResult != DialogResult.OK)
            {
                prompt.Dispose();
                return(null);
            }
            prompt.Dispose();
            return(AskUserToInsertUSBDrive());
        }
Beispiel #3
0
        private void hex_shutdown_Click(object sender, EventArgs e)
        {
            // LOG
            string logMSG = "SHUTDOWN button clicked";

            //GUI_Controls.uiLog.LOG(this, "hex_shutdown_Click", GUI_Controls.uiLog.LogLevel.GENERAL, logMSG);

            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);
            // set up msg prompt
            string sMSG = LanguageINI.GetString("msgShutDown");

            GUI_Controls.RoboMessagePanel newPrompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_WARNING, sMSG,
                                                                                        LanguageINI.GetString("UserShutdown"), LanguageINI.GetString("Ok"), LanguageINI.GetString("Cancel"));
            RoboSep_UserConsole.getInstance().addForm(newPrompt, newPrompt.Offset);

            // prompt user
            newPrompt.ShowDialog();
            if (newPrompt.DialogResult == DialogResult.OK)
            {
                this.Hide();
                RoboSep_UserConsole.getInstance().frmHomeOverlay.Hide();
                // shut down robosep system
                logMSG = "User Shutdown Confirmed";
                LogFile.AddMessage(TraceLevel.Info, logMSG);

                RoboSep_UserConsole.getInstance().InvokeShutdownAction();
            }
            newPrompt.Dispose();
        }
        private void btnMP1_Click(object sender, EventArgs e)
        {
            RoboMessagePanel prompt = new RoboMessagePanel(this, MessageIcon.MBICON_INFORMATION, "this is a 1 button message pannel.  See how there is only 1 option button at the bottom....", "1 button");

            prompt.ShowDialog();
            prompt.Dispose();
        }
        private void button_SaveList_Click(object sender, EventArgs e)
        {
            // Check if User list contains atleast 1 protocol (otherwise don't exit screen)
            bool validUser = myUserProtocols.Count > 0;

            if (validUser)
            {
                // save list
                saveUserList();

                // close protocol list and user protocol list
                RoboSep_Protocols.getInstance().UserName = strUserName;
                RoboSep_UserConsole.getInstance().Controls.Add(RoboSep_Protocols.getInstance());
                RoboSep_UserConsole.getInstance().Controls.Remove(this);

                // Update user list
                RoboSep_Protocols.getInstance().LoadUsers();

                // LOG
                string logMSG = "Save List button clicked";
                //GUI_Controls.uiLog.LOG(this, "button_SaveList_Click", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG);
                //  (logMSG);
                LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);
            }
            else
            {
                GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_WARNING,
                                                                                         LanguageINI.GetString("msgValidUser"), LanguageINI.GetString("headerValidUser"), LanguageINI.GetString("Ok"));
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                prompt.Dispose();
                RoboSep_UserConsole.hideOverlay();
            }
        }
        private void btnMP2_Click(object sender, EventArgs e)
        {
            RoboMessagePanel prompt = new RoboMessagePanel(this, MessageIcon.MBICON_INFORMATION, "this is a 2 button message pannel.  See how there are 2 option buttons at the bottom....",
                                                           "2 buttons", "Excellent", "Meh");

            prompt.ShowDialog();
            prompt.Dispose();
        }
Beispiel #7
0
        private void validateEntry()
        {
            try
            {
                // if value is within specified range
                if (textBox_value.Text != string.Empty &&
                    Convert.ToDouble(textBox_value.Text) <= UpperLimit &&
                    Convert.ToDouble(textBox_value.Text) >= LowerLimit)
                // enter button closes control and returns
                // value to previous control
                {
                    string returnedString = string.Format("{0:0.000}", Convert.ToDouble(textBox_value.Text));
                    returnLabel.Text = returnedString;
                    overlay.Hide();
                    this.DialogResult = DialogResult.OK;

                    // LOG
                    string logMSG = "Volume: " + returnedString;
                    //GUI_Controls.uiLog.LOG(this, "validateEntry", GUI_Controls.uiLog.LogLevel.DEBUG, logMSG);
                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Verbose, logMSG);
                }
                else
                {
                    string           sMSG   = NPMessages[0];
                    RoboMessagePanel prompt = new RoboMessagePanel(this, MessageIcon.MBICON_WARNING, sMSG, NPMessages[1], NPMessages[4]);
                    prompt.ShowDialog();
                    // clear text box and make active control
                    textBox_value.Text = "";
                    ActiveControl      = textBox_value;

                    // LOG
                    string logMSG = "Validating volume failed, not within range";
                    //GUI_Controls.uiLog.LOG(this, "validateEntry", GUI_Controls.uiLog.LogLevel.DEBUG, logMSG);
                    //  (logMSG);
                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);
                    prompt.Dispose();
                }
            }
            catch
            {
                string           sMSG   = NPMessages[0];
                RoboMessagePanel prompt = new RoboMessagePanel(this, MessageIcon.MBICON_ERROR, sMSG, NPMessages[1], NPMessages[4]);
                prompt.ShowDialog();
                // clear text box and make active control
                textBox_value.Text = "";
                ActiveControl      = textBox_value;

                // LOG
                string logMSG = "Validating volume failed, not within range";
                //GUI_Controls.uiLog.LOG(this, "validateEntry", GUI_Controls.uiLog.LogLevel.DEBUG, logMSG);
                LogFile.AddMessage(System.Diagnostics.TraceLevel.Verbose, logMSG);
                prompt.Dispose();
            }
        }
Beispiel #8
0
        private void b_Click(object sender, EventArgs e)
        {
            GUI_Controls.GUIButton b = sender as GUI_Controls.GUIButton;
            if (b == null)
            {
                return;
            }

            string msg = b.Tag as string;

            if (string.IsNullOrEmpty(msg))
            {
                return;
            }

            GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_INFORMATION, msg, String.Empty);
            RoboSep_UserConsole.showOverlay();
            prompt.ShowDialog();
            prompt.Dispose();
            RoboSep_UserConsole.hideOverlay();
            return;
        }
Beispiel #9
0
        private void button_SaveReports_Click(object sender, EventArgs e)
        {
            string msg = "", title = "";

            GUI_Controls.RoboMessagePanel prompt = null;

            int[] arrItemsChecked = GetItemsChecked();
            if (arrItemsChecked == null || arrItemsChecked.Length == 0)
            {
                msg    = LanguageINI.GetString("msgSelectReports");
                title  = LanguageINI.GetString("headerSelectReports");
                prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_WARNING, msg, title, LanguageINI.GetString("Ok"));
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                RoboSep_UserConsole.hideOverlay();
                prompt.Dispose();
                return;
            }

            List <string> lstUSBDrives = AskUserToInsertUSBDrive();

            if (lstUSBDrives == null || lstUSBDrives.Count == 0)
            {
                return;
            }

            string USBDrive = "";

            // search for directory
            foreach (string drive in lstUSBDrives)
            {
                if (Directory.Exists(drive))
                {
                    USBDrive = drive;
                    break;
                }
            }

            if (string.IsNullOrEmpty(USBDrive))
            {
                msg    = LanguageINI.GetString("msgUSBFail");
                prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_ERROR, msg, LanguageINI.GetString("headerSaveUSB"), LanguageINI.GetString("Ok"));
                //RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                RoboSep_UserConsole.hideOverlay();

                //GUI_Controls.uiLog.LOG(this, "button_SaveReports_Click", GUI_Controls.uiLog.LogLevel.WARNING, "USB drive not detected");
                LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "USB drive not detected");
                prompt.Dispose();
                return;
            }

            // see if save target directory exist
            string systemPath  = RoboSep_UserDB.getInstance().sysPath;
            string reportsPath = systemPath + "reports\\";

            if (!Directory.Exists(reportsPath))
            {
                Directory.CreateDirectory(reportsPath);
            }

            string      sTitle       = LanguageINI.GetString("headerSaveReportUSB");
            FileBrowser SelectFolder = new FileBrowser(RoboSep_UserConsole.getInstance(), sTitle, USBDrive, "");

            SelectFolder.ShowDialog();
            if (SelectFolder.DialogResult != DialogResult.Yes)
            {
                RoboSep_UserConsole.hideOverlay();
                SelectFolder.Dispose();
                return;
            }

            string Target = SelectFolder.Target;

            List <string> lstSourceFiles = new List <string>();

            // copy all selected folders to Target Directory
            FileInfo selectedReport;
            int      nIndex = 0;

            for (int i = 0; i < arrItemsChecked.Length; i++)
            {
                int ReportNumber = arrItemsChecked[i];

                // open file browser to allow user to select specific file location
                selectedReport = myReportFiles[ReportNumber];

                nIndex = selectedReport.Name.LastIndexOf('.');
                if (nIndex < 0)
                {
                    return;
                }

                string sFileName = selectedReport.Name.Substring(0, nIndex);
                sFileName += ".pdf";

                string sFullFileName = selectedReport.DirectoryName;
                if (sFullFileName.LastIndexOf('\\') != sFullFileName.Length - 1)
                {
                    sFullFileName += "\\";
                }

                sFullFileName += sFileName;
                if (File.Exists(sFullFileName))
                {
                    lstSourceFiles.Add(sFullFileName);
                }
            }

            // Copy files
            SelectFolder.ShowProgressBarWhileCopying = true;
            SelectFolder.CopyToTargetDirEx(lstSourceFiles.ToArray(), Target);
            SelectFolder.Dispose();
        }
        private bool ValidateName(string iLoginID)
        {
            if (string.IsNullOrEmpty(iLoginID))
            {
                return(false);
            }

            string newLoginID = iLoginID.Trim();

            char[] invalidCharacters = new char[] { '~', '[', ']', '{', '}', '<', '>', '&', '/', '\\', '\'', '=', '~' };
            int    nIndex            = -1;

            // Check for duplicate
            if (slistUserNames.Contains(newLoginID))
            {
                // prompt user
                string sMsg    = LanguageINI.GetString("msgUserOccupied");
                string sHeader = LanguageINI.GetString("headerUserInvalid");
                string sButton = LanguageINI.GetString("Ok");
                GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_ERROR, sMsg, sHeader, sButton);
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                prompt.Dispose();
                RoboSep_UserConsole.hideOverlay();
                return(false);
            }
            else if ((nIndex = newLoginID.IndexOfAny(invalidCharacters)) >= 0)
            {
                string sInvalidCharacter = newLoginID.Substring(nIndex, 1);

                // prompt user
                string sTemp   = LanguageINI.GetString("msgUserInvalidCharacters");
                string sMsg    = String.Format(sTemp, sInvalidCharacter);
                string sHeader = LanguageINI.GetString("headerUserInvalid");
                string sButton = LanguageINI.GetString("Ok");
                GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_ERROR, sMsg, sHeader, sButton);
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                prompt.Dispose();
                RoboSep_UserConsole.hideOverlay();
                return(false);
            }
            else
            {
                string[] aPresetNames = RoboSep_UserDB.getInstance().GetProtocolPresetNames();
                if (aPresetNames != null && aPresetNames.Length > 0)
                {
                    string sName = Array.Find(aPresetNames, (x => { return(!string.IsNullOrEmpty(x) && x.ToLower() == newLoginID.ToLower()); }));
                    if (!string.IsNullOrEmpty(sName))
                    {
                        // prompt user
                        string sMsg    = LanguageINI.GetString("msgNameUsedByPresets");
                        string sHeader = LanguageINI.GetString("headerUserInvalid");
                        string sButton = LanguageINI.GetString("Ok");
                        GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_ERROR, sMsg, sHeader, sButton);
                        RoboSep_UserConsole.showOverlay();;
                        prompt.ShowDialog();
                        prompt.Dispose();
                        RoboSep_UserConsole.hideOverlay();
                        return(false);
                    }
                }
            }
            return(true);
        }
        private void button_Save_Click(object sender, EventArgs e)
        {
            string sTempUserLoginID = textBox_NewUserLoginID.Text.Trim();

            if (string.IsNullOrEmpty(sTempUserLoginID))
            {
                // Sunny to do
                string sMSG  = LanguageINI.GetString("lblUserName");
                string sMSG1 = LanguageINI.GetString("lblIsEmpty");
                string sMSG2 = LanguageINI.GetString("lblEnterUserName");
                string sOK   = LanguageINI.GetString("Ok");
                string sMSG3 = String.Format("{0} {1}", sMSG, sMSG1);
                string sMSG4 = sMSG2;

                GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_ERROR,
                                                                                         sMSG3, sMSG4, sOK);
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                RoboSep_UserConsole.hideOverlay();
                prompt.Dispose();
                return;
            }
            else if (0 <= sTempUserLoginID.IndexOf(reservedChar))
            {
                string sHeader = LanguageINI.GetString("headerReservedChar");
                string sMSG    = LanguageINI.GetString("lblUserName");
                string sMSG1   = LanguageINI.GetString("lblContainsIllegalChars");
                string sMSG2   = LanguageINI.GetString("lblEnterUserName");
                sMSG += " ";
                sMSG += sMSG1;
                string sMSG3 = String.Format(sMSG, reservedChar.ToString());
                sMSG3 += sMSG2;

                GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_ERROR,
                                                                                         sMSG3, sHeader, LanguageINI.GetString("Ok"));
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                RoboSep_UserConsole.hideOverlay();
                prompt.Dispose();
                return;
            }
            else if (sTempUserLoginID.Length > maxUserLoginStringLength)
            {
                // Sunny to do
                string sMSG  = LanguageINI.GetString("lblUserName");
                string sMSG1 = LanguageINI.GetString("lblIsTooLong");
                string sTemp = LanguageINI.GetString("lblUserNameMaxLength");
                string sMSG2 = String.Format(sTemp, maxUserLoginStringLength);
                string sMSG4 = sMSG2 + LanguageINI.GetString("lblEnterUserName");
                string sMSG5 = sMSG + " " + sMSG1;

                GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_ERROR,
                                                                                         sMSG4, sMSG5, LanguageINI.GetString("Ok"));
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                RoboSep_UserConsole.hideOverlay();
                prompt.Dispose();
                return;
            }

            int nIndex = sTempUserLoginID.IndexOf(spaceChar);

            if (0 < nIndex)
            {
                sTempUserLoginID = sTempUserLoginID.Replace(spaceChar, reservedChar);
            }
            string sUserLoginID = sTempUserLoginID;

            if (ValidateName(sUserLoginID) == false)
            {
                return;
            }

            string destination = DefaultImage;

            if (File.Exists(tempUser.TempImageIconPath))
            {
                // Copy image from temporary folder to image folder
                string temp = tempUser.TempImageIconPath;
                int    fileExtensionIndex = temp.LastIndexOf('.');
                string fileExtension      = temp.Substring(fileExtensionIndex);

                int    lastBackslashIndex = temp.LastIndexOf('\\'); // must escape the '\'
                string tempDirectory      = temp.Remove(lastBackslashIndex, temp.Length - lastBackslashIndex);

                string fileName = sUserLoginID;
                fileName += ImageIconFilePosfix;
                fileName += fileExtension;

                string targetDestination = systemPath + "images\\";
                if (!Directory.Exists(targetDestination))
                {
                    Directory.CreateDirectory(targetDestination);
                }

                destination = targetDestination + fileName;
                bool bContinue = false;

                for (int i = 0; i < maxSameUserLoginIDImageIconFile; i++)
                {
                    if (!File.Exists(destination))
                    {
                        bContinue = true;
                        break;
                    }
                    destination = string.Format("{0}{1}{2}{3}{4}", targetDestination, sUserLoginID, i, ImageIconFilePosfix, fileExtension);
                }

                if (bContinue != true)
                {
                    // LOG
                    string LOGmsg = "New user login screen: failed to save user info. File '";
                    LOGmsg += "' aready exists.";

                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, LOGmsg);
                    return;
                }

                File.Copy(tempUser.TempImageIconPath, destination);

                // Remove temporary folder
                Directory.Delete(tempDirectory, true);
            }
            NewLoginID = sUserLoginID;

            // Add visual effect
            string            title  = LanguageINI.GetString("headerSavingInProgress");
            RoboMessagePanel4 saving = new GUI_Controls.RoboMessagePanel4(RoboSep_UserConsole.getInstance(), title, 500, 20);

            RoboSep_UserConsole.showOverlay();
            saving.ShowDialog();

            RoboSep_UserConsole.hideOverlay();

            if (bCreateNewUser)
            {
                // create new user info in INI file
                string strTemp = sUserLoginID + "Image";
                UserINI.IniWriteValue(sUserLoginID, strTemp, destination);
            }
            else
            {
                // rename the userlogin
                RenameUserNameInUserInfoINI(DefaultLoginID, NewLoginID);

                // rename protocols and MRUs
                RoboSep_UserDB.getInstance().RenameProtocolsAndMRUs(DefaultLoginID, NewLoginID);
            }

            // update user preferences
            string UserToBeUpdated = NewLoginID;

            if (dictUserPreferences == null && dictDevicePreferences == null)
            {
                // User preferences are not set
                dictUserPreferences   = new Dictionary <string, bool>();
                dictDevicePreferences = new Dictionary <string, bool>();

                if (bCreateNewUser)
                {
                    // Use default user and device preferences for new user.
                    RoboSep_UserDB.getInstance().getDefaultUserAndDevicePreferences(dictUserPreferences, dictDevicePreferences);
                }
                else
                {
                    RoboSep_UserDB.getInstance().getUserAndDevicePreferences(DefaultLoginID, dictUserPreferences, dictDevicePreferences);
                    if (dictUserPreferences.Count == 0 || dictDevicePreferences.Count == 0)
                    {
                        // Use default user and device preferences if the user preferences file not existed.
                        RoboSep_UserDB.getInstance().getDefaultUserAndDevicePreferences(dictUserPreferences, dictDevicePreferences);
                    }
                }
            }

            string UserLogin = bCreateNewUser ? NewLoginID : DefaultLoginID;

            // save user preferences
            UserDetails.SaveUserPreferences(UserLogin, dictUserPreferences, dictDevicePreferences);

            if (!bCreateNewUser)
            {
                // rename the user preferences file
                UserDetails.RenameUserPreferencesFile(DefaultLoginID, NewLoginID);
            }

            saving.Dispose();

            // remove Control
            this.Close();
            DialogResult = DialogResult.OK;
        }