/// ******************************************************************************** /// <summary> /// Read users names list from file. /// </summary> /// <created>art2m,5/20/2019</created> /// <changed>art2m,5/23/2019</changed> /// ******************************************************************************** private void ReadUserFileFillListBox() { var dirPath = SpellingPropertiesClass.AppDataDirectoryPath; var dirName = SpellingPropertiesClass.GetArt2MSpellDirectoryName; dirPath = DirectoryFileOperationsClass.CombineStringsMakeDirectoryPath(dirPath, dirName); if (string.IsNullOrEmpty(dirPath)) { return; } var fileName = SpellingPropertiesClass.GetArt2MSpellUserListFileName; var filePath = DirectoryFileOperationsClass.CombineDirectoryPathFileNameCheckCreateFile(dirPath, fileName); if (string.IsNullOrEmpty(filePath)) { return; } if (!SpellingReadWriteClass.ReadUsersSpellingListPathsFile(filePath)) { return; } this.FillListBoxWithUserNames(); }
/// <summary> /// if user enters text save it to user name. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">Instance containing the event data.</param> private void OnButtonOk_Click(object sender, EventArgs e) { var name = this.txtUserName.Text.Trim(); if (string.IsNullOrEmpty(name) || name.Length < 1) { SpellingPropertiesClass.UserName = string.Empty; return; } SpellingPropertiesClass.UserName = name; var dirPath = SpellingPropertiesClass.AppDataDirectoryPath; var dirName = SpellingPropertiesClass.GetArt2MSpellDirectoryName; dirPath = DirectoryFileOperationsClass.CombineStringsMakeDirectoryPath(dirPath, dirName); if (string.IsNullOrEmpty(dirPath)) { return; } var fileName = SpellingPropertiesClass.GetArt2MSpellUserListFileName; var filePath = DirectoryFileOperationsClass.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/23/2019</changed> /// ******************************************************************************** private static void AddNewUserToUserNameFile() { NameOfMethod = MethodBase.GetCurrentMethod().Name; if (UsersNameCollection.ContainsItem(SpellingPropertiesClass.UserName)) { InformationMessage = V2; ShowInformationMessageBox(); } UsersNameCollection.AddItem(SpellingPropertiesClass.UserName); var dirPath = SpellingPropertiesClass.AppDataDirectoryPath; var dirName = SpellingPropertiesClass.GetArt2MSpellDirectoryName; dirPath = DirectoryFileOperationsClass.CombineStringsMakeDirectoryPath(dirPath, dirName); if (string.IsNullOrEmpty(dirPath)) { return; } var fileName = SpellingPropertiesClass.GetArt2MSpellUserListFileName; var filePath = DirectoryFileOperationsClass.CombineDirectoryPathFileNameCheckCreateFile( dirPath, fileName); if (string.IsNullOrEmpty(filePath)) { return; } SpellingReadWriteClass.WriteUserNameFile(filePath); }
/// <summary> /// Display all of the users spelling list in the list box. /// </summary> /// <created>art2m,5/22/2019</created> /// <changed>art2m,5/22/2019</changed> private void DisplayUsersSpellingList() { MyMessagesClass.NameOfMethod = MethodBase.GetCurrentMethod().Name; var dirPath = SpellingPropertiesClass.AppDataDirectoryPath; var dirName = SpellingPropertiesClass.GetArt2MSpellDirectoryName; dirPath = DirectoryFileOperationsClass.CombineStringsMakeDirectoryPath(dirPath, dirName); if (string.IsNullOrEmpty(dirPath)) { return; } var fileName = SpellingPropertiesClass.SpellingListPathsFileName; var filePath = DirectoryFileOperationsClass.CombineDirectoryPathFileNameCheckCreateFile(dirPath, fileName); if (string.IsNullOrEmpty(filePath)) { return; } var retVal = SpellingReadWriteClass.ReadUsersSpellingListPathsFile(filePath); if (!retVal) { return; } this.FillListBoxWithPathsToUsersSpellingListFiles(); }
/// ******************************************************************************** /// <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() { MyMessagesClass.NameOfMethod = MethodBase.GetCurrentMethod().Name; var unc = new UsersNameCollection(); if (unc.ContainsItem(SpellingPropertiesClass.UserName)) { MyMessagesClass.InformationMessage = Resources.Art2MSpellMainForm_AddNewUserToUserNameFile_This_user_all_ready_exists_; MyMessagesClass.ShowInformationMessageBox(); } unc.AddItem(SpellingPropertiesClass.UserName); var dirPath = SpellingPropertiesClass.AppDataDirectoryPath; var dirName = SpellingPropertiesClass.GetArt2MSpellDirectoryName; dirPath = DirectoryFileOperationsClass.CombineStringsMakeDirectoryPath(dirPath, dirName); if (string.IsNullOrEmpty(dirPath)) { return; } var fileName = SpellingPropertiesClass.GetArt2MSpellUserListFileName; var filePath = DirectoryFileOperationsClass.CombineDirectoryPathFileNameCheckCreateFile(dirPath, fileName); if (string.IsNullOrEmpty(filePath)) { return; } SpellingReadWriteClass.WriteUserNameFile(filePath); }
/// ******************************************************************************** /// <summary> /// Get the path to file containing all users names. /// </summary> /// <returns></returns> /// <created>art2m,5/23/2019</created> /// <changed>art2m,5/23/2019</changed> /// ******************************************************************************** private static string GetAllUserNamesFile(string userDirPath) { var pathUserListName = SpellingPropertiesClass.SpellingListPathsFileName; var filePath = DirectoryFileOperationsClass.CombineDirectoryPathFileNameCheckCreateFile(userDirPath, pathUserListName); return string.IsNullOrEmpty(filePath) ? string.Empty : filePath; }
/// <summary> /// Open spelling list so user can edit the list or delete the list. /// </summary> /// <created>art2m,5/17/2019</created> /// <changed>art2m,5/17/2019</changed> private void OpenSpellingList() { MyMessagesClass.NameOfMethod = MethodBase.GetCurrentMethod().Name; var value = string.Empty; DialogResult retVal; using (var dlgInput = new SelectSpellingListForm()) { retVal = dlgInput.GetSpellingListPath(value); i } if (DialogResult.OK == retVal) { if (string.IsNullOrEmpty(value)) { MyMessagesClass.WarningMessage = "You need to name this file in order to save it."; MyMessagesClass.ShowWarningMessageBox(); return; } var filePath = DirectoryFileOperationsClass.CombineDirectoryPathFileNameCheckCreateFile( dirPath, value); WriteWordsToFile(filePath, words); } else { MyMessagesClass.WarningMessage = "You need to name this file in order to save it."; MyMessagesClass.ShowWarningMessageBox(); } /*using (var openDlg = new OpenFileDialog()) * { * openDlg.ShowDialog(); * * SpellingPropertiesClass.SpellingListPath = openDlg.FileName; * SpellingPropertiesClass.OpenedSpellingList = true; * SpellingPropertiesClass.CreatingNewSpellingList = false; * * * * this.lstWords.Items.Clear(); * * if (!this.GetWordsFromFile()) * { * return; * } * * this.SetButtonsEnabledState_OpenSpellingListButtonStateClicked(); * this.ChangeControlsBackgroundColors(); * }*/ }
/// ******************************************************************************** /// <summary> /// Read user name file into the collection so it can be used in other places. /// </summary> /// <created>art2m,5/26/2019</created> /// <changed>art2m,5/26/2019</changed> /// ******************************************************************************** private void ReadUserNameFile() { var fileName = SpellingPropertiesClass.GetArt2MSpellUserListFileName; var filePath = DirectoryFileOperationsClass.CombineDirectoryPathFileNameCheckCreateFile(SpellingPropertiesClass.Art2MSpellDirectoryPath, fileName); if (string.IsNullOrEmpty(filePath)) { return; } SpellingPropertiesClass.UserNameFilePath = filePath; SpellingReadWriteClass.ReadUsersSpellingListPathsFile(filePath); }
public void CombineDirectoryPathFileNameCheckCreateFile_TestCheckFileExistsOrCreateFile() { // Assign var dirPath1 = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); var dirName = SpellingPropertiesClass.GetArt2MSpellDirectoryName; const string FileName = "Ar2mSpellUserList"; // Act var dirPath = DirectoryFileOperationsClass.CombineStringsMakeDirectoryPath(dirPath1, dirName); var filePath = DirectoryFileOperationsClass.CombineDirectoryPathFileNameCheckCreateFile(dirPath, FileName); // Assert Assert.IsTrue(File.Exists(filePath)); }