예제 #1
0
        private static CommandResult CmdCloseCurrentDocument(ICommandTarget target)
        {
            IPoderosaDocument document = CommandTargetUtil.AsDocumentOrViewOrLastActivatedDocument(target);

            if (document == null)
            {
                return(CommandResult.Ignored);
            }

            SessionManagerPlugin sm     = SessionManagerPlugin.Instance;
            IPoderosaView        view   = sm.FindDocumentHost(document).LastAttachedView;
            IPoderosaMainWindow  window = view == null ? null : (IPoderosaMainWindow)view.ParentForm.GetAdapter(typeof(IPoderosaMainWindow));
            bool was_active             = window == null ? false : window.DocumentTabFeature.ActiveDocument == document;

            PrepareCloseResult result = sm.CloseDocument(document);

            if (result == PrepareCloseResult.Cancel)
            {
                return(CommandResult.Cancelled);
            }

            //同じビューに別のドキュメントが来ていればそれをアクティブに
            if (was_active)
            {
                IPoderosaDocument newdoc = view.Document;
                if (newdoc != null)
                {
                    sm.ActivateDocument(newdoc, ActivateReason.InternalAction);
                }
            }

            return(CommandResult.Succeeded);
        }
예제 #2
0
        public void MouseMiddleButton(TabKey key)
        {
            IPoderosaDocument    doc = KeyToDocument(key);
            SessionManagerPlugin sm  = SessionManagerPlugin.Instance;

            bool          was_active = _tabBarTable.ActiveTabKey == key;
            IPoderosaView view       = sm.FindDocumentHost(doc).LastAttachedView;

            sm.CloseDocument(doc);

            //アクティブなやつを閉じたらば
            if (was_active && view != null && view.Document != null)
            {
                sm.ActivateDocument(view.Document, ActivateReason.InternalAction);
            }
        }