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);
        }
Beispiel #2
0
        void btnSaveScript_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (cboScript.Items.Count == 0)
                {
                    return;
                }
                if (cboScript.SelectedItem == null)
                {
                    return;
                }

                VM_RenameScript script = cboScript.SelectedItem as VM_RenameScript;
                script.IsEnabledOnImport = chkIsUsedForImports.IsChecked.Value ? 1 : 0;
                script.Script            = txtRenameScript.Text;
                if (script.Save())
                {
                    defaultScriptID = script.RenameScriptID;

                    // refresh data
                    RefreshScripts();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
        private bool SaveScript()
        {
            try
            {
                if (cboScript.Items.Count == 0)
                {
                    return(false);
                }
                if (cboScript.SelectedItem == null)
                {
                    return(false);
                }

                VM_RenameScript script = cboScript.SelectedItem as VM_RenameScript;
                script.IsEnabledOnImport = chkIsUsedForImports.IsChecked.Value ? 1 : 0;
                script.Script            = txtRenameScript.Text;

                Controller controller = cboController.SelectedItem as Controller;
                script.RenamerType = controller.RenamerType;

                if (script.Save())
                {
                    defaultScriptID = script.RenameScriptID;

                    // refresh data
                    RefreshScripts();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            return(false);
        }