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 void AllocateTabToControl(TabKey key, Control target)
        {
            IAdaptable ad = target as IAdaptable;

            if (ad == null)
            {
                return;
            }

            IPoderosaView view = (IPoderosaView)ad.GetAdapter(typeof(IPoderosaView));

            if (view == null)
            {
                return;
            }

            SessionManagerPlugin.Instance.AttachDocumentAndView(KeyToDocument(key), view);
        }
        //CommandTargetからTerminalSessionを得る
        public static ITerminalControlHost AsTerminal(ICommandTarget target)
        {
            IPoderosaView view = AsViewOrLastActivatedView(target);

            if (view == null)
            {
                return(null);
            }
            else
            {
                IPoderosaDocument doc = view.Document;
                if (doc == null)
                {
                    return(null);
                }
                return((ITerminalControlHost)doc.OwnerSession.GetAdapter(typeof(ITerminalControlHost)));
            }
        }
Beispiel #4
0
        public void InternalAttachView(IPoderosaDocument document, IPoderosaView view)
        {
            Debug.Assert(document == _document);
            ViewBridge viewbridge = (ViewBridge)view.GetAdapter(typeof(ViewBridge));

            _view = viewbridge;
            viewbridge.Attach(this, _document);
            Debug.WriteLine("Replace DUMMYSESSION");

            //苦しい条件だが、Ctrl+Shiftならキャプション変更をテスト
            Keys m = Control.ModifierKeys;

            if (m == (Keys.Control | Keys.Shift))
            {
                _caption         += "P";
                _document.Caption = _caption;
                SessionManagerPlugin.Instance.RefreshDocumentStatus(document);
            }
        }
Beispiel #5
0
        public void InternalDetachView(IPoderosaDocument document, IPoderosaView view)
        {
            Debug.WriteLineIf(DebugOpt.ViewManagement, "DETACH VIEW");
            Debug.Assert(document == _terminal.IDocument);
            TerminalView tv = (TerminalView)view.GetAdapter(typeof(TerminalView));

            Debug.Assert(tv != null);
            TerminalControl tp = tv.TerminalControl;

            Debug.Assert(tp != null); //Detachするときにはこのビューになっている必要あり

            if (!tp.IsDisposed)
            {
                _terminal.Detach(tp);
                tp.Detach();
            }

            _terminalControl = null;
        }
Beispiel #6
0
 private static string ViewName(IPoderosaView view)
 {
     if (view == null)
     {
         return("null");
     }
     else
     {
         IContentReplaceableView rv = (IContentReplaceableView)view.GetAdapter(typeof(IContentReplaceableView));
         if (rv != null)
         {
             return(rv.GetCurrentContent().GetType().Name);
         }
         else
         {
             return(view.GetType().Name);
         }
     }
 }
Beispiel #7
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 #8
0
        public void StartNewSession(ISession session, IPoderosaView firstView)
        {
            firstView = AdjustToOuterView(firstView);
            SessionHost host = new SessionHost(this, session);

            _sessionMap.Add(session, host);
            session.InternalStart(host);
            foreach (ISessionListener listener in _sessionListeners)
            {
                listener.OnSessionStart(session);
            }

            //この時点で、少なくとも一つドキュメントがないといけない。2つ以上は不可、でもいいかもしれない
            if (host.DocumentCount == 0)
            {
                throw new InvalidOperationException("session must register at least one document in InternalStart()");
            }
            AttachDocumentAndView(host.DocumentAt(0), firstView);
        }
