コード例 #1
0
ファイル: PopupRootStyle.cs プロジェクト: MarkWalls/Perspex
 private Control Template(PopupRoot control)
 {
     return new Border
     {
         [~Border.BackgroundProperty] = control[~PopupRoot.BackgroundProperty],
         Content = new ContentPresenter
         {
             Name = "contentPresenter",
             [~ContentPresenter.ContentProperty] = control[~PopupRoot.ContentProperty],
         }
     };
 }
コード例 #2
0
ファイル: ToolTip.cs プロジェクト: MarkWalls/Perspex
        /// <summary>
        /// Shows a tooltip for the specified control.
        /// </summary>
        /// <param name="control">The control.</param>
        private static void ShowToolTip(Control control)
        {
            if (control != null)
            {
                if (popup == null)
                {
                    popup = new PopupRoot
                    {
                        Content = new ToolTip(),
                    };
                }

                var cp = MouseDevice.Instance.GetPosition(control);
                var position = control.PointToScreen(cp) + new Vector(0, 22);

                popup.Parent = control;
                ((ToolTip)popup.Content).Content = GetTip(control);
                popup.SetPosition(position);
                popup.Show();

                current = control;
            }
        }
コード例 #3
0
ファイル: Popup.cs プロジェクト: MarkWalls/Perspex
        /// <summary>
        /// Opens the popup.
        /// </summary>
        public void Open()
        {
            if (this.popupRoot == null)
            {
                this.popupRoot = new PopupRoot(this.DependencyResolver)
                {
                    Parent = this,
                    [~PopupRoot.ContentProperty] = this[~ChildProperty],
                    [~PopupRoot.WidthProperty] = this[~WidthProperty],
                    [~PopupRoot.HeightProperty] = this[~HeightProperty],
                    [~PopupRoot.MinWidthProperty] = this[~MinWidthProperty],
                    [~PopupRoot.MaxWidthProperty] = this[~MaxWidthProperty],
                    [~PopupRoot.MinHeightProperty] = this[~MinHeightProperty],
                    [~PopupRoot.MaxHeightProperty] = this[~MaxHeightProperty],
                };
            }

            this.popupRoot.SetPosition(this.GetPosition());
            this.topLevel.Deactivated += this.MaybeClose;
            this.popupRoot.AddHandler(PopupRoot.PointerPressedEvent, this.MaybeClose, RoutingStrategies.Bubble, true);
            this.topLevel.AddHandler(TopLevel.PointerPressedEvent, this.MaybeClose, RoutingStrategies.Tunnel);

            this.PopupRootCreated?.Invoke(this, EventArgs.Empty);

            this.popupRoot.Show();
            this.IsOpen = true;
            this.Opened?.Invoke(this, EventArgs.Empty);
        }