コード例 #1
0
        private void AddNewScriptCommand(string script)
        {
            if (m_scripts == null)
            {
                if (m_parentScript != null)
                {
                    m_scripts = m_controller.CreateNewEditableScriptsChild(m_parentScript, m_helper.ControlDefinition.Attribute, script, true);
                }
                else
                {
                    m_scripts = m_controller.CreateNewEditableScripts(ElementName, m_helper.ControlDefinition.Attribute, script, true, true);
                }
            }
            else
            {
                m_scripts.AddNew(script, ElementName);
            }

            int newScriptIndex = m_scripts.Count - 1;

            RefreshScriptsList();

            SetSelectedIndex(newScriptIndex);
            lstScripts.Focus();

            IEditableScript newScript = m_scripts[newScriptIndex];

            if (m_scriptParameterControlMap.ContainsKey(newScript) && m_scriptParameterControlMap[newScript].ContainsKey("0"))
            {
                IElementEditorControl ctl = m_scriptParameterControlMap[newScript]["0"];
                Control focusControl      = ctl.FocusableControl;

                if (focusControl != null)
                {
                    Thread newThread = new Thread(() => SetFocusAfterDelay(focusControl));
                    newThread.Start();
                }
            }
        }