示例#1
0
        internal EditableIfScript(EditorController controller, IfScript script, UndoLogger undoLogger)
            : base(controller, script, undoLogger)
        {
            m_ifScript = script;

            m_ifScript.IfScriptUpdated += m_ifScript_IfScriptUpdated;

            if (m_ifScript.ThenScript == null)
            {
                m_ifScript.ThenScript = new MultiScript();
            }

            m_thenScript = EditableScripts.GetInstance(Controller, m_ifScript.ThenScript);
            m_thenScript.Updated += nestedScript_Updated;

            foreach (var elseIfScript in m_ifScript.ElseIfScripts)
            {
                EditableElseIf newEditableElseIf = new EditableElseIf(elseIfScript, this);
                m_elseIfScripts.Add(elseIfScript.Script, newEditableElseIf);
                newEditableElseIf.EditableScripts.Updated += nestedScript_Updated;
            }

            if (m_ifScript.ElseScript != null)
            {
                m_elseScript = EditableScripts.GetInstance(Controller, m_ifScript.ElseScript);
                m_elseScript.Updated += nestedScript_Updated;
            }
        }
示例#2
0
 private void RegisterNestedScriptForUpdates(EditableScripts script)
 {
     if (!m_watchedNestedScripts.Contains(script))
     {
         script.Updated += nestedScript_Updated;
         m_watchedNestedScripts.Add(script);
     }
 }
示例#3
0
        void m_ifScript_IfScriptUpdated(object sender, IfScript.IfScriptUpdatedEventArgs e)
        {
            switch (e.EventType)
            {
                case IfScript.IfScriptUpdatedEventArgs.IfScriptUpdatedEventType.AddedElse:
                    m_elseScript = EditableScripts.GetInstance(Controller, m_ifScript.ElseScript);
                    m_elseScript.Updated += nestedScript_Updated;
                    if (AddedElse != null) AddedElse(this, new EventArgs());
                    break;
                case IfScript.IfScriptUpdatedEventArgs.IfScriptUpdatedEventType.RemovedElse:
                    m_elseScript.Updated -= nestedScript_Updated;
                    m_elseScript = null;
                    if (RemovedElse != null) RemovedElse(this, new EventArgs());
                    break;
                case IfScript.IfScriptUpdatedEventArgs.IfScriptUpdatedEventType.AddedElseIf:
                    EditableScripts editableNewScript = EditableScripts.GetInstance(Controller, e.Data.Script);
                    editableNewScript.Updated += nestedScript_Updated;

                    // Wrap the newly created elseif in an EditableElseIf and add it to our internal dictionary
                    EditableElseIf newEditableElseIf = new EditableElseIf(e.Data, this);
                    m_elseIfScripts.Add(e.Data.Script, newEditableElseIf);

                    // Raise the update to display in the UI
                    if (AddedElseIf != null)
                    {
                        AddedElseIf(this, new ElseIfEventArgs(newEditableElseIf));
                    }
                    break;
                case IfScript.IfScriptUpdatedEventArgs.IfScriptUpdatedEventType.RemovedElseIf:
                    EditableScripts.GetInstance(Controller, e.Data.Script).Updated -= nestedScript_Updated;
                    if (RemovedElseIf != null) RemovedElseIf(this, new ElseIfEventArgs(m_elseIfScripts[e.Data.Script]));
                    m_elseIfScripts.Remove(e.Data.Script);
                    break;
                default:
                    throw new Exception("Unhandled event");
            }

            RaiseUpdated(new EditableScriptUpdatedEventArgs(DisplayString()));
        }