Esempio n. 1
0
 private void bnBrowse_Click(object sender, System.EventArgs e)
 {
     folderBrowser.SelectedPath = FolderName;
     if (folderBrowser.ShowDialog(this) == DialogResult.OK)
     {
         Result     = FaResult.kfaDifferentFolder;
         FolderName = folderBrowser.SelectedPath;
         Close();
     }
 }
Esempio n. 2
0
        public MissingFolderAction(string showName, string season, string folderName)
        {
            InitializeComponent();

            Result         = FaResult.kfaCancel;
            FolderName     = folderName;
            txtShow.Text   = showName;
            txtSeason.Text = season;
            txtFolder.Text = FolderName;

            if (string.IsNullOrEmpty(FolderName))
            {
                txtFolder.Text   = "Click Browse..., or Drag+Drop a folder onto this window.";
                bnCreate.Enabled = false;
                bnRetry.Enabled  = false;
            }
        }
Esempio n. 3
0
 private void MissingFolderAction_DragDrop(object sender, [NotNull] DragEventArgs e)
 {
     string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
     foreach (string path in files)
     {
         try
         {
             DirectoryInfo di = new DirectoryInfo(path);
             if (di.Exists)
             {
                 FolderName = path;
                 Result     = FaResult.kfaDifferentFolder;
                 Close();
                 return;
             }
         }
         catch
         {
             // ignored
         }
     }
 }
        private void CreateSeasonFolder(ShowItem si, int snum, ICollection <string> ignoredLocations, string proposedFolderName)
        {
            string folder = proposedFolderName;

            // generate new filename info
            // ReSharper disable once RedundantAssignment
            bool          goAgain      = false;
            DirectoryInfo di           = null;
            bool          firstAttempt = true;

            do
            {
                goAgain = false;
                if (!string.IsNullOrEmpty(folder))
                {
                    try
                    {
                        di = new DirectoryInfo(folder);
                    }
                    catch
                    {
                        break;
                    }
                }

                if (ignoredLocations.Contains(folder))
                {
                    break;
                }

                if (di != null && di.Exists)
                {
                    continue;
                }

                string sn          = si.ShowName;
                string text        = snum + " of " + si.MaxSeason();
                string theFolder   = folder;
                string otherFolder = null;

                FaResult whatToDo = GetDefaultAction();

                if (TVSettings.Instance.AutoCreateFolders && firstAttempt)
                {
                    whatToDo     = FaResult.kfaCreate;
                    firstAttempt = false;
                }

                if (whatToDo == FaResult.kfaNotSet)
                {
                    // no command line guidance, so ask the user
                    MissingFolderAction mfa = new MissingFolderAction(sn, text, theFolder);
                    mfa.ShowDialog();
                    whatToDo    = mfa.Result;
                    otherFolder = mfa.FolderName;
                }

                switch (whatToDo)
                {
                case FaResult.kfaRetry:
                    goAgain = true;
                    break;

                case FaResult.kfaDifferentFolder:
                    folder  = otherFolder;
                    goAgain = UpdateDirectory(si, snum, folder);
                    break;

                case FaResult.kfaNotSet:
                    break;

                case FaResult.kfaCancel:
                    throw new TVRenameOperationInterruptedException();

                case FaResult.kfaCreate:
                    TryCreateDirectory(folder, sn, text);
                    goAgain = true;
                    break;

                case FaResult.kfaIgnoreOnce:
                    ignoredLocations.Add(folder);
                    break;

                case FaResult.kfaIgnoreAlways:
                    si.IgnoreSeasons.Add(snum);
                    Doc.SetDirty();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            } while (goAgain);
        }
Esempio n. 5
0
 private void bnCancel_Click(object sender, System.EventArgs e)
 {
     Result = FaResult.kfaCancel;
     Close();
 }
Esempio n. 6
0
 private void bnRetry_Click(object sender, System.EventArgs e)
 {
     Result = FaResult.kfaRetry;
     Close();
 }
Esempio n. 7
0
 private void bnCreate_Click(object sender, System.EventArgs e)
 {
     Result = FaResult.kfaCreate;
     Close();
 }
Esempio n. 8
0
 private void bnIgnoreAlways_Click(object sender, System.EventArgs e)
 {
     Result = FaResult.kfaIgnoreAlways;
     Close();
 }
        private void CreateFolder(MovieConfiguration si, ICollection <string> ignoredLocations, string proposedFolderName, IDialogParent owner)
        {
            string folder = proposedFolderName;

            // generate new filename info
            // ReSharper disable once RedundantAssignment
            bool          goAgain      = false;
            DirectoryInfo di           = null;
            bool          firstAttempt = true;

            do
            {
                goAgain = false;
                if (!string.IsNullOrEmpty(folder))
                {
                    try
                    {
                        di = new DirectoryInfo(folder);
                    }
                    catch (Exception e)
                    {
                        LOGGER.Warn($"Could not create Folder {folder} as {e.Message}.");
                        break;
                    }
                }

                if (ignoredLocations.Contains(folder))
                {
                    break;
                }

                if (di != null && di.Exists)
                {
                    continue;
                }

                string?otherFolder = null;

                FaResult whatToDo = GetDefaultAction();

                if (TVSettings.Instance.AutoCreateFolders && firstAttempt)
                {
                    whatToDo     = FaResult.kfaCreate;
                    firstAttempt = false;
                }

                if (whatToDo == FaResult.kfaNotSet)
                {
                    // no command line guidance, so ask the user
                    MissingFolderAction mfa = new MissingFolderAction(si.ShowName, "", folder);

                    owner.ShowChildDialog(mfa);
                    whatToDo    = mfa.Result;
                    otherFolder = mfa.FolderName;
                    mfa.Dispose();
                }

                switch (whatToDo)
                {
                case FaResult.kfaRetry:
                    goAgain = true;
                    break;

                case FaResult.kfaDifferentFolder:
                    if (otherFolder != null)
                    {
                        folder = otherFolder;
                    }
                    goAgain = UpdateDirectory(si, folder);
                    break;

                case FaResult.kfaNotSet:
                    break;

                case FaResult.kfaCancel:
                    throw new TVRenameOperationInterruptedException();

                case FaResult.kfaCreate:
                    TryCreateDirectory(folder, si.ShowName);
                    goAgain = true;
                    break;

                case FaResult.kfaIgnoreOnce:
                    ignoredLocations.Add(folder);
                    break;

                case FaResult.kfaIgnoreAlways:
                    // si.IgnoreSeasons.Add(snum);  TODO What should we do here? Turn off auto / manual folders?
                    Doc.SetDirty();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            } while (goAgain);
        }