Example #1
0
        /// <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)
        {
            StoryDocument doc = document.As <StoryDocument>();

            m_controlHostService.UnregisterControl(doc.Control);

            // close the document
            m_documentRegistry.Remove(document);
        }
Example #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);
        }
Example #3
0
        public static bool ConfirmClose(IDocument document, IFileDialogService fileDialogService)
        {
            var game = document.As <Game.GameExtensions>();

            if (game == null)
            {
                return(true);
            }
            var terrain      = game.Terrain;
            var sceneManager = game.SceneManager;

            if (terrain == null || sceneManager == null)
            {
                return(true);
            }

            var  layerIds       = terrain.GetAllLayerIds();
            bool hasActiveLocks = false;

            foreach (var l in layerIds)
            {
                hasActiveLocks |= sceneManager.HasTerrainLock(l);
            }

            if (hasActiveLocks)
            {
                string message = "You still have active terrain locks. These are unsaved areas of terrain."
                                 + System.Environment.NewLine + "Do you want to save all active terrain locks?";
                FileDialogResult result = fileDialogService.ConfirmFileClose(message);
                if (result == FileDialogResult.Yes)
                {
                    foreach (var l in layerIds)
                    {
                        try
                        {
                            using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                            {
                                sceneManager.SaveTerrainLock(l, progress);
                            }
                        }
                        catch (Exception ex)
                        {
                            ControlsLibrary.BasicControls.ExceptionReport.Show(ex, "Saving terrain lock");
                        }
                    }
                }
                else if (result == FileDialogResult.Cancel)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #4
0
        /// <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>
        public void Activate(Control control)
        {
            if (control.Tag is StoryDocument)
            {
                IDocument doc = (IDocument)control.Tag;
                m_documentRegistry.ActiveDocument = doc;

                StoryContext context = doc.As <StoryContext>();
                m_contextRegistry.ActiveContext = context;

                m_commandService.SetActiveClient(this);
            }
        }
Example #5
0
        /// <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)
        {
            EditingContext context = document.As <EditingContext>();

            // 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);

            // finally unregister the control and release the reference to it
            ViewingContext viewingContext = document.As <ViewingContext>();

            m_controlHostService.UnregisterControl(viewingContext.Control);
            viewingContext.Control.Dispose();
            viewingContext.Control = null;
        }
Example #6
0
        /// <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)
        {
            EventSequenceContext context = document.As <EventSequenceContext>();

            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);
        }
Example #7
0
            private bool IsObjectPartOfDocument(IDocument document, object obj)
            {
                if (document == null || obj == null)
                {
                    return(false);
                }
                if (document.Equals(obj))
                {
                    return(true);
                }
                //try enumerable context.
                var enumContext = document.As <IEnumerableContext>();

                if (enumContext != null && enumContext.Items != null)
                {
                    if (enumContext.Items.Any(elm => AdaptableEquals(elm, obj)))
                    {
                        return(true);
                    }
                }

                return(false);
            }
Example #8
0
        /// <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)
        {
            EditingContext context = document.As<EditingContext>();

            // 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);

            // finally unregister the control and release the reference to it
            ViewingContext viewingContext = document.As<ViewingContext>();
            m_controlHostService.UnregisterControl(viewingContext.Control);
            viewingContext.Control.Dispose();
            viewingContext.Control = null;
        }
Example #9
0
 /// <summary>
 /// Makes the document visible to the user</summary>
 /// <param name="document">Document to show</param>
 public void Show(IDocument document)
 {
     ViewingContext viewingContext = document.As<ViewingContext>();
     m_controlHostService.Show(viewingContext.Control);
 }
Example #10
0
        /// <summary>
        /// Makes the document visible to the user</summary>
        /// <param name="document">Document to show</param>
        public void Show(IDocument document)
        {
            EventSequenceContext context = document.As <EventSequenceContext>();

            m_controlHostService.Show(context.ListView);
        }
Example #11
0
        /// <summary>
        /// Makes the document visible to the user</summary>
        /// <param name="document">Document to show</param>
        public void Show(IDocument document)
        {
            ViewingContext viewingContext = document.As <ViewingContext>();

            m_controlHostService.Show(viewingContext.Control);
        }
Example #12
0
        /// <summary>
        /// Makes the document visible to the user</summary>
        /// <param name="document">Document to show</param>
        public void Show(IDocument document)
        {
            StoryDocument doc = document.As <StoryDocument>();

            m_controlHostService.Show(doc.Control);
        }
Example #13
0
            private bool IsObjectPartOfDocument(IDocument document, object obj)
            {
                if (document == null || obj == null) return false;
                if (document.Equals(obj)) return true;
                //try enumerable context.
                var enumContext = document.As<IEnumerableContext>();
                if (enumContext != null && enumContext.Items != null)
                {
                    if (enumContext.Items.Any(elm => AdaptableEquals(elm, obj)))
                        return true;                    
                }

                return false;
            }
Example #14
0
        /// <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)
        {
            EventSequenceContext context = document.As<EventSequenceContext>();
            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);
        }
Example #15
0
 /// <summary>
 /// Makes the document visible to the user</summary>
 /// <param name="document">Document to show</param>
 public void Show(IDocument document)
 {
     EventSequenceContext context = document.As<EventSequenceContext>();
     m_controlHostService.Show(context.ListView);
 }
Example #16
0
 /// <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)
 {
     StoryDocument doc = document.As<StoryDocument>();
     m_controlHostService.UnregisterControl(doc.Control);
     
     // close the document
     m_documentRegistry.Remove(document);
 }
Example #17
0
 /// <summary>
 /// Makes the document visible to the user</summary>
 /// <param name="document">Document to show</param>
 public void Show(IDocument document)
 {
     StoryDocument doc = document.As<StoryDocument>();
     m_controlHostService.Show(doc.Control);
 }