예제 #1
0
        /// <summary>
        ///     Display dialog browser for user to locate top level music directory.
        /// </summary>
        /// <returns>
        /// </returns>
        public string FindMusicDirectoryBrowser()
        {
            _msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var musicDirectory = DisplayFileBrowser.SelectToplevelMusicDirectory();
            var validate       = new ValidationClass();


            if (!validate.ValidateStringIsNotNull(musicDirectory))
            {
                _msgBox.Msg = "You need to set your music directory.";
                _msgBox.ShowInformationMessageBox();

                return(string.Empty);
            }

            var retVal = validate.ValidateDirectoryExists(musicDirectory);

            if (retVal)
            {
                SongRecordProperties.MusicDirectoryPath = UserEnviormentInfoProperties.UserMusicDirectoryPath;
                SongRecordProperties.MusicDirectoryName =
                    new DirectoryInfo(UserEnviormentInfoProperties.UserMusicDirectoryPath).Name;

                return(musicDirectory);
            }

            _msgBox.Msg = "Found no music files in this directory. Use browser"
                          + Environment.NewLine + "to select your music directory.";
            _msgBox.ShowErrorMessageBox();
            return(string.Empty);
        }
예제 #2
0
        /// <summary>
        ///     Finds the name of the user.
        /// </summary>
        /// <returns>
        ///     <c>true</c> , if user name was found, <c>false</c> otherwise.
        /// </returns>
        public bool FindUserName()
        {
            _msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            UserEnviormentInfoProperties.UserName = Environment.UserName;

            var validate = new ValidationClass();

            return(validate.ValidateStringIsNotNull(UserEnviormentInfoProperties.UserName));
        }
예제 #3
0
        /// <summary>
        ///     If file exists read user music directory path from file.
        /// </summary>
        /// <returns>true if path is read else false.</returns>
        public static bool ReadMusicPathFile()
        {
            const string musicManger = nameof(MusicManagerCurrent);

            var pathInfo = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            pathInfo = Path.Combine(pathInfo, musicManger);
            pathInfo = Path.Combine(pathInfo, "MusicInformation.txt");

            var length = new FileInfo(pathInfo).Length;

            // No file to read so exit.
            if (!File.Exists(pathInfo) ||
                length == 0)
            {
                return(false);
            }

            var validate = new ValidationClass();
            var msgBox   = new MyMessageBox();

            // Read the file and display it line by line.
            using (var sr = new StreamReader(pathInfo))
            {
                string musicPath;
                while ((musicPath = sr.ReadLine()) != null)
                {
                    if (Directory.Exists(musicPath))
                    {
                        if (validate.ValidateDirectoryExists(musicPath))
                        {
                            UserEnviormentInfoProperties.UserMusicDirectoryPath = musicPath;
                            SongRecordProperties.MusicDirectoryPath             = musicPath;
                            SongRecordProperties.MusicDirectoryName             =
                                new DirectoryInfo(UserEnviormentInfoProperties.UserMusicDirectoryPath).Name;
                        }
                        else
                        {
                            msgBox.Msg = "Found no music files in this directory. Use browser"
                                         + Environment.NewLine + "to select your music directory.";
                            msgBox.ShowErrorMessageBox();
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
예제 #4
0
        /// <summary>
        ///     The GetPathToSpecialDirectoryAppDataLocal.
        /// </summary>
        /// <returns>
        ///     The <see cref="string" /> .
        /// </returns>
        // ReSharper disable once MemberCanBeMadeStatic.Global
        public bool GetPathToSpecialDirectoryAppDataLocal()
        {
            var validate = new ValidationClass();
            var dirPath  = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            if (!validate.ValidateStringIsNotNull(dirPath))
            {
                return(false);
            }

            UserEnviormentInfoProperties.GetApplicationDataPath = dirPath;

            return(true);
        }
예제 #5
0
        /// <summary>
        ///     Display file browser for user to find home directory.
        /// </summary>
        /// <exception cref="DirectoryNotFoundException" />
        public void FindUserHomeDirectoryBrowser()
        {
            var validate = new ValidationClass();

            var home = DisplayFileBrowser.SelectUserHomeDirectory();

            if (!validate.ValidateStringIsNotNull(home) || !validate.ValidateStringHasLength(home))
            {
                _msgBox.Msg = "Unable to locate your home directory. "
                              + "You will need to click on Set location menu and select home to set this.";
                _msgBox.ShowErrorMessageBox();
            }


            UserEnviormentInfoProperties.UserHomeDirectoryPath = home;
        }
예제 #6
0
        /// <summary>
        ///     Locates the default music directory.
        /// </summary>
        /// <returns>
        ///     path string to default windows directory else empty string.
        /// </returns>
        public string LocateDefaultMusicDirectory()
        {
            var retVal = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);

            var validate = new ValidationClass();

            if (!validate.ValidateDirectoryExists(retVal))
            {
                retVal = string.Empty;
            }

            SongRecordProperties.MusicDirectoryPath = retVal;
            SongRecordProperties.MusicDirectoryName =
                new DirectoryInfo(UserEnviormentInfoProperties.UserMusicDirectoryPath).Name;

            return(retVal);
        }
예제 #7
0
        /// <summary>
        ///     <para>
        ///         Get the path to LocalAppData Directory. Fill
        ///         BookListPaths.PathAppDataDirectory With the Path to the directory.
        ///     </para>
        ///     <para>
        ///         If unable to locate the directory then
        ///         etDefaultDirectoriesAndFilesExist to false. This Path must be found
        ///         as all other directories for the program are contained in this
        ///         directory.
        ///     </para>
        /// </summary>
        public bool GetAppDataDirectoryPath()
        {
            var validate = new ValidationClass();

            var cls = new DirectoryFileClass();

            // Saves the AppData directory path to BookListPaths.PathAppDataDirectory

            cls.GetPathToSpecialDirectoryAppDataLocal();

            var dirExists = validate.ValidateDirectoryExists(UserEnviormentInfoProperties.GetApplicationDataPath);

            if (dirExists)
            {
                return(true);
            }

            this._msgBox.Msg = this._myMsg.MessageUnableToFindTheAppDataDirectory;
            this._msgBox.ShowErrorMessageBox();
            return(false);
        }