/// <summary>Called when [ok button clicked].</summary>
        /// <param name="sender">The source of the event</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void OnOKButton_Clicked(object sender, EventArgs e)
        {
            var coll = new BookDataCollection();

            BookListPathsProperties.AuthorsNameCurrent = lblAuthor.Text;
            var clsComb = new CombinePathsClass();

            var filePath = clsComb.CombineDirectoryPathWithFileName(BookListPathsProperties.PathAuthorsDirectory,
                                                                    BookListPathsProperties.AuthorsNameCurrent);

            var valid  = new ValidationClass();
            var msgBox = new MyMessageBoxClass();

            if (!valid.ValidateStringHasLength(filePath))
            {
                msgBox.Msg = "Unable to complete the operation.";
                msgBox.ShowErrorMessageBox();
                return;
            }

            BookListPathsProperties.PathOfCurrentWorkingFile = filePath;

            coll.ClearCollection();
            Close();
        }
示例#2
0
 private void ValidateUserHasMadeTextSelection(string value)
 {
     if (!ValidationClass.ValidateStringHasLength(value))
     {
         throw ArgumentNullException();
     }
 }
 private void ValidateUserHasMadeTextSelection(string value)
 {
     if (!ValidationClass.ValidateStringHasLength(value))
     {
         throw new ArgumentNullException("You must select some text");
     }
 }
示例#4
0
        /// <summary>
        ///     Searches the by authors name button clicked.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void SearchByAuthorsNameButton_Clicked(object sender, EventArgs e)
        {
            _msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            if (_valid.ValidateStringIsNotNull(txtSearch.Text.Trim()))
            {
                return;
            }

            var str = txtSearch.Text.Trim();

            if (!_valid.ValidateStringHasLength(str))
            {
                return;
            }

            SearchForAuthorsName(str);
        }
示例#5
0
        /// <summary>
        ///     Add new <paramref name="item" /> to the collection.
        /// </summary>
        public bool AddItem([NotNull] string item)
        {
            if (!_validate.ValidateStringIsNotNull(item))
            {
                return(false);
            }
            if (!_validate.ValidateStringHasLength(item))
            {
                return(false);
            }

            if (ContainsItem(item))
            {
                return(false);
            }

            _coll.Add(item);
            return(true);
        }
示例#6
0
        /// <summary>
        /// Get the users music directory path.
        /// </summary>
        private void GetMusicDirectoryPath()
        {
            var userInfo = new UserInformation();
            var validate = new ValidationClass();

            var dirPath = userInfo.LocateDefaultMusicDirectory();

            if (validate.ValidateStringHasLength(dirPath))
            {
                txtMusic.Text = dirPath;
            }

            dirPath = userInfo.FindMusicDirectoryBrowser();
        }
示例#7
0
        private void OnReplaceBookInformationDataButton_Clicked(object sender, EventArgs e)
        {
            if (ValidationClass.ValidateStringHasLength(title))
            {
                var sb = new StringBuilder();
            }

            sb.Append(this.title);
            sb.Append("-");
            sb.Append(this.series);

            this.txtData.Text = sb.ToString();

            this.DataCopy.RemoveAt(this.index);
            this.DataCopy.Add(sb.ToString());

            this.btnLast.PerformClick();

            this.txtSeries.Text = string.Empty;
            this.txtTitle.Text  = string.Empty;
            this.series         = string.Empty;
            this.title          = string.Empty;
        }
        /// <summary>
        ///     The OnSaveRecordButton_Clicked.
        /// </summary>
        /// <param name="sender">
        ///     The source of the event. <see cref="Object" /> The source of the
        ///     event.
        /// </param>
        /// <param name="e">
        ///     The e <see cref="EventArgs" /> Instance containing the event data.
        /// </param>
        private void OnSaveRecordButton_Clicked(object sender, EventArgs e)
        {
            _msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var dirFileOp = new FileClass();

            var dirAuthors = BookListPathsProperties.PathAuthorsDirectory;

            var authorOp = new AuthorOperationsClass();

            if (!_valid.ValidateStringIsNotNull(dirAuthors))
            {
                return;
            }
            if (!_valid.ValidateStringHasLength(dirAuthors))
            {
                return;
            }
            if (!_valid.ValidateStringHasLength(txtAuthor.Text.Trim()))
            {
                return;
            }
            if (!_valid.ValidateDirectoryExists(dirAuthors))
            {
                return;
            }


            var fileName = authorOp.AddDashBetweenAuthorsFirstMiddleLastName(txtAuthor.Text);

            if (!_valid.ValidateStringHasLength(fileName))
            {
                return;
            }

            var cls      = new CombinePathsClass();
            var filePath = cls.CombineDirectoryPathWithFileName(dirAuthors, fileName);

            if (!_valid.ValidateStringHasLength(filePath))
            {
                return;
            }

            if (_valid.ValidateFileExists(filePath, false))
            {
                _msgBox.Msg = "This file all ready exists.";
                _msgBox.ShowInformationMessageBox();
                return;
            }

            if (dirFileOp.CreateNewFile(filePath))
            {
                _msgBox.Msg = "Author file created successfully.";
                _msgBox.ShowInformationMessageBox();
                BookListPathsProperties.AuthorsNameCurrent       = fileName;
                BookListPathsProperties.PathOfCurrentWorkingFile = filePath;

                AddNewAuthorFileNameToAuthorsList(fileName);

                return;
            }

            BookListPathsProperties.AuthorsNameCurrent       = string.Empty;
            BookListPathsProperties.PathOfCurrentWorkingFile = string.Empty;

            _msgBox.Msg = "Failed to create the file for this author.";
            _msgBox.ShowErrorMessageBox();
        }
示例#9
0
 private void ValidateUserHasMadeTextSelection(string value)
 {
     if (ValidationClass.ValidateStringHasLength(value))
 }