示例#1
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (ScriptMgr == null)
            {
                throw new ArgumentNullException("ScriptMgr", "A script manager has not been assigned!");
            }
            //
            string new_name = txtName.Text;

            if (!isNameValid(new_name))
            {
                txtName.SelectAll();
                //txtName.Focus();
                return;
            }
            //
            // check if script name exists
            if (ScriptMgr.Contains(new_name))
            {
                showError("Script name already exists!");
                txtName.SelectAll();
                //txtName.Focus();
                return;
            }
            //
            string super = lstParentClass.Text;

            if (super == "None")
            {
                super = null;
            }
            else
            {
                if (!ScriptMgr.Contains(super))
                {
                    showError("Parent class not found!");
                    lstParentClass.Focus();
                    return;
                }
            }
            //
            ScriptItem script = new ScriptItem();

            script.Name         = txtName.Text;
            script.Data         = buildTemplate(new_name, super);
            script.IsDecompiled = true;
            script.IsModified   = true;
            //
            ScriptMgr.Set(script);
            ScriptMgr.HasChanges = true;
            NewScript            = script;
            DialogResult         = true;
            //Close();
        }