Example #1
0
		public static Task ShowAsync(PopupControl control, bool hideApplicationBar, bool showFullScreen)
		{
			return TaskUtilities.RunCallbackMethodAsync<PopupControl, bool, bool, PopupControl>(
				(a, b, c, d) => Show(a, b, c, d), 
				control, hideApplicationBar, showFullScreen);
		}
Example #2
0
		public static Popup Show(PopupControl control, bool hideApplicationBar, bool showFullScreen, Action<PopupControl> completed)
		{
			if (popupStack == null)
				popupStack = new Stack<PopupControl>();

			var oldState = new PageDeactivator();
			var page = PhoneApplication.CurrentPage;

			var heightSub = 0.0;
			if (hideApplicationBar && page.ApplicationBar != null && page.ApplicationBar.IsVisible)
			{
				page.ApplicationBar.IsVisible = false;
				heightSub = page.ApplicationBar.Mode == ApplicationBarMode.Minimized
					? page.ApplicationBar.MiniSize
					: page.ApplicationBar.DefaultSize;
			}
			else
				hideApplicationBar = false;

			var content = page.Content;
			content.IsHitTestVisible = false;

			var popup = new Popup
			{
				Child = control,
				HorizontalAlignment = HorizontalAlignment.Stretch,
				VerticalAlignment = VerticalAlignment.Stretch
			};

			control.Popup = popup;

			if (SystemTray.IsVisible && !(SystemTray.Opacity < 1.0))
				heightSub += 32; 

			// set popup size
			if (showFullScreen)
				popup.Height = page.ActualHeight + heightSub;
			popup.Width = page.ActualWidth;

			// set control size
			if (showFullScreen)
				control.Height = page.ActualHeight + heightSub;
			control.Width = page.ActualWidth;

			// hide underlying page
			if (showFullScreen && content.Visibility == Visibility.Visible)
				content.Visibility = Visibility.Collapsed;
			else
				showFullScreen = false; 

			// deactivate page
            var color = ColorUtilities.RemoveAlpha(
                PhoneApplication.IsDarkTheme ? ColorUtilities.FromHex("#22FFFFFF") :
                ColorUtilities.FromHex("#DDFFFFFF"), Colors.Black);
			var oldColor = SystemTray.BackgroundColor;

			control.SetBackgroundColor(color);
			oldState.DoIt(false);

			// register back key event
			object handlerObject = null; 
			if (page is ExtendedPage)
			{
				handlerObject = ((ExtendedPage)page).AddBackKeyPressHandler(args =>
				{
					if (popupStack.Peek() == control)
					{
						args.Cancel = true;
						control.GoBack();
					}
				});
			}
			else
			{
				var handler = new EventHandler<CancelEventArgs>((sender, args) =>
				{
					if (popupStack.Peek() == control)
					{
						args.Cancel = true;
						control.GoBack();
					}
				});
				page.BackKeyPress += handler;
				handlerObject = handler;
			}

			SystemTray.BackgroundColor = color;

			popup.IsOpen = true;

			// hide underlying popups
			foreach (var p in popupStack)
				p.Visibility = Visibility.Collapsed;
			popupStack.Push(control);

			control.Closed += delegate
			{
				if (showFullScreen)
					content.Visibility = Visibility.Visible;

				if (hideApplicationBar && page.ApplicationBar != null)
					page.ApplicationBar.IsVisible = true;

				content.IsHitTestVisible = true;

				popup.IsOpen = false;

				popupStack.Pop();
				if (popupStack.Count > 0)
					popupStack.Peek().Visibility = Visibility.Visible; 

				oldState.Revert();

				if (page is ExtendedPage)
					((ExtendedPage)page).RemoveBackKeyPressAsyncHandler((Func<CancelEventArgs, Task>) handlerObject);
				else
					page.BackKeyPress -= (EventHandler<CancelEventArgs>)handlerObject;
				
				SystemTray.BackgroundColor = oldColor;
				if (completed != null)
					completed(control);
			};

			return popup;
		}
Example #3
0
		public static Popup Show(PopupControl control)
		{
			return Show(control, false, false, null);
		}
Example #4
0
		public static Popup Show(PopupControl control, bool hideApplicationBar, bool showFullScreen, Action<PopupControl> completed)
		{
			var oldState = new PageDeactivator();
			var page = PhonePage.CurrentPage;

			var heightSub = 0.0;
			if (hideApplicationBar && page.ApplicationBar.IsVisible)
			{
				page.ApplicationBar.IsVisible = false;
				heightSub = page.ApplicationBar.Mode == ApplicationBarMode.Minimized
								? page.ApplicationBar.MiniSize
								: page.ApplicationBar.DefaultSize;
			}
			else
				hideApplicationBar = false;

			var content = page.Content;
			content.IsHitTestVisible = false;

			if (showFullScreen && content.Visibility == Visibility.Visible)
				content.Visibility = Visibility.Collapsed;
			else
				showFullScreen = false; 

			var popup = new Popup
			{
				Child = control,
				HorizontalAlignment = HorizontalAlignment.Stretch,
				VerticalAlignment = VerticalAlignment.Stretch
			};

			control.Popup = popup;

			if (showFullScreen)
				popup.Height = page.ActualHeight + heightSub;
			popup.Width = page.ActualWidth;

			if (showFullScreen)
				control.Height = page.ActualHeight + heightSub;
			control.Width = page.ActualWidth;

			var color = ColorUtility.RemoveAlpha(
				PhoneApplication.IsDarkTheme ? ColorUtility.FromHex("#22FFFFFF") :
				ColorUtility.FromHex("#DDFFFFFF"), Colors.Black);

			var oldColor = SystemTray.BackgroundColor;

			control.SetBackgroundColor(color);
			oldState.DoIt(false);

			var del = new EventHandler<CancelEventArgs>(delegate(object sender, CancelEventArgs args)
			{
				args.Cancel = true;
				control.GoBack();
			});
			page.BackKeyPress += del;

			SystemTray.BackgroundColor = color;

			popup.IsOpen = true;
			control.Closed += delegate
			{
				if (showFullScreen)
					content.Visibility = Visibility.Visible;

				if (hideApplicationBar)
					page.ApplicationBar.IsVisible = true;

				content.IsHitTestVisible = true;

				popup.IsOpen = false;
				oldState.Revert();

				page.BackKeyPress -= del;
				SystemTray.BackgroundColor = oldColor;

				if (completed != null)
					completed(control);
			};

			return popup;
		}
