Ejemplo n.º 1
0
 /// <summary>
 /// Make the List of author names match the FileNames.
 /// </summary>
 public static void GetAuthorFileNamesAddToAuthorsNamesList()
 {
     AuthorNamesListCollection.ClearCollection();
     for (var index = 0; index < AuthorsFileNamesCollection.ItemsCount(); index++)
     {
         AuthorNamesListCollection.AddItem(AuthorsFileNamesCollection.GetItemAt(index));
     }
 }
        private void LoadListBoxWithAuthorNames()
        {
            for (var index = 0; index < AuthorsFileNamesCollection.ItemsCount(); index++)
            {
                var authorName = AuthorNamesListCollection.GetItemAt(index);
                //var authorName = AuthorsTextOperations.ReplaceFirstLatNameSeperatorWithSpace(name);
                lstSearch.Items.Add(authorName);
            }

            lstSearch.Sorted = true;
        }
Ejemplo n.º 3
0
        private static void AddAuthorsListToCollection(IEnumerable <string> authors)
        {
            //var authorsList = FileInputClass.ReadTextDataFromFile(fileAuthorsPath);

            foreach (var author in authors)
            {
                if (!AuthorNamesListCollection.ContainsItem(author))
                {
                    AuthorNamesListCollection.AddItem(author);
                }
            }
        }
Ejemplo n.º 4
0
        private void LoadListBoxWithAuthorNames()
        {
            for (var index = 0; index < AuthorsFileNamesCollection.ItemsCount(); index++)
            {
                var authorName = AuthorNamesListCollection.GetItemAt(index);
                this.lstSearch.Items.Add(authorName);
            }

            if (this.lstSearch != null)
            {
                this.lstSearch.Sorted = true;
            }
        }
        /// ********************************************************************************
        /// <summary>
        ///     Write spelling words list to file.
        /// </summary>
        /// <param name="filePath">Path to write file to.</param>
        /// <returns>True if file is written else false.</returns>
        /// <created>art2m,5/20/2019</created>
        /// <changed>art2m,5/23/2019</changed>
        /// ********************************************************************************
        public static bool WriteArthurFileNamesToListFile(string filePath)
        {
            try
            {
                using (var streamWriter = new StreamWriter(filePath, false))
                {
                    for (var index = 0; index < AuthorNamesListCollection.ItemsCount(); index++)
                    {
                        streamWriter.WriteLine(AuthorNamesListCollection.GetItemAt(index));
                    }
                }

                return(true);
            }
            catch (UnauthorizedAccessException ex)
            {
                MyMessagesClass.ErrorMessage = "You do not have access writes for this operation.";

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (ArgumentNullException ex)
            {
                MyMessagesClass.ErrorMessage = "The path variable contains a null string. " + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (ArgumentException ex)
            {
                MyMessagesClass.ErrorMessage = "The file path value is a null string. " + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (DirectoryNotFoundException ex)
            {
                MyMessagesClass.ErrorMessage = "Unable to locate the directory.";

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (PathTooLongException ex)
            {
                MyMessagesClass.ErrorMessage = "the file path is to long.";

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (SecurityException ex)
            {
                MyMessagesClass.ErrorMessage = "The operation has caused a security violation.";

                Debug.WriteLine(ex.ToString());
            }
            catch (IOException ex)
            {
                MyMessagesClass.ErrorMessage = "File path has invalid characters in it. " + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }

            return(false);
        }
        /// ********************************************************************************
        /// <summary>
        ///     Write spelling words list to file.
        /// </summary>
        /// <param name="filePath">Path to write file to.</param>
        /// <returns>True if file is written else false.</returns>
        /// <created>art2m,5/20/2019</created>
        /// <changed>art2m,5/23/2019</changed>
        /// ********************************************************************************
        public static bool WriteArthurFileNamesToListFile(string filePath)
        {
            try
            {
                using (var streamWriter = new StreamWriter(filePath, false))
                {
                    for (var index = 0; index < AuthorNamesListCollection.ItemsCount(); index++)
                    {
                        streamWriter.WriteLine(AuthorNamesListCollection.GetItemAt(index));
                    }
                }

                return(true);
            }
            catch (UnauthorizedAccessException ex)
            {
                MyMessagesClass.ErrorMessage = V7;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (ArgumentNullException ex)
            {
                MyMessagesClass.ErrorMessage = V1 + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (ArgumentException ex)
            {
                MyMessagesClass.ErrorMessage = V2 + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (DirectoryNotFoundException ex)
            {
                MyMessagesClass.ErrorMessage = V3;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (PathTooLongException ex)
            {
                MyMessagesClass.ErrorMessage = V4;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }
            catch (SecurityException ex)
            {
                MyMessagesClass.ErrorMessage = V5;

                Debug.WriteLine(ex.ToString());
            }
            catch (IOException ex)
            {
                MyMessagesClass.ErrorMessage = V6 + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
            }

            return(false);
        }