Esempio n. 1
0
        private static CustomPopupPlacement[] CustomPopupPlacementCallbackImpl(Size popupSize, Size targetSize, Point offset)
        {
            var verticalPlacement   = new CustomPopupPlacement(offset, PopupPrimaryAxis.Vertical);
            var horizontalPlacement = new CustomPopupPlacement(offset, PopupPrimaryAxis.Horizontal);

            return(new[] { verticalPlacement, horizontalPlacement });
        }
Esempio n. 2
0
        private CustomPopupPlacement[] PlaceAutocompletePopup(Size popupSize, Size targetSize, Point offset)
        {
            var zoom = _node.WorkspaceViewModel.Zoom;

            double x;
            var    scaledSpacing = autocompletePopupSpacing * targetSize.Width / _node.ActualWidth;

            if (PortModel.PortType == PortType.Input)
            {
                // Offset popup to the left by its width from left edge of node and spacing.
                x = -scaledSpacing - popupSize.Width;
            }
            else
            {
                // Offset popup to the right by node width and spacing from left edge of node.
                x = scaledSpacing + targetSize.Width;
            }
            // Offset popup down from the upper edge of the node by the node header and corresponding to the respective port.
            // Scale the absolute heights by the target height (passed to the callback) and the actual height of the node.
            var scaledHeight   = targetSize.Height / _node.ActualHeight;
            var absoluteHeight = NodeModel.HeaderHeight + PortModel.Index * PortModel.Height;
            var y = absoluteHeight * scaledHeight;

            var placement = new CustomPopupPlacement(new Point(x, y), PopupPrimaryAxis.None);

            return(new[] { placement });
        }
Esempio n. 3
0
        //<SnippetDelegateInstance>
        public CustomPopupPlacement[] placePopup(Size popupSize,
                                                 Size targetSize,
                                                 Point offset)
        {
            //var height = Screen.PrimaryScreen.- System.Windows.SystemParameters.WorkArea.Height;
            //var width = System.Windows.SystemParameters.WorkArea.Width;
            var point = SystemParameters.WorkArea.BottomRight;

            point.Y = point.Y - popupSize.Height;

            var width  = Screen.PrimaryScreen.WorkingArea.Width - _text.Width;
            var height = Screen.PrimaryScreen.WorkingArea.Height - _text.Height;

            Debug.WriteLine("popup size = " + popupSize);
            Debug.WriteLine("target Size = " + targetSize);
            Debug.WriteLine("offset = " + offset);
            Debug.WriteLine("Width = " + Screen.PrimaryScreen.WorkingArea.Width + " - " + _text.Width + "=" + width);
            Debug.WriteLine("Height = " + Screen.PrimaryScreen.WorkingArea.Height + " - " + _text.Height + "=" + height);
            CustomPopupPlacement placement1 =
                new CustomPopupPlacement(new Point(width, height), PopupPrimaryAxis.Horizontal);

//            CustomPopupPlacement placement2 =
//               new CustomPopupPlacement(new Point(2000, 20), PopupPrimaryAxis.Horizontal);

            CustomPopupPlacement[] ttplaces =
                new CustomPopupPlacement[] { placement1 };
            return(ttplaces);
        }
