Пример #1
0
        /**
         * Activate処理のルート
         * NOTE 重複コールはここでブロックするようにする。
         * アクティブなドキュメントが変化するのは、
         *   - Viewをクリックしてフォーカスが変わるとき
         *   - タブをクリックしたとき
         *   - キーボードショートカット等、Poderosaのコードが発動するとき
         * の3つ。
         * そのうちのどれであるかを指定してここを呼ぶ。例えば、Focus移動のときは改めてFocus()を呼ばないなど内部で場合分けがなされる
         */
        public void ActivateDocument(IPoderosaDocument document, ActivateReason reason)
        {
            Debug.Assert(document != null);

            //ネストの防止 Focus系イベントハンドラがあるとどうしても呼ばれてしまうので
            if (_activateContext != null)
            {
                return;
            }

            try {
                _activateContext = new ActivateContext(document, reason);

                DocumentHost dh = FindDocumentHost(document);
                Debug.Assert(dh != null);

                if (dh.CurrentView != null)   //既に見えている場合
                {
                    if (reason != ActivateReason.ViewGotFocus)
                    {
                        SetFocusToView(dh.CurrentView); //ユーザのフォーカス指定だった場合はそれに任せる
                    }
                }
                else   //見えてはいなかった場合
                {
                    IPoderosaView view = dh.LastAttachedView;
                    Debug.Assert(view != null); //これを強制する仕組みをどこかにほしいかも。今はすべてのDocumentが最初にAttachDocumentAndViewされることを想定している
                    AttachDocumentAndView(document, view);
                    Debug.Assert(dh.CurrentView == view);
                    if (!view.AsControl().Focused)
                    {
                        view.AsControl().Focus();
                    }
                }

                Debug.Assert(dh.CurrentView.Document == document);


                //通知
                NotifyActivation(ViewToForm(dh.CurrentView), document, reason);
            }
            finally {
                _activateContext = null;
                if (DebugOpt.DumpDocumentRelation)
                {
                    DumpDocumentRelation();
                }
            }
        }
Пример #2
0
 public ActivateContext(IPoderosaDocument document, ActivateReason reason) {
     _document = document;
     _reason = reason;
 }
Пример #3
0
        private void NotifyActivation(IPoderosaForm form, IPoderosaDocument document, ActivateReason reason) {
            Debug.Assert(document != null);
            IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow));

            if (window != null) {
                //Tabへの通知。TabClickのときはTabが自前で処理してるのでOK
                if (reason != ActivateReason.TabClick)
                    window.DocumentTabFeature.Activate(document);
                //listenerへの通知
                foreach (IActiveDocumentChangeListener listener in _activeDocumentChangeListeners)
                    listener.OnDocumentActivated(window, document);
            }
        }
Пример #4
0
        /**
         * Activate処理のルート
         * NOTE 重複コールはここでブロックするようにする。
         * アクティブなドキュメントが変化するのは、
         *   - Viewをクリックしてフォーカスが変わるとき
         *   - タブをクリックしたとき
         *   - キーボードショートカット等、Poderosaのコードが発動するとき
         * の3つ。
         * そのうちのどれであるかを指定してここを呼ぶ。例えば、Focus移動のときは改めてFocus()を呼ばないなど内部で場合分けがなされる
         */
        public void ActivateDocument(IPoderosaDocument document, ActivateReason reason) {
            Debug.Assert(document != null);

            //ネストの防止 Focus系イベントハンドラがあるとどうしても呼ばれてしまうので
            if (_activateContext != null)
                return;

            try {
                _activateContext = new ActivateContext(document, reason);

                DocumentHost dh = FindDocumentHost(document);
                Debug.Assert(dh != null);

                if (dh.CurrentView != null) { //既に見えている場合
                    if (reason != ActivateReason.ViewGotFocus)
                        SetFocusToView(dh.CurrentView); //ユーザのフォーカス指定だった場合はそれに任せる
                }
                else { //見えてはいなかった場合
                    IPoderosaView view = dh.LastAttachedView;
                    Debug.Assert(view != null); //これを強制する仕組みをどこかにほしいかも。今はすべてのDocumentが最初にAttachDocumentAndViewされることを想定している
                    AttachDocumentAndView(document, view);
                    Debug.Assert(dh.CurrentView == view);
                    if (!view.AsControl().Focused)
                        view.AsControl().Focus();
                }

                Debug.Assert(dh.CurrentView.Document == document);


                //通知
                NotifyActivation(ViewToForm(dh.CurrentView), document, reason);
            }
            finally {
                _activateContext = null;
                if (DebugOpt.DumpDocumentRelation)
                    DumpDocumentRelation();
            }
        }
