Exemplo n.º 1
0
        public DialogResult Show(IWindow?parent)
        {
            var    window = NativeCast.To <GtkWindow>(parent);
            IntPtr dialog = IntPtr.Zero;

            try
            {
                using GLibString title   = Title;
                using GLibString message = Message;
                dialog = Gtk.Dialog.CreateMessageDialog(
                    window?.Handle ?? IntPtr.Zero,
                    GtkDialogFlags.Modal | GtkDialogFlags.DestroyWithParent,
                    GtkMessageType.Other,
                    MapButtons(Buttons),
                    IntPtr.Zero);

                GLib.SetProperty(dialog, "title", title);
                GLib.SetProperty(dialog, "text", message);

                var result = Gtk.Dialog.Run(dialog);
                return(MapResult(result));
            }
            finally { if (dialog != IntPtr.Zero)
                      {
                          Gtk.Widget.Destroy(dialog);
                      }
            }
        }
Exemplo n.º 2
0
        public DialogResult Show(IWindow parent)
        {
            var window = parent as GtkWindow;

            if (parent != null && window == null)
            {
                throw new ArgumentException("Invalid window type.", nameof(parent));
            }

            IntPtr dialog = IntPtr.Zero;

            try
            {
                using (GLibString title = Title)
                    using (GLibString message = Message)
                    {
                        dialog = Gtk.Dialog.CreateMessageDialog(
                            window?.Handle ?? IntPtr.Zero,
                            GtkDialogFlags.Modal | GtkDialogFlags.DestroyWithParent,
                            GtkMessageType.Other,
                            MapButtons(Buttons),
                            IntPtr.Zero);

                        GLib.SetProperty(dialog, "title", title);
                        GLib.SetProperty(dialog, "text", message);

                        var result = Gtk.Dialog.Run(dialog);
                        return(MapResult(result));
                    }
            }
            finally { if (dialog != IntPtr.Zero)
                      {
                          Gtk.Widget.Destroy(dialog);
                      }
            }
        }