Пример #1
0
        static private void ShowMsg(Gtk.Window main, string title, string txt, Gtk.MessageType type)
        {
            var dlg = new Gtk.MessageDialog(
                main,
                Gtk.DialogFlags.Modal,
                type,
                Gtk.ButtonsType.Ok,
                title
                );

            dlg.Text  = txt;
            dlg.Title = title;

            if (type == Gtk.MessageType.Error)
            {
                dlg.Title += " Error";
            }
            else
            {
                dlg.Title += " Information";
            }

            dlg.Run();
            dlg.Destroy();
        }
Пример #2
0
 static void ShowDialog(string title, string message, Gtk.MessageType msgType, Gtk.ButtonsType btnType)
 {
     Gtk.MessageDialog md = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, msgType, btnType, message);
     md.Title = title;
     md.Run();
     md.Destroy();
 }
Пример #3
0
 public CustomMessageDialog(
     Gtk.Window parent,
     Gtk.MessageType messageType,
     string format,
     params object[] args) :
     this(parent, messageType, Gtk.ButtonsType.Ok, "", String.Format(format, args))
 {
 }
Пример #4
0
 private void DisplayMsg(Gtk.MessageType MessageType, string msg)
 {
     HigMessageDialog.RunHigMessageDialog(null,
                                          Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent,
                                          MessageType,
                                          Gtk.ButtonsType.Ok,
                                          msg,
                                          null);
 }
Пример #5
0
 // constructor for a HIG confirmation alert with two buttons
 public HigMessageDialog(Gtk.Window parent,
                         Gtk.DialogFlags flags,
                         Gtk.MessageType type,
                         string header,
                         string msg,
                         string ok_caption)
     : this(parent, flags, type, Gtk.ButtonsType.Cancel, header, msg)
 {
     AddButton(ok_caption, Gtk.ResponseType.Ok, false);
 }
Пример #6
0
        void ShowMessageDialog(string title, string message, Gtk.MessageType messageType)
        {
            HIGMessageDialog dialog =
                new HIGMessageDialog(
                    Note.Window,
                    Gtk.DialogFlags.DestroyWithParent,
                    messageType,
                    Gtk.ButtonsType.Ok,
                    title,
                    message);

            dialog.Run();
            dialog.Destroy();
        }
Пример #7
0
        //Run and destroy a standard confirmation dialog
        public static Gtk.ResponseType RunHigConfirmation(Gtk.Window parent,
                                                          Gtk.DialogFlags flags,
                                                          Gtk.MessageType type,
                                                          string header,
                                                          string msg,
                                                          string ok_caption)
        {
            HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, header, msg, ok_caption);

            try {
                return((Gtk.ResponseType)hmd.Run());
            } finally {
                hmd.Destroy();
            }
        }
Пример #8
0
        //run and destroy a standard dialog
        public static Gtk.ResponseType RunHigMessageDialog(Gtk.Window parent,
                                                           Gtk.DialogFlags flags,
                                                           Gtk.MessageType type,
                                                           Gtk.ButtonsType buttons,
                                                           string header,
                                                           string msg)
        {
            HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, buttons, header, msg);

            try {
                return((Gtk.ResponseType)hmd.Run());
            } finally {
                hmd.Destroy();
            }
        }
Пример #9
0
        public CustomMessageDialog(
            Gtk.Window parent,
            Gtk.MessageType messageType,
            Gtk.ButtonsType buttonsType,
            string title, string text) : base(Gtk.WindowType.Toplevel)
        {
            this.Build();

            if (parent != null)
            {
                base.TransientFor = parent;
                base.SetPosition(Gtk.WindowPosition.CenterOnParent);
                base.Decorated = parent.Decorated;
            }
            else
            {
                base.SetPosition(Gtk.WindowPosition.Center);
            }
            base.KeepAbove = true;

            base.Title  = title;
            Text        = text;
            MessageType = messageType;
            ButtonsType = buttonsType;

            this.btnPositive.Clicked += HandlePositiveClicked;
            this.btnNegative.Clicked += HandleNegativeClicked;
            this.DeleteEvent         += delegate(object o, Gtk.DeleteEventArgs args)
            {
                if (btnNegative.Visible)
                {
                    this.btnNegative.Click();
                }
                else
                {
                    this.btnPositive.Click();
                }
            };
        }
