コード例 #1
0
        // Unused and untested 
        public static void ShowMessage(string message, UIElement placementTarget, PlacementMode placementMode=PlacementMode.Top)
        {
            var f = new Callisto.Controls.Flyout();

            var b = new Border()
                           {
                               Width = 300,
                               Height = 125
                           };

            TextBlock tb = new TextBlock();
            tb.HorizontalAlignment = HorizontalAlignment.Center;
            tb.VerticalAlignment = VerticalAlignment.Center;
            tb.TextWrapping = TextWrapping.Wrap;
            tb.FontSize = 12f;
            tb.Text = message;

            b.Child = tb;

            f.Content = b;

            f.Placement = placementMode;
            f.PlacementTarget = placementTarget;

            f.IsOpen = true;
        }
コード例 #2
0
ファイル: ToolTipService.cs プロジェクト: kangaroo/moon
        public static void SetPlacement(DependencyObject element, PlacementMode value)
        {
            if (element == null) 
            {
                throw new ArgumentNullException("element");
            } 
 
            element.SetValue(ToolTipService.PlacementProperty, value);
        } 
コード例 #3
0
ファイル: InlinePopup.cs プロジェクト: unbearab1e/FlattyTweet
 public void ShowAnimated(PlacementMode preferedPlacement, FrameworkElement targetPlacement, System.Windows.Point? mousePositionPoint = null)
 {
     this.Show();
       if (!mousePositionPoint.HasValue)
     mousePositionPoint = new System.Windows.Point?(System.Windows.Application.Current.MainWindow.PointToScreen(Mouse.GetPosition((IInputElement) System.Windows.Application.Current.MainWindow)));
       this.UpdatePosition = (Action) (() => this.SetPosition(preferedPlacement, targetPlacement, mousePositionPoint.Value, false));
       this.UpdatePosition();
       this.Owner.LocationChanged += new EventHandler(this.Owner_LocationChanged);
       this.Owner.SizeChanged += new SizeChangedEventHandler(this.Owner_SizeChanged);
       this.SizeChanged += new SizeChangedEventHandler(this.InlinePopup_SizeChanged);
 }
コード例 #4
0
 /// <summary>
 /// Displays a popup containing the FileBinding menu features.
 /// </summary>
 public static EditVideoWindow InstancePopup(UIElement target, PlacementMode placement, Guid? videoId, string fileName, IMediaPlayerBusiness player, ClosingCallback callback) {
     EditVideoWindow NewForm = new EditVideoWindow();
     NewForm.isPopup = true;
     NewForm.videoId = videoId;
     if (videoId != null && videoId != Guid.Empty)
         NewForm.videoId = videoId;
     else
         NewForm.fileName = fileName;
     NewForm.player = player;
     NewForm.callback = callback;
     WindowHelper.SetScale(NewForm.FileBindingButton.ContextMenu);
     NewForm.Window_Loaded(null, null);
     NewForm.ShowFileBindingMenu(target, placement);
     return NewForm;
 }
コード例 #5
0
ファイル: FlyoutDialog.cs プロジェクト: sdao/TuneOut
        /// <summary>
        /// Shows a flyout with the current <seealso cref="Text"/> and <seealso cref="Commands"/>.
        /// </summary>
        /// <param name="target">The object near which to show the flyout.</param>
        /// <param name="placement">The direction from the <paramref name="target"/> to show the flyout.</param>
        /// <param name="maxWidth">The maximum width of the flyout. If null, automatically determines a feasible width.</param>
        public override void Show(UIElement target, PlacementMode placement, double? maxWidth)
        {
            // Create text
            TextBlock textContainer = new TextBlock()
            {
                Text = this.Text,
                Style = Application.Current.Resources["FlyoutText"] as Style
            };

            // Create action buttons
            StackPanel flyoutButtonContainer = new StackPanel()
            {
                Orientation = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Right
            };

            foreach (IUICommand cmd in _commands)
            {
                Button button = new Button()
                {
                    Content = new TextBlock() { Text = cmd.Label },
                    Tag = cmd,
                    Style = Application.Current.Resources["FlyoutActionButton"] as Style
                };

                button.Click += button_Click;

                flyoutButtonContainer.Children.Add(button);
            }

            // Create outer container
            var outerContainer = new StackPanel()
            {
                Orientation = Orientation.Vertical,
                Margin = new Thickness(10d)
            };

            outerContainer.Children.Add(textContainer);
            outerContainer.Children.Add(flyoutButtonContainer);

            lock (__showLock)
            {
                Content = outerContainer;
                base.Show(target, placement, maxWidth);
            }
        }
