/// <summary> /// Notifies the client that its Control has been activated. Activation occurs when /// the Control gets focus, or a parent "host" Control gets focus.</summary> /// <param name="control">Client Control that was activated</param> /// <remarks>This method is only called by IControlHostService if the Control was previously /// registered for this IControlHostClient.</remarks> void IControlHostClient.Activate(Control control) { WinGuiCommonDataDocument document = control.Tag as WinGuiCommonDataDocument; if (document != null) { m_documentRegistry.ActiveDocument = document; WinGuiCommonDataContext context = document.As <WinGuiCommonDataContext>(); m_contextRegistry.ActiveContext = context; } }
private void UpdateControlInfo() { string filePath = Uri.LocalPath; string fileName = Path.GetFileName(filePath); if (Dirty) { fileName += "*"; } WinGuiCommonDataContext context = this.As <WinGuiCommonDataContext>(); context.ControlInfo.Name = fileName; context.ControlInfo.Description = filePath; }
/// <summary> /// Opens or creates a document at the given URI</summary> /// <param name="uri">Document URI</param> /// <returns>Document, or null if the document couldn't be opened or created</returns> public IDocument Open(Uri uri) { DomNode node = null; string filePath = uri.LocalPath; string fileName = Path.GetFileName(filePath); if (File.Exists(filePath)) { // read existing document using standard XML reader using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { DomXmlReader reader = new DomXmlReader(m_schemaLoader); node = reader.Read(stream, uri); } } else { // create new document by creating a Dom node of the root type defined by the schema node = new DomNode(Schema.winGuiCommonDataType.Type, Schema.winGuiCommonDataRootElement); } WinGuiCommonDataDocument document = null; if (node != null) { // Initialize Dom extensions now that the data is complete node.InitializeExtensions(); WinGuiCommonDataContext context = node.As <WinGuiCommonDataContext>(); ControlInfo controlInfo = new ControlInfo(fileName, filePath, StandardControlGroup.Center); context.ControlInfo = controlInfo; // set document URI document = node.As <WinGuiCommonDataDocument>(); document.Uri = uri; context.ListView.Tag = document; // show the ListView control m_controlHostService.RegisterControl(context.ListView, controlInfo, this); } return(document); }
/// <summary> /// Closes the document and removes any views of it from the UI</summary> /// <param name="document">Document to close</param> public void Close(IDocument document) { WinGuiCommonDataContext context = Adapters.As <WinGuiCommonDataContext>(document); m_controlHostService.UnregisterControl(context.ListView); context.ControlInfo = null; // close all active EditingContexts in the document foreach (DomNode node in context.DomNode.Subtree) { foreach (EditingContext editingContext in node.AsAll <EditingContext>()) { m_contextRegistry.RemoveContext(editingContext); } } // close the document m_documentRegistry.Remove(document); }
/// <summary> /// Makes the document visible to the user</summary> /// <param name="document">Document to show</param> public void Show(IDocument document) { WinGuiCommonDataContext context = Adapters.As <WinGuiCommonDataContext>(document); m_controlHostService.Show(context.ListView); }