Ejemplo n.º 1
0
        private void CleanupDocument(DocumentHost dh)
        {
            IPoderosaForm owner_window = ViewToForm(dh.LastAttachedView);
            IPoderosaView visible_view = dh.CurrentView;
            bool          was_active   = false;

            if (visible_view != null)
            {
                was_active = visible_view.AsControl().Focused;
                dh.DetachView();
                FireDocViewRelationChange();
            }

            if (owner_window != null)
            {
                NotifyRemove(owner_window, dh.Document);
            }

            dh.SessionHost.CloseDocument(dh.Document);
            _documentMap.Remove(dh.Document);

            //閉じたドキュメントのビューが見えていた場合は、その位置の別のドキュメントを見せる
            //TODO ウィンドウを閉じるときはこの処理は不要
            if (visible_view != null && visible_view.ParentForm.GetAdapter(typeof(IPoderosaMainWindow)) != null)
            {
                ShowBackgroundDocument(visible_view);
                if (was_active && visible_view.Document != null)
                {
                    ActivateDocument(visible_view.Document, ActivateReason.InternalAction);
                }
            }
        }
Ejemplo n.º 2
0
        public void AttachDocumentAndView(IPoderosaDocument document, IPoderosaView view)
        {
            view = AdjustToOuterView(view);
            DocumentHost dh = FindDocumentHost(document);

            Debug.Assert(dh != null, "the document must be registered by calling ISessionHost#RegisterDocument");

            if (view.Document == document)
            {
                Debug.Assert(dh.CurrentView == view);
                return; //何もしない
            }

            IPoderosaView previous_view = dh.CurrentView;                  //関連づけを指定するドキュメントがもともと見えていたビュー
            IPoderosaForm last_window   = ViewToForm(dh.LastAttachedView); //もともとの所有ウィンドウ。初めてのAttachではnullであることにちゅうい

            //現在の関連を一旦切る
            if (previous_view != null)
            {
                Debug.WriteLineIf(DebugOpt.DumpDocumentRelation, "Detach Prev View " + ViewName(previous_view));
                dh.DetachView();
            }
            Debug.Assert(dh.CurrentView == null);

            //接続先にドキュメントが存在していればそれを切り離す
            IPoderosaDocument existing_doc = view.Document;

            if (existing_doc != null)   //対象のビューに古いのがひっついていたら外す
            {
                DocumentHost eh = FindDocumentHost(existing_doc);
                Debug.Assert(eh.CurrentView == view);
                Debug.WriteLineIf(DebugOpt.DumpDocumentRelation, String.Format("Detach Destination View doc={0} view={1}", existing_doc.GetType().Name, ViewName(view)));
                eh.DetachView();
            }

            //新規の接続
            Debug.Assert(view.Document == null && dh.CurrentView == null); //Attach準備ができていること確認
            dh.AttachView(view);

            //移動することで新規に見えるようになるドキュメントを探索
            if (previous_view != null && previous_view != view)
            {
                DocumentHost new_visible_doc = ShowBackgroundDocument(previous_view);
                Debug.Assert(new_visible_doc != dh);
            }

            //ドキュメントを保有するウィンドウが変化したら通知。初回Attachではlast_mainwindow==nullであることに注意
            if (last_window != view.ParentForm)
            {
                if (last_window != null)
                {
                    NotifyRemove(last_window, document);
                }
                NotifyAdd(ViewToForm(view), document);
            }

            FireDocViewRelationChange();
        }
Ejemplo n.º 3
0
        private void CleanupDocument(DocumentHost dh) {
            IPoderosaForm owner_window = ViewToForm(dh.LastAttachedView);
            IPoderosaView visible_view = dh.CurrentView;
            bool was_active = false;
            if (visible_view != null) {
                was_active = visible_view.AsControl().Focused;
                dh.DetachView();
                FireDocViewRelationChange();
            }

            if (owner_window != null) {
                NotifyRemove(owner_window, dh.Document);
            }

            dh.SessionHost.CloseDocument(dh.Document);
            _documentMap.Remove(dh.Document);

            //閉じたドキュメントのビューが見えていた場合は、その位置の別のドキュメントを見せる
            //TODO ウィンドウを閉じるときはこの処理は不要
            if (visible_view != null && visible_view.ParentForm.GetAdapter(typeof(IPoderosaMainWindow)) != null) {
                ShowBackgroundDocument(visible_view);
                if (was_active && visible_view.Document != null)
                    ActivateDocument(visible_view.Document, ActivateReason.InternalAction);
            }
        }
Ejemplo n.º 4
0
        private void CleanupDocument(DocumentHost dh)
        {
            IPoderosaForm owner_window = ViewToForm(dh.LastAttachedView);
            IPoderosaView visible_view = dh.CurrentView;
            bool was_active = false;
            if (visible_view != null) {
                was_active = visible_view.AsControl().Focused;
                dh.DetachView();
                FireDocViewRelationChange();
            }

            if (owner_window != null) {
                NotifyRemove(owner_window, dh.Document);
            }

            dh.SessionHost.CloseDocument(dh.Document);
            _documentMap.Remove(dh.Document);

            //�‚����h�L�������g�̃r���[�������Ă����ꍇ�́A���̈ʒu�̕ʂ̃h�L�������g�������
            //TODO �E�B���h�E��‚���Ƃ��͂��̏����͕s�v
            if (visible_view != null && visible_view.ParentForm.GetAdapter(typeof(IPoderosaMainWindow)) != null) {
                ShowBackgroundDocument(visible_view);
                if (was_active && visible_view.Document != null)
                    ActivateDocument(visible_view.Document, ActivateReason.InternalAction);
            }
        }