Esempio n. 1
0
        // Button click event
        protected void OnButtonClick(object sender, RoutedEventArgs args)
        {
            Avarice.Controls.Button targetButton = (Avarice.Controls.Button)sender;
            int buttonIndex = buttonContainer.Children.IndexOf(targetButton);

            // Dismiss self
            if (shouldAutoDismissWhenClickOnButtons)
            {
                DismissWithButtonIndex(buttonIndex);
            }
            else
            {
                var evt = new ModalPopupEventArgs();
                evt.ButtonIndex = buttonIndex;
                ButtonClick.DispatchEvent(this, evt);
            }
        }
Esempio n. 2
0
        public void DismissWithButtonIndex(int buttonIndex)
        {
            // Remove from history
            if (popupHistory.Contains(this))
                popupHistory.Remove(this);

            CurrentPage.NavigationService.Navigated -= OnPageNavigated;
            CurrentPage.BackKeyPress -= OnBackKeyPress;

            this.Projection = new PlaneProjection { CenterOfRotationX = 0, RotationX = 0 };

            Storyboard animation = new Storyboard();
            Duration duration = new Duration(TimeSpan.FromSeconds(0.3));
            animation.Duration = duration;

            var alphaAnimation = new DoubleAnimation();
            alphaAnimation.Duration = duration;
            alphaAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
            animation.Children.Add(alphaAnimation);
            alphaAnimation.To = 0;
            Storyboard.SetTarget(alphaAnimation, this);
            Storyboard.SetTargetProperty(alphaAnimation, new PropertyPath("Opacity"));

            var planeAnimation = new DoubleAnimation();
            planeAnimation.Duration = duration;
            planeAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
            animation.Children.Add(planeAnimation);
            planeAnimation.To = -90;
            Storyboard.SetTarget(planeAnimation, this.Projection);
            Storyboard.SetTargetProperty(planeAnimation, new PropertyPath("RotationX"));

            animation.Begin();
            animation.Completed += (sender, args) =>
            {
                // Perform cleanup
                if (typeof(IModalPopupContent).IsAssignableFrom(contentElement.GetType()))
                {
                    var modalContent = contentElement as IModalPopupContent;
                    modalContent.OnPopupRemoved();
                }

                if (popupContainer != null)
                {
                    popupContainer.IsOpen = false;
                    popupContainer = null;
                }

                var e = new ModalPopupEventArgs();
                e.ButtonIndex = buttonIndex;
                DismissWithButtonClick.DispatchEventOnMainThread(this, e);

                Dispatcher.BeginInvoke(() => {
                    // Show application bar
                    if (isApplicationBarVisibleBeforePopup)
                        CurrentPage.ApplicationBar.IsVisible = true;

                    if (isSystemTrayVisibleBeforePopup)
                        SystemTray.IsVisible = true;

                    HostView.IsHitTestVisible = true;
                    //HostView.Opacity = 1;
                });

            };
        }