/// <summary>
        /// Windowを生成して返す
        /// </summary>
        /// <returns></returns>
        protected virtual Window CreateWindow(INotification notification)
        {
            Window window;

            if (this.WindowType == null)
            {
                if (notification == null)
                {
                    window = new DefaultWindow()
                    {
                        Width = 300, Height = 150
                    };
                }
                else if (notification is IConfirmation)
                {
                    window = new DefaultConfirmationWindow()
                    {
                        Confirmation = (IConfirmation)notification
                    };
                }
                else
                {
                    window = new DefaultNotificationWindow()
                    {
                        Notification = notification
                    };
                }
            }
            else
            {
                window = this.WindowType.GetConstructor(Type.EmptyTypes).Invoke(null) as Window;
            }
            return(window);
        }
Example #2
0
        /// <summary>
        /// When no WindowContent is sent this method is used to create a default basic window to show
        /// the corresponding <see cref="INotification"/> or <see cref="IConfirmation"/>.
        /// </summary>
        /// <param name="notification">The INotification or IConfirmation parameter to show.</param>
        /// <returns></returns>
        protected MetroWindow CreateDefaultWindow(INotification notification)
        {
            MetroWindow window = null;

            if (notification is INormalNotification)
            {
                window = new DefaultWindow()
                {
                    Notification = notification
                };
            }
            else if (notification is IConfirmation)
            {
                window = new DefaultConfirmationWindow()
                {
                    Confirmation = (IConfirmation)notification
                };
            }
            else
            {
                var findItem = PopupWindows.CurrentWidows.Find(o => o.Uid == notification.Id);
                if (findItem != null)
                {
                    window = findItem;
                }
                else
                {
                    notification.Id = notification.Id ?? Guid.NewGuid().ToString();
                    window          = new DefaultNotificationWindow()
                    {
                        Notification = notification
                    };
                    window.Uid = notification.Id;
                }

                //notification.Id = notification.Id ?? Guid.NewGuid().ToString();
                //window = new DefaultNotificationWindow() { Notification = notification };
                //window.Uid = notification.Id;
            }

            var mainWindow = Application.Current.MainWindow;

            window.Uid = notification.Id;
            // notification.SecOwner = window;
            if (notification.SecondOwner)
            {
                // window.Owner = notification.SecOwner;
            }
            else
            {
                window.Owner = mainWindow;
            }

            PopupWindows.CurrentWidows.Add(window);

            //  PopupWindows.CurrentWidows.Add(window);

            return(window);
        }
Example #3
0
        /// <summary>
        /// When no WindowContent is sent this method is used to create a default basic window to show
        /// the corresponding <see cref="INotification"/> or <see cref="IConfirmation"/>.
        /// </summary>
        /// <param name="notification">The INotification or IConfirmation parameter to show.</param>
        /// <returns></returns>
        protected Window CreateDefaultWindow(INotification notification)
        {
            Window window = null;

            if (notification is IConfirmation)
            {
                window = new DefaultConfirmationWindow()
                {
                    Confirmation = (IConfirmation)notification
                };
            }
            else
            {
                window = new DefaultNotificationWindow()
                {
                    Notification = notification
                };
            }

            return(window);
        }
Example #4
0
        public void WhenWindowContentIsNotSet_ShouldUseDefaultWindowForConfirmations()
        {
            TestablePopupWindowAction popupWindowAction = new TestablePopupWindowAction();

            popupWindowAction.IsModal = true;
            popupWindowAction.CenterOverAssociatedObject = true;

            INotification notification = new Confirmation();

            notification.Title   = "Title";
            notification.Content = "Content";

            Assert.True(popupWindowAction.IsModal);
            Assert.True(popupWindowAction.CenterOverAssociatedObject);

            Window window = popupWindowAction.GetWindow(notification);

            Assert.IsType <DefaultConfirmationWindow>(window);

            DefaultConfirmationWindow defaultWindow = window as DefaultConfirmationWindow;

            Assert.Same(defaultWindow.Confirmation, notification);
        }
Example #5
0
        public void WhenWindowContentIsNotSet_ShouldUseDefaultWindowForConfirmations()
        {
            TestablePopupWindowAction popupWindowAction = new TestablePopupWindowAction();

            popupWindowAction.IsModal = true;
            popupWindowAction.CenterOverAssociatedObject = true;

            INotification notification = new Confirmation();

            notification.Title   = "Title";
            notification.Content = "Content";

            Assert.AreEqual(popupWindowAction.IsModal, true);
            Assert.AreEqual(popupWindowAction.CenterOverAssociatedObject, true);

            Window window = popupWindowAction.GetWindow(notification);

            Assert.IsInstanceOfType(window, typeof(DefaultConfirmationWindow));

            DefaultConfirmationWindow defaultWindow = window as DefaultConfirmationWindow;

            Assert.ReferenceEquals(defaultWindow.Confirmation, notification);
        }