コード例 #6
0
ファイル: Placement.cs プロジェクト: highzion/Granular
        private static PlacementBase GetPlacement(PlacementMode placementMode)
        {
            switch (placementMode)
            {
                case PlacementMode.Absolute: return AbsolutePlacement.Default;
                case PlacementMode.Relative: return RelativePlacement.Default;
                case PlacementMode.Bottom: return BottomPlacement.Default;
                case PlacementMode.Center: return CenterPlacement.Default;
                case PlacementMode.Right: return RightPlacement.Default;
                case PlacementMode.AbsolutePoint: return AbsolutePointPlacement.Default;
                case PlacementMode.RelativePoint: return RelativePointPlacement.Default;
                case PlacementMode.Mouse: return MousePlacement.Default;
                case PlacementMode.MousePoint: return MousePointPlacement.Default;
                case PlacementMode.Left: return LeftPlacement.Default;
                case PlacementMode.Top: return TopPlacement.Default;
            }

            throw new Granular.Exception("Unexpected PlacementMode \"{0}\"", placementMode);
        }
コード例 #7
0
 public static void SetMenuPlacementMode(DependencyObject obj, PlacementMode value)
 {
     obj.SetValue(MenuPlacementModeProperty, value);
 }
コード例 #8
0
        private static void SetMenuPlacement(MenuItem menuItem, PlacementMode mode)
        {
            ModuleProc PROC = new ModuleProc("MenuExtensions", "SetMenuPlacement");

            try
            {
                Popup menuItemPopup = menuItem.Template.FindName("PART_Popup", menuItem) as Popup;
                if (menuItemPopup != null)
                {
                    menuItemPopup.Placement = mode;
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
        }
コード例 #9
0
ファイル: PinnableTooltip.cs プロジェクト: Orcomp/Orc.Toolkit
        /// <summary>
        /// The validate placement.
        /// </summary>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <param name="placement">
        /// The placement.
        /// </param>
        /// <param name="plugin">
        /// The plugin.
        /// </param>
        /// <param name="width">
        /// The width.
        /// </param>
        /// <param name="height">
        /// The height.
        /// </param>
        /// <returns>
        /// The <see cref="PlacementMode"/>.
        /// </returns>
        private static PlacementMode ValidatePlacement(
            IList<Point> target, PlacementMode placement, Rect plugin, double width, double height)
        {
            switch (placement)
            {
                case PlacementMode.Right:
                    double num5 = Math.Max(0.0, target[0].X - 1.0);
                    double num6 = plugin.Width - Math.Min(plugin.Width, target[1].X + 1.0);
                    if ((num6 < width) && (num6 < num5))
                    {
                        placement = PlacementMode.Left;
                    }

                    break;
                case PlacementMode.Left:
                    double num7 = Math.Min(plugin.Width, target[1].X + width) - target[1].X;
                    double num8 = target[0].X - Math.Max(0.0, target[0].X - width);
                    if ((num8 < width) && (num8 < num7))
                    {
                        placement = PlacementMode.Right;
                    }

                    break;
                case PlacementMode.Top:
                    double num9 = target[0].Y - Math.Max(0.0, target[0].Y - height);
                    double num10 = Math.Min(plugin.Height, plugin.Height - height) - target[2].Y;
                    if ((num9 < height) && (num9 < num10))
                    {
                        placement = PlacementMode.Bottom;
                    }

                    break;
                case PlacementMode.Bottom:
                    double num11 = Math.Max(0.0, target[0].Y);
                    double num12 = plugin.Height - Math.Min(plugin.Height, target[2].Y);
                    if ((num12 < height) && (num12 < num11))
                    {
                        placement = PlacementMode.Top;
                    }

                    break;
            }

            return placement;
        }
コード例 #10
0
ファイル: PinnableTooltip.cs プロジェクト: Orcomp/Orc.Toolkit
        /// <summary>
        /// The place popup.
        /// </summary>
        /// <param name="plugin">
        /// The plugin.
        /// </param>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <param name="toolTip">
        /// The tool tip.
        /// </param>
        /// <param name="placement">
        /// The placement.
        /// </param>
        /// <returns>
        /// The <see cref="Point"/>.
        /// </returns>
        private static Point PlacePopup(Rect plugin, Point[] target, Point[] toolTip, PlacementMode placement)
        {
            Rect bounds = GetBounds(target);
            Rect rect2 = GetBounds(toolTip);
            double width = rect2.Width;
            double height = rect2.Height;

            placement = ValidatePlacement(target, placement, plugin, width, height);

            Point[] pointArray = GetPointArray(target, placement, plugin, width, height);
            int index = GetIndex(plugin, width, height, pointArray);
            Point point = CalculatePoint(target, placement, plugin, width, height, pointArray, index, bounds);

            return point;
        }
コード例 #11
0
ファイル: Popup.cs プロジェクト: nlh774/DotNetReferenceSource
        // Retrieves a list of the interesting points of the popups child in the popup window space
        private Point[] GetChildInterestPoints(PlacementMode placement)
        {
            UIElement child = Child;

            if (child == null)
            {
                return InterestPointsFromRect(new Rect());
            }

            Point[] interestPoints = InterestPointsFromRect(new Rect(new Point(), child.RenderSize));


            UIElement target = GetTarget() as UIElement;

            // Popup positioning is based on the PlacementTarget or the Placement mode
            if (target != null && !IsAbsolutePlacementMode(placement))
            {
                // In scenarios where the flow direction is different between the
                // child and target, the child rect should be treated as it is flipped
                if ((FlowDirection)target.GetValue(FlowDirectionProperty) !=
                    (FlowDirection)child.GetValue(FlowDirectionProperty))
                {
                    SwapPoints(ref interestPoints[(int)InterestPoint.TopLeft], ref interestPoints[(int)InterestPoint.TopRight]);
                    SwapPoints(ref interestPoints[(int)InterestPoint.BottomLeft], ref interestPoints[(int)InterestPoint.BottomRight]);
                }
            }

            // Use remove the render transform translation from the child
            Vector offset = _popupRoot.Value.AnimationOffset;

            // Transform InterestPoints to popup's space
            GeneralTransform childToPopupTransform = TransformToClient(child, _popupRoot.Value);

            for (int i = 0; i < 5; i++)
            {
                // subtract Animation offset and transform point to the screen coordinate space
                childToPopupTransform.TryTransform(interestPoints[i] - offset, out interestPoints[i]);
            }

            return interestPoints;
        }
コード例 #12
0
 /// <summary>
 /// The set placement.
 /// </summary>
 /// <param name="element">
 /// The element.
 /// </param>
 /// <param name="value">
 /// The value.
 /// </param>
 public static void SetPlacement(DependencyObject element, PlacementMode value)
 {
     element.SetValue(PlacementProperty, value);
 }
コード例 #13
0
ファイル: Flyout.cs プロジェクト: sdao/TuneOut
        /// <summary>
        /// Shows a flyout with the current <seealso cref="Content"/>.
        /// </summary>
        /// <param name="target">The object near which to show the flyout.</param>
        /// <param name="placement">The direction from the <paramref name="target"/> to show the flyout.</param>
        /// <param name="maxWidth">The maximum width of the flyout. If null, automatically determines a feasible width.</param>
        public virtual void Show(UIElement target, PlacementMode placement, double? maxWidth)
        {
            lock (__showLock)
            {
                if (__currentOpenFlyout != null)
                {
                    // Must close previous one before opening a new one.
                    __currentOpenFlyout.DisposeFlyout();
                }

                IsOpen = true;

                // Deconnect content
                var contentParent = Content.Parent as Panel;
                if (contentParent != null)
                {
                    contentParent.Children.Remove(Content);
                }

                // Create flyout
                _flyout = new Callisto.Controls.Flyout()
                {
                    Content = this.Content,
                    PlacementTarget = target,
                    Placement = placement
                };

                if (maxWidth.HasValue)
                {
                    _flyout.MaxWidth = maxWidth.Value;
                }

                _flyout.Closed += _flyout_Closed;
                _flyout.IsOpen = true;
            }
        }
コード例 #14
0
        public void ShowFileBindingMenu(UIElement target, PlacementMode placement) {
            // Set context menu items visibility.
            if (player == null)
                FileBindingButton.ContextMenu.Items.Remove(menuPlay);
            else
                menuPlay.IsEnabled = (!fileNotFound && video.FileName != null);
            if (!isPopup)
                FileBindingButton.ContextMenu.Items.Remove(menuEdit);
            string DefaultFileName = GetDefaultFileName();
            menuMoveFile.IsEnabled = (video.Title.Length > 0 && video.FileName != null && video.FileName != DefaultFileName);
            if (menuMoveFile.IsEnabled)
                menuMoveFile.Header = string.Format("_Move to \"{0}\"", DefaultFileName);
            else
                menuMoveFile.Header = "_Move to Default Location";
            if (isNew)
                menuSelectFile.Header = "_Select Existing Entry...";
            else
                menuSelectFile.Header = "_Select Another File...";
            menuDownloadVideo.IsEnabled = (!downloaded && (fileNotFound || video.FileName == null) && video.DownloadUrl.Length > 0);
            menuExtractAudio.IsEnabled = (!fileNotFound && video.FileName != null);
            menuRemoveBinding.IsEnabled = (!isNew && video.FileName != null);
            menuDeleteVideo.IsEnabled = (!fileNotFound && video.FileName != null);
            if (isNew)
                menuDeleteVideo.Header = "Delete _File";
            else
                menuDeleteVideo.Header = "Delete Attached _File";
            menuDeleteEntry.IsEnabled = !isNew;

            // Show context menu.
            FileBindingButton.ContextMenu.IsEnabled = true;
            FileBindingButton.ContextMenu.PlacementTarget = target;
            FileBindingButton.ContextMenu.Placement = placement;
            FileBindingButton.ContextMenu.IsOpen = true;
        }
コード例 #15
0
 public static void SetPlacement(DependencyObject obj, PlacementMode value)
 {
     obj.SetValue(PlacementProperty, value);
 }
コード例 #16
0
ファイル: Popup.cs プロジェクト: nlh774/DotNetReferenceSource
        private Rect GetMouseRect(PlacementMode placement)
        {
            NativeMethods.POINT mousePoint = _secHelper.GetMouseCursorPos(GetTarget());

            if (placement == PlacementMode.Mouse)
            {
                // In Mouse mode, the bounding box of the mouse cursor becomes the target
                int cursorWidth, cursorHeight, hotX, hotY;
                GetMouseCursorSize(out cursorWidth, out cursorHeight, out hotX, out hotY);

                // Add a margin of 1 px above and below the mouse
                return new Rect(mousePoint.x, mousePoint.y - 1, Math.Max(0, cursorWidth - hotX), Math.Max(0, cursorHeight - hotY + 2));
            }
            else
            {
                // In MousePoint mode, the mouse position is the target
                return new Rect(mousePoint.x, mousePoint.y, 0, 0);
            }
        }
コード例 #17
0
ファイル: Popup.cs プロジェクト: nlh774/DotNetReferenceSource
        // Gets the primary axis for the specified placement mode
        private static PopupPrimaryAxis GetPrimaryAxis(PlacementMode placement)
        {
            switch (placement)
            {
                case PlacementMode.Right:
                case PlacementMode.Left:
                    return PopupPrimaryAxis.Vertical;

                case PlacementMode.Bottom:
                case PlacementMode.Top:
                case PlacementMode.RelativePoint:
                case PlacementMode.AbsolutePoint:
                    return PopupPrimaryAxis.Horizontal;

                case PlacementMode.Relative:
                case PlacementMode.Mouse:
                case PlacementMode.MousePoint:
                case PlacementMode.Center:
                case PlacementMode.Absolute:
                case PlacementMode.Custom:
                default:
                    return PopupPrimaryAxis.None;
            }
        }
コード例 #18
0
ファイル: Popup.cs プロジェクト: nlh774/DotNetReferenceSource
        // Returns the ith possible alignment for the given PlacementMode
        private PointCombination GetPointCombination(PlacementMode placement, int i, out PopupPrimaryAxis axis)
        {
            Debug.Assert(i >= 0 && i < GetNumberOfCombinations(placement));

            bool dropFromRight = SystemParameters.MenuDropAlignment;

            switch (placement)
            {
                case PlacementMode.Bottom:
                case PlacementMode.Mouse:
                    axis = PopupPrimaryAxis.Horizontal;
                    if (dropFromRight)
                    {
                        if (i == 0) return new PointCombination(InterestPoint.BottomRight, InterestPoint.TopRight);
                        if (i == 1) return new PointCombination(InterestPoint.TopRight, InterestPoint.BottomRight);
                    }
                    else
                    {
                        if (i == 0) return new PointCombination(InterestPoint.BottomLeft, InterestPoint.TopLeft);
                        if (i == 1) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft);
                    }
                    break;


                case PlacementMode.Top:
                    axis = PopupPrimaryAxis.Horizontal;
                    if (dropFromRight)
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopRight, InterestPoint.BottomRight);
                        if (i == 1) return new PointCombination(InterestPoint.BottomRight, InterestPoint.TopRight);

                    }
                    else
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft);
                        if (i == 1) return new PointCombination(InterestPoint.BottomLeft, InterestPoint.TopLeft);

                    }
                    break;


                case PlacementMode.Right:
                case PlacementMode.Left:
                    axis = PopupPrimaryAxis.Vertical;
                    dropFromRight |= DropOpposite;

                    if ((dropFromRight && placement == PlacementMode.Right) ||
                        (!dropFromRight && placement == PlacementMode.Left))
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight);
                        if (i == 1) return new PointCombination(InterestPoint.BottomLeft, InterestPoint.BottomRight);
                        if (i == 2) return new PointCombination(InterestPoint.TopRight, InterestPoint.TopLeft);
                        if (i == 3) return new PointCombination(InterestPoint.BottomRight, InterestPoint.BottomLeft);
                    }
                    else
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopRight, InterestPoint.TopLeft);
                        if (i == 1) return new PointCombination(InterestPoint.BottomRight, InterestPoint.BottomLeft);
                        if (i == 2) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight);
                        if (i == 3) return new PointCombination(InterestPoint.BottomLeft, InterestPoint.BottomRight);
                    }
                    break;

                case PlacementMode.Relative:
                case PlacementMode.RelativePoint:
                case PlacementMode.MousePoint:
                case PlacementMode.AbsolutePoint:
                    axis = PopupPrimaryAxis.Horizontal;
                    if (dropFromRight)
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight);
                        if (i == 1) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopLeft);
                        if (i == 2) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomRight);
                        if (i == 3) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft);
                    }
                    else
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopLeft);
                        if (i == 1) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight);
                        if (i == 2) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft);
                        if (i == 3) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomRight);
                    }
                    break;

                case PlacementMode.Center:
                    axis = PopupPrimaryAxis.None;
                    return new PointCombination(InterestPoint.Center, InterestPoint.Center);

                case PlacementMode.Absolute:
                case PlacementMode.Custom:
                default:
                    axis = PopupPrimaryAxis.None;
                    return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopLeft);
            }

            return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight);
        }
