示例#1
0
        private void EnsureFrameInterfaceClosed()
        {
            // Optionally post the data changes
            if (_postBeforeClosingEmbedded)
            {
                _frameInterfaceNode.PostChanges();
            }

            // Invoke the before close embedded handler
            if (_beforeCloseEmbedded != null)
            {
                _beforeCloseEmbedded.Execute(this, new EventParams("AInterface", _frameInterfaceNode));
            }

            try
            {
                _frameInterfaceNode.HostNode.BroadcastEvent(new DisableSourceEvent());
                if (_sourceLink != null)
                {
                    _sourceLink.TargetSource = null;
                }
            }
            finally
            {
                try
                {
                    _frameInterfaceNode.HostNode.Dispose();
                }
                finally
                {
                    _frameInterfaceNode = null;
                    RemoveMenu();
                }
            }
        }
示例#2
0
        // This is based the Frame code
        private void ResetFrameInterfaceNode(bool build)
        {
            BeginUpdate();
            try
            {
                // Clean up the old frame if there is one
                if (_frameInterfaceNode != null)
                {
                    // Optionally post the data changes
                    if (_postBeforeClosingEmbedded)
                    {
                        _frameInterfaceNode.PostChanges();
                    }

                    // Invoke the before close embedded handler
                    if (_beforeCloseEmbedded != null)
                    {
                        _beforeCloseEmbedded.Execute(this, new EventParams("AInterface", _frameInterfaceNode));
                    }

                    try
                    {
                        _frameInterfaceNode.HostNode.BroadcastEvent(new DisableSourceEvent());
                        if (_sourceLink != null)
                        {
                            _sourceLink.TargetSource = null;
                        }
                    }
                    finally
                    {
                        try
                        {
                            _frameInterfaceNode.HostNode.Dispose();
                        }
                        finally
                        {
                            _frameInterfaceNode = null;
                            RemoveMenu();
                        }
                        InvalidateLaidOut();
                    }
                }
                // Create the new frame
                if
                (
                    build &&
                    ShouldLoad()
                )
                {
                    IHost host = HostNode.Session.CreateHost();
                    try
                    {
                        _frameInterfaceNode = new FrameInterface(this);
                        try
                        {
                            host.Load(_document, _frameInterfaceNode);
                            if (_sourceLink != null)
                            {
                                _sourceLink.TargetSource = _frameInterfaceNode.MainSource;
                            }
                            if (_frameInterfaceNode.MainSource != null && !String.IsNullOrEmpty(_filter))
                            {
                                _frameInterfaceNode.MainSource.Filter = _filter;
                            }
                            host.Open(!Active);
                            if (Active)
                            {
                                BroadcastEvent(new FormShownEvent());
                            }
                        }
                        catch
                        {
                            _frameInterfaceNode.Dispose();
                            _frameInterfaceNode = null;
                            throw;
                        }
                    }
                    catch
                    {
                        host.Dispose();
                        throw;
                    }
                }
            }
            finally
            {
                if (Active)
                {
                    UpdateLayout();
                }
                EndUpdate(Active);
            }
        }