Beispiel #1
0
        /// <summary>
        /// Shows the popup.
        /// </summary>
        /// <param name="popupView">The popup view.</param>
        /// <param name="presenter">The presenter.</param>
        /// <param name="location">The location.</param>
        /// <param name="paddingX">The padding x.</param>
        /// <param name="paddingY">The padding y.</param>
        public void ShowPopup(View popupView, View presenter, PopupLocation location, float paddingX = 0, float paddingY = 0)
        {
            DismissPopup();
            this.popup = popupView;

            Constraint constraintX = null, constraintY = null;

            switch (location)
            {
            case PopupLocation.Bottom:
                constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - this.popup.WidthRequest) / 2);
                constraintY = Constraint.RelativeToParent(parent => parent.Y + presenter.Y + presenter.Height + paddingY);
                break;

            case PopupLocation.Top:
                constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - this.popup.WidthRequest) / 2);
                constraintY = Constraint.RelativeToParent(parent =>
                                                          parent.Y + presenter.Y - this.popup.HeightRequest / 2 - paddingY);
                break;
                //case PopupLocation.Left:
                //    constraintX = Constraint.RelativeToView(presenter, (parent, view) => ((view.X + view.Height / 2) - parent.X) + this.popup.HeightRequest / 2);
                //    constraintY = Constraint.RelativeToView(presenter, (parent, view) => parent.Y + view.Y + view.Width + paddingY);
                //    break;
                //case PopupLocation.Right:
                //    constraintX = Constraint.RelativeToView(presenter, (parent, view) => ((view.X + view.Height / 2) - parent.X) + this.popup.HeightRequest / 2);
                //    constraintY = Constraint.RelativeToView(presenter, (parent, view) => parent.Y + view.Y - this.popup.WidthRequest - paddingY);
                //    break;
            }

            this.ShowPopup(popupView, constraintX, constraintY);
        }
        public static Rect GetDropDownRect(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, PopupLocation[] locationPriorityOrder)
        {
            if (locationPriorityOrder == null)
            {
                locationPriorityOrder = new PopupLocation[] { PopupLocation.Below };
            }
            List <Rect> rects = new List <Rect>();

            PopupLocation[] locationArray = locationPriorityOrder;
            for (int i = 0; i < locationArray.Length; i++)
            {
                Rect rect;
                switch (locationArray[i])
                {
                case PopupLocation.Below:
                    if (!PopupBelow(buttonRect, minSize, maxSize, popupContainerWindow, out rect))
                    {
                        break;
                    }
                    return(rect);

                case PopupLocation.Above:
                    if (!PopupAbove(buttonRect, minSize, maxSize, popupContainerWindow, out rect))
                    {
                        goto Label_008B;
                    }
                    return(rect);

                case PopupLocation.Left:
                    if (!PopupLeft(buttonRect, minSize, maxSize, popupContainerWindow, out rect))
                    {
                        goto Label_00B1;
                    }
                    return(rect);

                case PopupLocation.Right:
                    if (!PopupRight(buttonRect, minSize, maxSize, popupContainerWindow, out rect))
                    {
                        goto Label_00D7;
                    }
                    return(rect);

                default:
                {
                    continue;
                }
                }
                rects.Add(rect);
                continue;
Label_008B:
                rects.Add(rect);
                continue;
Label_00B1:
                rects.Add(rect);
                continue;
Label_00D7:
                rects.Add(rect);
            }
            return(GetLargestRect(rects));
        }
        public static Rect GetDropDownRect(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, PopupLocation[] locationPriorityOrder)
        {
            if (locationPriorityOrder == null)
            {
                locationPriorityOrder = new PopupLocation[] { PopupLocation.Below };
            }
            List<Rect> rects = new List<Rect>();
            PopupLocation[] locationArray = locationPriorityOrder;
            for (int i = 0; i < locationArray.Length; i++)
            {
                Rect rect;
                switch (locationArray[i])
                {
                    case PopupLocation.Below:
                        if (!PopupBelow(buttonRect, minSize, maxSize, popupContainerWindow, out rect))
                        {
                            break;
                        }
                        return rect;

                    case PopupLocation.Above:
                        if (!PopupAbove(buttonRect, minSize, maxSize, popupContainerWindow, out rect))
                        {
                            goto Label_008B;
                        }
                        return rect;

                    case PopupLocation.Left:
                        if (!PopupLeft(buttonRect, minSize, maxSize, popupContainerWindow, out rect))
                        {
                            goto Label_00B1;
                        }
                        return rect;

                    case PopupLocation.Right:
                        if (!PopupRight(buttonRect, minSize, maxSize, popupContainerWindow, out rect))
                        {
                            goto Label_00D7;
                        }
                        return rect;

                    default:
                    {
                        continue;
                    }
                }
                rects.Add(rect);
                continue;
            Label_008B:
                rects.Add(rect);
                continue;
            Label_00B1:
                rects.Add(rect);
                continue;
            Label_00D7:
                rects.Add(rect);
            }
            return GetLargestRect(rects);
        }
