internal void UpdateScriptGrid() { if (tabs.SelectedTab != scriptingTab) { return; } if (scriptlistView.Items.Count > 0) { scriptlistView.BeginUpdate(); try { foreach (ListViewItem litem in scriptlistView.Items) { string filename = litem.Text; Scripts.EnhancedScript script = Scripts.Search(filename); { if (script != null) { litem.SubItems[1].Text = script.Status; } } } } finally { scriptlistView.EndUpdate(); } } }
private void AddScriptInGrid() { openFileDialogscript.Filter = "Script Files|*.py;*.uos;*.txt"; DialogResult result = openFileDialogscript.ShowDialog(); if (result == DialogResult.OK) // Test result. { string filename = Path.GetFileName(openFileDialogscript.FileName); string scriptPath = NormalizePath(openFileDialogscript.FileName.Substring(0, openFileDialogscript.FileName.LastIndexOf("\\") + 1)); string razorPath = NormalizePath(Path.Combine(Assistant.Engine.RootPath, "Scripts")); if (scriptPath.Equals(razorPath, StringComparison.OrdinalIgnoreCase)) { Scripts.EnhancedScript script = Scripts.Search(filename); if (script == null) { scriptTable.Rows.Add(filename, Properties.Resources.red, "Idle", false, false, false, Keys.None, false); ReloadScriptTable(); } } else { MessageBox.Show("Error, Script file must be in Scripts folder!"); } } }
private static string LoadFromFile(string filename, bool wait, bool loop, bool run, bool autostart) { string status = "Loaded"; string classname = Path.GetFileNameWithoutExtension(filename); string fullpath = Path.Combine(Assistant.Engine.RootPath, "Scripts", filename); string text = null; if (File.Exists(fullpath)) { //text = File.ReadAllText(fullpath); } else { return("ERROR: file not found"); } Scripts.EnhancedScript script = new Scripts.EnhancedScript(filename, text, wait, loop, run, autostart); //string result = script.Create(null); //if (result == "Created") if (true) { Scripts.EnhancedScripts.TryAdd(filename, script); } //else //{ // status = "ERROR: " + result; //} return(status); }
private void RunCurrentScript(bool run) { if (scriptlistView.SelectedItems.Count == 1) { string filename = scriptlistView.SelectedItems[0].Text; Scripts.EnhancedScript script = Scripts.Search(filename); if (script != null) { script.Run = run; } } }
private static string LoadFromFile(string filename, bool wait, bool loop, bool run, bool autostart, string fullpath) { string status = "Loaded"; string classname = Path.GetFileNameWithoutExtension(filename); string text = null; if (!File.Exists(fullpath)) { return("ERROR: file not found"); } Scripts.EnhancedScript script = new Scripts.EnhancedScript(filename, text, wait, loop, run, autostart); Scripts.EnhancedScripts.TryAdd(filename, script); return(status); }
private void AddScriptInGrid() { openFileDialogscript.Filter = "Script Files|*.py;*.uos;*.txt;*.cs"; DialogResult result = openFileDialogscript.ShowDialog(); if (result == DialogResult.OK) // Test result. { string filename = Path.GetFileName(openFileDialogscript.FileName); string scriptPath = NormalizePath(openFileDialogscript.FileName.Substring(0, openFileDialogscript.FileName.LastIndexOf("\\") + 1)); Scripts.EnhancedScript script = Scripts.Search(filename); if (script == null) { scriptTable.Rows.Add(filename, Properties.Resources.red, "Idle", false, false, false, Keys.None, false, Path.Combine(scriptPath.ToLower(), filename)); ReloadScriptTable(); } } }
private void buttonScriptRefresh_Click(object sender, EventArgs e) { if (scriptTable != null && scriptTable.Rows.Count > 0 && scriptlistView.SelectedItems.Count == 1) { DataRow row = scriptTable.Rows[scriptlistView.SelectedItems[0].Index]; string scriptname = row[0].ToString(); Scripts.EnhancedScript script = Scripts.Search(scriptname); if (script != null) { string fullpath = Path.Combine(Assistant.Engine.RootPath, "Scripts", scriptname); if (File.Exists(fullpath) && Scripts.EnhancedScripts.ContainsKey(scriptname)) { //string text = File.ReadAllText(fullpath); //bool loop = script.Loop; //bool wait = script.Wait; //bool run = script.Run; //bool autostart = script.AutoStart; bool isRunning = script.IsRunning; if (isRunning) { script.Stop(); } //Scripts.EnhancedScript reloaded = new Scripts.EnhancedScript(scriptname, text, wait, // loop, run, autostart); //reloaded.Create(null); Scripts.EnhancedScripts[scriptname].FileChangeDate = DateTime.MinValue; if (isRunning) { script.Start(); } } } } }