예제 #1
0
        public T ActivateScript <T> (string scriptName)
            where T : IScript
        {
            var path = FileNamer.GetScriptPath(scriptName);

            return((T)ActivateScriptFromFile(path));
        }
예제 #2
0
        private void ReNameButton_Click(object sender, EventArgs e)
        {
            ///Create multi-file name
            ///Get selected files from list view box
            ///
            ArrayList SelectedNames = new ArrayList();

            foreach (ListViewItem itemName in ListViewBox.Items)
            {
                if (itemName.Checked == true)
                {
                    SelectedNames.Add(itemName.Text);
                    Console.Out.WriteLine(itemName.Text);
                }
            }
            if (SelectedNames.Count > 0)
            {
                ///Create a filenamer
                ///
                FileNamer ChangeFiles = new FileNamer(Decimal.ToInt32(NumericChange.Value), IncrementButton.Checked, Decimal.ToInt32(NumericStartNumber.Value), SelectedNames, CurrentDirectory, SelectedNames.Count, @NewNameBox.Text);
            }
            ////Redo listviewbox
            ListViewBox.Items.Clear();
            DirectoryInfo info = new DirectoryInfo(CurrentDirectory);

            if (info.Exists)
            {
                //Update the FileListBox with items!
                foreach (FileInfo newFile in info.GetFiles())
                {
                    //newItem = new ListViewItem(childNode.Text);
                    ListViewBox.Items.Add(newFile.Name);
                }
            }
        }
예제 #3
0
        public IScript ActivateScriptAt(string scriptName, string workingDirectory)
        {
            var scriptPath = FileNamer.GetScriptPath(scriptName, workingDirectory);

            var script = ActivateScriptFromFile(scriptPath);

            script.Relocate(workingDirectory);

            return(script);
        }
예제 #4
0
        public IScript ActivateScript(string scriptName)
        {
            var path = FileNamer.GetScriptPath(scriptName);

            if (String.IsNullOrEmpty(path))
            {
                throw new ScriptNotFoundException(scriptName);
            }

            return(ActivateScriptFromFile(path));
        }
        public void Test_Save()
        {
            Console.WriteLine ("Preparing test");

            // Create the entity
            var entity = new SimpleEntity ();

            Console.WriteLine ("Executing test");

            var data = GetGitDB ();

            // Save the entity
            data.Save (entity);

            var filePath = new FileNamer (new DirectoryContext (Environment.CurrentDirectory)).CreateFilePath (entity.TypeName, entity.Id);

            Assert.IsTrue (File.Exists (filePath));
        }
예제 #6
0
 private void btnApply_Click(object sender, EventArgs e)
 {
     try
     {
         FileNamer fileNamer = new FileNamer();
         try
         {
             Dictionary<ProcessorNamer, string> tempFileNames = new Dictionary<ProcessorNamer, string>(this._processorNamers.Count);
             foreach (ProcessorNamer pn in this._processorNamers)
             {
                 if (pn.HasError)
                 {
                     throw new Exception(pn.Error);
                 }
                 string tempFilename = pn.OriginalFullFilename;
                 for (int i = 0; ; i++)
                 {
                     tempFilename += "-tmp-" + i.ToString();
                     if (!File.Exists(tempFilename))
                     {
                         break;
                     }
                 }
                 tempFileNames.Add(pn, tempFilename);
                 fileNamer.Rename(pn.OriginalFullFilename, tempFilename);
             }
             foreach (KeyValuePair<ProcessorNamer, string> tfn in tempFileNames)
             {
                 fileNamer.Rename(tfn.Value, tfn.Key.NewFullFilename);
             }
         }
         catch
         {
             try
             {
                 fileNamer.Revert();
             }
             catch
             { }
             throw;
         }
         foreach (ProcessorNamer pn in this._processorNamers)
         {
             pn.Processor.SetFullFilename(pn.NewFullFilename);
             this._someChanged = true;
         }
         if (this.cbxFormat.SelectedIndex == 0)
         {
             MediaData.Properties.Settings.Default.BatchRenameLastFormat = "";
         }
         else
         {
             List<string> rememberFormat = new List<string>();
             rememberFormat.Add(this.cbxFormat.Text);
             if (!string.IsNullOrEmpty(MediaData.Properties.Settings.Default.BatchRenameFormats))
             {
                 foreach (string s in MediaData.Properties.Settings.Default.BatchRenameFormats.Split('|'))
                 {
                     string s2 = s.Trim();
                     if (s2.Length > 0 && !rememberFormat.Contains(s2))
                     {
                         rememberFormat.Add(s2);
                     }
                 }
             }
             MediaData.Properties.Settings.Default.BatchRenameFormats = string.Join("|", rememberFormat);
             MediaData.Properties.Settings.Default.BatchRenameLastFormat = this.cbxFormat.Text;
         }
         try
         {
             MediaData.Properties.Settings.Default.Save();
         }
         catch
         { }
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception x)
     {
         MessageBox.Show(x.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }