Пример #1
0
        private void ReadSourceDirectory()
        {
            try
            {
                if (!Directory.Exists(Settings.SourceDir))
                {
                    MessageBox.Show("Source Directory does not exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.button_ReadSourceDirectory.BackgroundImage = global::Chrismo.TagMotion.Properties.Resources.media_playback_start;
                    _ReadingSourceDirectory = !_ReadingSourceDirectory;
                    return;
                }
            }
            catch
            {
                MessageBox.Show("Source Directory does not exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.button_ReadSourceDirectory.BackgroundImage = global::Chrismo.TagMotion.Properties.Resources.media_playback_start;
                _ReadingSourceDirectory = !_ReadingSourceDirectory;
                return;
            }

            _Collection = new Collection(Settings.SourceDir);

            try
            {
                _Collection.ReadDirectory();
            }
            catch (OutOfMemoryException)
            {
                _Collection.StopReading = true;
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(FileNotFoundException) && ex.Message.Contains("System.Core"))
                    MessageBox.Show("You need to install the latest Version of the .NET Runtime. (3.5 or higher)");
                else
                    MessageBox.Show("Error during Reading the Source Directory:" + Environment.NewLine + ex.Message);

                return;
            }

            switch (Settings.SortType)
            {
                case "Path": _Collection.Sort(SortType.Path); break;
                case "CreationTime": _Collection.Sort(SortType.CreationTime); break;
                case "Artist": _Collection.Sort(SortType.Artist); break;
                case "Year": _Collection.Sort(SortType.Year); break;
                case "Comment": _Collection.Sort(SortType.Comment); break;
            }

            this.FillTreeview();

            this.button_ReadSourceDirectory.BackgroundImage = global::Chrismo.TagMotion.Properties.Resources.media_playback_start;

            _ReadingSourceDirectory = false;

            Settings.SelectedSourceDir = _SelectedSourceDir;
        }