Пример #10
0
 /// <summary>Show a message in a dialog box</summary>
 /// <param name="message">The message.</param>
 /// <param name="title">The dialog title</param>
 /// <param name="msgType">The type of dialog message</param>
 /// <param name="buttonType">Button type</param>
 /// <returns>The message dialog return value</returns>
 public int ShowMsgDialog(string message, string title, Gtk.MessageType msgType, Gtk.ButtonsType buttonType)
 {
     return(this.view.ShowMsgDialog(message, title, msgType, buttonType));
 }
Пример #11
0
        public HigMessageDialog(Gtk.Window parent,
                                Gtk.DialogFlags flags,
                                Gtk.MessageType type,
                                Gtk.ButtonsType buttons,
                                string header,
                                string msg)
            : base()
        {
            BorderWidth     = 5;
            Resizable       = false;
            Title           = "";
            SkipTaskbarHint = true;

            ContentArea.Spacing = 12;
            ActionArea.Layout   = Gtk.ButtonBoxStyle.End;

            Gtk.HBox hbox = new Gtk.HBox(false, 12);
            hbox.BorderWidth = 5;
            hbox.Show();
            ContentArea.PackStart(hbox, false, false, 0);

            image = null;

            switch (type)
            {
            case Gtk.MessageType.Error:
                image = new Gtk.Image(Gtk.Stock.DialogError, Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Question:
                image = new Gtk.Image(Gtk.Stock.DialogQuestion, Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Info:
                image = new Gtk.Image(Gtk.Stock.DialogInfo, Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Warning:
                image = new Gtk.Image(Gtk.Stock.DialogWarning, Gtk.IconSize.Dialog);
                break;
            }

            image.Yalign = 0.1f;
            image.Show();
            hbox.PackStart(image, false, false, 0);

            inner_vbox = new Gtk.VBox(false, 12);
            inner_vbox.Show();
            hbox.PackStart(inner_vbox, true, true, 0);

            label_vbox = new Gtk.VBox(false, 0);
            label_vbox.Show();
            inner_vbox.PackStart(label_vbox, true, true, 0);

            string title = String.Format("<span weight='bold' size='larger'>{0}" +
                                         "</span>\n",
                                         GLib.Markup.EscapeText(header));

            Gtk.Label label;

            label           = new Gtk.Label(title);
            label.UseMarkup = true;
            label.Justify   = Gtk.Justification.Left;
            label.LineWrap  = true;
            label.SetAlignment(0.0f, 0.5f);
            label.Show();
            label_vbox.PackStart(label, false, false, 0);

            message_label  = label = new Gtk.Label();
            label.Text     = msg;
            label.Justify  = Gtk.Justification.Left;
            label.LineWrap = true;
            label.SetAlignment(0.0f, 0.5f);
            label.Show();
            label_vbox.PackStart(label, false, false, 0);

            switch (buttons)
            {
            case Gtk.ButtonsType.None:
                break;

            case Gtk.ButtonsType.Ok:
                AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
                break;

            case Gtk.ButtonsType.Close:
                AddButton(Gtk.Stock.Close, Gtk.ResponseType.Close, true);
                break;

            case Gtk.ButtonsType.Cancel:
                AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, true);
                break;

            case Gtk.ButtonsType.YesNo:
                AddButton(Gtk.Stock.No, Gtk.ResponseType.No, false);
                AddButton(Gtk.Stock.Yes, Gtk.ResponseType.Yes, true);
                break;

            case Gtk.ButtonsType.OkCancel:
                AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false);
                AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
                break;
            }

            if (parent != null)
            {
                TransientFor = parent;
            }

            if ((int)(flags & Gtk.DialogFlags.Modal) != 0)
            {
                Modal = true;
            }

            if ((int)(flags & Gtk.DialogFlags.DestroyWithParent) != 0)
            {
                DestroyWithParent = true;
            }
        }
Пример #12
0
        public HIGMessageDialog(Gtk.Window parent,
                                Gtk.DialogFlags flags,
                                Gtk.MessageType type,
                                Gtk.ButtonsType buttons,
                                string header,
                                string msg)
            : base()
        {
            HasSeparator = false;
            BorderWidth  = 5;
            Resizable    = false;
            Title        = "";

            VBox.Spacing      = 12;
            ActionArea.Layout = Gtk.ButtonBoxStyle.End;

            accel_group = new Gtk.AccelGroup();
            AddAccelGroup(accel_group);

            Gtk.HBox hbox = new Gtk.HBox(false, 12);
            hbox.BorderWidth = 5;
            hbox.Show();
            VBox.PackStart(hbox, false, false, 0);

            switch (type)
            {
            case Gtk.MessageType.Error:
                image = new Gtk.Image(Gtk.Stock.DialogError,
                                      Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Question:
                image = new Gtk.Image(Gtk.Stock.DialogQuestion,
                                      Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Info:
                image = new Gtk.Image(Gtk.Stock.DialogInfo,
                                      Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Warning:
                image = new Gtk.Image(Gtk.Stock.DialogWarning,
                                      Gtk.IconSize.Dialog);
                break;

            default:
                image = new Gtk.Image();
                break;
            }

            if (image != null)
            {
                image.Show();
                image.Yalign = 0;
                hbox.PackStart(image, false, false, 0);
            }

            Gtk.VBox label_vbox = new Gtk.VBox(false, 0);
            label_vbox.Show();
            hbox.PackStart(label_vbox, true, true, 0);

            string title = String.Format("<span weight='bold' size='larger'>{0}" +
                                         "</span>\n",
                                         header);

            Gtk.Label label;

            label              = new Gtk.Label(title);
            label.UseMarkup    = true;
            label.UseUnderline = false;
            label.Justify      = Gtk.Justification.Left;
            label.LineWrap     = true;
            label.SetAlignment(0.0f, 0.5f);
            label.Show();
            label_vbox.PackStart(label, false, false, 0);

            label              = new Gtk.Label(msg);
            label.UseMarkup    = true;
            label.UseUnderline = false;
            label.Justify      = Gtk.Justification.Left;
            label.LineWrap     = true;
            label.SetAlignment(0.0f, 0.5f);
            label.Show();
            label_vbox.PackStart(label, false, false, 0);

            extra_widget_vbox = new Gtk.VBox(false, 0);
            extra_widget_vbox.Show();
            label_vbox.PackStart(extra_widget_vbox, true, true, 12);

            switch (buttons)
            {
            case Gtk.ButtonsType.None:
                break;

            case Gtk.ButtonsType.Ok:
                AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
                break;

            case Gtk.ButtonsType.Close:
                AddButton(Gtk.Stock.Close, Gtk.ResponseType.Close, true);
                break;

            case Gtk.ButtonsType.Cancel:
                AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, true);
                break;

            case Gtk.ButtonsType.YesNo:
                AddButton(Gtk.Stock.No, Gtk.ResponseType.No, false);
                AddButton(Gtk.Stock.Yes, Gtk.ResponseType.Yes, true);
                break;

            case Gtk.ButtonsType.OkCancel:
                AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false);
                AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
                break;
            }

            if (parent != null)
            {
                TransientFor = parent;
            }

            if ((int)(flags & Gtk.DialogFlags.Modal) != 0)
            {
                Modal = true;
            }

            if ((int)(flags & Gtk.DialogFlags.DestroyWithParent) != 0)
            {
                DestroyWithParent = true;
            }
        }
Пример #13
0
 internal void ShowMessageDialog(string message, string title, Gtk.ButtonsType buttonsType, Gtk.MessageType messageType)
 {
     Gtk.MessageDialog dlg = new Gtk.MessageDialog(this,
                                                   Gtk.DialogFlags.Modal,
                                                   messageType,
                                                   buttonsType, message);
     dlg.Title = title;
     dlg.Run();
     dlg.Destroy();
 }