public bool ShowDialog(RuntimeScript runtimeScript, KeyObject obj)
 {
     using (var acd = new AppCommandDialog())
         if (acd.ShowDialog() == DialogResult.OK && acd.SelectedCommand != null)
         {
             runtimeScript.RuntimeName = AppCommandRuntime.AppCommandRuntimeName;
             runtimeScript.Data        = acd.SelectedCommand.GetData();
             return(true);
         }
     return(false);
 }
Beispiel #2
0
        private void Menu_Click(object sender, EventArgs e)
        {
            if (_scriptEditor == null ||
                !((sender as ToolStripMenuItem).Tag is string t))
            {
                return;
            }
            switch (t)
            {
            case "edit":
                if (_runtimeScript == null)
                {
                    break;
                }
                var rcs = AppCommands.ToAppCommnad(_runtimeScript?.Data);
                using (var acr = new AppCommandDialog(rcs ?? APPCOMMAND.APPCOMMAND_SAVE))
                    if (acr.ShowDialog() == DialogResult.OK && acr.SelectedCommand != null)
                    {
                        _runtimeScript.Data = acr.SelectedCommand.GetData();
                    }
                _scriptEditor.RefreshView();
                break;

            case "add":
                if (_keyObject == null)
                {
                    break;
                }
                using (var acr = new AppCommandDialog())
                    if (acr.ShowDialog() == DialogResult.OK && acr.SelectedCommand != null)
                    {
                        _keyObject.Scripts.AddRuntimeScript(new RuntimeScript {
                            RuntimeName = AppCommandRuntime.AppCommandRuntimeName,
                            Data        = acr.SelectedCommand.GetData()
                        });
                        _scriptEditor.RefreshView();
                    }
                break;
            }
        }