Exemple #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 -= _model_PropertyChanged;
        }
Exemple #2
0
        public override Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel)
        {
            var targetModel = _targetPane.Model as ILayoutDocumentPane;

            if (targetModel == null)
            {
                return(null);
            }
            var manager = targetModel.Root.Manager;

            //ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;
            LayoutDocumentPaneGroup parentGroup;
            LayoutPanel             parentGroupPanel;

            if (!FindParentLayoutDocumentPane(targetModel, out parentGroup, out parentGroupPanel))
            {
                return(null);
            }
            var documentPaneControl =
                manager.FindLogicalChildren <FrameworkElement>()
                .OfType <ILayoutControl>()
                .First(
                    d => parentGroup != null ? Equals(d.Model, parentGroup) : Equals(d.Model, parentGroupPanel))
                as
                FrameworkElement;
            var 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);
        }
Exemple #3
0
        public override Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel)
        {
            //var anchorablePaneDropTarget = target as AnchorablePaneDropTarget;

            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));
                }
                var translatedDetectionRect = new Rect(DetectionRects[0].TopLeft, DetectionRects[0].BottomRight);
                translatedDetectionRect.Offset(-overlayWindow.Left, -overlayWindow.Top);
                var pathFigure = new 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 }));
            }
            }

            return(null);
        }
 private void CreateOverlayWindow()
 {
     if (_overlayWindow == null)
         _overlayWindow = new OverlayWindow(this);
     var 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;
 }
Exemple #5
0
        public override Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel)
        {
            var anchorableFloatingWindowModel = floatingWindowModel as LayoutAnchorableFloatingWindow;

            if (anchorableFloatingWindowModel != null)
            {
                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();
        }
 private void DestroyOverlayWindow()
 {
     if (_overlayWindow == null)
         return;
     _overlayWindow.Close();
     _overlayWindow = null;
 }
        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 -= _model_PropertyChanged;
        }
Exemple #8
0
 public abstract Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindow);