DockPanel Suite(Problem with activated document)

DockPanel Suite(Problem with activated document)

近期在看wenfenluo兄的DockPanel Suite,DockPanel Suite是.Net下WinForm开发的界面开发工具包,它可以良好的仿制vs.net2003的风格,

实现自动隐藏,浮动等功能,详细请查看http://sourceforge.net/projects/dockpanelsuite/

感受到其非凡的功能,但其中也发现一些小的bug,在此做以标记,以备后查!

bug描述:
比如,当我建立打开3个Document窗口(Document1,Document2,Document3),一个Solution Explorer时!
现在我选择的是Document3文档显示,但是如果进行Solution Explorer自动隐藏或关闭时,
就会显示Document1了,而并不是当前我选中的doucment3,也就是说,在进行Solution Explorer自动隐藏时,会重新定位当前Show的窗体!

Solution:
对于上面的bug问题,困扰我一段时间,查询N多资料,并没什么好的办法,N久才发现下面的东东让我比较感觉兴趣
http://sourceforge.net/forum/forum.php?thread_id=1550843&forum_id=402316
在此感谢outsider (outshider) 的回复,虽然解决方案并不是非常理想的,但也不失为一种解决办法。
1.解决状态变换时Document变换的问题请用按照下面方法修改源码:
The active document changes after the call to SetParent(); in DockPane.cs::RefreshStateChange. I haven't found the exact

location, so the solution is pretty lame: I wrapped the call with some code that saves the active document. The result is a

flicker as the old document becomes active again...should do until I have the time to look deeper into the problem.
 
Form f = null;
if (this.ParentForm != null)
f = this.ParentForm.ActiveMdiChild;
SetParent();//original call
if (f != null)
f.Activate();

2.解决关闭时Document变换的问题,请再按照下面方法修改源码:
Ok...now it loses the active document in DockWindow::OnLayout. 
Saving/restoring the active document works, but I don't like it:  
if (DisplayingList.Count == 0) 

if (Visible) 

Form c = null;
if (DockPanel != null && DockPanel.ParentForm.ActiveMdiChild != null)
c = DockPanel.ParentForm.ActiveMdiChild;
Visible = false; //original code 
if (c != null)
c.Activate();

}

原文地址:https://www.cnblogs.com/linfuguo/p/562565.html