Ejemplo n.º 1
0
        void btnPreviewFiles_Click(object sender, RoutedEventArgs e)
        {
            EnableDisableControls(false);
            //HideShowControls(System.Windows.Visibility.Hidden);
            WorkerRunning    = true;
            WorkerNotRunning = false;
            stopWorker       = false;

            VM_RenameScript script = new VM_RenameScript();

            script.IsEnabledOnImport = 0;
            script.Script            = txtRenameScript.Text;
            script.ScriptName        = Constants.Renamer.TempFileName;

            Controller controller = cboController.SelectedItem as Controller;

            script.RenamerType = controller?.RenamerType; //prevent null reference

            if (!script.Save())
            {
                return;
            }

            WorkerJob job = new WorkerJob();

            job.RenameScript = "NULL";
            job.FileResults  = FileResults;

            previewWorker.RunWorkerAsync(job);
        }
Ejemplo n.º 2
0
        void btnPreviewFiles_Click(object sender, RoutedEventArgs e)
        {
            EnableDisableControls(false);
            //HideShowControls(System.Windows.Visibility.Hidden);
            WorkerRunning    = true;
            WorkerNotRunning = false;
            stopWorker       = false;

            WorkerJob job = new WorkerJob();

            job.RenameScript = txtRenameScript.Text;
            job.FileResults  = FileResults;

            previewWorker.RunWorkerAsync(job);
        }
Ejemplo n.º 3
0
        void renameWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkerJob        job    = e.Argument as WorkerJob;
            BackgroundWorker worker = sender as BackgroundWorker;

            foreach (VM_VideoLocal_Renamed ren in job.FileResults)
            {
                if (stopWorker)
                {
                    return;
                }
                ren.NewFileName = "";
            }

            int curFile = 0;
            int delay   = 0;

            foreach (VM_VideoLocal_Renamed ren in job.FileResults)
            {
                if (stopWorker)
                {
                    return;
                }

                curFile++;
                delay++;


                VM_VideoLocal_Renamed raw =
                    (VM_VideoLocal_Renamed)VM_ShokoServer.Instance.ShokoServices.RenameAndMoveFile(ren.VideoLocalID,
                                                                                                   job.RenameScript, job.Move);

                ren.NewFileName = raw.NewFileName;
                ren.Success     = raw.Success;

                // do this so we don't lock the UI
                if (delay == 20)
                {
                    renameWorker.ReportProgress(0, new WorkerStatusContainer(job.FileResults.Count, curFile));
                    delay = 0;
                }
            }
        }
Ejemplo n.º 4
0
        void btnRenameFiles_Click(object sender, RoutedEventArgs e)
        {
            string           msg = string.Format(Shoko.Commons.Properties.Resources.Rename_Confirm);
            MessageBoxResult res = MessageBox.Show(msg, Shoko.Commons.Properties.Resources.Confirm, MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (res != MessageBoxResult.Yes)
            {
                return;
            }

            EnableDisableControls(false);

            WorkerRunning    = true;
            WorkerNotRunning = false;
            stopWorker       = false;

            WorkerJob job = new WorkerJob();

            job.RenameScript = txtRenameScript.Text;
            job.FileResults  = FileResults;

            renameWorker.RunWorkerAsync(job);
        }
Ejemplo n.º 5
0
        void btnRenameFiles_Click(object sender, RoutedEventArgs e)
        {
            string           msg = string.Format(Shoko.Commons.Properties.Resources.Rename_Confirm);
            MessageBoxResult res = MessageBox.Show(msg, Shoko.Commons.Properties.Resources.Confirm,
                                                   MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (res != MessageBoxResult.Yes)
            {
                return;
            }

            EnableDisableControls(false);

            if (!SaveScript())
            {
                return;
            }

            WorkerRunning    = true;
            WorkerNotRunning = false;
            stopWorker       = false;

            WorkerJob job = new WorkerJob();

            job.RenameScript = (cboScript.SelectedItem as VM_RenameScript)?.ScriptName;
            job.FileResults  = FileResults;
            job.Move         = chkMoveIfNeeded.IsChecked ?? false;

            if (job.RenameScript == null)
            {
                MessageBox.Show("The Selected Item is NULL", Shoko.Commons.Properties.Resources.Error,
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            renameWorker.RunWorkerAsync(job);
        }