/// <summary>DockingHelperを表示し、マウスのイテレータへの当たり判定を行います。</summary> /// <param name="bay">DockingHelperを重ねるDockBayBase</param> /// <param name="pane">PaneHelperを重ねるDockPaneBase</param> /// <returns>マウスオーバーされてるイテレータ</returns> public DragDropEffects GetDragDropEffect(DockBayBase bay, DockPaneBase pane) { //引数bayへDockingHelperを重ねる var rect = new Rect(bay.PointToScreen(new Point(0, 0)), bay.RenderSize); Left = rect.X; Top = rect.Y; Width = rect.Width; Height = rect.Height; Visibility = Visibility.Visible; if (pane != null) { //引数paneの中央へ重なるようにPaneHelperを移動させる var p = pane.TranslatePoint(new Point(pane.ContentLeft, pane.ContentTop), this); PaneHelper.Margin = new Thickness( ((pane.ContentWidth - PaneHelper.RenderSize.Width) / 2) + p.X, ((pane.ContentHeight - PaneHelper.RenderSize.Height) / 2) + p.Y, 0, 0); } //マウスポインタ座標からDragDropEffectsを求める var pt = Mouse.GetPosition(this); var res = (new[] { new {Ind = (FrameworkElement)InTopIndicator, Eff = DragDropEffects.Top}, new {Ind = (FrameworkElement)InBottomIndicator, Eff = DragDropEffects.Bottom}, new {Ind = (FrameworkElement)InLeftIndicator, Eff = DragDropEffects.Left}, new {Ind = (FrameworkElement)InRightIndicator, Eff = DragDropEffects.Right}, new {Ind = (FrameworkElement)OutTopIndicator, Eff = DragDropEffects.OuterTop}, new {Ind = (FrameworkElement)OutBottomIndicator, Eff = DragDropEffects.OuterBottom}, new {Ind = (FrameworkElement)OutLeftIndicator, Eff = DragDropEffects.OuterLeft}, new {Ind = (FrameworkElement)OutRightIndicator, Eff = DragDropEffects.OuterRight}, new {Ind = (FrameworkElement)InCenterIndicator, Eff = DragDropEffects.Fill}, new {Ind = (FrameworkElement)bay, Eff = DragDropEffects.Enter}, }) .Where(pair => pair.Ind.Visibility == System.Windows.Visibility.Visible && new Rect(pair.Ind.TranslatePoint(new Point(), this), pair.Ind.RenderSize).Contains(pt)) .Select(pair => pair.Eff) .Concat(new[] { DragDropEffects.None }) .First(); return res; }
public void AddPanesOf(DockBayBase bay, DockDirection align, DockLength size) { var bayConf = bay.GetConfig(); var pneConf = bayConf.Children.FirstOrDefault(); foreach (var p in ((DockBayLayoutEngine)bay.LayoutEngine).DockPanes .Select(l => (DockPaneBase)l.Target).ToArray()) p.Remove(); var pne = (DockPaneBase)pneConf.Target.Target; pne.Length = size; pne.Align = align; Items.Add(pne); foreach (var pConf in bayConf.Children .Skip(1).Reverse() .Concat(pneConf.Children)) { var pane = (DockPaneBase)pConf.Target.Target; pane.Align = pConf.Align; pane.Length = pConf.Size; pneConf.Target.Target.Items.Add(pane); pane.ApplyConfig(pConf); } }
public DockBayLayoutEngine(DockBayBase target) : base(target) { DockPanes = new List<DockPaneLayoutEngine>(); PaneAdded += pane_PaneAdded; }