protected override void OnClosed(EventArgs e) { var root = Model.Root; root.Manager.RemoveFloatingWindow(this); root.CollectGarbage(); if (_overlayWindow != null) { _overlayWindow.Close(); _overlayWindow = null; } base.OnClosed(e); if (!CloseInitiatedByUser) { root.FloatingWindows.Remove(_model); } _model.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(_model_PropertyChanged); }
public override System.Windows.Media.Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel) { var anchorableFloatingWindowModel = floatingWindowModel as LayoutAnchorableFloatingWindow; var layoutAnchorablePane = anchorableFloatingWindowModel.RootPanel as ILayoutPositionableElement; var layoutAnchorablePaneWithActualSize = anchorableFloatingWindowModel.RootPanel as ILayoutPositionableElementWithActualSize; var targetScreenRect = TargetElement.GetScreenArea(); switch (Type) { case DropTargetType.DockingManagerDockLeft: { var desideredWidth = layoutAnchorablePane.DockWidth.IsAbsolute ? layoutAnchorablePane.DockWidth.Value : layoutAnchorablePaneWithActualSize.ActualWidth; var previewBoxRect = new Rect( targetScreenRect.Left - overlayWindow.Left, targetScreenRect.Top - overlayWindow.Top, Math.Min(desideredWidth, targetScreenRect.Width / 2.0), targetScreenRect.Height); return(new RectangleGeometry(previewBoxRect)); } case DropTargetType.DockingManagerDockTop: { var desideredHeight = layoutAnchorablePane.DockHeight.IsAbsolute ? layoutAnchorablePane.DockHeight.Value : layoutAnchorablePaneWithActualSize.ActualHeight; var previewBoxRect = new Rect( targetScreenRect.Left - overlayWindow.Left, targetScreenRect.Top - overlayWindow.Top, targetScreenRect.Width, Math.Min(desideredHeight, targetScreenRect.Height / 2.0)); return(new RectangleGeometry(previewBoxRect)); } case DropTargetType.DockingManagerDockRight: { var desideredWidth = layoutAnchorablePane.DockWidth.IsAbsolute ? layoutAnchorablePane.DockWidth.Value : layoutAnchorablePaneWithActualSize.ActualWidth; var previewBoxRect = new Rect( targetScreenRect.Right - overlayWindow.Left - Math.Min(desideredWidth, targetScreenRect.Width / 2.0), targetScreenRect.Top - overlayWindow.Top, Math.Min(desideredWidth, targetScreenRect.Width / 2.0), targetScreenRect.Height); return(new RectangleGeometry(previewBoxRect)); } case DropTargetType.DockingManagerDockBottom: { var desideredHeight = layoutAnchorablePane.DockHeight.IsAbsolute ? layoutAnchorablePane.DockHeight.Value : layoutAnchorablePaneWithActualSize.ActualHeight; var previewBoxRect = new Rect( targetScreenRect.Left - overlayWindow.Left, targetScreenRect.Bottom - overlayWindow.Top - Math.Min(desideredHeight, targetScreenRect.Height / 2.0), targetScreenRect.Width, Math.Min(desideredHeight, targetScreenRect.Height / 2.0)); return(new RectangleGeometry(previewBoxRect)); } } throw new InvalidOperationException(); }
public override System.Windows.Media.Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel) { switch (Type) { case DropTargetType.DocumentPaneDockInside: { var targetScreenRect = TargetElement.GetScreenArea(); targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top); if (_tabIndex == -1) { return(new RectangleGeometry(targetScreenRect)); } else { var translatedDetectionRect = new Rect(DetectionRects[0].TopLeft, DetectionRects[0].BottomRight); translatedDetectionRect.Offset(-overlayWindow.Left, -overlayWindow.Top); var pathFigure = new PathFigure(); pathFigure.StartPoint = targetScreenRect.BottomRight; pathFigure.Segments.Add(new LineSegment() { Point = new Point(targetScreenRect.Right, translatedDetectionRect.Bottom) }); pathFigure.Segments.Add(new LineSegment() { Point = translatedDetectionRect.BottomRight }); pathFigure.Segments.Add(new LineSegment() { Point = translatedDetectionRect.TopRight }); pathFigure.Segments.Add(new LineSegment() { Point = translatedDetectionRect.TopLeft }); pathFigure.Segments.Add(new LineSegment() { Point = translatedDetectionRect.BottomLeft }); pathFigure.Segments.Add(new LineSegment() { Point = new Point(targetScreenRect.Left, translatedDetectionRect.Bottom) }); pathFigure.Segments.Add(new LineSegment() { Point = targetScreenRect.BottomLeft }); pathFigure.IsClosed = true; pathFigure.IsFilled = true; pathFigure.Freeze(); return(new PathGeometry(new PathFigure[] { pathFigure })); } } case DropTargetType.DocumentPaneDockBottom: { var targetScreenRect = TargetElement.GetScreenArea(); targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top); targetScreenRect.Offset(0.0, targetScreenRect.Height / 2.0); targetScreenRect.Height /= 2.0; return(new RectangleGeometry(targetScreenRect)); } case DropTargetType.DocumentPaneDockTop: { var targetScreenRect = TargetElement.GetScreenArea(); targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top); targetScreenRect.Height /= 2.0; return(new RectangleGeometry(targetScreenRect)); } case DropTargetType.DocumentPaneDockLeft: { var targetScreenRect = TargetElement.GetScreenArea(); targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top); targetScreenRect.Width /= 2.0; return(new RectangleGeometry(targetScreenRect)); } case DropTargetType.DocumentPaneDockRight: { var targetScreenRect = TargetElement.GetScreenArea(); targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top); targetScreenRect.Offset(targetScreenRect.Width / 2.0, 0.0); targetScreenRect.Width /= 2.0; return(new RectangleGeometry(targetScreenRect)); } } return(null); }
public abstract Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindow);
public override System.Windows.Media.Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel) { Rect targetScreenRect; ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane; var manager = targetModel.Root.Manager; //ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane; LayoutDocumentPaneGroup parentGroup; LayoutPanel parentGroupPanel; if (!FindParentLayoutDocumentPane(targetModel, out parentGroup, out parentGroupPanel)) { return(null); } //if (targetModel.Parent is LayoutDocumentPaneGroup) //{ // var parentGroup = targetModel.Parent as LayoutDocumentPaneGroup; // var documentPaneGroupControl = manager.FindLogicalChildren<LayoutDocumentPaneGroupControl>().First(d => d.Model == parentGroup); // targetScreenRect = documentPaneGroupControl.GetScreenArea(); //} //else //{ // var documentPaneControl = manager.FindLogicalChildren<LayoutDocumentPaneControl>().First(d => d.Model == targetModel); // targetScreenRect = documentPaneControl.GetScreenArea(); //} //var parentPanel = targetModel.FindParent<LayoutPanel>(); var documentPaneControl = manager.FindLogicalChildren <FrameworkElement>().OfType <ILayoutControl>().First(d => parentGroup != null ? d.Model == parentGroup : d.Model == parentGroupPanel) as FrameworkElement; targetScreenRect = documentPaneControl.GetScreenArea(); switch (Type) { case DropTargetType.DocumentPaneDockAsAnchorableBottom: { targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top); targetScreenRect.Offset(0.0, targetScreenRect.Height - targetScreenRect.Height / 3.0); targetScreenRect.Height /= 3.0; return(new RectangleGeometry(targetScreenRect)); } case DropTargetType.DocumentPaneDockAsAnchorableTop: { targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top); targetScreenRect.Height /= 3.0; return(new RectangleGeometry(targetScreenRect)); } case DropTargetType.DocumentPaneDockAsAnchorableRight: { targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top); targetScreenRect.Offset(targetScreenRect.Width - targetScreenRect.Width / 3.0, 0.0); targetScreenRect.Width /= 3.0; return(new RectangleGeometry(targetScreenRect)); } case DropTargetType.DocumentPaneDockAsAnchorableLeft: { targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top); targetScreenRect.Width /= 3.0; return(new RectangleGeometry(targetScreenRect)); } } return(null); }