Esempio n. 1
0
        /// <summary>
        /// Open file dialog so user can locate episode in file directory.
        /// </summary>
        /// <param name="showActionModifer">Whether to display action modifier after path is selected</param>
        /// <param name="copyAction">Whether to copy file, move otherwise</param>
        /// <param name="items">Organization items to add move/copy action to once located</param>
        /// <returns>true if locate was sucessful</returns>
        public bool UserLocate(bool showActionModifer, bool copyAction, out List<OrgItem> items)
        {
            // Initialize org items
            items = new List<OrgItem>();

            // Open file dialog
            VistaOpenFileDialog ofd = new VistaOpenFileDialog();
            ofd.Filter = "All Files|*.*";
            if (!(bool)ofd.ShowDialog())
                return false;

            // Try to get episode information from file
            int fileEpSeason, fileEpNumber1, fileEpNumber2;
            bool fileInfoFound = FileHelper.GetEpisodeInfo(ofd.FileName, this.Show.DatabaseName, out fileEpSeason, out fileEpNumber1, out fileEpNumber2);

            // Assign episodes
            TvEpisode ep1 = this;
            TvEpisode ep2 = null;

            // Locate could be for double episode file, only taken if one of the episode from file matches selected
            if (fileInfoFound && fileEpSeason == this.Season)
            {
                if (fileEpNumber1 == this.DisplayNumber)
                {
                    if (fileEpNumber2 > 0)
                        show.FindEpisode(ep1.Season, fileEpNumber2, false, out ep2);
                    else
                        ep2 = null;
                }
                else if (fileEpNumber2 == this.DisplayNumber)
                {
                    if (fileEpNumber1 > 0 && show.FindEpisode(this.Season, fileEpNumber1, false, out ep1))
                        ep2 = this;
                    else
                        ep1 = this;
                }
            }

            // Build org item
            OrgAction action = copyAction ? OrgAction.Copy : OrgAction.Move;
            string destination = show.BuildFilePath(ep1, ep2, Path.GetExtension(ofd.FileName));
            OrgItem item = new OrgItem(OrgStatus.Found, action, ofd.FileName, destination, ep1, ep2, FileCategory.TvVideo, null);

            // Display modifier
            if (showActionModifer)
            {
                OrgItemEditorWindow editor = new OrgItemEditorWindow(item);
                editor.ShowDialog();

                // Add results if valid
                if (editor.Results == null)
                    return false;

                items.Add(editor.Results);
                return true;
            }

            items.Add(item);
            return true;
        }
        private void EditSelectedItem()
        {
            OrgItem selItem = (this.SelectedOrgItems[0] as OrgItem);
            OrgItemEditorWindow editor = new OrgItemEditorWindow(selItem);
            editor.ShowDialog();

            if (editor.Results != null)
                selItem.Clone(editor.Results);
            else
                return;

            if (selItem.Action != OrgAction.None)
                selItem.Enable = true;

            // Automatically apply the movie to unknown items with similar names
            if (lastRunScan == ScanType.Directory && selItem.Category == FileCategory.MovieVideo && (selItem.Action == OrgAction.Move || selItem.Action == OrgAction.Copy))
            {
                foreach (OrgItem item in this.OrgItems)
                {
                    if(FileHelper.PathsVerySimilar(item.SourcePath, selItem.SourcePath))
                    {
                        item.Movie = selItem.Movie;
                        item.DestinationPath = item.Movie.BuildFilePath(item.SourcePath);
                        item.Action = selItem.Action;
                        item.Enable = true;
                    }
                }
            }
        }