Example #5
0
        public static Popup Show(PopupControl control, bool hideApplicationBar, bool showFullScreen, Action <PopupControl> completed)
        {
            if (popupStack == null)
            {
                popupStack = new Stack <PopupControl>();
            }

            var oldState = new PageDeactivator();
            var page     = PhoneApplication.CurrentPage;

            var heightSub = 0.0;

            if (hideApplicationBar && page.ApplicationBar != null && page.ApplicationBar.IsVisible)
            {
                page.ApplicationBar.IsVisible = false;
                heightSub = page.ApplicationBar.Mode == ApplicationBarMode.Minimized
                                        ? page.ApplicationBar.MiniSize
                                        : page.ApplicationBar.DefaultSize;
            }
            else
            {
                hideApplicationBar = false;
            }

            var content = page.Content;

            content.IsHitTestVisible = false;

            var popup = new Popup
            {
                Child = control,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch
            };

            control.Popup = popup;

            if (SystemTray.IsVisible && !(SystemTray.Opacity < 1.0))
            {
                heightSub += 32;
            }

            // set popup size
            if (showFullScreen)
            {
                popup.Height = page.ActualHeight + heightSub;
            }
            popup.Width = page.ActualWidth;

            // set control size
            if (showFullScreen)
            {
                control.Height = page.ActualHeight + heightSub;
            }
            control.Width = page.ActualWidth;

            // hide underlying page
            if (showFullScreen && content.Visibility == Visibility.Visible)
            {
                content.Visibility = Visibility.Collapsed;
            }
            else
            {
                showFullScreen = false;
            }

            // deactivate page
            var color = ColorUtilities.RemoveAlpha(
                PhoneApplication.IsDarkTheme ? ColorUtilities.FromHex("#22FFFFFF") :
                ColorUtilities.FromHex("#DDFFFFFF"), Colors.Black);
            var oldColor = SystemTray.BackgroundColor;

            control.SetBackgroundColor(color);
            oldState.DoIt(false);

            // register back key event
            object handlerObject = null;

            if (page is ExtendedPage)
            {
                handlerObject = ((ExtendedPage)page).AddBackKeyPressHandler(args =>
                {
                    if (popupStack.Peek() == control)
                    {
                        args.Cancel = true;
                        control.GoBack();
                    }
                });
            }
            else
            {
                var handler = new EventHandler <CancelEventArgs>((sender, args) =>
                {
                    if (popupStack.Peek() == control)
                    {
                        args.Cancel = true;
                        control.GoBack();
                    }
                });
                page.BackKeyPress += handler;
                handlerObject      = handler;
            }

            SystemTray.BackgroundColor = color;

            popup.IsOpen = true;

            // hide underlying popups
            foreach (var p in popupStack)
            {
                p.Visibility = Visibility.Collapsed;
            }
            popupStack.Push(control);

            control.Closed += delegate
            {
                if (showFullScreen)
                {
                    content.Visibility = Visibility.Visible;
                }

                if (hideApplicationBar && page.ApplicationBar != null)
                {
                    page.ApplicationBar.IsVisible = true;
                }

                content.IsHitTestVisible = true;

                popup.IsOpen = false;

                popupStack.Pop();
                if (popupStack.Count > 0)
                {
                    popupStack.Peek().Visibility = Visibility.Visible;
                }

                oldState.Revert();

                if (page is ExtendedPage)
                {
                    ((ExtendedPage)page).RemoveBackKeyPressAsyncHandler((Func <CancelEventArgs, Task>)handlerObject);
                }
                else
                {
                    page.BackKeyPress -= (EventHandler <CancelEventArgs>)handlerObject;
                }

                SystemTray.BackgroundColor = oldColor;
                if (completed != null)
                {
                    completed(control);
                }
            };

            return(popup);
        }
Example #6
0
 public static Task ShowAsync(PopupControl control, bool hideApplicationBar, bool showFullScreen)
 {
     return(TaskUtilities.RunCallbackMethodAsync <PopupControl, bool, bool, PopupControl>(
                (a, b, c, d) => Show(a, b, c, d),
                control, hideApplicationBar, showFullScreen));
 }
Example #7
0
 public static Popup Show(PopupControl control)
 {
     return(Show(control, false, false, null));
 }