public bool SendCommand(CommandInfo ci) { Control focusedControl = Sce.Atf.WinFormsUtil.GetFocusedControl(); while (focusedControl != null && !(focusedControl is ICommandClient)) { focusedControl = focusedControl.Parent; } ICommandClient focusedCmdClient = focusedControl as ICommandClient; if (focusedCmdClient != null) { if (focusedCmdClient.CanDoCommand(ci.CommandTag)) { focusedCmdClient.DoCommand(ci.CommandTag); return(true); } } focusedCmdClient = DocumentManager.GetInst().ActiveDocument as ICommandClient; if (focusedCmdClient != null) { if (focusedCmdClient.CanDoCommand(ci.CommandTag)) { focusedCmdClient.DoCommand(ci.CommandTag); return(true); } } return(false); }
void dockPanel_ActiveDocumentChanged(object sender, EventArgs e) { DockContent newContent = dockPanel.ActiveContent as DockContent; if (newContent == null) { return; } if (newContent is Controls.DocumentDockContent) { DocumentManager.GetInst().Activate(((Controls.DocumentDockContent)newContent).Document); } }
object Resolve(Type type) { try { // Check in settings if (typeof(SettingsObject).IsAssignableFrom(type)) { return(SettingsManager.GetInst().GetSettingsObject(type)); } // Check in the UIRegistry //if (typeof(System.Windows.Forms.Control).IsAssignableFrom(type)) //{ // object o = UIRegistry.GetInst().GetSingle(type); // if (o != null) // return o; //} // Check in the DocumentManager? if (typeof(IDocument).IsAssignableFrom(type)) { if (firstAttempt_) { DocumentManager.GetInst().DocumentChanged += Required_DocumentChanged; } if (DocumentManager.GetInst().ActiveDocument != null && type.IsAssignableFrom(DocumentManager.GetInst().ActiveDocument.GetType())) { return(DocumentManager.GetInst().ActiveDocument); } } failed_ = true; return(null); } finally { firstAttempt_ = false; } }