Beispiel #9
0
        public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
        {
            if (!CanExecute(target))
            {
                return(CommandResult.Ignored);
            }
            TerminalTransmission output = GetSession().TerminalTransmission;

            //string data = Clipboard.GetDataObject().GetData("Text") as string;
            string data = Clipboard.GetText();

            if (data == null || data.Length == 0)
            {
                return(CommandResult.Ignored);
            }

            ITerminalEmulatorOptions options = TerminalSessionsPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions;

            if (options.AlertOnPasteNewLineChar)
            {
                // Data will be split by CR, LF, CRLF or Environment.NewLine by TextReader.ReadLine,
                // So we check the data about CR, LF and Environment.NewLine.
                if (data.IndexOfAny(new char[] { '\r', '\n' }) >= 0 || data.Contains(Environment.NewLine))
                {
                    IPoderosaView view = (IPoderosaView)_control.GetAdapter(typeof(IPoderosaView));
                    IPoderosaForm form = view.ParentForm;
                    if (form != null)
                    {
                        DialogResult res = form.AskUserYesNo(TEnv.Strings.GetString("Message.AskPasteNewLineChar"));
                        if (res != DialogResult.Yes)
                        {
                            return(CommandResult.Ignored);
                        }
                    }
                }
            }

            //TODO 長文のときにダイアログを出して中途キャンセル可能に
            StringReader reader = new StringReader(data);

            output.SendTextStream(reader, data[data.Length - 1] == '\n');
            return(CommandResult.Succeeded);
        }
        //Parameterからスタートするタイプ 今はtargetはwindow強制だがViewでも可能にしたい
        public ITerminalSession StartTerminalSession(ICommandTarget target, ITerminalParameter destination, ITerminalSettings settings)
        {
            IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));

            if (window == null)
            {
                IPoderosaView view = (IPoderosaView)target.GetAdapter(typeof(IPoderosaView));
                window = (IPoderosaMainWindow)view.ParentForm.GetAdapter(typeof(IPoderosaMainWindow));
            }
            Debug.Assert(window != null);

            ITerminalConnection connection = OpenConnection(window, destination, settings);

            if (connection == null)
            {
                return(null);
            }

            return(StartTerminalSession(target, connection, settings));
        }
Beispiel #11
0
        internal static TerminalDocument AsTerminalDocument(ICommandTarget target)
        {
            IPoderosaView view = AsViewOrLastActivatedView(target);

            if (view == null)
            {
                return(null);
            }
            else
            {
                IPoderosaDocument doc = view.Document;
                if (doc == null)
                {
                    return(null);
                }
                else
                {
                    return((TerminalDocument)doc.GetAdapter(typeof(TerminalDocument)));
                }
            }
        }
Beispiel #12
0
 protected override void OnDragDrop(DragEventArgs args)
 {
     base.OnDragDrop(args);
     try {
         IWinFormsService  wfs      = TerminalEmulatorPlugin.Instance.GetWinFormsService();
         IPoderosaDocument document = (IPoderosaDocument)wfs.GetDraggingObject(args.Data, typeof(IPoderosaDocument));
         if (document != null)
         {
             IPoderosaView view = (IPoderosaView)this.GetAdapter(typeof(IPoderosaView));
             TerminalEmulatorPlugin.Instance.GetSessionManager().AttachDocumentAndView(document, view);
             TerminalEmulatorPlugin.Instance.GetSessionManager().ActivateDocument(document, ActivateReason.DragDrop);
         }
         else
         {
             wfs.BypassDragDrop(this, args);
         }
     }
     catch (Exception ex) {
         RuntimeUtil.ReportException(ex);
     }
 }
Beispiel #13
0
        public IPoderosaView GetCandidateViewForNewDocument()
        {
            Debug.Assert(_paneDivision != null);
            if (_singlePane != null)
            {
                Debug.Assert(_paneDivision.IsEmpty);
                return((IPoderosaView)_singlePane);
            }

            IPoderosaView firstPane = null;
            IPoderosaView result    = null;

            _paneDivision.FindFirst(delegate(PaneDivision.IPane p) {
                IPoderosaView v = (IPoderosaView)p; //TODO GetAdapterか. 上のキャストもおなじ
                if (firstPane == null)
                {
                    firstPane = v;      //先頭
                }
                if (v.Document == null) //ドキュメントのないビュー優先
                {
                    result = v;
                    return(true);
                }
                else
                {
                    return(false);
                }
            });

            //空きビューがあればそこへ、なければnull
            if (result != null)
            {
                return(result);
            }
            else
            {
                return(firstPane);
            }
        }
Beispiel #14
0
        protected void OnOK(object sender, EventArgs args)
        {
            this.DialogResult = DialogResult.None;
            _targetView       = GetTargetView();
            ITerminalParameter term = PrepareTerminalParameter();

            if (term == null)
            {
                return; //設定に誤りがある場合
            }
            TerminalControl tc = (TerminalControl)_targetView.GetAdapter(typeof(TerminalControl));
            Size            sz = tc.CalcTerminalSize((_terminalSettings.RenderProfile == null) ?
                                                     this.GetInitialRenderProfile() : _terminalSettings.RenderProfile);

            term.SetTerminalSize(sz.Width, sz.Height);

            _loginButton.Enabled  = false;
            _cancelButton.Enabled = false;
            this.Cursor           = Cursors.WaitCursor;
            _originalText         = this.Text;
            this.Text             = String.Format("{0} - {1}", _originalText, TEnv.Strings.GetString("Caption.HowToCancel"));

            StartConnection();
        }
