Exemplo n.º 1
0
        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);
        }
        protected override void OnClosed(EventArgs e)
        {
            var root = Model.Root;

            if (root != null)
            {
                LayoutRoot layoutRoot = root as LayoutRoot;
                if (layoutRoot != null)
                {
                    layoutRoot.Updated -= OnRootUpdated;
                }

                root.Manager.RemoveFloatingWindow(this);
                root.CollectGarbage();
            }
            if (_overlayWindow != null)
            {
                _overlayWindow.Close();
                _overlayWindow = null;
            }

            base.OnClosed(e);

            if (!CloseInitiatedByUser && (root != null))
            {
                root.FloatingWindows.Remove(_model);
            }

            // We have to clear binding instead of creating a new empty binding.
            BindingOperations.ClearBinding(_model, VisibilityProperty);

            _model.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(_model_PropertyChanged);
            Activated        -= LayoutAnchorableFloatingWindowControl_Activated;
            IsVisibleChanged -= this.LayoutAnchorableFloatingWindowControl_IsVisibleChanged;
            BindingOperations.ClearBinding(this, VisibilityProperty);
            BindingOperations.ClearBinding(this, SingleContentLayoutItemProperty);
        }
Exemplo n.º 3
0
 public abstract Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindow);
Exemplo n.º 4
0
        public override System.Windows.Media.Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel)
        {
            //var anchorablePaneDropTarget = target as AnchorablePaneDropTarget;
            var anchorableFloatingWindowModel      = floatingWindowModel as LayoutAnchorableFloatingWindow;
            var layoutAnchorablePane               = anchorableFloatingWindowModel.RootPanel as ILayoutPositionableElement;
            var layoutAnchorablePaneWithActualSize = anchorableFloatingWindowModel.RootPanel as ILayoutPositionableElementWithActualSize;

            switch (Type)
            {
            case DropTargetType.AnchorablePaneDockBottom:
            {
                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.AnchorablePaneDockTop:
            {
                var targetScreenRect = TargetElement.GetScreenArea();
                targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top);

                targetScreenRect.Height /= 2.0;

                return(new RectangleGeometry(targetScreenRect));
            }

            case DropTargetType.AnchorablePaneDockLeft:
            {
                var targetScreenRect = TargetElement.GetScreenArea();
                targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top);

                targetScreenRect.Width /= 2.0;

                return(new RectangleGeometry(targetScreenRect));
            }

            case DropTargetType.AnchorablePaneDockRight:
            {
                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));
            }

            case DropTargetType.AnchorablePaneDockInside:
            {
                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.TopLeft;
                    pathFigure.Segments.Add(new LineSegment()
                        {
                            Point = new Point(targetScreenRect.Left, translatedDetectionRect.Top)
                        });
                    pathFigure.Segments.Add(new LineSegment()
                        {
                            Point = translatedDetectionRect.TopLeft
                        });
                    pathFigure.Segments.Add(new LineSegment()
                        {
                            Point = translatedDetectionRect.BottomLeft
                        });
                    pathFigure.Segments.Add(new LineSegment()
                        {
                            Point = translatedDetectionRect.BottomRight
                        });
                    pathFigure.Segments.Add(new LineSegment()
                        {
                            Point = translatedDetectionRect.TopRight
                        });
                    pathFigure.Segments.Add(new LineSegment()
                        {
                            Point = new Point(targetScreenRect.Right, translatedDetectionRect.Top)
                        });
                    pathFigure.Segments.Add(new LineSegment()
                        {
                            Point = targetScreenRect.TopRight
                        });
                    pathFigure.IsClosed = true;
                    pathFigure.IsFilled = true;
                    pathFigure.Freeze();
                    return(new PathGeometry(new PathFigure[] { pathFigure }));
                }
            }
            }

            return(null);
        }
        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();
        }
 void CreateOverlayWindow()
 {
     if (_overlayWindow == null)
         _overlayWindow = new OverlayWindow(this);
     Rect rectWindow = new Rect(this.PointToScreenDPIWithoutFlowDirection(new Point()), this.TransformActualSizeToAncestor());
     _overlayWindow.Left = rectWindow.Left;
     _overlayWindow.Top = rectWindow.Top;
     _overlayWindow.Width = rectWindow.Width;
     _overlayWindow.Height = rectWindow.Height;
 }
        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);
        }
 void DestroyOverlayWindow()
 {
     if (_overlayWindow != null)
     {
         _overlayWindow.Close();
         _overlayWindow = null;
     }
 }
        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);
        }
