private void ScriptingOptions_Click(object sender, EventArgs e) { if (TemplateList.FocusedItem != null) { TemplateScriptData data = new TemplateScriptData(); if (File.Exists(_fileStr + TemplateList.FocusedItem.Text + "\\ScriptData.json")) { data = ReadWrite.GetTemplateScriptData(_fileStr + TemplateList.FocusedItem.Text + "\\ScriptData.json"); } else { data.PostImportScriptActive = false; data.PreImportScriptActive = false; data.PreImportScriptPath = ""; data.PostImportScriptPath = ""; } ModifyScriptForm form = new ModifyScriptForm(data, TemplateList.FocusedItem.Text); form.Show(); } }
public ModifyScriptForm(TemplateScriptData data, string TemplateName) { InitializeComponent(); _templateName = TemplateName; if (data.PreImportScriptActive) { UsePreImportScript.Checked = true; PreImportScriptPath.Text = data.PreImportScriptPath; if (!String.IsNullOrEmpty(data.PreImportArgs)) { PreArgsText.Text = data.PreImportArgs; } } if (data.PostImportScriptActive) { UsePostImportScript.Checked = true; PostImportScriptPath.Text = data.PostImportScriptPath; if (!String.IsNullOrEmpty(data.PostImportArgs)) { PostArgsText.Text = data.PostImportArgs; } } }
private void Save_Click(object sender, EventArgs e) { TemplateScriptData data = new TemplateScriptData(); if (UsePreImportScript.Checked) { data.PreImportScriptActive = true; data.PreImportScriptPath = PreImportScriptPath.Text; if (!String.IsNullOrEmpty(PreArgsText.Text)) { data.PreImportArgs = PreArgsText.Text; } } else { data.PreImportScriptActive = false; data.PreImportScriptPath = ""; } if (UsePostImportScript.Checked) { data.PostImportScriptActive = true; data.PostImportScriptPath = PostImportScriptPath.Text; if (!String.IsNullOrEmpty(PostArgsText.Text)) { data.PostImportArgs = PostArgsText.Text; } } else { data.PostImportScriptActive = false; data.PostImportScriptPath = ""; } ReadWrite.WriteTemplateScriptData(Path.Combine(@CommonData.Preferences.TemplatesDirectory, _templateName + "\\", "ScriptData.json"), data); this.Close(); }
private void Save_Click(object sender, EventArgs e) { if (TemplateObjects.Count > 0) { if (UsePreImportScript.Checked && string.IsNullOrEmpty(PreImportScriptPath.Text)) { MessageBox.Show("Script Path Required"); } else if (UsePostImportScript.Checked && string.IsNullOrEmpty(PostImportScriptPath.Text)) { MessageBox.Show("Script Path Required"); } else if (!string.IsNullOrEmpty(TemplateName.Text)) { System.IO.Directory.CreateDirectory(Path.Combine(@CommonData.Preferences.TemplatesDirectory, TemplateName.Text)); ReadWrite.WriteTemplate(TemplateObjects, Path.Combine(@CommonData.Preferences.TemplatesDirectory, TemplateName.Text + "\\")); if (UsePreImportScript.Checked || UsePostImportScript.Checked) { TemplateScriptData data = new TemplateScriptData(); if (UsePreImportScript.Checked) { data.PreImportScriptActive = true; data.PreImportScriptPath = PreImportScriptPath.Text; if (!String.IsNullOrEmpty(PreArgsText.Text)) { data.PreImportArgs = PreArgsText.Text; } } else { data.PreImportScriptActive = false; data.PreImportScriptPath = ""; } if (UsePostImportScript.Checked) { data.PostImportScriptActive = true; data.PostImportScriptPath = PostImportScriptPath.Text; if (!String.IsNullOrEmpty(PostArgsText.Text)) { data.PostImportArgs = PostArgsText.Text; } } else { data.PostImportScriptActive = false; data.PostImportScriptPath = ""; } ReadWrite.WriteTemplateScriptData(Path.Combine(@CommonData.Preferences.TemplatesDirectory, TemplateName.Text + "\\", "ScriptData.json"), data); } TemplateSaved = true; this.Close(); } else { MessageBox.Show("Template name not valid"); } } else { MessageBox.Show("There are no objects chosen for the template."); } }