Beispiel #15
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 #16
0
        public void StartNewSession(ISession session, IPoderosaView firstView) {
            firstView = AdjustToOuterView(firstView);
            SessionHost host = new SessionHost(this, session);
            _sessionMap.Add(session, host);
            session.InternalStart(host);
            foreach (ISessionListener listener in _sessionListeners)
                listener.OnSessionStart(session);

            //この時点で、少なくとも一つドキュメントがないといけない。2つ以上は不可、でもいいかもしれない
            if (host.DocumentCount == 0)
                throw new InvalidOperationException("session must register at least one document in InternalStart()");
            AttachDocumentAndView(host.DocumentAt(0), firstView);
        }
Beispiel #17
0
 public void InternalDetachView(IPoderosaDocument document, IPoderosaView view)
 {
     Debug.Assert(document == _document);
     _view.Attach(this, null);
     _view = null;
 }
Beispiel #18
0
 private static string ViewName(IPoderosaView view) {
     if (view == null)
         return "null";
     else {
         IContentReplaceableView rv = (IContentReplaceableView)view.GetAdapter(typeof(IContentReplaceableView));
         if (rv != null)
             return rv.GetCurrentContent().GetType().Name;
         else
             return view.GetType().Name;
     }
 }
Beispiel #19
0
        public void DetachView() {
            Debug.Assert(_currentView != null);
            IContentReplaceableView rv = (IContentReplaceableView)_currentView.GetAdapter(typeof(IContentReplaceableView));
            IPoderosaView internalview = rv == null ? _currentView : rv.GetCurrentContent(); //ContentReplaceableViewのときは中身を使用
            _sessionHost.Session.InternalDetachView(_document, internalview);

            if (rv != null && rv.AsControl().Visible)
                rv.AssureEmptyViewClass();

            _currentView = null;
        }
Beispiel #20
0
 private IPoderosaForm ViewToForm(IPoderosaView view) {
     if (view == null)
         return null;
     else {
         return (IPoderosaForm)view.ParentForm.GetAdapter(typeof(IPoderosaForm));
     }
 }
Beispiel #21
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 #22
0
        public void StartNewSession(ISession session, IPoderosaView firstView)
        {
            firstView = AdjustToOuterView(firstView);
            SessionHost host = new SessionHost(this, session);
            _sessionMap.Add(session, host);
            session.InternalStart(host);
            foreach (ISessionListener listener in _sessionListeners)
                listener.OnSessionStart(session);

            //���̎��_�ŁA���Ȃ��Ƃ��ƒh�L�������g���Ȃ��Ƃ����Ȃ��B�Q�ˆȏ�͕s�A�ł�����������Ȃ�
            if (host.DocumentCount == 0)
                throw new InvalidOperationException("session must register at least one document in InternalStart()");
            AttachDocumentAndView(host.DocumentAt(0), firstView);
        }
 public void InternalAttachView(IPoderosaDocument document, IPoderosaView view) {
     _view = (CommandResultViewerControl)view.GetAdapter(typeof(CommandResultViewerControl));
     Debug.Assert(_view != null);
     _view.SetParent(this);
 }
Beispiel #24
0
        public void InternalAttachView(IPoderosaDocument document, IPoderosaView view) {
            Debug.Assert(document==_document);
            ViewBridge viewbridge = (ViewBridge)view.GetAdapter(typeof(ViewBridge));
            _view = viewbridge;
            viewbridge.Attach(this, _document);
            Debug.WriteLine("Replace DUMMYSESSION");

            //苦しい条件だが、Ctrl+Shiftならキャプション変更をテスト
            Keys m = Control.ModifierKeys;
            if(m==(Keys.Control|Keys.Shift)) {
                _caption += "P";
                _document.Caption = _caption;
                SessionManagerPlugin.Instance.RefreshDocumentStatus(document);
            }
        }
