コード例 #1
0
        private void AddFile()
        {
            string filePath = testMode ?
                              Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"../../../File Examples/file_example_1.mp3")) :
                              GetFilePath_OpenDialog("mp3");

            if (filePath != null && File.Exists(filePath) && !BasicFunctions.FileInUse(filePath))
            {
                // check if File is already in list
                bool FileIsInList = false;
                foreach (MusicFileTag FileInList in MusicFileTags)
                {
                    if (FileInList.FilePath == filePath)
                    {
                        FileIsInList = true;
                        MessageBox.Show("This file is already in the list");
                    }
                }
                if (!FileIsInList)
                {
                    MusicFileTag newFile = TaggingLogic.AddFile(filePath);
                    MusicFileTags.Add(newFile);
                    NumberOfFiles++;
                }
            }
            else
            {
                if (BasicFunctions.FileInUse(filePath))
                {
                    MessageBox.Show("Sorry, this file cannot be opened. " +
                                    "Either it is currently in use or this program does not have the necessary rights to read the file.");
                }
            }
        }
コード例 #2
0
 public MainWindowViewModel()
 {
     DetailVM = new DetailViewModel(this);
     DetailView = new DetailView(DetailVM);
     MusicFileTags = new ObservableCollection<MusicFileTag>();
     SelectedItems = new List<MusicFileTag>();
     Logic = new TaggingLogic();
     DetColWidth = new GridLength(1, GridUnitType.Pixel);
     InitCommands();
     SetDefaultNotification();
 }
コード例 #3
0
        public Main_ViewModel(bool _testMode = false)
        {
            testMode = _testMode;

            MusicFileTags = new ObservableCollection <MusicFileTag>();
            Logic         = new TaggingLogic();
            AllGenres     = new ObservableCollection <string>(ComboboxCollections.AllGenres);
            AllLanguages  = new ObservableCollection <string>(ComboboxCollections.AllLanguages);
            AllMoods      = new ObservableCollection <string>(ComboboxCollections.AllMoods);
            AllVersions   = new ObservableCollection <string>(ComboboxCollections.AllVersions);
            AllKeys       = new ObservableCollection <string>(ComboboxCollections.AllKeys);

            // Commands
            AddFileCommand        = new DelegateCommand(AddFile);
            SaveFileTagsCommand   = new DelegateCommand(SaveFileTags);
            SaveAllFilesCommand   = new DelegateCommand(SaveAllFiles);
            RemoveFileCommand     = new DelegateCommand(RemoveFile);
            CopyfromV1Command     = new DelegateCommand(CopyfromV1);
            CopyfromV2Command     = new DelegateCommand(CopyfromV2);
            CreatePlaylistCommand = new DelegateCommand(CreatePlaylist);
            LoadPlaylistCommand   = new DelegateCommand(LoadPlaylist);
            InfoCommand           = new DelegateCommand(OpenGitHubWebsite);
        }