Esempio n. 1
0
        /// <summary>
        /// This is not completely foolproof,
        /// but it works most of the time.
        /// NOT recursive. Will NOT add OP's ED's or Specials.
        /// </summary>
        private void LocateFiles_Click(object sender, RoutedEventArgs e)
        {
            object entry = (sender as MenuItem).Tag;

            if (entry is AnimeEntry)
            {
                List <FileEntry> files = m_myList.SelectFilesFromAnime((entry as AnimeEntry).aid);

                if (files.Count > 0)
                {
                    Forms.FolderBrowserDialog dlg = new Forms.FolderBrowserDialog();
                    dlg.ShowNewFolderButton = false;

                    Forms.DialogResult result = dlg.ShowDialog();
                    if (result == Forms.DialogResult.OK)
                    {
                        ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
                        {
                            List <string> fPaths = new List <string>();
                            List <string> uPaths = new List <string>();

                            foreach (string _file in Directory.GetFiles(dlg.SelectedPath, "*.*")
                                     .Where(x => allowedVideoFiles.Contains("*" + Path.GetExtension(x).ToLower())))
                            {
                                fPaths.Add(_file);
                            }

                            foreach (FileEntry file in files)
                            {
                                string path = fPaths.FirstOrDefault(x => !uPaths.Contains(x) &&
                                                                    Regex.IsMatch(x, String.Format(@"([p\.\[\]\(\) _-]0?{0}[v\.\[\]\(\) _-]).*(\[[A-F0-9]{{8}}])?", file.epno)));
                                if (path != string.Empty)
                                {
                                    file.path = path;
                                    uPaths.Add(path);
                                }
                            }
                        }));
                    }

                    MylistTreeListView.Refresh();
                }
                else
                {
                    MessageBox.Show("No file entries found for the selected anime.");
                }
            }
            else if (entry is FileEntry)
            {
                SetFileLocation(entry as FileEntry);
            }
        }
Esempio n. 2
0
        private void RemoveFromList_Click(object sender, RoutedEventArgs e)
        {
            FileEntry fEntry = (FileEntry)(sender as MenuItem).Tag;

            if (m_aniDBAPI.MyListDel(fEntry.lid))
            {
                if (!String.IsNullOrEmpty(fEntry.path))
                {
                    AniDBAPI.AppendDebugLine(String.Format("Removed {0} from mylist.", Path.GetFileName(fEntry.path)));
                }

                m_myList.DeleteFile(fEntry.lid);
                MylistTreeListView.Refresh();
            }
        }
Esempio n. 3
0
        private void OnFileInfoFetched(FileInfoFetchedArgs e)
        {
            if (!m_myList.isSQLConnOpen)
            {
                Dispatcher.Invoke(new Action(m_myList.Create));
                Dispatcher.BeginInvoke(new Action(SetMylistVisibility));
            }

            m_myList.InsertFileInfo(e);
            Dispatcher.BeginInvoke(new Action(delegate
            {
                if (MylistTreeListView != null)
                {
                    MylistTreeListView.Refresh();
                }
            }));
        }
Esempio n. 4
0
        private bool SetFileLocation(FileEntry entry)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Filter = "Video Files|" + String.Join(";", allowedVideoFiles) + "|All Files|*.*";
            dlg.Title  = String.Format("Browsing for {0} Episode {1}", m_myList.SelectAnimeFromFile(entry.fid).title, entry.epno);

            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                entry.path = dlg.FileName;
                MylistTreeListView.Refresh();

                return(true);
            }

            return(false);
        }