Beispiel #25
0
        private static IPoderosaCommand GetPasteCommand(IPoderosaView view)
        {
            IGeneralViewCommands cmds = CommandTargetUtil.AsGeneralViewCommands(view);

            return(cmds == null ? null : cmds.Paste);
        }
Beispiel #26
0
 public void InternalDetachView(IPoderosaDocument document, IPoderosaView view) {
     Debug.Assert(document==_document);
     _view.Attach(this, null);
     _view = null;
 }
Beispiel #27
0
 public void InternalDetachView(IPoderosaDocument document, IPoderosaView view)
 {
     _view = null;
 }
Beispiel #28
0
 private static IPoderosaCommand GetPasteCommand(IPoderosaView view)
 {
     IGeneralViewCommands cmds = CommandTargetUtil.AsGeneralViewCommands(view);
     return cmds == null ? null : cmds.Paste;
 }
Beispiel #29
0
 private DocumentHost FindNewVisibleDoc(IPoderosaView view)
 {
     view = AdjustToOuterView(view);
     //TODO ����͂��������B���̃��[����A�^�u�ł̏��ԁA�A�N�e�B�u�ɂȂ������Ԃ�L���A�ȂǕ����̎�i���l�����邵�A�v���O�C���Ŋg�����ׂ��Ƃ���
     foreach (DocumentHost dh in _documentMap.Values) {
         if (dh.LastAttachedView == view)
             return dh;
     }
     return null;
 }
 public void InternalDetachView(IPoderosaDocument document, IPoderosaView view) {
     _view = null;
 }
Beispiel #31
0
 private DocumentHost FindNewVisibleDoc(IPoderosaView view) {
     view = AdjustToOuterView(view);
     //TODO これはいい加減。このルールも、タブでの順番、アクティブになった順番を記憶、など複数の手段が考えられるし、プラグインで拡張すべきところ
     foreach (DocumentHost dh in _documentMap.Values) {
         if (dh.LastAttachedView == view)
             return dh;
     }
     return null;
 }
Beispiel #32
0
 public void InternalAttachView(IPoderosaDocument document, IPoderosaView view) {
     _view = (PoderosaLogViewControl)view.GetAdapter(typeof(PoderosaLogViewControl));
     Debug.Assert(_view != null);
     _view.SetParent(this);
 }
Beispiel #33
0
 private IPoderosaDocument ViewToActiveDocument(IPoderosaView view) {
     IPoderosaForm form = view.ParentForm;
     IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow));
     if (window != null)
         return window.DocumentTabFeature.ActiveDocument;
     else
         return view.Document;
 }
Beispiel #34
0
        public void ApplySplitInfo(string format)
        {
            try {
                //�����l��
                IPoderosaView[] previous_views = GetAllViews();
                IPoderosaDocument[] documents = new IPoderosaDocument[previous_views.Length]; //�����K�p��A�N�e�B�u�ɂȂ���
                for (int i = 0; i < previous_views.Length; i++)
                    documents[i] = previous_views[i].Document;
                IPoderosaView[] new_views;

                SessionManagerPlugin sm = SessionManagerPlugin.Instance;

                if (format.Length > 0) {
                    Form container = _parent.AsForm();
                    container.SuspendLayout();
                    Control old_root = this.RootControl;
                    _paneDivision.ApplySplitInfo(old_root.Parent, old_root, format,
                        delegate(string label) {
                            return CreateNewPane(_defaultViewFactory, DockStyle.Fill);
                        }); //�Ƃ肠�����f�t�H���g�t�@�N�g���ō쐬
                    container.ResumeLayout(true);
                    _singlePane = null; //�������ɏI������Ƃ��̂�
                    new_views = GetAllViews(); //�V�����̂�擾
                }
                else {
                    IContentReplaceableView view;
                    UnifyAll(out view);
                    new_views = new IPoderosaView[] { view };
                }

                //�����h�L�������g�ɍēK�p
                foreach (DocumentHost dh in sm.GetAllDocumentHosts()) {
                    int index = CollectionUtil.ArrayIndexOf(previous_views, dh.LastAttachedView);
                    if (index != -1) {
                        IPoderosaView new_view = index < new_views.Length ? new_views[index] : new_views[0]; //������������擪��
                        dh.AlternateView(new_view);
                    }
                }

                //��Ƃ��Active��������‚�ēK�p
                for (int i = 0; i < documents.Length; i++) {
                    if (documents[i] != null)
                        sm.AttachDocumentAndView(documents[i], sm.FindDocumentHost(documents[i]).LastAttachedView); //LastAttachedView�͂��̏�̃��[�v�œK�p�ς�
                }

            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
            }
        }