コード例 #19
0
ファイル: Popup.cs プロジェクト: nlh774/DotNetReferenceSource
        // Gets the number of InterestPoint combinations for the given placement
        private static int GetNumberOfCombinations(PlacementMode placement)
        {
            switch (placement)
            {
                case PlacementMode.Bottom:
                case PlacementMode.Top:
                case PlacementMode.Mouse:
                    return 2;

                case PlacementMode.Right:
                case PlacementMode.Left:
                case PlacementMode.RelativePoint:
                case PlacementMode.MousePoint:
                case PlacementMode.AbsolutePoint:
                    return 4;

                case PlacementMode.Custom:
                    return 0;

                case PlacementMode.Absolute:
                case PlacementMode.Relative:
                case PlacementMode.Center:
                default:
                    return 1;
            }
        }
コード例 #20
0
ファイル: PlacementHelper.cs プロジェクト: mparsin/Elements
 public Point GetPlacementOrigin(PlacementMode placementMode)
 {
     Point placement = this.GetPlacementOriginWithoutRounding(placementMode);
     return new Point(Math.Round(placement.X, 0), Math.Round(placement.Y, 0));
 }
コード例 #21
0
ファイル: PlacementHelper.cs プロジェクト: mparsin/Elements
        private Point GetPlacementOriginWithoutRounding(PlacementMode placementMode)
        {
            bool rightToLeft = this.IsRightToLeft;
            if (rightToLeft)
            {
                if (placementMode == PlacementMode.Left)
                {
                    placementMode = PlacementMode.Right;
                }
                else if (placementMode == PlacementMode.Right)
                {
                    placementMode = PlacementMode.Left;
                }
            }

            switch (placementMode)
            {
                case PlacementMode.Bottom:
                    if (this.CanFitBottom())
                    {
                        this.ActualPlacement = PlacementMode.Bottom;
                        return this.FitBottom();
                    }
                    if (this.CanFitTop())
                    {
                        this.ActualPlacement = PlacementMode.Top;
                        return this.FitTop();
                    }
                    this.ActualPlacement = PlacementMode.Bottom;
                    return this.AdjustForBottom();

                case PlacementMode.Top:
                    if (this.CanFitTop())
                    {
                        this.ActualPlacement = PlacementMode.Top;
                        return this.FitTop();
                    }
                    if (this.CanFitBottom())
                    {
                        this.ActualPlacement = PlacementMode.Bottom;
                        return this.FitBottom();
                    }
                    this.ActualPlacement = PlacementMode.Top;
                    return this.AdjustForTop();

                case PlacementMode.Left:
                    if (this.CanFitLeft())
                    {
                        this.ActualPlacement = PlacementMode.Left;
                        if (rightToLeft)
                        {
                            return this.FitRight();
                        }
                        else
                        {
                            return this.FitLeft();
                        }
                    }
                    if (this.CanFitRight())
                    {
                        this.ActualPlacement = PlacementMode.Right;
                        if (rightToLeft)
                        {
                            return this.FitLeft();
                        }
                        else
                        {
                            return this.FitRight();
                        }
                    }
                    if (rightToLeft)
                    {
                        return this.AdjustForRight();
                    }
                    else
                    {
                        return this.AdjustForLeft();
                    }

                case PlacementMode.Right:
                    if (this.CanFitRight())
                    {
                        this.ActualPlacement = PlacementMode.Right;
                        if (rightToLeft)
                        {
                            return this.FitLeft();
                        }
                        else
                        {
                            return this.FitRight();
                        }
                    }
                    if (this.CanFitLeft())
                    {
                        this.ActualPlacement = PlacementMode.Left;
                        if (rightToLeft)
                        {
                            return this.FitRight();
                        }
                        else
                        {
                            return this.FitLeft();
                        }
                    }
                    this.ActualPlacement = PlacementMode.Right;

                    if (rightToLeft)
                    {
                        return this.AdjustForLeft();
                    }
                    else
                    {
                        return this.AdjustForRight();
                    }

                case PlacementMode.Center:
                    this.ActualPlacement = PlacementMode.Center;
                    return this.FitCenter();

                case PlacementMode.Absolute:
                case PlacementMode.MousePoint:
                    this.ActualPlacement = PlacementMode.Absolute;
                    return this.FitAbsolute();
                case PlacementMode.Mouse:
                    this.ActualPlacement = PlacementMode.Mouse;
                    return this.FitMouse();

                default:
                    throw new NotSupportedException("placementMode");
            }
        }
