0

我们的应用程序在我们的 Windows 应用程序中使用 MonoDevelop.Components.Docking 框架。我们上次更新到最新版本是在 2010 年 11 月。我遇到了一些有趣的行为,这些行为发生在以下情况:

  • 按 DockGroupType.Tabbed ParentGroup 中第一个面板的自动隐藏按钮

  • 将鼠标悬停在折叠的面板上,直到它展开

  • 将面板拖到选项卡组的中心(回到原始位置)并放下

此时,面板调整为显示面板将被放置的位置的蓝色矩形的大小,然后从主窗口取消停靠以浮动在该大小。这仅发生在选项卡式组中的第一项上。我在 DockGroupItem.cs(第 112 行,GetDockTarget(..))中发现了一段被注释掉的代码,似乎它可以处理这个问题。但是,它引用了一个未定义的 DockPosition 类型,CenterAfter。该方法如下,注释掉的部分以粗体显示:

public bool GetDockTarget (DockItem item, int px, int py, Gdk.Rectangle rect, out DockDelegate dockDelegate, out Gdk.Rectangle outrect)
{

 dockDelegate = null;                

 if (item != this.item && this.item.Visible && rect.Contains (px,py)) {

      int xdockMargin = (int) ((double)rect.Width * (1.0 - DockFrame.ItemDockCenterArea)) / 2;

      int ydockMargin = (int) ((double)rect.Height * (1.0 - DockFrame.ItemDockCenterArea)) / 2;

      DockPosition pos;                   

/*    if (ParentGroup.Type == DockGroupType.Tabbed) {

            rect = new Gdk.Rectangle (rect.X + xdockMargin, rect.Y + ydockMargin,rect.Width - xdockMargin*2, rect.Height - ydockMargin*2);

            pos = DockPosition.CenterAfter;

      }

*/    if (px <= rect.X + xdockMargin && ParentGroup.Type != DockGroupType.Horizontal) {

            outrect = new Gdk.Rectangle (rect.X, rect.Y, xdockMargin, rect.Height);

            pos = DockPosition.Left;

      }

      else if (px >= rect.Right - xdockMargin && ParentGroup.Type != DockGroupType.Horizontal) {

            outrect = new Gdk.Rectangle (rect.Right - xdockMargin, rect.Y, xdockMargin, rect.Height);

            pos = DockPosition.Right;

      }

      else if (py <= rect.Y + ydockMargin && ParentGroup.Type != DockGroupType.Vertical) {

            outrect = new Gdk.Rectangle (rect.X, rect.Y, rect.Width, ydockMargin);

            pos = DockPosition.Top;

      }

      else if (py >= rect.Bottom - ydockMargin && ParentGroup.Type != DockGroupType.Vertical) {

            outrect = new Gdk.Rectangle (rect.X, rect.Bottom - ydockMargin, rect.Width, ydockMargin);

            pos = DockPosition.Bottom;

      }

      else {

            outrect = new Gdk.Rectangle (rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin*2, rect.Height - ydockMargin*2);

            pos = DockPosition.Center;
      }          

      dockDelegate = delegate (DockItem dit) {

            DockGroupItem it = ParentGroup.AddObject (dit, pos, Id);

            it.SetVisible (true);

            ParentGroup.FocusItem (it);

      };

      return true;
 }

 outrect = Gdk.Rectangle.Zero;
 return false;
}

我已经尝试了一些小事情,但到目前为止没有任何影响行为。关于我可以编辑什么以使其正常工作的任何想法?谢谢!

4

1 回答 1

0

为了解决上面的问题,我添加了一个检查以查看停靠的项目是否与选项卡组中的第一个项目相同,如果是,则适当地修改插入索引,因为尝试在组中将项目插入自身之前会导致浮动问题。由于它的状态是“自动隐藏”,它在技术上仍然是可见的,所以被保存在选项卡组的可见对象列表中。变化如下。

DockGroup.cs(第 122 行) - 注释掉索引增加:

public DockGroupItem AddObject (DockItem obj, DockPosition pos, string relItemId)
{
...
else if (pos == DockPosition.CenterBefore || pos == DockPosition.Center) {
                if (type != DockGroupType.Tabbed)
                    gitem = Split (DockGroupType.Tabbed, pos == DockPosition.CenterBefore, obj, npos);
                else {
                    //if (pos == DockPosition.Center) // removed to fix issue with drag/docking the 1st tab item after autohiding 
                        //npos++;
                    gitem = new DockGroupItem (Frame, obj);
                    dockObjects.Insert (npos, gitem);
                    gitem.ParentGroup = this;
                }
            }
            ResetVisibleGroups ();
            return gitem;
}

DockGroup.cs(第 912 行) - 添加了对同一项目的检查

internal override bool GetDockTarget (DockItem item, int px, int py, out DockDelegate dockDelegate, out Gdk.Rectangle rect)
        {
            if (!Allocation.Contains (px, py) || VisibleObjects.Count == 0) {
                dockDelegate = null;
                rect = Gdk.Rectangle.Zero;
                return false;
            }

            if (type == DockGroupType.Tabbed) {
                // this is a fix for issue with drag/docking the 1st tab item after autohiding it
                int pos = 0;
                if (item.Id == ((DockGroupItem)VisibleObjects[0]).Id)
                {
                    pos++;
                }

                // Tabs can only contain DockGroupItems
                return ((DockGroupItem)VisibleObjects[pos]).GetDockTarget (item, px, py, Allocation, out dockDelegate, out rect);
            }
...
于 2011-06-24T16:31:04.187 回答