Exemple #1
0
            public AlertButton GenericAlert(Window parent, MessageDescription message)
            {
                var dialog = new AlertDialog(message)
                {
                    TransientFor = parent ?? DesktopService.GetParentForModalWindow()
                };

                return(dialog.Run());
            }
Exemple #2
0
            public string GetTextResponse(Window parent, string question, string caption, string initialValue, bool isPassword)
            {
                var dialog = new TextQuestionDialog {
                    Question     = question,
                    Caption      = caption,
                    Value        = initialValue,
                    IsPassword   = isPassword,
                    TransientFor = parent ?? DesktopService.GetParentForModalWindow()
                };

                if (dialog.Run())
                {
                    return(dialog.Value);
                }
                return(null);
            }
Exemple #3
0
        /// <summary>
        /// Positions a dialog relative to its parent on platforms where default placement is known to be poor.
        /// </summary>
        public static void PlaceDialog(Window childControl, Window parent)
        {
            //HACK: this is a workaround for broken automatic window placement on Mac
            if (!Platform.IsMac)
            {
                return;
            }

            if (parent == null)
            {
                if (childControl.nativeWidget is Gtk.Window gtkChild)
                {
                    if (gtkChild.Modal)
                    {
                        parent = DesktopService.GetParentForModalWindow();
                    }
                }
            }

            CenterWindow(childControl, parent);
        }
Exemple #4
0
        /// <summary>
        /// Places and runs a transient dialog. Does not destroy it, so values can be retrieved from its widgets.
        /// </summary>
        public static int RunCustomDialog(Dialog dlg, Window parent)
        {
            // if dialog is modal, make sure it's parented on any existing modal dialog
            Gtk.Dialog dialog = dlg;
            if (dialog.Modal)
            {
                parent = DesktopService.GetParentForModalWindow();
            }

            //ensure the dialog has a parent
            if (parent == null)
            {
                if (dialog.TransientFor != null)
                {
                    parent = dialog.TransientFor;
                }
                else
                {
                    parent = RootWindow;
                }
            }

            //TODO: use native parenting API for native windows
            if (parent.nativeWidget is Gtk.Window)
            {
                dialog.TransientFor      = parent;
                dialog.DestroyWithParent = true;
            }

            MonoDevelop.Components.IdeTheme.ApplyTheme(dialog);

            if (dialog.Title == null)
            {
                dialog.Title = BrandingService.ApplicationName;
            }

                        #if MAC
            Runtime.RunInMainThread(() => {
                // If there is a native NSWindow model window running, we need
                // to show the new dialog over that window.
                if (NSApplication.SharedApplication.ModalWindow != null || (parent.nativeWidget is NSWindow && dialog.Modal))
                {
                    EventHandler shownHandler = null;
                    shownHandler = (s, e) => {
                        ShowCustomModalDialog(dialog, parent);
                        dialog.Shown -= shownHandler;
                    };
                    dialog.Shown += shownHandler;
                }
                else
                {
                    PlaceDialog(dialog, parent);
                }
            }).Wait();
                        #endif

            var initialRootWindow = Xwt.MessageDialog.RootWindow;
            try {
                Xwt.MessageDialog.RootWindow = Xwt.Toolkit.CurrentEngine.WrapWindow(dialog);
                IdeApp.DisableIdleActions();
                int result = GtkWorkarounds.RunDialogWithNotification(dialog);
                // Focus parent window once the dialog is ran, as focus gets lost
                if (parent != null)
                {
                    DesktopService.FocusWindow(parent);
                }

                return(result);
            } finally {
                Xwt.MessageDialog.RootWindow = initialRootWindow;
                IdeApp.EnableIdleActions();
            }
        }