Пример #5
0
 public ActivateContext(IPoderosaDocument document, ActivateReason reason)
 {
     _document = document;
     _reason   = reason;
 }
Пример #6
0
        private void NotifyActivation(IPoderosaForm form, IPoderosaDocument document, ActivateReason reason)
        {
            Debug.Assert(document != null);
            IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow));

            if (window != null)
            {
                //Tabへの通知。TabClickのときはTabが自前で処理してるのでOK
                if (reason != ActivateReason.TabClick)
                {
                    window.DocumentTabFeature.Activate(document);
                }
                //listenerへの通知
                foreach (IActiveDocumentChangeListener listener in _activeDocumentChangeListeners)
                {
                    listener.OnDocumentActivated(window, document);
                }
            }
        }
Пример #7
0
        private void NotifyActivation(IPoderosaForm form, IPoderosaDocument document, ActivateReason reason)
        {
            Debug.Assert(document != null);
            IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow));

            if (window != null) {
                //Tab�ւ̒ʒm�BTabClick�̂Ƃ���Tab�����O�ŏ������Ă�̂�OK
                if (reason != ActivateReason.TabClick)
                    window.DocumentTabFeature.Activate(document);
                //listener�ւ̒ʒm
                foreach (IActiveDocumentChangeListener listener in _activeDocumentChangeListeners)
                    listener.OnDocumentActivated(window, document);
            }
        }
Пример #8
0
        /**
         * Activate�����̃��[�g
         * NOTE �d���R�[���͂����Ńu���b�N����悤�ɂ���B
         * �A�N�e�B�u�ȃh�L�������g���ω�����̂́A
         *   - View��N���b�N���ăt�H�[�J�X���ς��Ƃ�
         *   - �^�u��N���b�N�����Ƃ�
         *   - �L�[�{�[�h�V���[�g�J�b�g���APoderosa�̃R�[�h����������Ƃ�
         * �̂R�B
         * ���̂����̂ǂ�ł��邩��w�肵�Ă�����ĂԁB�Ⴆ�΁AFocus�ړ��̂Ƃ��͉��߂�Focus()��Ă΂Ȃ��ȂǓ���ŏꍇ�������Ȃ����
         */
        public void ActivateDocument(IPoderosaDocument document, ActivateReason reason)
        {
            Debug.Assert(document != null);

            //�l�X�g�̖h�~ Focus�n�C�x���g�n���h��������Ƃǂ����Ă�Ă΂�Ă��܂��̂�
            if (_activateContext != null)
                return;

            try {
                _activateContext = new ActivateContext(document, reason);

                DocumentHost dh = FindDocumentHost(document);
                Debug.Assert(dh != null);

                if (dh.CurrentView != null) { //���Ɍ����Ă���ꍇ
                    if (reason != ActivateReason.ViewGotFocus)
                        SetFocusToView(dh.CurrentView); //���[�U�̃t�H�[�J�X�w�肾�����ꍇ�͂���ɔC����
                }
                else { //�����Ă͂��Ȃ������ꍇ
                    IPoderosaView view = dh.LastAttachedView;
                    Debug.Assert(view != null); //������������d�g�݂�ǂ����ɂق�������B���͂��ׂĂ�Document���ŏ���AttachDocumentAndView����邱�Ƃ�z�肵�Ă���
                    AttachDocumentAndView(document, view);
                    Debug.Assert(dh.CurrentView == view);
                    if (!view.AsControl().Focused)
                        view.AsControl().Focus();
                }

                Debug.Assert(dh.CurrentView.Document == document);

                //�ʒm
                NotifyActivation(ViewToForm(dh.CurrentView), document, reason);
            }
            finally {
                _activateContext = null;
                if (DebugOpt.DumpDocumentRelation)
                    DumpDocumentRelation();
            }
        }