Beispiel #4
0
        public void ShowPopup(View popupView, View presenter, PopupLocation location, float paddingX = 0, float paddingY = 0)
        {
            this.DismissPopup();
            this.popup = popupView;

            Constraint constraintX = null, constraintY = null, constraintW = null, constraintH = null;

            switch (location)
            {
            case PopupLocation.Bottom:
                constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - this.popup.WidthRequest) / 2);
                constraintY = Constraint.RelativeToParent(parent => parent.Y + presenter.Y + presenter.Height + paddingY);
                break;

            case PopupLocation.Top:
                constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - this.popup.WidthRequest) / 2);
                constraintY = Constraint.RelativeToParent(parent =>
                                                          parent.Y + presenter.Y - this.popup.HeightRequest / 2 - paddingY);
                break;
                //case PopupLocation.Left:
                //    constraintX = Constraint.RelativeToView(presenter, (parent, view) => ((view.X + view.Height / 2) - parent.X) + this.popup.HeightRequest / 2);
                //    constraintY = Constraint.RelativeToView(presenter, (parent, view) => parent.Y + view.Y + view.Width + paddingY);
                //    break;
                //case PopupLocation.Right:
                //    constraintX = Constraint.RelativeToView(presenter, (parent, view) => ((view.X + view.Height / 2) - parent.X) + this.popup.HeightRequest / 2);
                //    constraintY = Constraint.RelativeToView(presenter, (parent, view) => parent.Y + view.Y - this.popup.WidthRequest - paddingY);
                //    break;
            }

            constraintW = Constraint.RelativeToParent(p => this.popup.WidthRequest);
            constraintH = Constraint.RelativeToParent(p => this.popup.HeightRequest);

            this.content.InputTransparent = true;
            this.Children.Add(
                this.popup,
                constraintX,
                constraintY,
                constraintW,
                constraintH
                );

            if (Device.OS == TargetPlatform.Android)
            {
                this.Children.Remove(this.content);
                this.Children.Add(this.content, () => this.Bounds);
            }

            //this.LowerChild(this.Content);

            this.UpdateChildrenLayout();
        }
        public void ShowPopup(View popupView, View presenter, PopupLocation location, float paddingX = 0, float paddingY = 0)
        {
            this.DismissPopup();
            this.popup = popupView;

            Constraint constraintX = null, constraintY = null, constraintW = null, constraintH = null;

            switch (location)
            {
                case PopupLocation.Bottom:
                    constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - this.popup.WidthRequest) / 2);
                    constraintY = Constraint.RelativeToParent(parent => parent.Y + presenter.Y + presenter.Height + paddingY);
                    break;
                case PopupLocation.Top:
                    constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - this.popup.WidthRequest) / 2);
                    constraintY = Constraint.RelativeToParent(parent => 
                        parent.Y + presenter.Y - this.popup.HeightRequest / 2 - paddingY);
                    break;
                //case PopupLocation.Left:
                //    constraintX = Constraint.RelativeToView(presenter, (parent, view) => ((view.X + view.Height / 2) - parent.X) + this.popup.HeightRequest / 2);
                //    constraintY = Constraint.RelativeToView(presenter, (parent, view) => parent.Y + view.Y + view.Width + paddingY);
                //    break;
                //case PopupLocation.Right:
                //    constraintX = Constraint.RelativeToView(presenter, (parent, view) => ((view.X + view.Height / 2) - parent.X) + this.popup.HeightRequest / 2);
                //    constraintY = Constraint.RelativeToView(presenter, (parent, view) => parent.Y + view.Y - this.popup.WidthRequest - paddingY);
                //    break;
            }

            constraintW = Constraint.RelativeToParent(p => this.popup.WidthRequest);
            constraintH = Constraint.RelativeToParent(p => this.popup.HeightRequest);

            this.content.InputTransparent = true;
            this.Children.Add(
                this.popup,
                constraintX,
                constraintY,
                constraintW,
                constraintH
                );

            if (Device.OS == TargetPlatform.Android)
            {
                this.Children.Remove(this.content);
                this.Children.Add(this.content, () => this.Bounds);
            }

            //this.LowerChild(this.Content);

            this.UpdateChildrenLayout();
        }
 private void LateUpdate()
 {
     if (locations != null)
     {
         for (int i = 0; i < locations.Length; i++)
         {
             PopupLocation location = locations[i];
             {
                 if (location.ContainsPlayer() && !location.HasDisplayed)
                 {
                     Debug.Log("Show Popup.");
                     location.HasDisplayed = false;
                     StartCoroutine(location.DisplayPopup());
                 }
             }
         }
     }
 }