Beispiel #35
0
 private static IPoderosaView AdjustToOuterView(IPoderosaView view) {
     //ContentReplaceableSiteがあればその親を使用する
     IContentReplaceableViewSite s = (IContentReplaceableViewSite)view.GetAdapter(typeof(IContentReplaceableViewSite));
     if (s != null)
         return s.CurrentContentReplaceableView;
     else
         return view;
 }
Beispiel #36
0
        public IPoderosaView AssureViewClass(Type viewclass)
        {
            if (viewclass == _content.GetType())
                return _content; //�_�C�i�~�b�N�Ȓu���͕s�v�AOK�I

            IContentReplaceableViewSite site = (IContentReplaceableViewSite)_content.GetAdapter(typeof(IContentReplaceableViewSite));

            Control p = _content.AsControl().Parent;
            p.SuspendLayout();
            if (site != null)
                site.CurrentContentReplaceableView = null; //IContentReplaceableViewSite�����邩�ǂ����̓I�v�V���i��

            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());
            //���R���g���[���Ƀh�L�������g�������‚��Ă�����A�����O���Ȃ��ƕs����������
            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 #37
0
        //ビューとの関連付け変更
        public void AttachView(IPoderosaView view) {
            _lastAttachedView = view;
            _currentView = view;

            IViewFactory vf = WindowManagerPlugin.Instance.ViewFactoryManager.GetViewFactoryByDoc(_document.GetType());
            IContentReplaceableView rv = (IContentReplaceableView)view.GetAdapter(typeof(IContentReplaceableView));
            IPoderosaView internalview = rv == null ? view : rv.AssureViewClass(vf.GetViewType()); //ContentReplaceableViewのときは中身を使用
            Debug.Assert(vf.GetViewType() == internalview.GetType());
            _sessionHost.Session.InternalAttachView(_document, internalview);
        }
Beispiel #38
0
        //ビューからのコントロールの取得
        private static TerminalControl CastTerminalControl(IPoderosaView view) {
            IContentReplaceableView rv = (IContentReplaceableView)view.GetAdapter(typeof(IContentReplaceableView));
            Debug.Assert(rv!=null); //現状では分割方式でしか動作していないのでここまでは必ず成功
            IPoderosaView content = rv.GetCurrentContent();

            if(content is TerminalView)
                return ((TerminalView)content).TerminalControl;
            else
                return null;
        }
Beispiel #39
0
 //Viewが閉じられるなどで代替のビューに置換する
 public void AlternateView(IPoderosaView view) {
     if (_currentView != null)
         DetachView();
     _lastAttachedView = view;
 }
Beispiel #40
0
 public void ChangeLastAttachedViewForWindow(IPoderosaMainWindow window, IPoderosaView alternative) {
     alternative = AdjustToOuterView(alternative);
     foreach (DocumentHost dh in _documentMap.Values) {
         if (dh.LastAttachedView.ParentForm == window) {
             dh.AlternateView(alternative);
             FireDocViewRelationChange();
         }
     }
 }
Beispiel #41
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; //�֘A�Â���w�肷��h�L�������g����Ƃ�ƌ����Ă����r���[
            IPoderosaForm last_window = ViewToForm(dh.LastAttachedView); //��Ƃ�Ƃ̏��L�E�B���h�E�B���߂Ă�Attach�ł�null�ł��邱�Ƃɂ��イ��

            //���݂̊֘A���U�؂�
            if (previous_view != null) {
                Debug.WriteLineIf(DebugOpt.DumpDocumentRelation, "Detach Prev View " + ViewName(previous_view));
                dh.DetachView();
            }
            Debug.Assert(dh.CurrentView == null);

            //�ڑ���Ƀh�L�������g�����݂��Ă���΂����؂藣��
            IPoderosaDocument existing_doc = view.Document;
            if (existing_doc != null) { //�Ώۂ̃r���[�ɌÂ��̂��Ђ��‚��Ă�����O��
                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();
            }

            //�V�K�̐ڑ�
            Debug.Assert(view.Document == null && dh.CurrentView == null); //Attach�������ł��Ă��邱�Ɗm�F
            dh.AttachView(view);

            //�ړ����邱�ƂŐV�K�Ɍ�����悤�ɂȂ�h�L�������g��T��
            if (previous_view != null && previous_view != view) {
                DocumentHost new_visible_doc = ShowBackgroundDocument(previous_view);
                Debug.Assert(new_visible_doc != dh);
            }

            //�h�L�������g��ۗL����E�B���h�E���ω�������ʒm�B����Attach�ł�last_mainwindow==null�ł��邱�Ƃɒ���
            if (last_window != view.ParentForm) {
                if (last_window != null)
                    NotifyRemove(last_window, document);
                NotifyAdd(ViewToForm(view), document);
            }

            FireDocViewRelationChange();
        }