コード例 #22
0
 public void Show(PlacementMode placement)
 {
     this.IsOpen = true;
     this.Placement = placement;
 }
コード例 #23
0
 public static void SetMode(DependencyObject container, PlacementMode value)
 {
     container.SetValue(ModeProperty, value);
 }
コード例 #24
0
ファイル: Popup.cs プロジェクト: nlh774/DotNetReferenceSource
        private static bool IsAbsolutePlacementMode(PlacementMode placement)
        {
            switch (placement)
            {
                case PlacementMode.MousePoint:
                case PlacementMode.Mouse:
                case PlacementMode.AbsolutePoint:
                case PlacementMode.Absolute:
                    return true;
            }

            return false;
        }
コード例 #25
0
        /// <summary>
        /// Sets the tooltip's placement mode.
        /// </summary>
        /// <param name="element">The element to update.</param>
        /// <param name="value">A <see cref="PlacementMode"/> value which specifies how the tooltip is arranged on the screen.</param>
        public static void SetPlacement(DependencyObject element, PlacementMode value)
        {
            Contract.Require(element, "element");

            element.SetValue(PlacementProperty, value);
        }
コード例 #26
0
ファイル: Popup.cs プロジェクト: nlh774/DotNetReferenceSource
        // Retrieves a list of the interesting points of the popup target in screen space
        private Point[] GetPlacementTargetInterestPoints(PlacementMode placement)
        {
            if (_positionInfo == null)
            {
                _positionInfo = new PositionInfo();
            }

            // Calculate the placement rectangle, which is the rectangle that popup will position relative to.
            Rect placementRect = PlacementRectangle;

            Point[] interestPoints;

            UIElement target = GetTarget() as UIElement;

            Vector offset = new Vector(HorizontalOffset, VerticalOffset);

            // Popup positioning is based on the PlacementTarget or the Placement mode
            if (target == null || IsAbsolutePlacementMode(placement))
            {
                // When the Mode is Mouse, the placement rectangle is the mouse position
                if (placement == PlacementMode.Mouse || placement == PlacementMode.MousePoint)
                {
                    if (_positionInfo.MouseRect == Rect.Empty)
                    {
                        // Everytime something changes we will reposition the popup.  We generally don't
                        // want to get a new position for the mouse at every reposition (for example,
                        // if the popup's content size is animated the popup will keep repositioning,
                        // but we should not pick up a new position for the mouse).
                        _positionInfo.MouseRect = GetMouseRect(placement);
                    }

                    placementRect = _positionInfo.MouseRect;
                }
                else if (placementRect == Rect.Empty)
                {
                    placementRect = new Rect();
                }

                offset = _secHelper.GetTransformToDevice().Transform(offset);

                // Offset the rect
                placementRect.Offset(offset);

                // These points are already positioned in screen coordinates
                // no transformations are necessary
                interestPoints = InterestPointsFromRect(placementRect);
            }
            else
            {
                // If no rectangle was given, then use the render bounds of the target
                if (placementRect == Rect.Empty)
                {
                    if (placement != PlacementMode.Relative && placement != PlacementMode.RelativePoint)
                        placementRect = new Rect(0.0, 0.0, target.RenderSize.Width, target.RenderSize.Height);
                    else // For relative and relative point use upperleft corner of target
                        placementRect = new Rect();
                }

                // Offset the rect
                placementRect.Offset(offset);

                // Get the points int the target's coordinate space
                interestPoints = InterestPointsFromRect(placementRect);

                // Next transform from the target's space to the screen space
                Visual rootVisual = GetRootVisual(target);
                GeneralTransform targetToClientTransform = TransformToClient(target, rootVisual);

                // transform point to the screen coordinate space
                for (int i = 0; i < 5; i++)
                {
                    targetToClientTransform.TryTransform(interestPoints[i], out interestPoints[i]);

                    interestPoints[i] = _secHelper.ClientToScreen(rootVisual, interestPoints[i]);
                }
            }

            return interestPoints;
        }