Exemplo n.º 10
0
        public override Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel)
        {
            LayoutAnchorableFloatingWindow layoutAnchorableFloatingWindow = floatingWindowModel as LayoutAnchorableFloatingWindow;
            LayoutAnchorablePaneGroup      rootPanel = layoutAnchorableFloatingWindow.RootPanel;
            LayoutAnchorablePaneGroup      layoutAnchorablePaneGroup = layoutAnchorableFloatingWindow.RootPanel;

            switch (base.Type)
            {
            case DropTargetType.AnchorablePaneDockLeft:
            {
                Rect screenArea = base.TargetElement.GetScreenArea();
                screenArea.Offset(-overlayWindow.Left, -overlayWindow.Top);
                screenArea.Width = screenArea.Width / 2;
                return(new RectangleGeometry(screenArea));
            }

            case DropTargetType.AnchorablePaneDockTop:
            {
                Rect height = base.TargetElement.GetScreenArea();
                height.Offset(-overlayWindow.Left, -overlayWindow.Top);
                height.Height = height.Height / 2;
                return(new RectangleGeometry(height));
            }

            case DropTargetType.AnchorablePaneDockRight:
            {
                Rect width = base.TargetElement.GetScreenArea();
                width.Offset(-overlayWindow.Left, -overlayWindow.Top);
                width.Offset(width.Width / 2, 0);
                width.Width = width.Width / 2;
                return(new RectangleGeometry(width));
            }

            case DropTargetType.AnchorablePaneDockBottom:
            {
                Rect rect = base.TargetElement.GetScreenArea();
                rect.Offset(-overlayWindow.Left, -overlayWindow.Top);
                rect.Offset(0, rect.Height / 2);
                rect.Height = rect.Height / 2;
                return(new RectangleGeometry(rect));
            }

            case DropTargetType.AnchorablePaneDockInside:
            {
                Rect screenArea1 = base.TargetElement.GetScreenArea();
                screenArea1.Offset(-overlayWindow.Left, -overlayWindow.Top);
                if (this._tabIndex == -1)
                {
                    return(new RectangleGeometry(screenArea1));
                }
                Rect rect1 = new Rect(base.DetectionRects[0].TopLeft, base.DetectionRects[0].BottomRight);
                rect1.Offset(-overlayWindow.Left, -overlayWindow.Top);
                PathFigure pathFigure = new PathFigure()
                {
                    StartPoint = screenArea1.TopLeft
                };
                pathFigure.Segments.Add(new LineSegment()
                    {
                        Point = new Point(screenArea1.Left, rect1.Top)
                    });
                pathFigure.Segments.Add(new LineSegment()
                    {
                        Point = rect1.TopLeft
                    });
                pathFigure.Segments.Add(new LineSegment()
                    {
                        Point = rect1.BottomLeft
                    });
                pathFigure.Segments.Add(new LineSegment()
                    {
                        Point = rect1.BottomRight
                    });
                pathFigure.Segments.Add(new LineSegment()
                    {
                        Point = rect1.TopRight
                    });
                pathFigure.Segments.Add(new LineSegment()
                    {
                        Point = new Point(screenArea1.Right, rect1.Top)
                    });
                pathFigure.Segments.Add(new LineSegment()
                    {
                        Point = screenArea1.TopRight
                    });
                pathFigure.IsClosed = true;
                pathFigure.IsFilled = true;
                pathFigure.Freeze();
                return(new PathGeometry(new PathFigure[] { pathFigure }));
            }
            }
            return(null);
        }