public static bool SaveUserPreferences(string userName, Dictionary <string, bool> dictUserPreferences, Dictionary <string, bool> dictDevicePreferences) { if (string.IsNullOrEmpty(userName) || dictUserPreferences == null || dictDevicePreferences == null) { return(false); } string systemPath = getBasePath(); string targetDestination = systemPath + "users\\"; if (!Directory.Exists(targetDestination)) { Directory.CreateDirectory(targetDestination); } // LOG string logMSG = "saving user preferences for user " + userName; // (logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); bool bRet1, bRet2; bRet1 = SavePreferencesSection("USER", userName, dictUserPreferences); bRet2 = SavePreferencesSection("DEVICE", userName, dictDevicePreferences); return(bRet1 && bRet2); }
public static bool DeleteUserPreferences(string userName) { if (string.IsNullOrEmpty(userName)) { return(false); } string systemPath = getBasePath(); string fullFileNamePath = systemPath + "users\\"; if (!Directory.Exists(fullFileNamePath)) { return(false); } // LOG string logMSG = "removing user preferences for user " + userName; // (logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); fullFileNamePath += userName; fullFileNamePath += ".ini"; if (!File.Exists(fullFileNamePath)) { return(false); } File.Delete(fullFileNamePath); return(true); }
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 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(); }
public void Clear() { QuadrantLabel = ""; QuadrantLabel_Abbv = ""; Quadrant_message = ""; QuadrantVolume = 0; QuadrantsRequired = 0; volMin = 0; volMax = 0; bQuadrantInUse = false; if (Divider != null) { Divider.Visible = true; } bIsMaintenance = false; if (SelectProtocol != null) { SelectProtocol.Visible = true; } Update(); // LOG string logMSG = "Quadrant info Cleared"; //GUI_Controls.uiLog.LOG(this, "Clear", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); }
private void button_Cancel_Click(object sender, EventArgs e) { // Sunny to do // Remove temperory files if (tempUser.TempImageIconPath != null) { try { // delete temp folder Utilities.RemoveTempFileDirectory(tempUser.TempImageIconPath); } catch (Exception ex) { // LOG LogFile.LogException(System.Diagnostics.TraceLevel.Error, ex); } tempUser.Clear(); } RoboSep_UserConsole.hideOverlay(); this.DialogResult = DialogResult.Cancel; this.Close(); //RoboSep_UserConsole.UserConsole.removeForm(overlay); RoboSep_UserConsole.getInstance().Activate(); // LOG string logMSG = "User Login window closed without creating new user"; LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); }
private void removeSharingWithProtocolIndex(SharingProtocol sharer, int protocolIndex) { string logMSG; if (sharer == null) { logMSG = "removeSharingWithProtocolIndex called. Invalid input parameter 'sharer' is null."; LogFile.AddMessage(System.Diagnostics.TraceLevel.Verbose, logMSG); return; } int initQuad = 0; //make sure this protocol index doesn't map to anything if (sharedSectorsProtocolIndex != null) { for (int i = 0; i < 4; ++i) { if (i < sharedSectorsProtocolIndex.Length && sharedSectorsProtocolIndex[i] == protocolIndex) { sharedSectorsTranslation[i] = 0; initQuad = (initQuad == 0) ? i + 1 : initQuad; } } //remove from sharer if (initQuad != 0) { sharer.removeSharingWith(initQuad); } } }
public void addProtocols(List <RoboSep_Protocol> rpNew) { // check if protocol already exists in list for (int j = 0; j < rpNew.Count; j++) { bool alreadyAdded = false; for (int i = 0; i < myUserProtocols.Count; i++) { if (rpNew[j] == myUserProtocols[i]) { alreadyAdded = true; } } if (!alreadyAdded) { // add if it doesnt already exist myUserProtocols.Add(rpNew[j]); // LOG string logMSG = "Adding protocol " + rpNew[j].Protocol_Name + " to user list"; //GUI_Controls.uiLog.LOG(this, "addProtocols", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG); // (logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); } } // refresh list view to include new protocols refreshList(); }
protected virtual void btn_home_Click(object sender, EventArgs e) { // Open Home Window myHome = RoboSep_Home.getInstance(); RoboSep_UserConsole.getInstance().SuspendLayout(); myHome.Location = new Point(0, 0); RoboSep_UserConsole.getInstance().Controls.Add(myHome); RoboSep_UserConsole.getInstance().Controls.Remove(RoboSep_UserConsole.ctrlCurrentUserControl); myHome.Visible = true; myHome.Enabled = true; myHome.UpdateButtons(); myHome.BringToFront(); RoboSep_UserConsole.getInstance().SuspendLayout(); //RoboSep_UserConsole.getInstance().frmHomeOverlay.Show(); //RoboSep_UserConsole.getInstance().frmHomeOverlay.BringToFront(); //myHome.Location = new Point( //RoboSep_UserConsole.getInstance().Location.X + RoboSep_UserConsole.getInstance().myHome.GetOffset().X, //RoboSep_UserConsole.getInstance().Location.Y + RoboSep_UserConsole.getInstance().myHome.GetOffset().Y); //myHome.Show(); //myHome.BringToFront(); // LOG string logMSG = "Home button clicked"; //GUI_Controls.uiLog.LOG(this, "btn_home_Click", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Verbose, logMSG); }
private void listview_lvUser_Click(object sender, EventArgs e) { if (lvUser.SelectedItems.Count == 0) { return; } SelectedUser = lvUser.SelectedItems[0].Tag as string; if (string.IsNullOrEmpty(SelectedUser)) { return; } SelectedUser = SelectedUser.Trim(); #if false string userNameText = LanguageINI.GetString("lblUserName"); if (userNameText.ToLower() == SelectedUser.ToLower()) { this.button_NewUser.Tag = SelectedUser; this.button_NewUser_Click(this.button_NewUser, new EventArgs()); return; } #endif SelectUser(SelectedUser); // LOG string logMSG = "User '" + lvUser.SelectedItems[0].Text + "' is selected to run RoboSep-S"; // (logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); }
public void LoadUserToServer(string ActiveUser) { // LOG string logMSG = "Loading user profile"; LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); // load user from ini List <RoboSep_Protocol> tempList = RoboSep_UserDB.getInstance().loadUserProtocols(ActiveUser); if (tempList == null) { // prompt user that no protocols to load string sTitle = LanguageINI.GetString("headerNoProtocols"); string sMsg = LanguageINI.GetString("msgNoProtocols"); string sButton = LanguageINI.GetString("Ok"); RoboMessagePanel prompt = new RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_WARNING, sMsg, sTitle, sButton); RoboSep_UserConsole.showOverlay(); prompt.ShowDialog(); prompt.Dispose(); RoboSep_UserConsole.hideOverlay(); return; } StartLoadingProtocolsToServer(ActiveUser, tempList); }
public void MoveToStep(int completed) { // LOG string name = this.GetType().Name; string logMSG = "Progress bar " + name + " to step " + (completed).ToString(); //GUI_Controls.uiLog.LOG(this, "MoveToStep", GUI_Controls.uiLog.LogLevel.DEBUG, logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Verbose, logMSG); if (completed <= numSteps) { Pause(false); // make sure all steps before current // step are set to completed as "completed" // is updated to be complete if (completed != numSteps) { for (int i = 0; i < completed; i++) { progressBars[i].Completed(); } currentStep = completed; TimerCount = 0; hrs = mins = secs = 0; progressBars[completed].Start(); } Start(); } }
private void textbox_input_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { lastControl.Text = textbox_input.Text; if (frmOverlay != null) { frmOverlay.Hide(); } this.Close(); if (PreviousForm != null) { PreviousForm.Activate(); } this.DialogResult = DialogResult.OK; // LOG string logMSG = "Keboard output: '" + textbox_input.Text + "'"; //GUI_Controls.uiLog.LOG(this, "textbox_input_KeyDown", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG); // (logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); } }
// SetTab given from RoboSep_UserConsole variable "intCurrentHelpTab" private RoboSep_Help() { InitializeComponent(); // LOG string logMSG = "Initializing Help user control"; //GUI_Controls.uiLog.LOG(this, "RoboSep_Help", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); TabCheck = RoboSep_UserConsole.intCurrentHelpTab; // Create tab tab control content TabControls[0] = RoboSep_About.getInstance(); TabControls[1] = new BasePannel(); TabControls[2] = TabControls[1]; // resize controls to fit TabControls[1].Size = TabControls[0].Size; TabControls[2].Size = TabControls[0].Size; // set control locations to 0,0 for (int i = 0; i < TabControls.Length; i++) { TabControls[i].Location = new Point(0, 0); } // load tab content to display most recent tab this.Controls.Add(TabControls[TabCheck]); }
private void button_OK_Click(object sender, EventArgs e) { if (listView_users.SelectedItems.Count == 0) { // prompt user string title = LanguageINI.GetString("headerSelectUserFromList"); string msg = LanguageINI.GetString("lblSelectUserFromList"); string buttonTxt = LanguageINI.GetString("Ok"); GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), GUI_Controls.MessageIcon.MBICON_WARNING, msg, title, buttonTxt); RoboSep_UserConsole.showOverlay(); prompt.ShowDialog(); prompt.Dispose(); RoboSep_UserConsole.hideOverlay(); return; } SelectedUser = listView_users.SelectedItems[0].Tag as string; RoboSep_UserConsole.hideOverlay(); this.DialogResult = DialogResult.OK; this.Close(); // LOG string logMSG = "User " + listView_users.SelectedItems[0].Text + " Selected"; LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); }
/// <summary> /// /// </summary> public void ConfirmHydraulicFluidRefilled() { bool isRefillConfirmed = false; try { if (IsConnectionEnabled) { isRefillConfirmed = myXmlRpcProxy.SetHydroFluidFull(); } } catch (Exception ex) { // Log the details of the exception LogException(ex, "ConfirmHydraulicFluidRefilled"); } finally { if (!isRefillConfirmed) { LogFile.AddMessage(TraceLevel.Verbose, "Instrument Control API SetHydroFluidFull() returned " + isRefillConfirmed.ToString()); } } }
private void ShowSystemWindowHelperInUiThread(bool bCheckBoxKeyboard, bool bCheckBoxLidSensor, bool bCheckBoxLiquidSensor) { if (this.InvokeRequired) { this.Invoke((MethodInvoker) delegate() { this.ShowSystemWindowHelperInUiThread(bCheckBoxKeyboard, bCheckBoxLidSensor, bCheckBoxLiquidSensor); }); } else { RoboSep_UserConsole.getInstance().SuspendLayout(); RoboSep_System SystemWindow = RoboSep_System.getInstance(); SystemWindow.Visible = false; SystemWindow.Location = new Point(0, 0); RoboSep_UserConsole.getInstance().Controls.Add(SystemWindow); RoboSep_UserConsole.ctrlCurrentUserControl = SystemWindow; SystemWindow.RefreshSettings(bCheckBoxKeyboard, bCheckBoxLidSensor, bCheckBoxLiquidSensor); SystemWindow.Visible = true; closeHomeWindow(); SystemWindow.BringToFront(); SystemWindow.Focus(); // LOG string logMSG = "System button clicked"; //GUI_Controls.uiLog.LOG(this, "hex_system_Click", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); } }
private RoboSep_UserProtocolList() { InitializeComponent(); myUserProtocols = new List <RoboSep_Protocol>(); cancelButtons = new GUI_Controls.GUIButton[ITEMS_ON_SCREEN] { cncl0, cncl1, cncl2, cncl3, cncl4, cncl5, cncl6 }; List <Image> ilist = new List <Image>(); ilist.Add(Properties.Resources.BACK_STD); ilist.Add(Properties.Resources.BACK_OVER); ilist.Add(Properties.Resources.BACK_OVER); ilist.Add(Properties.Resources.Back_CLICK); button_Cancel.ChangeGraphics(ilist); cncl = new Image[2] { Properties.Resources.Cancel_STD, Properties.Resources.Cancel_STD1 }; // set up listview drag scroll properties (based on specific page properties) lvUserProtocols.LINE_SIZE = 9; lvUserProtocols.NUM_VISIBLE_ELEMENTS = 7; lvUserProtocols.VERTICAL_PAGE_SIZE = 4; // LOG string logMSG = "Generating New UserProtocol user control"; //GUI_Controls.uiLog.LOG(this, "RoboSep_UserProtocolList", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG); // (logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); }
private void removeSharingWith(SharingProtocol sharer) { string logMSG; if (sharer == null) { logMSG = "removeSharingWith called. Invalid input parameter 'sharer' is null."; LogFile.AddMessage(System.Diagnostics.TraceLevel.Verbose, logMSG); return; } int quadrantID = sharer.InitQuadrant + 1; //go through sharer's quadrants for (int i = 0; i < sharer.Quadrants; ++i) { //make sure no quadrant maps to it for (int j = 0; j < 4; ++j) { if (j < sharedSectorsTranslation.Length && sharedSectorsTranslation[j] == quadrantID + i) { sharedSectorsTranslation[j] = 0; } } } //clear sharer sharer.clear(); }
private void hex_service_Click(object sender, EventArgs e) { // LOG string logMSG = "Service button clicked"; //GUI_Controls.uiLog.LOG(this, "hex_service_Click", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); RoboSep_UserConsole.getInstance().SuspendLayout(); closeHomeWindow(); // see if Service target directory exist string systemPath = RoboSep_UserDB.getInstance().sysPath; string[] directories = systemPath.Split('\\'); //string servicePath = string.Empty; //for (int i = 0; i < directories.Length-2; i++) // servicePath += directories[i] + "\\"; //servicePath += "RoboSepService\\bin\\"; StringBuilder sPath = new StringBuilder(); for (int i = 0; i < directories.Length - 2; i++) { sPath.Append(directories[i]); sPath.Append("\\"); } sPath.Append("RoboSepService\\bin\\"); string servicePath = sPath.ToString(); // check if service directory exists if (!System.IO.Directory.Exists(servicePath)) { System.IO.Directory.CreateDirectory(servicePath); } // if Service.exe exists, run service.exe if (System.IO.File.Exists(servicePath + SERVICE_EXE_FILENAME)) { // run Service ProcessStartInfo ServiceStartInfo = new ProcessStartInfo(); ServiceStartInfo.WorkingDirectory = servicePath; ServiceStartInfo.FileName = SERVICE_EXE_FILENAME; ServiceStartInfo.WindowStyle = ProcessWindowStyle.Normal; Process ServiceProgram = new Process(); ServiceProgram.StartInfo = ServiceStartInfo; ServiceProgram.Start(); LogFile.AddMessage(TraceLevel.Warning, "Starting Service program"); } else { logMSG = "Could not locate Service Program at '" + servicePath + SERVICE_EXE_FILENAME + "'"; LogFile.AddMessage(TraceLevel.Warning, logMSG); } }
private void hex_help_Click(object sender, EventArgs e) { RoboSep_UserConsole.getInstance().SuspendLayout(); RoboSep_About about = null; switch (RoboSep_UserConsole.CurrentHelpTab) { case RoboSep_UserConsole.HelpTab.About: about = RoboSep_About.getInstance(); about.Location = new Point(0, 0); RoboSep_UserConsole.getInstance().Controls.Add(about); RoboSep_UserConsole.ctrlCurrentUserControl = about; break; case RoboSep_UserConsole.HelpTab.HelpVid: break; } closeHomeWindow(); if (about != null) { about.BringToFront(); about.Focus(); } // LOG string logMSG = "Help button clicked"; //GUI_Controls.uiLog.LOG(this, "hex_help_Click", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); }
private void hex_UserPreferences_Click(object sender, EventArgs e) { RoboSep_UserConsole.getInstance().SuspendLayout(); if (myUserPreferences != null) { myUserPreferences.Dispose(); myUserPreferences = null; } myUserPreferences = new RoboSep_UserPreferences(RoboSep_UserConsole.strCurrentUser, false, true); myUserPreferences.Parent = this.Parent; myUserPreferences.ClosingUserPreferencesApp += new EventHandler(HandleClosingUserPreferencesApp); //myUserPreferences.Location = new Point(0, 0); // RoboSep_UserConsole.getInstance().Controls.Add(myUserPreferences); // RoboSep_UserConsole.ctrlCurrentUserControl = myUserPreferences; myUserPreferences.Show(); myUserPreferences.BringToFront(); myUserPreferences.Focus(); // LOG string logMSG = "User Preferences button clicked"; LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); }
public void LoadUsers() { // update users list // load auto complete source textBox_UserName.AutoCompleteCustomSource.Clear(); string[] UserSource = RoboSep_UserDB.getInstance().getAllUsers(); if (UserSource != null) { for (int i = 0; i < UserSource.Length; i++) { if (UserSource[i] != "All Human" && UserSource[i] != "All Mouse" && UserSource[i] != "Whole Blood" && UserSource[i] != "Full List") { textBox_UserName.AutoCompleteCustomSource.Add(UserSource[i]); } } } // LOG string LOGmsg = "Reloading Auto Complete for User Textbox"; //GUI_Controls.uiLog.LOG(this, "LoadUsers", GUI_Controls.uiLog.LogLevel.INFO, LOGmsg); // (LOGmsg); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, LOGmsg); }
private void CalculateEstimatedTimeToCompletion(DateTime estimatedTimeOfCompletion, ref TimeSpan estimatedTimeToCompletion) { DateTime currentTime = DateTime.Now; estimatedTimeToCompletion = TimeSpan.Zero; // Check the Estimated Time of Completion is in the future if (DateTime.Compare(estimatedTimeOfCompletion, currentTime) > 0) { // Round up the estimated time of completion to the next minute (because we're // currently showing HH:mm format -- no seconds -- round up so we show // at least one minute for schedules < 60 seconds). // If the protocol actually finishes soon after the 1 minute time is shown, no-one // will worry too much (in contrast, showing zero time remaining while the protocol // is still running is not as comforting). estimatedTimeToCompletion = estimatedTimeOfCompletion.Subtract(currentTime); if (estimatedTimeToCompletion.TotalSeconds < 60.0d) { estimatedTimeToCompletion = estimatedTimeToCompletion.Add( TimeSpan.FromSeconds(59.0)); } #if (DEBUG) LogFile.AddMessage(TraceLevel.Verbose, "Calculated ETC = " + estimatedTimeToCompletion.ToString()); #endif } }
// loads names from slistUserNames list to listview items private void loadUserList() { // add items to list view listView_users.SuspendLayout(); int nIndex; string sName; ListViewItem lvItem; for (int i = 0; i < slistUserNames.Count; i++) { sName = slistUserNames[i]; nIndex = slistUserNames[i].IndexOf(reservedChar); if (0 < nIndex) { sName = sName.Replace(reservedChar, spaceChar); } lvItem = new ListViewItem(sName); lvItem.Tag = slistUserNames[i]; listView_users.Items.Add(lvItem); LogFile.AddMessage(System.Diagnostics.TraceLevel.Verbose, "adding user " + slistUserNames[i] + " to UserSelect window"); } listView_users.ResumeLayout(); listView_users.Refresh(); }
// Disposes the StopWatch instance and log the amount of time used on the operation. public void Dispose() { internalStopwatch.Stop(); string logMSG = String.Format("{0} takes {1}.", name, internalStopwatch.Elapsed); // (logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); }
public ConsoleINI() { iniPath = Environment.CurrentDirectory + "//GUI.ini"; LogFile.AddMessage(System.Diagnostics.TraceLevel.Verbose, "GUI.ini filepath: " + iniPath); // grab data from ini file readINI(); }
private string GenerateProfileIcon(string imgPath) { if (imgPath == null) { LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Generating Profile Icon returns. imgpath is null"); return(null); } LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Generating Profile Icon"); Image source = Image.FromFile(imgPath); Image workingImage = CropImage(source); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Cropped Image"); workingImage = scaleImage(workingImage, 48); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Scaled Image"); workingImage = frameImage(workingImage); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Framed Image"); string tempPath = Utilities.GetTempFileFolder(); //string framedPath = getTempFileName(tempPath, (UserName + "_framed"), ".png"); string framedPath = getFullImageIconTempFileName(tempPath, ".png"); try { if (!Directory.Exists(tempPath)) { Directory.CreateDirectory(tempPath); } // fails when saving over file it is currently using savePNG(framedPath, (Bitmap)workingImage, 100L); // set flag to valid if (tempUser != null) { tempUser.ImageIcon = workingImage; tempUser.TempImageIconPath = framedPath; } workingImage.Dispose(); } catch { LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Fail to save profile icon. "); } LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Profile Icon Saved"); return(framedPath); }
public static bool RenameUserPreferencesFile(string oldUserName, string newUserName) { if (string.IsNullOrEmpty(oldUserName) || string.IsNullOrEmpty(newUserName)) { return(false); } string systemPath = getBasePath(); string fullFileNamePath = systemPath + "users\\"; if (!Directory.Exists(fullFileNamePath)) { return(false); } string oldfullFileNamePath = fullFileNamePath + oldUserName; oldfullFileNamePath += ".ini"; if (!File.Exists(oldfullFileNamePath)) { return(false); } // LOG string logMSG = String.Format("renaming user preferences file name from {0}.ini to {1}.ini", oldUserName, newUserName); // (logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); string newfullFileNamePath = fullFileNamePath + newUserName; newfullFileNamePath += ".ini"; if (File.Exists(newfullFileNamePath)) { logMSG = String.Format("Failed to rename file from {0}.ini to {1}.ini. File {2}.ini is already existed.", oldUserName, newUserName, newUserName); // (logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); return(false); } try { File.Move(oldfullFileNamePath, newfullFileNamePath); } // Catch any exception if a file cannot be accessed // e.g. due to security restriction catch (Exception ex) { logMSG = String.Format("Failed to rename file from {0}.ini to {1}.ini. Exception: {2}.", oldUserName, newUserName, ex.Message); // (logMSG); LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG); return(false); } return(true); }
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(); } }