using System; using MBS.Framework; using MBS.Framework.UserInterface; namespace UniversalEditor.UserInterface { public class EditorApplication : UIApplication, IHostApplication { /// /// Gets or sets the current window of the host application. /// public IHostApplicationWindow CurrentWindow { get { return UniversalEditor.UserInterface.Engine.CurrentEngine.LastWindow; } set { UniversalEditor.UserInterface.Engine.CurrentEngine.LastWindow = value; } } /// /// Gets or sets the output window of the host application, where other plugins can read from and write to. /// public HostApplicationOutputWindow OutputWindow { get; set; } = new HostApplicationOutputWindow(); /// /// A collection of messages to display in the Error List panel. /// public HostApplicationMessage.HostApplicationMessageCollection Messages { get; } = new HostApplicationMessage.HostApplicationMessageCollection(); public event EventHandler EditorChanging; protected internal virtual void OnEditorChanging(EditorChangingEventArgs e) { EditorChanging?.Invoke(this, e); } public event EventHandler EditorChanged; protected internal virtual void OnEditorChanged(EditorChangedEventArgs e) { EditorChanged?.Invoke(this, e); } protected override Command FindCommandInternal(string commandID) { if (!Common.Reflection.Initialized) { // hack around an infinite loop we inadvertently created return base.FindCommandInternal(commandID); } EditorReference[] editors = Common.Reflection.GetAvailableEditors(); foreach (EditorReference er in editors) { Command cmd = er.Commands[commandID]; if (cmd != null) return cmd; } return base.FindCommandInternal(commandID); } protected override Context FindContextInternal(Guid contextID) { EditorReference[] editors = Common.Reflection.GetAvailableEditors(); foreach (EditorReference er in editors) { Context ctx = er.Contexts[contextID]; if (ctx != null) return ctx; } return base.FindContextInternal(contextID); } } }