示例#1
0
        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();
                        }
                    }
                }
            }
        }