Beispiel #1
0
        public DialogResult ShowDialog(Control parent)
        {
            Gtk.Window parentWindow = null;
            if (parent != null && parent.ParentWindow != null)
            {
                parentWindow = parent.ParentWindow.ControlObject as Gtk.Window;
            }

            control          = new Gtk.MessageDialog(parentWindow, Gtk.DialogFlags.Modal, Type.ToGtk(), Buttons.ToGtk(), false, string.Empty);
            control.Text     = Text;
            control.TypeHint = Gdk.WindowTypeHint.Dialog;
            var caption = Caption ?? ((parent != null && parent.ParentWindow != null) ? parent.ParentWindow.Title : null);

            if (!string.IsNullOrEmpty(caption))
            {
                control.Title = caption;
            }
            // must add buttons manually for this case
            if (Buttons == MessageBoxButtons.YesNoCancel)
            {
                var bn = (Gtk.Button)control.AddButton(Gtk.Stock.No, (int)Gtk.ResponseType.No);
                bn.UseStock = true;
                var bc = (Gtk.Button)control.AddButton(Gtk.Stock.Cancel, (int)Gtk.ResponseType.Cancel);
                bc.UseStock = true;
                var by = (Gtk.Button)control.AddButton(Gtk.Stock.Yes, (int)Gtk.ResponseType.Yes);
                by.UseStock = true;
            }
            control.DefaultResponse = DefaultButton.ToGtk(Buttons);
            int ret = control.Run();

            control.Hide();
#if GTKCORE
            control.Dispose();
#else
            control.Destroy();
#endif
            var result = ((Gtk.ResponseType)ret).ToEto();
            if (result == DialogResult.None)
            {
                switch (Buttons)
                {
                case MessageBoxButtons.OK:
                    result = DialogResult.Ok;
                    break;

                case MessageBoxButtons.YesNo:
                    result = DialogResult.No;
                    break;

                case MessageBoxButtons.OKCancel:
                case MessageBoxButtons.YesNoCancel:
                    result = DialogResult.Cancel;
                    break;
                }
            }
            return(result);
        }
Beispiel #2
0
 protected override void ShowErrorDialog(string msg, bool isFatal)
 {
     // show the error dialog
     using (var dlg = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, isFatal ? Gtk.MessageType.Error : Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, null))
     {
         dlg.Title = Program.Settings.Target;
         dlg.Text  = msg;
         dlg.Run();
         dlg.Hide();
     }
 }
        private void DoCancel()
        {
            m_parser.Cancel = true;
            this.Hide();
            String message = Catalog.GetString("Import cancelled, all changes reverted.");

            Gtk.MessageDialog dlg = new Gtk.MessageDialog(this, Gtk.DialogFlags.Modal, Gtk.MessageType.Info,
                                                          Gtk.ButtonsType.Ok, message);
            dlg.Run();
            dlg.Hide();
            dlg.Dispose();
        }
Beispiel #4
0
        private bool validateEntry()
        {
            if (String.IsNullOrEmpty(nameEntry.Text))
            {
                Gtk.MessageDialog msg = new Gtk.MessageDialog(this, Gtk.DialogFlags.DestroyWithParent,
                                                              Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                                              "The name field is required.");
                msg.Run();
                msg.Hide();
                msg.Dispose();
                return(false);
            }

            /*if (!locationWidget.Latitude.ValidateEntry())
             *      return false;
             * if (!locationWidget.Longitude.ValidateEntry())
             *      return false;*/
            return(true);
        }
        public bool ValidateEntry()
        {
            try
            {
                int    degrees = int.Parse(degreeEntry.Text, CultureInfo.InvariantCulture);
                double minutes = double.Parse(minuteEntry.Text, CultureInfo.InvariantCulture);

                if (degrees < 0 || minutes < 0)
                {
                    throw new Exception();
                }
                return(true);
            }
            catch (Exception)
            {
                Gtk.MessageDialog dlg = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent,
                                                              Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                                              Catalog.GetString("Invalid Coordinate"));
                dlg.Run();
                dlg.Hide();
                dlg.Dispose();
                return(false);
            }
        }
 internal void HandleActivation(object sender, EventArgs e)
 {
     try {
         Gnome.Url.Show (url);
     } catch (Exception) {
         string msg = String.Format (GettextCatalog.GetString ("Could not open the url {0}"), url);
         Gtk.MessageDialog md = new Gtk.MessageDialog (null, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, msg);
         md.Run ();
         md.Hide ();
     }
 }
 private bool validateEntry()
 {
     if (String.IsNullOrEmpty(nameEntry.Text))
     {
         Gtk.MessageDialog msg = new Gtk.MessageDialog(this, Gtk.DialogFlags.DestroyWithParent,
                                                       Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                                       "The name field is required.");
         msg.Run();
         msg.Hide();
         msg.Dispose();
         return false;
     }
     /*if (!locationWidget.Latitude.ValidateEntry())
         return false;
     if (!locationWidget.Longitude.ValidateEntry())
         return false;*/
     return true;
 }
 private void DoCancel()
 {
     m_parser.Cancel = true;
     this.Hide ();
     String message = Catalog.GetString("Import cancelled, all changes reverted.");
     Gtk.MessageDialog dlg = new Gtk.MessageDialog (this, Gtk.DialogFlags.Modal, Gtk.MessageType.Info,
                                                    Gtk.ButtonsType.Ok, message);
     dlg.Run ();
     dlg.Hide ();
     dlg.Dispose ();
 }
        public bool ValidateEntry()
        {
            try
            {
                int degrees = int.Parse(degreeEntry.Text, CultureInfo.InvariantCulture);
                double minutes = double.Parse(minuteEntry.Text, CultureInfo.InvariantCulture);

                if (degrees < 0 || minutes < 0)
                    throw new Exception();
                return true;
            }
            catch (Exception)
            {
                Gtk.MessageDialog dlg = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent,
                                                              Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                                              Catalog.GetString("Invalid Coordinate"));
                dlg.Run();
                dlg.Hide();
                dlg.Dispose();
                return false;
            }
        }