コード例 #27
0
ファイル: Popup.cs プロジェクト: RUSshy/ultraviolet
 /// <summary>
 /// Occurs when the value of the <see cref="Placement"/> dependency property changes.
 /// </summary>
 private static void HandlePlacementChanged(DependencyObject dobj, PlacementMode oldValue, PlacementMode newValue)
 {
     var popup = (Popup)dobj;
     popup.UpdatePopupArrange(popup.MostRecentFinalRect.Size);
 }
コード例 #28
0
ファイル: PinnableTooltip.cs プロジェクト: Orcomp/Orc.Toolkit
        /// <summary>
        /// The calculate point.
        /// </summary>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <param name="placement">
        /// The placement.
        /// </param>
        /// <param name="plugin">
        /// The plugin.
        /// </param>
        /// <param name="width">
        /// The width.
        /// </param>
        /// <param name="height">
        /// The height.
        /// </param>
        /// <param name="pointArray">
        /// The point array.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <param name="bounds">
        /// The bounds.
        /// </param>
        /// <returns>
        /// The <see cref="Point"/>.
        /// </returns>
        private static Point CalculatePoint(
            IList<Point> target,
            PlacementMode placement,
            Rect plugin,
            double width,
            double height,
            IList<Point> pointArray,
            int index,
            Rect bounds)
        {
            double x = pointArray[index].X;
            double y = pointArray[index].Y;
            if (index > 1)
            {
                if ((placement == PlacementMode.Left) || (placement == PlacementMode.Right))
                {
                    if (((Math.Abs(y - target[0].Y) > Epsilon) && (Math.Abs(y - target[1].Y) > Epsilon))
                        && ((Math.Abs((y + height) - target[0].Y) > Epsilon)
                            && (Math.Abs((y + height) - target[1].Y) > Epsilon)))
                    {
                        double num18 = bounds.Top + (bounds.Height / 2.0);
                        if ((num18 > 0.0) && ((num18 - 0.0) > (plugin.Height - num18)))
                        {
                            y = plugin.Height - height;
                        }
                        else
                        {
                            y = 0.0;
                        }
                    }
                }
                else if (((placement == PlacementMode.Top) || (placement == PlacementMode.Bottom))
                         && (((Math.Abs(x - target[0].X) > 0.0001) && (Math.Abs(x - target[1].X) > 0.0001))
                             && ((Math.Abs((x + width) - target[0].X) > 0.0001) && (Math.Abs((x + width) - target[1].X) > 0.0001))))
                {
                    double num19 = bounds.Left + (bounds.Width / 2.0);
                    if ((num19 > 0.0) && ((num19 - 0.0) > (plugin.Width - num19)))
                    {
                        x = plugin.Width - width;
                    }
                    else
                    {
                        x = 0.0;
                    }
                }
            }

            return new Point(x, y);
        }
