Exemple #1
0
        /// <summary>
        /// Requests permission to close the client's Control.</summary>
        /// <param name="control">Client control to be closed</param>
        /// <returns>True if the control can close, or false to cancel</returns>
        bool IControlHostClient.Close(Control control)
        {
            bool closed = true;

            SceneDocument document = control.Tag as SceneDocument;

            if (document != null)
            {
                SceneEditingContext context = document.As <SceneEditingContext>();
                if (context != null)
                {
                    m_controlHostService.UnregisterControl(context.TreeEditor.TreeControl);
                }

                closed = m_documentService.Close(document);
                if (closed)
                {
                    //m_currentEditContext = null;
                    m_propertyEditor.PropertyGrid.Bind(null);
                    m_contextRegistry.RemoveContext(document);
                }
            }

            return(closed);
        }
Exemple #2
0
        /// <summary>
        /// Makes the document visible to the user</summary>
        /// <param name="document">Document to show</param>
        public void Show(IDocument document)
        {
            // set the active document and context; as there is only one editing context in
            //  a document, the document is also a context.

            SceneEditingContext context = document.As <SceneEditingContext>();

            m_controlHostService.Show(context.TreeEditor.TreeControl);
        }
Exemple #3
0
        /// <summary>
        /// Activates the client control</summary>
        /// <param name="control">Client control to be activated</param>
        void IControlHostClient.Activate(Control control)
        {
            SceneDocument document = control.Tag as SceneDocument;

            if (document != null)
            {
                m_documentRegistry.ActiveDocument = document;

                SceneEditingContext context = document.As <SceneEditingContext>();
                m_contextRegistry.ActiveContext = context;
                //context.TreeEditor.TreeControl.Focus();
            }
        }
Exemple #4
0
        /// <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 = SceneEditingContext._CreateSceneRoot("Scene");
            }



            SceneDocument document = null;

            if (node != null)
            {
                // Initialize Dom extensions now that the data is complete; after this, all Dom node
                //  adapters will have been bound to their underlying Dom node.
                node.InitializeExtensions();

                SceneEditingContext context = node.As <SceneEditingContext>();

                ControlInfo controlInfo = new ControlInfo(fileName, filePath, StandardControlGroup.Center);
                controlInfo.IsDocument = true;
                context.ControlInfo    = controlInfo;

                document     = node.As <SceneDocument>();
                document.Uri = uri;

                context.PropertyEditor  = m_propertyEditor;
                context.ContextRegistry = m_contextRegistry;
                context.Initialize(m_commandService);
                context.TreeEditor.TreeControl.Tag = document;

                context.Root = node;
                m_controlHostService.RegisterControl(context.TreeEditor.TreeControl, context.ControlInfo, this);
            }
            return(document);
        }
Exemple #5
0
        private void UpdateControlInfo()
        {
            string filePath = Uri.LocalPath;
            string fileName = Path.GetFileName(filePath);

            if (Dirty)
            {
                fileName += "*";
            }

            SceneEditingContext context = this.As <SceneEditingContext>();

            context.ControlInfo.Name        = fileName;
            context.ControlInfo.Description = filePath;
        }