Beispiel #42
0
 public void SetLastAttachedViewForAllDocuments(IPoderosaView view) {
     view = AdjustToOuterView(view);
     foreach (DocumentHost dh in _documentMap.Values) {
         dh.AlternateView(view);
     }
     FireDocViewRelationChange();
 }
Beispiel #43
0
        private static TerminalControl CastOrCreateTerminalControl(IPoderosaView view) {
            TerminalControl c = CastTerminalControl(view);
            if(c!=null) return c; //キャストできればそれでOK。でなければ作る

            Debug.WriteLine("Creating New TerminalControl");
            IContentReplaceableView rv = (IContentReplaceableView)view.GetAdapter(typeof(IContentReplaceableView));
            TerminalControl tc = new TerminalControl();
            rv.ReplaceContent(new TerminalView(view.ParentForm, tc));
            return tc;
        }
Beispiel #44
0
 //viewの位置にある新規のドキュメントを見えるようにする。ドキュメントの表示位置を変えたとき、閉じたときに実行する
 private DocumentHost ShowBackgroundDocument(IPoderosaView view) {
     DocumentHost new_visible_doc = FindNewVisibleDoc(view);
     if (new_visible_doc != null) {
         new_visible_doc.AttachView(view);
     }
     return new_visible_doc;
 }
Beispiel #45
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();
        }
Beispiel #46
0
 //ViewのマージでのActivate処理
 public void ChangeLastAttachedViewForAllDocuments(IPoderosaView closing_view, IPoderosaView alternative)
 {
     closing_view = AdjustToOuterView(closing_view);
     alternative  = AdjustToOuterView(alternative);
     foreach (DocumentHost dh in _documentMap.Values)
     {
         if (dh.LastAttachedView == closing_view)
         {
             dh.AlternateView(alternative);
             FireDocViewRelationChange();
         }
     }
 }
Beispiel #47
0
 public SplittableViewPane(SplittableViewManager parent, IPoderosaView content)
 {
     _parent = parent;
     Debug.Assert(content != null);
     _content = content;
     IContentReplaceableViewSite site = (IContentReplaceableViewSite)_content.GetAdapter(typeof(IContentReplaceableViewSite));
     if (site != null)
         site.CurrentContentReplaceableView = this;
 }
Beispiel #48
0
 //ViewのマージでのActivate処理
 public void ChangeLastAttachedViewForAllDocuments(IPoderosaView closing_view, IPoderosaView alternative) {
     closing_view = AdjustToOuterView(closing_view);
     alternative = AdjustToOuterView(alternative);
     foreach (DocumentHost dh in _documentMap.Values) {
         if (dh.LastAttachedView == closing_view) {
             dh.AlternateView(alternative);
             FireDocViewRelationChange();
         }
     }
 }
Beispiel #49
0
 public void InternalDetachView(IPoderosaDocument document, IPoderosaView view) {
     Debug.WriteLineIf(DebugOpt.LogViewer, "LogView InternalDetach");
     _view = null;
 }
Beispiel #50
0
        public void InternalDetachView(IPoderosaDocument document, IPoderosaView view) {
            Debug.WriteLineIf(DebugOpt.ViewManagement, "DETACH VIEW");
            Debug.Assert(document == _terminal.IDocument);
            TerminalView tv = (TerminalView)view.GetAdapter(typeof(TerminalView));
            Debug.Assert(tv != null);
            TerminalControl tp = tv.TerminalControl;
            Debug.Assert(tp != null); //Detachするときにはこのビューになっている必要あり

            if (!tp.IsDisposed) {
                _terminal.Detach(tp);
                tp.Detach();
            }

            _terminalControl = null;
        }