コード例 #29
0
ファイル: Flyout.cs プロジェクト: larsduewel/callisto
        private Point PlacePopup(Rect window, Point[] target, Point[] flyout, PlacementMode placement)
        {
            Point[] pointArray;
            double y = 0.0;
            double x = 0.0;
            Rect bounds = GetBounds(target);
            Rect rect2 = GetBounds(flyout);
            double width = rect2.Width;
            double height = rect2.Height;
            if (placement == PlacementMode.Right)
            {
                double num5 = Math.Max(0.0, target[0].X);
                double num6 = window.Width - Math.Min(window.Width, target[1].X + 1.0);
                if ((num6 < width) && (num6 < num5))
                {
                    placement = PlacementMode.Left;
                }
            }
            else if (placement == PlacementMode.Left)
            {
                double num7 = window.Width - Math.Min(window.Width, target[1].X + 1.0);
                double num8 = Math.Max(0.0, target[0].X);
                if ((num8 < width) && (num8 < num7))
                {
                    placement = PlacementMode.Right;
                }
            }
            else if (placement == PlacementMode.Top)
            {
                double num9 = Math.Max(0.0, target[0].Y);
                double num10 = window.Height - Math.Min(window.Height, target[2].Y + 1.0);
                if ((num9 < height) && (num9 < num10))
                {
                    placement = PlacementMode.Bottom;
                }
            }
            else if (placement == PlacementMode.Bottom)
            {
                double num11 = Math.Max(0.0, target[0].Y);
                double num12 = window.Height - Math.Min(window.Height, target[2].Y + 1.0);
                if ((num12 < height) && (num12 < num11))
                {
                    placement = PlacementMode.Top;
                }
            }
            switch (placement)
            {
                case PlacementMode.Bottom:
                    pointArray = new Point[] { new Point(target[2].X, Math.Max((double)0.0, (double)(target[2].Y + 1.0))), new Point((target[3].X - width) + 1.0, Math.Max((double)0.0, (double)(target[2].Y + 1.0))), new Point(0.0, Math.Max((double)0.0, (double)(target[2].Y + 1.0))) };
                    break;

                case PlacementMode.Right:
                    pointArray = new Point[] { new Point(Math.Max((double)0.0, (double)(target[1].X + 1.0)), target[1].Y), new Point(Math.Max((double)0.0, (double)(target[3].X + 1.0)), (target[3].Y - height) + 1.0), new Point(Math.Max((double)0.0, (double)(target[1].X + 1.0)), 0.0) };
                    break;

                case PlacementMode.Left:
                    pointArray = new Point[] { new Point(Math.Min(window.Width, target[0].X) - width, target[1].Y), new Point(Math.Min(window.Width, target[2].X) - width, (target[3].Y - height) + 1.0), new Point(Math.Min(window.Width, target[0].X) - width, 0.0) };
                    break;

                case PlacementMode.Top:
                    pointArray = new Point[] { new Point(target[0].X, Math.Min(target[0].Y, window.Height) - height), new Point((target[1].X - width) + 1.0, Math.Min(target[0].Y, window.Height) - height), new Point(0.0, Math.Min(target[0].Y, window.Height) - height) };
                    break;

                default:
                    pointArray = new Point[] { new Point(0.0, 0.0) };
                    break;
            }
            double num13 = width * height;
            int index = 0;
            double num15 = 0.0;
            for (int i = 0; i < pointArray.Length; i++)
            {
                Rect rect3 = new Rect(pointArray[i].X, pointArray[i].Y, width, height);
                rect3.Intersect(window);
                double d = rect3.Width * rect3.Height;
                if (double.IsInfinity(d))
                {
                    index = pointArray.Length - 1;
                    break;
                }
                if (d > num15)
                {
                    index = i;
                    num15 = d;
                }
                if (d == num13)
                {
                    index = i;
                    break;
                }
            }
            // x = pointArray[index].X;
            x = pointArray[0].X; // TODO: taking this solves my horizontal nudging, but is a hack...keeping it though until a better solution
            y = pointArray[index].Y;
            if (index > 1)
            {
                if ((placement == PlacementMode.Left) || (placement == PlacementMode.Right))
                {
                    if (((y != target[0].Y) && (y != target[1].Y)) && (((y + height) != target[0].Y) && ((y + height) != target[1].Y)))
                    {
                        double num18 = bounds.Top + (bounds.Height / 2.0);
                        if ((num18 > 0.0) && ((num18 - 0.0) > (window.Height - num18)))
                        {
                            y = window.Height - height;
                        }
                        else
                        {
                            y = 0.0;
                        }
                    }
                }
                else if (((placement == PlacementMode.Top) || (placement == PlacementMode.Bottom)) && (((x != target[0].X) && (x != target[1].X)) && (((x + width) != target[0].X) && ((x + width) != target[1].X))))
                {
                    double num19 = bounds.Left + (bounds.Width / 2.0);
                    if ((num19 > 0.0) && ((num19 - 0.0) > (window.Width - num19)))
                    {
                        x = window.Width - width;
                    }
                    else
                    {
                        x = 0.0;
                    }
                }
            }

            _realizedPlacement = placement;

            return new Point(x, y);
        }
