Beispiel #1
0
        /// <inheritdoc />
        public bool Close(INotifyPropertyChanged viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            foreach (Window?window in Application.Current.Windows)
            {
                if (window == null || !viewModel.Equals(window.DataContext))
                {
                    continue;
                }

                try
                {
                    window.Close();
                    return(true);
                }
                catch (Exception e)
                {
                    Logger.Write($"Failed to close dialog: {e}");
                    break;
                }
            }

            return(false);
        }
Beispiel #2
0
        /// <inheritdoc />
        public bool Activate(INotifyPropertyChanged viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            return((
                       from Window? window in Application.Current.Windows
                       where window != null
                       where viewModel.Equals(window.DataContext)
                       select window.Activate()
                       ).FirstOrDefault());
        }
Beispiel #3
0
        /// <inheritdoc />
        public bool Activate(INotifyPropertyChanged viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            foreach (Window window in Application.Current.Windows)
            {
                if (viewModel.Equals(window.DataContext))
                {
                    return(window.Activate());
                }
            }

            return(false);
        }
Beispiel #4
0
        /// <inheritdoc />
        public void Close(INotifyPropertyChanged viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            foreach (Window?window in Application.Current.Windows)
            {
                if (window == null)
                {
                    continue;
                }

                if (viewModel.Equals(window.DataContext))
                {
                    window.Close();
                    return;
                }
            }

            throw new DialogNotFoundException();
        }