コード例 #1
0
        public Popup Show(PopupSize size, UIElement content = null)
        {
            var popup = Create(size, content);

            popup.IsOpen = true;
            return(popup);
        }
コード例 #2
0
ファイル: PopupViewModel.cs プロジェクト: Hostur/Games-Core
 public ShowPopupEvent(PopupOptions buttonOptions, string popupTitleKey, string popupContentKey, Action <PopupResult> onResultCallback, bool cancelOnBackgroundClick = false, PopupSize size = PopupSize.W800H600)
 {
     ButtonOptions               = buttonOptions;
     PopupTitleKey               = popupTitleKey;
     PopupContentKey             = popupContentKey;
     ResultCallback              = onResultCallback;
     Size                        = size;
     CancelOnBackgroundAvailable = cancelOnBackgroundClick;
 }
コード例 #3
0
        public Popup Create(PopupSize size, UIElement content = null)
        {
            var container = new ContentControl
            {
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                VerticalContentAlignment   = VerticalAlignment.Stretch,
                Height  = Window.Current.Bounds.Height,
                Width   = Window.Current.Bounds.Width,
                Content = content,
            };
            var popup = new Popup
            {
                Child            = container,
                HorizontalOffset = 0,
                VerticalOffset   = 0,
            };
            WindowSizeChangedEventHandler handler = (s, e) =>
            {
                if (popup.IsOpen)
                {
                    if (size == PopupSize.FullScreen)
                    {
                        container.Height = Window.Current.Bounds.Height;
                        container.Width  = Window.Current.Bounds.Width;
                    }
                    else if (size == PopupSize.ContentBased)
                    {
                        popup.HorizontalOffset = (Window.Current.Bounds.Width - popup.ActualWidth) / 2;
                        popup.VerticalOffset   = (Window.Current.Bounds.Height - popup.ActualHeight) / 2;
                    }
                }
            };

            popup.RegisterPropertyChangedCallback(Popup.IsOpenProperty, (d, e) =>
            {
                if (popup.IsOpen)
                {
                    Window.Current.SizeChanged += handler;
                }
                else
                {
                    Window.Current.SizeChanged -= handler;
                }
            });
            popup.Loaded += (s, e) => handler.Invoke(null, null);
            return(popup);
        }
コード例 #4
0
ファイル: PopupService.cs プロジェクト: Rasetech/Template10
 public Popup Create(PopupSize size, UIElement content = null)
 {
     var container = new ContentControl
     {
         HorizontalContentAlignment = HorizontalAlignment.Stretch,
         VerticalContentAlignment = VerticalAlignment.Stretch,
         Height = Window.Current.Bounds.Height,
         Width = Window.Current.Bounds.Width,
         Content = content,
     };
     var popup = new Popup
     {
         Child = container,
         HorizontalOffset = 0,
         VerticalOffset = 0,
     };
     WindowSizeChangedEventHandler handler = (s, e) =>
     {
         if (popup.IsOpen)
         {
             container.Height = e.Size.Height;
             container.Width = e.Size.Width;
         }
     };
     if (size == PopupSize.FullScreen)
     {
         popup.RegisterPropertyChangedCallback(Popup.IsOpenProperty, (d, e) =>
         {
             if (popup.IsOpen)
             {
                 Window.Current.SizeChanged += handler;
             }
             else
             {
                 Window.Current.SizeChanged -= handler;
             }
         });
     }
     return popup;
 }
コード例 #5
0
ファイル: PopupService.cs プロジェクト: Rasetech/Template10
 public Popup Show(PopupSize size, UIElement content = null)
 {
     var popup = Create(size, content);
     popup.IsOpen = true;
     return popup;
 }
コード例 #6
0
        public Popup Show(PopupSize size, UIElement content = null)
        {
            var popup = Create(size, content);

            return(Show(popup));
        }