コード例 #30
0
ファイル: PinnableTooltip.cs プロジェクト: Orcomp/Orc.Toolkit
        /// <summary>
        /// The get point array.
        /// </summary>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <param name="placement">
        /// The placement.
        /// </param>
        /// <param name="plugin">
        /// The plugin.
        /// </param>
        /// <param name="width">
        /// The width.
        /// </param>
        /// <param name="height">
        /// The height.
        /// </param>
        /// <returns>
        /// The <see><cref>Point[]</cref></see>.
        /// </returns>
        private static Point[] GetPointArray(
            IList<Point> target, PlacementMode placement, Rect plugin, double width, double height)
        {
            Point[] pointArray;
            switch (placement)
            {
                case PlacementMode.Bottom:
                    pointArray = new[]
                                     {
                                         new Point(target[2].X, Math.Max(0.0, target[2].Y + 1.0)), 
                                         new Point((target[3].X - width) + 1.0, Math.Max(0.0, target[2].Y + 1.0)), 
                                         new Point(0.0, Math.Max(0.0, target[2].Y + 1.0))
                                     };
                    break;

                case PlacementMode.Right:
                    pointArray = new[]
                                     {
                                         new Point(Math.Max(0.0, target[1].X + 1.0), target[1].Y), 
                                         new Point(Math.Max(0.0, target[3].X + 1.0), (target[3].Y - height) + 1.0), 
                                         new Point(Math.Max(0.0, target[1].X + 1.0), 0.0)
                                     };
                    break;

                case PlacementMode.Left:
                    pointArray = new[]
                                     {
                                         new Point(Math.Min(plugin.Width, target[0].X) - width, target[1].Y), 
                                         new Point(
                                             Math.Min(plugin.Width, target[2].X) - width, (target[3].Y - height) + 1.0), 
                                         new Point(Math.Min(plugin.Width, target[0].X) - width, 0.0)
                                     };
                    break;

                case PlacementMode.Top:
                    pointArray = new[]
                                     {
                                         new Point(target[0].X, Math.Min(target[0].Y, plugin.Height) - height), 
                                         new Point(
                                             (target[1].X - width) + 1.0, Math.Min(target[0].Y, plugin.Height) - height), 
                                         new Point(0.0, Math.Min(target[0].Y, plugin.Height) - height)
                                     };
                    break;

                default:
                    pointArray = new[] { new Point(0.0, 0.0) };
                    break;
            }

            return pointArray;
        }