Beispiel #7
0
        /// <summary>
        ///    Shows the popup.
        /// </summary>
        /// <param name="popupView">The popup view.</param>
        /// <param name="presenter">The presenter.</param>
        /// <param name="location">The location.</param>
        /// <param name="paddingX">The padding x.</param>
        /// <param name="paddingY">The padding y.</param>
        public void ShowPopup(View popupView, View presenter, PopupLocation location, float paddingX = 0, float paddingY = 0)
        {
            DismissPopup();
            popup = popupView;

            Constraint constraintX = null, constraintY = null;

            switch (location)
            {
            case PopupLocation.Bottom:
                constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - popup.WidthRequest) / 2);
                constraintY = Constraint.RelativeToParent(parent => parent.Y + presenter.Y + presenter.Height + paddingY);
                break;

            case PopupLocation.Top:
                constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - popup.WidthRequest) / 2);
                constraintY = Constraint.RelativeToParent(parent => parent.Y + presenter.Y - popup.HeightRequest / 2 - paddingY);
                break;
            }

            ShowPopup(popupView, constraintX, constraintY);
        }
Beispiel #8
0
		public void ShowPopup(View popupView, View presenter, PopupLocation location, float paddingX = 0, float paddingY = 0)
		{
			DismissPopup();
			_popup = popupView;

			Constraint constraintX = null, constraintY = null;

			switch (location)
			{
			case PopupLocation.Bottom:
				constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - _popup.WidthRequest)/2);
				constraintY = Constraint.RelativeToParent(parent => parent.Y + presenter.Y + presenter.Height + paddingY);
				break;
			case PopupLocation.Top:
				constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - _popup.WidthRequest)/2);
				constraintY = Constraint.RelativeToParent(parent =>
					parent.Y + presenter.Y - _popup.HeightRequest/2 - paddingY);
				break;
			}

			ShowPopup(popupView, constraintX, constraintY);
		}
Beispiel #9
0
        /// <summary>
        /// Shows the popup.
        /// </summary>
        /// <param name="popupView">The popup view.</param>
        /// <param name="presenter">The presenter.</param>
        /// <param name="location">The location.</param>
        /// <param name="paddingX">The padding x.</param>
        /// <param name="paddingY">The padding y.</param>
        public void ShowPopup(View popupView, View presenter, PopupLocation location, float paddingX = 0, float paddingY = 0)
        {
            DismissPopup();
            this.popup = popupView;

            Constraint constraintX = null, constraintY = null;

            switch (location)
            {
                case PopupLocation.Bottom:
                    constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - this.popup.WidthRequest)/2);
                    constraintY = Constraint.RelativeToParent(parent => parent.Y + presenter.Y + presenter.Height + paddingY);
                    break;
                case PopupLocation.Top:
                    constraintX = Constraint.RelativeToParent(parent => presenter.X + (presenter.Width - this.popup.WidthRequest)/2);
                    constraintY = Constraint.RelativeToParent(parent =>
                        parent.Y + presenter.Y - this.popup.HeightRequest/2 - paddingY);
                    break;
                //case PopupLocation.Left:
                //    constraintX = Constraint.RelativeToView(presenter, (parent, view) => ((view.X + view.Height / 2) - parent.X) + this.popup.HeightRequest / 2);
                //    constraintY = Constraint.RelativeToView(presenter, (parent, view) => parent.Y + view.Y + view.Width + paddingY);
                //    break;
                //case PopupLocation.Right:
                //    constraintX = Constraint.RelativeToView(presenter, (parent, view) => ((view.X + view.Height / 2) - parent.X) + this.popup.HeightRequest / 2);
                //    constraintY = Constraint.RelativeToView(presenter, (parent, view) => parent.Y + view.Y - this.popup.WidthRequest - paddingY);
                //    break;
            }

            this.ShowPopup(popupView, constraintX, constraintY);
        }
 public static string AsCssClass(this PopupLocation self)
 {
     return($"PopupLocation_{self.ToString()}");
 }