Esempio n. 1
0
        private static Window SetupExternalDialogWindow(BaseMetroDialog dialog)
        {
            var win = CreateExternalWindow();

            win.Width         = SystemParameters.PrimaryScreenWidth;
            win.MinHeight     = SystemParameters.PrimaryScreenHeight / 4.0;
            win.SizeToContent = SizeToContent.Height;

            dialog.ParentDialogWindow = win; //THIS IS ONLY, I REPEAT, ONLY SET FOR EXTERNAL DIALOGS!

            win.Content = dialog;

            dialog.HandleThemeChange();

            EventHandler closedHandler = null;

            closedHandler = (sender, args) =>
            {
                win.Closed -= closedHandler;
                dialog.ParentDialogWindow = null;
                win.Content = null;
            };
            win.Closed += closedHandler;

            return(win);
        }
Esempio n. 2
0
        private static Window SetupExternalDialogWindow(BaseMetroDialog dialog, [CanBeNull] Window windowOwner = null)
        {
            var win = CreateExternalWindow();

            win.Owner = windowOwner ?? Application.Current?.MainWindow;

            // Remove the border on left and right side
            win.BeginInvoke(x =>
            {
                x.SetCurrentValue(Control.BorderThicknessProperty, new Thickness(0, x.BorderThickness.Top, 0, x.BorderThickness.Bottom));
                if (x is MetroWindow metroWindow)
                {
                    metroWindow.SetCurrentValue(MetroWindow.ResizeBorderThicknessProperty, new Thickness(0, metroWindow.ResizeBorderThickness.Top, 0, metroWindow.ResizeBorderThickness.Bottom));
                }
            },
                            DispatcherPriority.Loaded);

            // Get the monitor working area
            var monitorWorkingArea = win.Owner.GetMonitorWorkSize();

            if (monitorWorkingArea != default)
            {
                win.Width     = monitorWorkingArea.Width;
                win.MinHeight = monitorWorkingArea.Height / 4.0;
                win.MaxHeight = monitorWorkingArea.Height;
            }
            else
            {
                win.Width     = SystemParameters.PrimaryScreenWidth;
                win.MinHeight = SystemParameters.PrimaryScreenHeight / 4.0;
                win.MaxHeight = SystemParameters.PrimaryScreenHeight;
            }

            dialog.ParentDialogWindow = win; //THIS IS ONLY, I REPEAT, ONLY SET FOR EXTERNAL DIALOGS!

            win.Content = dialog;

            dialog.HandleThemeChange();

            EventHandler closedHandler = null;

            closedHandler = (sender, args) =>
            {
                win.Closed -= closedHandler;
                dialog.ParentDialogWindow = null;
                win.Content = null;
            };
            win.Closed += closedHandler;

            win.SizeToContent = SizeToContent.Height;

            return(win);
        }