/// <summary> /// Add new users name to theAr2mSpell User List file. /// </summary> /// <created>art2m,5/17/2019</created> /// <changed>art2m,5/17/2019</changed> private static void AddNewUserToUserNameFile() { MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; var unc = new UsersNameCollection(); if (unc.ContainsItem(SpellingPropertiesClass.UserName)) { MyMessages.InformationMessage = "This user all ready exists."; MyMessages.ShowInformationMessageBox(); } unc.AddItem(SpellingPropertiesClass.UserName); SpellingReadWriteClass.WriteUserNameFile(); var dirPath = DirectoryFileOperations.CheckDirectoryPathExistsCreate(); var retVal = DirectoryFileOperations.CreateUserSpellingListDirectory(dirPath); if (retVal) { return; } MyMessages.ErrorMessage = "Unable to create user directory."; MyMessages.ShowErrorMessageBox(); }
/// ******************************************************************************** /// <summary> /// Add new users name to theAr2mSpell User List file. /// </summary> /// <created>art2m,5/17/2019</created> /// <changed>art2m,5/23/2019</changed> /// ******************************************************************************** private static void AddNewUserToUserNameFile() { MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; var unc = new UsersNameCollection(); if (unc.ContainsItem(SpellingPropertiesClass.UserName)) { MyMessages.InformationMessage = "This user all ready exists."; MyMessages.ShowInformationMessageBox(); } unc.AddItem(SpellingPropertiesClass.UserName); var dirPath = SpellingPropertiesClass.AppDataDirectoryPath; var dirName = SpellingPropertiesClass.GetArt2MSpellDirectoryName; dirPath = DirectoryFileOperations.CombineStringsMakeDirectoryPath(dirPath, dirName); if (string.IsNullOrEmpty(dirPath)) { return; } var fileName = SpellingPropertiesClass.GetArt2MSpellUserListFileName; var filePath = DirectoryFileOperations.CombineDirectoryPathFileNameCheckCreateFile(dirPath, fileName); if (string.IsNullOrEmpty(filePath)) { return; } SpellingReadWriteClass.WriteUserNameFile(filePath); }
/// <summary> /// Add new users name to theAr2mSpell User List file. /// </summary> /// <created>art2m,5/17/2019</created> /// <changed>art2m,5/17/2019</changed> private static void AddNewUserToUserNameFile() { MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; var unc = new UsersNameCollection(); if (unc.ContainsItem(SpellingPropertiesClass.UserName)) { MyMessages.InformationMessage = "This user all ready exists."; MyMessages.ShowInformationMessageBox(); } unc.AddItem(SpellingPropertiesClass.UserName); var dirPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); var dirName = SpellingPropertiesClass.GetArt2MSpellDirectoryName; dirPath = DirectoryFileOperations.CombineStringsMakeDirectoryPath(dirPath, dirName); if (string.IsNullOrEmpty(dirPath)) { return; } var filePath = DirectoryFileOperations.CombineStringsMakeFilePath() SpellingReadWriteClass.WriteUserNameFile(filePath); MyMessages.ErrorMessage = "Unable to create user directory."; MyMessages.ShowErrorMessageBox(); }
/// <summary> /// Add new users name to theAr2mSpell User List file. /// </summary> /// <created>art2m,5/17/2019</created> /// <changed>art2m,5/17/2019</changed> private static void AddNewUserToUserNameFile() { // TODO: Make method for editing and deleting users from user file. // TODO: Make method for adding existing spelling lists to current user. var unc = new UsersNameCollection(); if (unc.ContainsItem(SpellingPropertiesClass.UserName)) { MyMessages.InformationMessage = "This user all ready exists."; MyMessages.ShowInformationMessageBox(); } unc.AddItem(SpellingPropertiesClass.UserName); SpellingReadWriteClass.WriteUserNameFile(); var dirPath = DirectoryFileOperations.CheckDirectoryPathExistsCreate(); var retVal = DirectoryFileOperations.CreateUserSpellingListDirectory(dirPath); if (!retVal) { MyMessages.ErrorMessage = "Unable to create user directory."; MyMessages.ShowErrorMessageBox(); } }
/// <summary> /// Read user name file into collection. /// so user can log in with there name. This /// is used to keep each users spelling list together so they can choose /// an all ready saved spelling list to practice. /// </summary> /// <returns></returns> /// <created>art2m,5/20/2019</created> /// <changed>art2m,5/20/2019</changed> public static bool ReadUserNameFile() { // TODO: Add error handling to this method. MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; var dirPath = DirectoryFileOperations.CheckDirectoryPathExistsCreate(); var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath); try { using (var reader = new StreamReader(filePath)) { string user; while ((user = reader.ReadLine()) != null) { unc.AddItem(user.Trim()); } } return(true); } catch (Exception e) { Console.WriteLine(e); throw; } }
/// <summary> /// Add new users name to theAr2mSpell User List file. /// </summary> /// <created>art2m,5/17/2019</created> /// <changed>art2m,5/17/2019</changed> private static void AddNewUserToUserNameFile() { // TODO: Make method for editing and deleting users from user file. // TODO: Make method for adding existing spelling lists to current user. SpellingReadWriteClass.WriteUserNameFile(); var Unc = new UsersNameCollection(); if (!Unc.ContainsItem(SpellingPropertiesClass.UserName)) { Unc.AddItem(SpellingPropertiesClass.UserName); } }
/// <summary> /// Add new users name to theAr2mSpell User List file. /// </summary> /// <created>art2m,5/17/2019</created> /// <changed>art2m,5/17/2019</changed> private static void AddNewUserToUserNameFile() { // TODO: Make method for editing and deleting users from user file. // TODO: Make method for adding existing spelling lists to current user. var unc = new UsersNameCollection(); if (unc.ContainsItem(SpellingPropertiesClass.UserName)) { MyMessages.InformationMessage = "This user all ready exists."; MyMessages.ShowInformationMessageBox(); } unc.AddItem(SpellingPropertiesClass.UserName); SpellingReadWriteClass.WriteUserNameFile(); }
/// <summary> /// Read user name file into collection. /// so user can log in with there name. This /// is used to keep each users spelling list together so they can choose /// an all ready saved spelling list to practice. /// </summary> /// <returns></returns> /// <created>art2m,5/20/2019</created> /// <changed>art2m,5/20/2019</changed> public static bool ReadUserNameFile() { // TODO: Add error handling to this method. MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; var dirPath = DirectoryFileOperations.CheckDirectoryPathExistsCreate(); var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath); var userColl = new UsersNameCollection(); using (var reader = new StreamReader(filePath)) { string user; while ((user = reader.ReadLine()) != null) { userColl.AddItem(user.Trim()); } } return(true); }
/// ******************************************************************************** /// <summary> /// Reads file that contains all of the paths To users spelling List file. /// </summary> /// <returns>True if file read is successful.</returns> /// <created>art2m,5/23/2019</created> /// <changed>art2m,5/23/2019</changed> /// ******************************************************************************** public static bool ReadUsersSpellingListPathsFile(string filePath) { try { if (!File.Exists(filePath)) { return(false); } using (var reader = new StreamReader(filePath)) { string user; while ((user = reader.ReadLine()) != null) { UsersNameCollection.AddItem(user.Trim()); } } return(true); } catch (ArgumentNullException ex) { MyMessagesClass.ErrorMessage = "The file path value is a null string. " + filePath; Debug.WriteLine(ex.ToString()); MyMessagesClass.ShowErrorMessageBox(); return(false); } catch (ArgumentException ex) { MyMessagesClass.ErrorMessage = "The file path value is an empty string."; Debug.WriteLine(ex.ToString()); MyMessagesClass.ShowErrorMessageBox(); return(false); } catch (FileNotFoundException ex) { MyMessagesClass.ErrorMessage = "Unable to locate this file. " + filePath; Debug.WriteLine(ex.ToString()); MyMessagesClass.ShowErrorMessageBox(); return(false); } catch (DirectoryNotFoundException ex) { MyMessagesClass.ErrorMessage = "Unable to locate the directory."; Debug.WriteLine(ex.ToString()); MyMessagesClass.ShowErrorMessageBox(); return(false); } catch (IOException ex) { MyMessagesClass.ErrorMessage = "File path has invalid characters in it."; Debug.WriteLine(ex.ToString()); MyMessagesClass.ShowErrorMessageBox(); return(false); } }
/// ******************************************************************************** /// <summary> /// Read user name file into collection. /// so user can log in with there name. This /// is used to keep each users spelling list together so they can choose /// an all ready saved spelling list to practice. /// </summary> /// <returns></returns> /// <created>art2m,5/20/2019</created> /// <changed>art2m,5/23/2019</changed> /// ******************************************************************************** public static bool ReadUserNameFile(string filePath) { MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; try { using (var reader = new StreamReader(filePath)) { string user; while ((user = reader.ReadLine()) != null) { Unc.AddItem(user.Trim()); } } return(true); } catch (ArgumentNullException ex) { MyMessages.ErrorMessage = "The file path value is a null string. " + filePath; Debug.WriteLine(ex.ToString()); MyMessages.ShowErrorMessageBox(); return(false); } catch (ArgumentException ex) { MyMessages.ErrorMessage = "The file path value is an empty string."; Debug.WriteLine(ex.ToString()); MyMessages.ShowErrorMessageBox(); return(false); } catch (FileNotFoundException ex) { MyMessages.ErrorMessage = "Unable to locate this file. " + filePath; Debug.WriteLine(ex.ToString()); MyMessages.ShowErrorMessageBox(); return(false); } catch (DirectoryNotFoundException ex) { MyMessages.ErrorMessage = "Unable to locate the directory."; Debug.WriteLine(ex.ToString()); MyMessages.ShowErrorMessageBox(); return(false); } catch (IOException ex) { MyMessages.ErrorMessage = "File path has invalid characters in it."; Debug.WriteLine(ex.ToString()); MyMessages.ShowErrorMessageBox(); return(false); } }
/// <summary> /// Read user name file into collection. /// so user can log in with there name. This /// is used to keep each users spelling list together so they can choose /// an all ready saved spelling list to practice. /// </summary> /// <returns></returns> /// <created>art2m,5/20/2019</created> /// <changed>art2m,5/20/2019</changed> public static bool ReadUserNameFile() { // TODO: Add error handling to this method. MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; var dirPath = DirectoryFileOperations.CheckDirectoryPathExistsCreate(); var filePath = DirectoryFileOperations.CreatePathToUserFile(dirPath); try { using (var reader = new StreamReader(filePath)) { string user; while ((user = reader.ReadLine()) != null) { unc.AddItem(user.Trim()); } } return(true); } catch (ArgumentNullException ex) { MyMessages.ErrorMessage = "The file path value is a null string. " + filePath; Debug.WriteLine(ex.ToString()); MyMessages.ShowErrorMessageBox(); return(false); } catch (ArgumentException ex) { MyMessages.ErrorMessage = "The file path value is an empty string."; Debug.WriteLine(ex.ToString()); MyMessages.ShowErrorMessageBox(); return(false); } catch (FileNotFoundException ex) { MyMessages.ErrorMessage = "Unable to locate this file. " + filePath; Debug.WriteLine(ex.ToString()); MyMessages.ShowErrorMessageBox(); return(false); } catch (DirectoryNotFoundException ex) { MyMessages.ErrorMessage = "Unable to locate the directory."; Debug.WriteLine(ex.ToString()); MyMessages.ShowErrorMessageBox(); return(false); } catch (IOException ex) { MyMessages.ErrorMessage = "File path has invalid characters in it."; Debug.WriteLine(ex.ToString()); MyMessages.ShowErrorMessageBox(); return(false); } }