Esempio n. 4
0
        internal static CustomPopupPlacement[] PositionPopup(
            CustomPlacementMode placement,
            Size popupSize,
            Size targetSize,
            Point offset,
            FrameworkElement child = null)
        {
            Matrix transformToDevice = default;

            if (child != null)
            {
                Helper.TryGetTransformToDevice(child, out transformToDevice);
            }

            CustomPopupPlacement preferredPlacement = CalculatePopupPlacement(placement, popupSize, targetSize, offset, child, transformToDevice);

            CustomPopupPlacement?alternativePlacement = null;
            var alternativePlacementMode = GetAlternativePlacementMode(placement);

            if (alternativePlacementMode.HasValue)
            {
                alternativePlacement = CalculatePopupPlacement(alternativePlacementMode.Value, popupSize, targetSize, offset, child, transformToDevice);
            }

            if (alternativePlacement.HasValue)
            {
                return(new[] { preferredPlacement, alternativePlacement.Value });
            }
            else
            {
                return(new[] { preferredPlacement });
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Get the point at which callout will be placed and show the correct pointer.
        /// </summary>
        /// <param name="popupSize">Size.</param>
        /// <param name="targetSize">Size.</param>
        /// <param name="offset">Point.</param>
        /// <returns>If the Popup is hidden by a screen edge at the first position,
        /// the Popup is placed at the second position and so on.</returns>
        private CustomPopupPlacement[] _GetTopLeftPointShowPointer
            (Size popupSize, Size targetSize, Point offset)
        {
            // If visible part of the cell is smaller then callout pointer - dont show callout.
            if (targetSize.Height < _pointerHeight ||
                targetSize.Width < _ConvertWidth(_pointerHorizontalOffset))
            {
                Close(true);
                return(null);
            }

            // Point in which top left corner of callout will be placed.
            CustomPopupPlacement topLeftPoint;

            // Check that this is callout with upper pointer.
            if (_IsUpperPointer())
            {
                _MakeTopPointerVisible();

                // Check that this is left/right pointer and provide proper points for pointer.
                if (_IsLeftPointer())
                {
                    TopPointer.Points = _GetTopLeftPoints();
                    // Callout will point to bottom left corner of target.
                    topLeftPoint = new CustomPopupPlacement(
                        new Point(0, targetSize.Height), PopupPrimaryAxis.Vertical);
                }
                else
                {
                    TopPointer.Points = _GetTopRightPoints(grid.ActualWidth);

                    // Callout will point to bottom right corner of target.
                    topLeftPoint = new CustomPopupPlacement(
                        new Point(targetSize.Width - popupSize.Width, targetSize.Height), PopupPrimaryAxis.Vertical);
                }
            }
            else
            {
                _MakeBottomPointerVisible();

                if (_IsLeftPointer())
                {
                    BottomPointer.Points = _GetBottomLeftPoints();
                    // Callout will point to upper left corner of target.
                    topLeftPoint = new CustomPopupPlacement(
                        new Point(0, -popupSize.Height), PopupPrimaryAxis.Horizontal);
                }
                else
                {
                    BottomPointer.Points = _GetBottomRightPoints(grid.ActualWidth);
                    // Callout will point to upper right corner of target.
                    topLeftPoint = new CustomPopupPlacement(
                        new Point(targetSize.Width - popupSize.Width, -popupSize.Height), PopupPrimaryAxis.Horizontal);
                }
            }
            CustomPopupPlacement[] points = new CustomPopupPlacement[] { topLeftPoint };

            return(points);
        }
        public void ShowNotification(INotification notification)
        {
            Argument.IsNotNull(() => notification);

            if (IsSuspended)
            {
                Log.Debug("Notifications are suspended, queueing notification");

                _notificationsQueue.Enqueue(notification);

                return;
            }

            _dispatcherService.BeginInvoke(() =>
            {
                EnsureMainWindow();

                var hasActiveWindows = HasActiveWindows();
                if (!hasActiveWindows && notification.Priority <= NotificationPriority.Normal)
                {
                    Log.Debug($"Not showing notification '{notification}' since priority is '{notification.Priority}' and app has no active windows.");
                    return;
                }

                Log.Debug("Showing notification '{0}'", notification);

                var notificationLocation = _notificationPositionService.GetLeftTopCorner(NotificationSize, CurrentNotifications.Count);

                var popup = new Popup();

                popup.AllowsTransparency            = true;
                popup.Placement                     = PlacementMode.Custom;
                popup.CustomPopupPlacementCallback += (popupSize, targetSize, offset) =>
                {
                    var x = DpiHelper.CalculateSize(DpiHelper.DpiX, notificationLocation.X);
                    var y = DpiHelper.CalculateSize(DpiHelper.DpiY, notificationLocation.Y);

                    var popupPlacement = new CustomPopupPlacement(new Point(x, y), PopupPrimaryAxis.None);

                    var ttplaces = new[] { popupPlacement };
                    return(ttplaces);
                };

                var notificationViewModel          = _viewModelFactory.CreateViewModel <NotificationViewModel>(notification, null);
                notificationViewModel.ClosedAsync += async(sender, e) => popup.IsOpen = false;

                var notificationView         = new NotificationView();
                notificationView.DataContext = notificationViewModel;
                notificationView.Unloaded   += OnNotificationViewUnloaded;

                popup.Child = notificationView;

                popup.IsOpen = true;

                OpenedNotification?.Invoke(this, new NotificationEventArgs(notification));

                CurrentNotifications.Add(notification);
            });
        }
Esempio n. 7
0
 public CustomPopupPlacement[] placePopup(Size popupSize, Size targetSize, Point offset)
 {
     CustomPopupPlacement[] ttplaces =
         new CustomPopupPlacement[] { new CustomPopupPlacement() };
     ttplaces[0].Point       = new Point(-50, 90);
     ttplaces[0].PrimaryAxis = PopupPrimaryAxis.Vertical;
     return(ttplaces);
 }
Esempio n. 8
0
        public void ShowNotification(INotification notification)
        {
            Argument.IsNotNull(() => notification);

            if (IsSuspended)
            {
                Log.Debug("Notifications are suspended, queueing notification");

                _notificationsQueue.Enqueue(notification);

                return;
            }

            EnsureMainWindow();

            _dispatcherService.BeginInvoke(() =>
            {
                Log.Debug("Showing notification '{0}'", notification);

                var notificationLocation = _notificationPositionService.GetLeftTopCorner(NotificationSize, CurrentNotifications.Count);

                var popup = new Popup();

                popup.AllowsTransparency            = true;
                popup.Placement                     = PlacementMode.Custom;
                popup.CustomPopupPlacementCallback += (popupSize, targetSize, offset) =>
                {
                    var x = DpiHelper.CalculateSize(DpiHelper.DpiX, notificationLocation.X);
                    var y = DpiHelper.CalculateSize(DpiHelper.DpiY, notificationLocation.Y);

                    var popupPlacement = new CustomPopupPlacement(new Point(x, y), PopupPrimaryAxis.None);

                    var ttplaces = new [] { popupPlacement };
                    return(ttplaces);
                };

                //popup.Placement = PlacementMode.AbsolutePoint;
                //popup.PlacementRectangle = new Rect(notificationLocation.X, notificationLocation.Y, NotificationSize.Width, NotificationSize.Height);

                var notificationViewModel          = _viewModelFactory.CreateViewModel <NotificationViewModel>(notification);
                notificationViewModel.ClosedAsync += async(sender, e) => popup.IsOpen = false;

                // TODO: consider factory
                var notificationView         = new NotificationView();
                notificationView.DataContext = notificationViewModel;
                notificationView.Unloaded   += OnNotificationViewUnloaded;

                popup.Child = notificationView;

                popup.IsOpen = true;

                OpenedNotification.SafeInvoke(this, new NotificationEventArgs(notification));

                CurrentNotifications.Add(notification);
            });
        }
        protected virtual CustomPopupPlacement[] CalculatePopupPlacement(Size popupSize, Size targetSize, Point offset)
        {
            var verticalOffsets   = GetVerticalOffsets(VerticalPlacement, popupSize.Height, targetSize.Height, offset.Y);
            var horizontalOffsets = GetHorizontalOffsets(HorizontalPlacement, popupSize.Width, targetSize.Width, offset.X);

            var placement1 = new CustomPopupPlacement(new Point(horizontalOffsets[0], verticalOffsets[0]), PopupPrimaryAxis.Vertical);
            var placement2 = new CustomPopupPlacement(new Point(horizontalOffsets[1], verticalOffsets[1]), PopupPrimaryAxis.Horizontal);

            return(new[] { placement1, placement2 });
        }
Esempio n. 10
0
 public CustomPopupPlacement[] placeToolTip(Size popupSize,
                                            Size targetSize,
                                            Point offset)
 {
     CustomPopupPlacement[] ttplaces =
         new CustomPopupPlacement[] { new CustomPopupPlacement() };
     ttplaces[0].Point       = new Point(0, 80);
     ttplaces[0].PrimaryAxis = PopupPrimaryAxis.Horizontal;
     return(ttplaces);
 }
Esempio n. 11
0
        CustomPopupPlacement[] placePopup(Size popupSize, Size targetSize, Point offset)
        {
            double xOffset = (double)this.AssociatedObject.CaretPosition.GetCharacterRect(LogicalDirection.Forward).Right;
            double yOffset = (double)this.AssociatedObject.CaretPosition.GetCharacterRect(LogicalDirection.Forward).Bottom;

            CustomPopupPlacement placementSubstitution = new CustomPopupPlacement(new Point(xOffset, -this.Height), PopupPrimaryAxis.Vertical);
            CustomPopupPlacement placementDefault      = new CustomPopupPlacement(new Point(xOffset, yOffset), PopupPrimaryAxis.Horizontal);

            return(new CustomPopupPlacement[] { placementDefault, placementSubstitution });
        }
Esempio n. 12
0
        // Calculate two variants: below and upper ribbon
        private CustomPopupPlacement[] CustomPopupPlacementMethod(Size popupSize, Size targetSize, Point offset)
        {
            if (this.PlacementTarget is null)
            {
#if NETCOREAPP3_0
                return(Array.Empty <CustomPopupPlacement>());
#else
                return(new CustomPopupPlacement[] { });
#endif
            }

            Ribbon    ribbon          = null;
            UIElement topLevelElement = null;
            FindControls(this.PlacementTarget, ref ribbon, ref topLevelElement);

            // Exclude QAT items
            var notQuickAccessItem  = !IsQuickAccessItem(this.PlacementTarget);
            var notContextMenuChild = !IsContextMenuChild(this.PlacementTarget);
            var rightToLeftOffset   = this.FlowDirection == FlowDirection.RightToLeft
                                           ? -popupSize.Width
                                           : 0;

            var decoratorChild = GetDecoratorChild(topLevelElement);

            if (notQuickAccessItem &&
                this.IsRibbonAligned &&
                ribbon != null)
            {
                var belowY = ribbon.TranslatePoint(new Point(0, ribbon.ActualHeight), this.PlacementTarget).Y;
                var aboveY = ribbon.TranslatePoint(new Point(0, 0), this.PlacementTarget).Y - popupSize.Height;
                var below  = new CustomPopupPlacement(new Point(rightToLeftOffset, belowY + 1), PopupPrimaryAxis.Horizontal);
                var above  = new CustomPopupPlacement(new Point(rightToLeftOffset, aboveY - 1), PopupPrimaryAxis.Horizontal);
                return(new[] { below, above });
            }

            if (notQuickAccessItem &&
                this.IsRibbonAligned &&
                notContextMenuChild &&
                topLevelElement is Window == false &&
                decoratorChild != null)
            {
                // Placed on Popup?
                var belowY = decoratorChild.TranslatePoint(new Point(0, ((FrameworkElement)decoratorChild).ActualHeight), this.PlacementTarget).Y;
                var aboveY = decoratorChild.TranslatePoint(new Point(0, 0), this.PlacementTarget).Y - popupSize.Height;
                var below  = new CustomPopupPlacement(new Point(rightToLeftOffset, belowY + 1), PopupPrimaryAxis.Horizontal);
                var above  = new CustomPopupPlacement(new Point(rightToLeftOffset, aboveY - 1), PopupPrimaryAxis.Horizontal);
                return(new[] { below, above });
            }

            return(new[]
            {
                new CustomPopupPlacement(new Point(rightToLeftOffset, this.PlacementTarget.RenderSize.Height + 1), PopupPrimaryAxis.Horizontal),
                new CustomPopupPlacement(new Point(rightToLeftOffset, -popupSize.Height - 1), PopupPrimaryAxis.Horizontal)
            });
        }
Esempio n. 13
0
        public static CustomPopupPlacement[] RightCenteredPlacement(
            Size popupSize, Size targetSize, Point offset)
        {
            var centerY        = (targetSize.Height - popupSize.Height) / 2;
            var leftCenter     = new Point(-popupSize.Width - offset.X, centerY + offset.Y);
            var rightCenter    = new Point(targetSize.Width + offset.X, centerY + offset.Y);
            var leftPlacement  = new CustomPopupPlacement(leftCenter, PopupPrimaryAxis.Vertical);
            var rightPlacement = new CustomPopupPlacement(rightCenter, PopupPrimaryAxis.Vertical);

            return(new[] { rightPlacement, leftPlacement });
        }
Esempio n. 14
0
        public static CustomPopupPlacement[] BottomCenteredPlacement(
            Size popupSize, Size targetSize, Point offset)
        {
            var centerX         = (targetSize.Width - popupSize.Width) / 2;
            var topCenter       = new Point(centerX + offset.X, -popupSize.Height - offset.Y);
            var bottomCenter    = new Point(centerX + offset.X, targetSize.Height + offset.Y);
            var topPlacement    = new CustomPopupPlacement(topCenter, PopupPrimaryAxis.Horizontal);
            var bottomPlacement = new CustomPopupPlacement(bottomCenter, PopupPrimaryAxis.Horizontal);

            return(new[] { bottomPlacement, topPlacement });
        }
Esempio n. 15
0
        public CustomPopupPlacement[] PlacePopup(Size popupSize, Size targetSize, Point offset)
        {
            CustomPopupPlacement placement;

            DpiScale dpiScale = VisualTreeHelper.GetDpi(this);

            switch ((AppBarEdge)Settings.Instance.Edge)
            {
            case AppBarEdge.Top:
                if (FlowDirection == FlowDirection.LeftToRight)
                {
                    placement = new CustomPopupPlacement(new Point((popupSize.Width * -1) + (offset.X * dpiScale.DpiScaleX),
                                                                   targetSize.Height + (offset.Y * dpiScale.DpiScaleY)),
                                                         PopupPrimaryAxis.Horizontal);
                }
                else
                {
                    placement = new CustomPopupPlacement(new Point(-1 * offset.X * dpiScale.DpiScaleX,
                                                                   targetSize.Height + (offset.Y * dpiScale.DpiScaleY)),
                                                         PopupPrimaryAxis.Horizontal);
                }
                break;

            case AppBarEdge.Left:
                placement = new CustomPopupPlacement(new Point(offset.X * dpiScale.DpiScaleX - (FlowDirection == FlowDirection.LeftToRight ? 0 : targetSize.Width),
                                                               (popupSize.Height * -1) + (offset.Y * dpiScale.DpiScaleY)),
                                                     PopupPrimaryAxis.Horizontal);
                break;

            case AppBarEdge.Right:
                placement = new CustomPopupPlacement(new Point((popupSize.Width * -1) + (offset.X * dpiScale.DpiScaleX),
                                                               (popupSize.Height * -1) + (offset.Y * dpiScale.DpiScaleY)),
                                                     PopupPrimaryAxis.Horizontal);
                break;

            default:
                // bottom taskbar
                if (FlowDirection == FlowDirection.LeftToRight)
                {
                    placement = new CustomPopupPlacement(new Point((popupSize.Width * -1) + (offset.X * dpiScale.DpiScaleX),
                                                                   (popupSize.Height * -1) + (offset.Y * dpiScale.DpiScaleY)),
                                                         PopupPrimaryAxis.Horizontal);
                }
                else
                {
                    placement = new CustomPopupPlacement(new Point(-1 * offset.X * dpiScale.DpiScaleX,
                                                                   (popupSize.Height * -1) + (offset.Y * dpiScale.DpiScaleY)),
                                                         PopupPrimaryAxis.Horizontal);
                }
                break;
            }

            return(new CustomPopupPlacement[] { placement });
        }
Esempio n. 16
0
        private CustomPopupPlacement[] Location(Size popupSize, Size targetSize, Point offset)
        {
            CustomPopupPlacement placement1 =
                new CustomPopupPlacement(new Point(RelativeRect.X, targetSize.Height + RelativeRect.Y), PopupPrimaryAxis.Vertical);

            CustomPopupPlacement placement2 =
                new CustomPopupPlacement(new Point(0, 0), PopupPrimaryAxis.Horizontal);

            CustomPopupPlacement[] ttplaces =
                new CustomPopupPlacement[] { placement1, placement2 };
            return(ttplaces);
        }
Esempio n. 17
0
        private CustomPopupPlacement[] placePopup(Size popupSize, Size targetSize, Point offset)
        {
            CustomPopupPlacement placement1 =
                new CustomPopupPlacement(new Point(targetSize.Width - popupSize.Width - 10, targetSize.Height - popupSize.Height - 10), PopupPrimaryAxis.Vertical);

            CustomPopupPlacement placement2 =
                new CustomPopupPlacement(new Point(10, 20), PopupPrimaryAxis.Horizontal);

            CustomPopupPlacement[] ttplaces =
                new CustomPopupPlacement[] { placement1, placement2 };
            return(ttplaces);
        }
Esempio n. 18
0
        public CustomPopupPlacement[] PlaceMessagePopup(Size popupSize,
                                                        Size targetSize,
                                                        Point offset)
        {
            Point p = new Point(targetSize.Width - popupSize.Width - 8, 8);

            CustomPopupPlacement placement1 =
                new CustomPopupPlacement(p, PopupPrimaryAxis.Horizontal);

            CustomPopupPlacement[] ttplaces =
                new CustomPopupPlacement[] { placement1 };
            return(ttplaces);
        }
Esempio n. 19
0
        //<SnippetDelegateInstance>
        public CustomPopupPlacement[] placePopup(Size popupSize,
                                                 Size targetSize,
                                                 Point offset)
        {
            CustomPopupPlacement placement1 =
                new CustomPopupPlacement(new Point(1000, 1000), PopupPrimaryAxis.Vertical);

            CustomPopupPlacement placement2 =
                new CustomPopupPlacement(new Point(10, 20), PopupPrimaryAxis.Horizontal);

            CustomPopupPlacement[] ttplaces =
                new CustomPopupPlacement[] { placement1, placement2 };
            return(ttplaces);
        }
        public CustomPopupPlacement[] placePopup(Size popupSize, Size targetSize, Point offset)
        {
            CustomPopupPlacement placement;

            //odgleglosc strzalki do najblizszego konca (15) + rozpoczecie strzalki do srodka strzalki (10)
            var arrowCenterToEndLenght = 25;

            placement = new CustomPopupPlacement(new Point(-((popupSize.Width - targetSize.Width / 2) - arrowCenterToEndLenght), targetSize.Height), PopupPrimaryAxis.Vertical);

            CustomPopupPlacement[] ttplaces =
                new CustomPopupPlacement[] { placement };

            return(ttplaces);
        }
Esempio n. 21
0
        public CustomPopupPlacement[] PlacePopup(Size popupSize, Size targetSize, Point offset)
        {
            Point popupLocation = new Point(targetSize.Width - popupSize.Width, targetSize.Height);

            CustomPopupPlacement placement1 =
                new CustomPopupPlacement(popupLocation, PopupPrimaryAxis.Vertical);

            CustomPopupPlacement placement2 =
                new CustomPopupPlacement(popupLocation, PopupPrimaryAxis.Horizontal);

            CustomPopupPlacement[] ttplaces =
                new CustomPopupPlacement[] { placement1, placement2 };
            return(ttplaces);
        }
Esempio n. 22
0
        private CustomPopupPlacement[] MKPopupPlacement(Size a, Size b, Point c)
        {
            //
            // MKRoot.AlignReferencePoint.

            // TODO: The MenuKiller's align reference report must report when it changes, so we can reposition the
            // Popup... However, it'd be nice to know whether that is possible at all.
            // ISSUE: The popup kills performance, moving it makes matters A LOT worse
            CustomPopupPlacement pl = new CustomPopupPlacement(new Point(0, 0), PopupPrimaryAxis.None);

            CustomPopupPlacement[] arr = new CustomPopupPlacement[1];
            arr[0] = pl;
            return(arr);
        }
        //<SnippetDelegateInstance>
        public CustomPopupPlacement[] placePopup(Size popupSize,
                                                 Size targetSize,
                                                 Point offset)
        {
            var Width = Screen.PrimaryScreen.Bounds.Width;
            CustomPopupPlacement placement1 =
                new CustomPopupPlacement(new Point(2000, 2000), PopupPrimaryAxis.Vertical);

            CustomPopupPlacement placement2 =
                new CustomPopupPlacement(new Point(2000, 20), PopupPrimaryAxis.Horizontal);

            CustomPopupPlacement[] ttplaces =
                new CustomPopupPlacement[] { placement1, placement2 };
            return(ttplaces);
        }
Esempio n. 24
0
        // Calculate two variants: below and upper ribbon
        CustomPopupPlacement[] CustomPopupPlacementMethod(Size popupSize, Size targetSize, Point offset)
        {
            if (PlacementTarget == null)
            {
                return new CustomPopupPlacement[] { }
            }
            ;

            Ribbon    ribbon          = null;
            UIElement topLevelElement = null;

            FindControls(PlacementTarget, ref ribbon, ref topLevelElement);

            // Exclude QAT items
            bool   notQuickAccessItem  = !IsQuickAccessItem(PlacementTarget);
            bool   notContextMenuChild = !IsContextMenuChild(PlacementTarget);
            double rightToLeftOffset   = FlowDirection == FlowDirection.RightToLeft
                                           ? -popupSize.Width
                                           : 0;

            UIElement decoratorChild = GetDecoratorChild(topLevelElement);

            if (notQuickAccessItem && IsRibbonAligned && (ribbon != null))
            {
                double belowY = ribbon.TranslatePoint(new Point(0, ribbon.ActualHeight), PlacementTarget).Y;

                double aboveY = ribbon.TranslatePoint(new Point(0, 0), PlacementTarget).Y - popupSize.Height;
                CustomPopupPlacement below = new CustomPopupPlacement(new Point(rightToLeftOffset, belowY + 1), PopupPrimaryAxis.Horizontal);
                CustomPopupPlacement above = new CustomPopupPlacement(new Point(rightToLeftOffset, aboveY - 1), PopupPrimaryAxis.Horizontal);
                return(new CustomPopupPlacement[] { below, above });
            }
            else if (notQuickAccessItem && IsRibbonAligned && notContextMenuChild && (!(topLevelElement is Window)) && (decoratorChild != null))
            {
                // Placed on Popup?
                double belowY = decoratorChild.TranslatePoint(new Point(0, ((FrameworkElement)decoratorChild).ActualHeight), PlacementTarget).Y;
                double aboveY = decoratorChild.TranslatePoint(new Point(0, 0), PlacementTarget).Y - popupSize.Height;
                CustomPopupPlacement below = new CustomPopupPlacement(new Point(rightToLeftOffset, belowY + 1), PopupPrimaryAxis.Horizontal);
                CustomPopupPlacement above = new CustomPopupPlacement(new Point(rightToLeftOffset, aboveY - 1), PopupPrimaryAxis.Horizontal);
                return(new CustomPopupPlacement[] { below, above });
            }
            else
            {
                return(new CustomPopupPlacement[] {
                    new CustomPopupPlacement(new Point(rightToLeftOffset, PlacementTarget.RenderSize.Height + 1), PopupPrimaryAxis.Horizontal),
                    new CustomPopupPlacement(new Point(rightToLeftOffset, -popupSize.Height - 1), PopupPrimaryAxis.Horizontal)
                });
            }
        }
Esempio n. 25
0
        public CustomPopupPlacement[] PlacePopup(Size popupSize,
                                                 Size targetSize,
                                                 Point offset)
        {
            var p          = TextButton.PointToScreen(new Point(0, 0));
            var placement1 =
                new CustomPopupPlacement(new Point(p.X + TextButton.ActualWidth / 2 - popupSize.Width / 2, p.Y - popupSize.Height), PopupPrimaryAxis.Vertical);

            var placement2 =
                new CustomPopupPlacement(new Point(10, 20), PopupPrimaryAxis.Horizontal);

            var ttplaces =
                new CustomPopupPlacement[] { placement1 };

            return(ttplaces);
        }
        //<SnippetDelegateInstance>
        public CustomPopupPlacement[] placePopup(Size popupSize,
                                                 Size targetSize,
                                                 Point offset)
        {
            var width  = System.Windows.SystemParameters.PrimaryScreenWidth;
            var height = System.Windows.SystemParameters.PrimaryScreenHeight;

            CustomPopupPlacement placement1 =
                new CustomPopupPlacement(new Point(width, height), PopupPrimaryAxis.Vertical);

            CustomPopupPlacement placement2 =
                new CustomPopupPlacement(new Point(2000, 20), PopupPrimaryAxis.Horizontal);

            CustomPopupPlacement[] ttplaces =
                new CustomPopupPlacement[] { placement1, placement2 };
            return(ttplaces);
        }
        private CustomPopupPlacement[] CustomPlacement(Size popupSize, Size targetSize, Point offset)
        {
            System.Windows.Point screenPoint = owningExtension.TranslateToScreenPoint(CursorPosition);


            CustomPopupPlacement bottomPlacement = new CustomPopupPlacement()
            {
                Point       = new Point(screenPoint.X, screenPoint.Y + Configurations.FontDisplayHeight),
                PrimaryAxis = PopupPrimaryAxis.Vertical
            };

            CustomPopupPlacement topPlacement = new CustomPopupPlacement()
            {
                Point       = new Point(screenPoint.X, screenPoint.Y - popupSize.Height),
                PrimaryAxis = PopupPrimaryAxis.Vertical
            };

            return(new CustomPopupPlacement[] { bottomPlacement, topPlacement });
        }
        //<SnippetDelegateInstance>
        public CustomPopupPlacement[] placePopup(Size popupSize,
                                                 Size targetSize,
                                                 Point offset)
        {
            //var height = Screen.PrimaryScreen.- System.Windows.SystemParameters.WorkArea.Height;
            //var width = System.Windows.SystemParameters.WorkArea.Width;
            var width  = Screen.PrimaryScreen.WorkingArea.Width;
            var height = Screen.PrimaryScreen.WorkingArea.Height;

            CustomPopupPlacement placement1 =
                new CustomPopupPlacement(new Point(width, height - 20), PopupPrimaryAxis.Vertical);

//            CustomPopupPlacement placement2 =
//               new CustomPopupPlacement(new Point(2000, 20), PopupPrimaryAxis.Horizontal);

            CustomPopupPlacement[] ttplaces =
                new CustomPopupPlacement[] { placement1 };
            return(ttplaces);
        }
Esempio n. 29
0
        private CustomPopupPlacement[] CustomPopupCallback(Size popupSize, Size targetSize, Point offset)
        {
            //Console.WriteLine(popupSize.Height + " " + popupSize.Width);
            //Console.WriteLine(targetSize.Height);
            //Console.WriteLine(offset);

            CustomPopupPlacement popupPlacement = new CustomPopupPlacement()
            {
                Point = new Point(Math.Abs(popupSize.Width - targetSize.Width) / -2d, targetSize.Height)
            };

            CustomPopupPlacement popupPlacementAlt = new CustomPopupPlacement()
            {
                Point = new Point(0d, targetSize.Height)
            };


            return(new CustomPopupPlacement[] { popupPlacement, popupPlacementAlt });
        }
Esempio n. 30
0
        public CustomPopupPlacement[] placePopup(Size popupSize, Size targetSize, Point offset)
        {
            //Point _point = PointToScreen(pointFromMain);
            //pointFromMain;

            double popupTop   = pointFromMain.Y - Popup1.Height;
            double popupLeft  = pointFromMain.X - Popup1.Width;
            double popupRight = pointFromMain.X + Popup1.Width;

            //if (popupTop < 0)
            //{
            //    pointFromMain.Y = 0;
            //}

            //if (popupLeft < 0)
            //{
            //    pointFromMain.X = 0;
            //}

            Point point2Screen = this.PointToScreen(pointFromMain);
            Point screen2Point = this.PointFromScreen(pointFromMain);

            //double screenWidth = SystemParameters.WorkArea.Width;
            //double screenHeight = SystemParameters.WorkArea.Height;


            var interopHelper = new WindowInteropHelper(System.Windows.Application.Current.MainWindow);
            var activeScreen  = System.Windows.Forms.Screen.FromHandle(interopHelper.Handle);

            //if (popupRight > )
            //{

            //}

            CustomPopupPlacement placement1 = new CustomPopupPlacement(pointFromMain, PopupPrimaryAxis.Vertical);
            CustomPopupPlacement placement2 = new CustomPopupPlacement(pointFromMain, PopupPrimaryAxis.Horizontal);

            CustomPopupPlacement[] ttplaces = new CustomPopupPlacement[] { placement1, placement2 };

            return(ttplaces);
        }