public PopupViewContainer(PopupViewCreationParam cp) {
     this.SuspendLayout();
     InitializeComponent();
     _view = cp.ViewFactory.CreateNew(this);
     _view.AsControl().Dock = DockStyle.Fill;
     _view.AsControl().Size = cp.InitialSize;
     this.Controls.Add(_view.AsControl());
     this.ClientSize = cp.InitialSize;
     this.ResumeLayout(false);
 }
Beispiel #2
0
 public PopupViewContainer(PopupViewCreationParam cp)
 {
     this.SuspendLayout();
     InitializeComponent();
     _view = cp.ViewFactory.CreateNew(this);
     _view.AsControl().Dock = DockStyle.Fill;
     _view.AsControl().Size = cp.InitialSize;
     this.Controls.Add(_view.AsControl());
     this.ClientSize = cp.InitialSize;
     this.ResumeLayout(false);
 }
Beispiel #3
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();
                }
            }
        }
Beispiel #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);

            //閉じたドキュメントのビューが見えていた場合は、その位置の別のドキュメントを見せる
            //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);
                }
            }
        }
Beispiel #5
0
        //ビューにフォーカスをセットした状態にする。ポップアップウィンドウの場合、まだウィンドウがロードされていないケースもあるのでそこに注意!
        private void SetFocusToView(IPoderosaView view)
        {
            IPoderosaForm        form  = view.ParentForm;
            IPoderosaPopupWindow popup = (IPoderosaPopupWindow)form.GetAdapter(typeof(IPoderosaPopupWindow));

            if (popup != null)
            {
                if (!popup.AsForm().Visible)
                {
                    popup.UpdateStatus();
                    popup.AsForm().Show();
                }
            }

            if (!view.AsControl().Focused)
            {
                view.AsControl().Focus(); //既にウィンドウは見えている
            }
        }
Beispiel #6
0
        public void OnDocViewRelationChange()
        {
#if false
            foreach (DocumentHost dh in SessionManagerPlugin.Instance.GetAllDocumentHosts())
            {
                IPoderosaView v = dh.CurrentView;
                IPoderosaView l = dh.LastAttachedView;
                Debug.WriteLine(String.Format("Attach doc={0} view={1} last={2}",
                                              dh.Document.Caption,
                                              v == null? "null" : ((CharacterDocumentViewer)v.AsControl()).InstanceID,
                                              ((Poderosa.Terminal.TerminalControl)l.AsControl()).InstanceID));
            }
            Debug.WriteLine("END DUMP");
#endif
        }
Beispiel #7
0
        public IPoderosaView AssureViewClass(Type viewclass)
        {
            if (viewclass == _content.GetType())
            {
                return(_content);                              //ダイナミックな置換は不要、OK!
            }
            IContentReplaceableViewSite site = (IContentReplaceableViewSite)_content.GetAdapter(typeof(IContentReplaceableViewSite));

            Control p = _content.AsControl().Parent;

            p.SuspendLayout();
            if (site != null)
            {
                site.CurrentContentReplaceableView = null;            //IContentReplaceableViewSiteが取れるかどうかはオプショナル
            }
            Debug.WriteLineIf(DebugOpt.ViewManagement, String.Format("Replace ViewClass {0} => {1}", _content.GetType().Name, viewclass.Name));
            IPoderosaView newview = CreateView(viewclass);

            UIUtil.ReplaceControl(p, _content.AsControl(), newview.AsControl());
            //旧コントロールにドキュメントがくっついていたら、それを外さないと不整合生じる
            if (_content.Document != null)
            {
                SessionManagerPlugin.Instance.FindDocumentHost(_content.Document).DetachView();
            }

            _content.AsControl().Dispose();
            _content = newview;
            site     = (IContentReplaceableViewSite)newview.GetAdapter(typeof(IContentReplaceableViewSite));
            if (site != null)
            {
                site.CurrentContentReplaceableView = this;
            }

            p.ResumeLayout(true);
            return(newview);
        }
Beispiel #8
0
 public Control AsDotNet()
 {
     return(_content.AsControl());
 }
Beispiel #9
0
        //ビューにフォーカスをセットした状態にする。ポップアップウィンドウの場合、まだウィンドウがロードされていないケースもあるのでそこに注意!
        private void SetFocusToView(IPoderosaView view) {
            IPoderosaForm form = view.ParentForm;
            IPoderosaPopupWindow popup = (IPoderosaPopupWindow)form.GetAdapter(typeof(IPoderosaPopupWindow));
            if (popup != null) {
                if (!popup.AsForm().Visible) {
                    popup.UpdateStatus();
                    popup.AsForm().Show();
                }
            }

            if (!view.AsControl().Focused)
                view.AsControl().Focus(); //既にウィンドウは見えている
        }