private bool Validate(IDock sourceDock, IDock targetDock, object sender, DragEventArgs e, bool bExecute) { var point = DropHelper.GetPosition(sender, e); if (sourceDock != targetDock && sourceDock.Factory is IDockFactory factory) { if (e.DragEffects == DragDropEffects.Copy) { if (bExecute) { // TODO: Clone layout and insert into Views collection. } return(true); } else if (e.DragEffects == DragDropEffects.Move) { if (bExecute) { factory.Move(sourceDock, targetDock); } return(true); } else if (e.DragEffects == DragDropEffects.Link) { if (bExecute) { factory.Swap(sourceDock, targetDock); } return(true); } } return(false); }
/// <inheritdoc/> public bool Validate(object sender, DragEventArgs e, object sourceContext, object targetContext, object state) { if (state is DockOperation operation && sourceContext is IView sourceView && targetContext is IView targetView) { _manager.Position = ToDockPoint(DropHelper.GetPosition(sender, e)); _manager.ScreenPosition = ToDockPoint(DropHelper.GetPositionScreen(sender, e)); Logger.Log($"Validate [{Id}]: {sourceView.Title} -> {targetView.Title} [{operation}] [{_manager.Position}] [{_manager.ScreenPosition}]"); return(_manager.Validate(sourceView, targetView, ToDragAction(e), operation, false)); } return(false); }
private bool Validate(IDock layout, object context, object sender, DragEventArgs e, bool bExecute) { var point = DropHelper.GetPosition(sender, e); switch (sender) { case TabStrip strip: return(ValidateTabStrip(layout, e, bExecute, strip)); case DockPanel panel: return(ValidateDockPanel(layout, e, bExecute, panel)); } if (e.Data.Get(DragDataFormats.Parent) is TabStripItem item) { var strip = item.Parent as TabStrip; if (strip.DataContext is IDock container) { if (bExecute) { int itemIndex = strip.ItemContainerGenerator.IndexFromContainer(item); var position = DropHelper.GetPositionScreen(sender, e); // WIP: This is work in progress. //var splitLayout = container.SplitLayout(context, SplitDirection.Left); //layout.ReplaceView(container, splitLayout); var window = layout.CurrentView.CreateWindow(container, itemIndex, context); window.X = position.X; window.Y = position.Y; window.Width = 300; window.Height = 400; window.Id = "Dock"; window.Title = "Dock"; window.Layout.Title = "Dock"; window.Present(false); return(true); } return(true); } } return(false); }
/// <inheritdoc/> public bool Execute(object sender, DragEventArgs e, object sourceContext, object targetContext, object state) { if (_executed == false && state is DockOperation operation && sourceContext is IView sourceView && targetContext is IView targetView) { _manager.Position = ToDockPoint(DropHelper.GetPosition(sender, e)); _manager.ScreenPosition = ToDockPoint(DropHelper.GetPositionScreen(sender, e)); Logger.Log($"Execute [{Id}]: {sourceView.Title} -> {targetView.Title} [{operation}] [{_manager.Position}] [{_manager.ScreenPosition}]"); bool bResult = _manager.Validate(sourceView, targetView, ToDragAction(e), operation, true); if (bResult == true) { Logger.Log($"Executed [{Id}]: {sourceView.Title} -> {targetView.Title} [{operation}] [{_manager.Position}] [{_manager.ScreenPosition}]"); _executed = true; return(true); } return(false); } return(false); }