本文整理汇总了C#中Gtk.MessageDialog.AddButton方法的典型用法代码示例。如果您正苦于以下问题:C# MessageDialog.AddButton方法的具体用法?C# MessageDialog.AddButton怎么用?C# MessageDialog.AddButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.MessageDialog
的用法示例。
在下文中一共展示了MessageDialog.AddButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CloseProject
public static bool CloseProject()
{
if (Project.Modified) {
string msg = Catalog.GetString ("Do you want to save the project before closing?");
Gtk.MessageDialog dlg = new Gtk.MessageDialog (null, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, ButtonsType.None, msg);
dlg.AddButton (Catalog.GetString ("Close without saving"), Gtk.ResponseType.No);
dlg.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
dlg.AddButton (Gtk.Stock.Save, Gtk.ResponseType.Yes);
Gtk.ResponseType res = (Gtk.ResponseType) dlg.Run ();
dlg.Destroy ();
if (res == Gtk.ResponseType.Cancel)
return false;
if (res == Gtk.ResponseType.Yes) {
if (!SaveProject ())
return false;
}
}
object[] obs = new object [openWindows.Count];
openWindows.Values.CopyTo (obs, 0);
foreach (Gtk.Widget page in obs) {
WidgetNotebook.Remove (page);
page.Destroy ();
}
openWindows.Clear ();
Project.Close ();
MainWindow.Title = "Stetic";
ProjectView.Clear ();
return true;
}
示例2: ShowCertDialog
private void ShowCertDialog ()
{
Logger.Debug ("Showing Cert Dialog: " + Handler.UserMessage);
CertPolicyHandler.Response ret = CertPolicyHandler.Response.None;
using (var handle = new AutoResetEvent(false)) {
Application.Invoke (delegate {
try {
using (MessageDialog md = new MessageDialog (null, DialogFlags.Modal,
MessageType.Warning, ButtonsType.None, Handler.UserMessage +
"\n\nDo you trust this certificate?") {
Title = "Untrusted Certificate"})
{
using (var noButton = md.AddButton("No", (int)CertPolicyHandler.Response.CertDeny))
using (var justNowButton = md.AddButton("Just now", (int)CertPolicyHandler.Response.CertAcceptSession))
using (var alwaysButton = md.AddButton("Always", (int)CertPolicyHandler.Response.CertAcceptAlways))
{
ret = (CertPolicyHandler.Response)md.Run ();
md.Destroy ();
}
}
} finally {
handle.Set ();
}
}
);
handle.WaitOne ();
}
Logger.Debug ("Cert Dialog return:" + ret.ToString ());
Handler.UserResponse = ret;
}
示例3: ShowYesNoCancelDialog
public static ResponseType ShowYesNoCancelDialog(Window parent, string message)
{
var dialog = new MessageDialog (parent, DialogFlags.Modal, MessageType.Question, ButtonsType.None, message);
dialog.AddButton ("Close without Saving", (int) ResponseType.No);
dialog.AddButton ("Cancel", (int) ResponseType.Cancel);
dialog.AddButton ("Save", (int) ResponseType.Yes);
ResponseType ret = (ResponseType) dialog.Run ();
dialog.Destroy ();
return ret;
}
示例4: Activated
private void Activated(object sender, EventArgs e)
{
// Commit any pending changes
PintaCore.Tools.Commit ();
// If it's not dirty, just close it
if (!PintaCore.Workspace.ActiveDocument.IsDirty) {
PintaCore.Workspace.CloseActiveDocument ();
return;
}
var primary = Catalog.GetString ("Save the changes to image \"{0}\" before closing?");
var secondary = Catalog.GetString ("If you don't save, all changes will be permanently lost.");
var message = string.Format (markup, primary, secondary);
var md = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal,
MessageType.Warning, ButtonsType.None, true,
message, System.IO.Path.GetFileName (PintaCore.Workspace.ActiveDocument.Filename));
// Use the standard button order for each OS.
if (PintaCore.System.OperatingSystem == OS.Windows) {
md.AddButton (Stock.Save, ResponseType.Yes);
md.AddButton (Catalog.GetString ("Close without saving"), ResponseType.No);
md.AddButton (Stock.Cancel, ResponseType.Cancel);
}
else {
md.AddButton (Catalog.GetString ("Close without saving"), ResponseType.No);
md.AddButton (Stock.Cancel, ResponseType.Cancel);
md.AddButton (Stock.Save, ResponseType.Yes);
}
// so that user won't accidentally overwrite
md.DefaultResponse = ResponseType.Cancel;
ResponseType response = (ResponseType)md.Run ();
md.Destroy ();
if (response == ResponseType.Yes) {
PintaCore.Workspace.ActiveDocument.Save (false);
// If the image is still dirty, the user
// must have cancelled the Save dialog
if (!PintaCore.Workspace.ActiveDocument.IsDirty)
PintaCore.Workspace.CloseActiveDocument ();
} else if (response == ResponseType.No) {
PintaCore.Workspace.CloseActiveDocument ();
}
}
示例5: Execute
public override bool Execute()
{
var message =
new MessageDialog(null, DialogFlags.DestroyWithParent,
MessageType.Info, ButtonsType.None,
Markup.EscapeText(_message));
if (_continue)
{
message.AddButton("Continue", ResponseType.Ok);
}
message.AddButton("Stop", ResponseType.Cancel);
var response = (ResponseType) message.Run();
message.Destroy();
return response == ResponseType.Ok;
}
示例6: ShowConfirmationDialog
public static void ShowConfirmationDialog (string title, string text, string icon_name, System.Action action)
{
MessageDialog md = new MessageDialog (null, 0, MessageType.Question, ButtonsType.None, text);
md.Title = title;
md.Image = Image.NewFromIconName (icon_name, Gtk.IconSize.Dialog);
md.Image.Visible = true;
md.Image.Show ();
md.AddButton (Stock.Cancel, ResponseType.Cancel);
md.AddButton (title, ResponseType.Ok);
md.DefaultResponse = ResponseType.Ok;
md.Response += (o, args) => {
if (args.ResponseId == ResponseType.Ok)
action.Invoke ();
md.Destroy ();
};
md.Show ();
}
示例7: ShowSavePendingChangesDialog
public System.Windows.Forms.DialogResult ShowSavePendingChangesDialog()
{
Gtk.MessageDialog dlg = new Gtk.MessageDialog(this, DialogFlags.Modal, MessageType.Question,
ButtonsType.None, false, "Save pending changes?");
dlg.AddButton ("Yes", ResponseType.Yes);
dlg.AddButton ("No", ResponseType.No);
dlg.AddButton("Cancel", ResponseType.Cancel);
int response = dlg.Run();
dlg.Destroy();
switch ((ResponseType)response)
{
case ResponseType.Yes:
return System.Windows.Forms.DialogResult.Yes;
case ResponseType.No:
return System.Windows.Forms.DialogResult.No;
case ResponseType.Cancel:
case ResponseType.DeleteEvent: // dialog close button
return System.Windows.Forms.DialogResult.Cancel;
default: // should never happen
return System.Windows.Forms.DialogResult.Abort;
}
}
示例8: ClipboardEmptyError
private void ClipboardEmptyError()
{
var primary = Catalog.GetString ("Paste cancelled");
var secondary = Catalog.GetString ("The clipboard does not contain an image");
var markup = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}\n";
markup = string.Format (markup, primary, secondary);
var md = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal,
MessageType.Error, ButtonsType.None, true,
markup);
md.AddButton (Stock.Ok, ResponseType.Yes);
md.Run ();
md.Destroy ();
}
示例9: Show
public override WindowResponse Show(object parent, string message, string title, MessageWindowType type, MessageWindowButtons bType)
{
Window p = (Window)parent;
MessageType t = GtkHelper.GetWinType(type);
MessageDialog md = new MessageDialog(p, DialogFlags.Modal, t, ButtonsType.None, message);
md.Title = title;
if (p != null && p.Icon != null) { md.Icon = p.Icon; }
md.WindowPosition = WindowPosition.CenterOnParent;
if (bType == MessageWindowButtons.Ok || bType == MessageWindowButtons.OkCancel) md.AddButton(Message.GetString("Ok"), ResponseType.Ok);
if (bType == MessageWindowButtons.Close) md.AddButton(Message.GetString("Close"), ResponseType.Close);
if (bType == MessageWindowButtons.YesNo || bType == MessageWindowButtons.YesNoCancel) { md.AddButton(Message.GetString("Yes"), ResponseType.Yes); md.AddButton(Message.GetString("No"), ResponseType.No); }
if (bType == MessageWindowButtons.AbortRetryIgnore || bType == MessageWindowButtons.RetryCancel) md.AddButton(Message.GetString("Retry"), ResponseType.Accept);
if (bType == MessageWindowButtons.AbortRetryIgnore) md.AddButton(Message.GetString("Ignore"), ResponseType.Reject);
if (bType == MessageWindowButtons.Cancel || bType == MessageWindowButtons.OkCancel || bType == MessageWindowButtons.RetryCancel || bType == MessageWindowButtons.YesNoCancel || bType == MessageWindowButtons.AbortRetryIgnore) md.AddButton(Message.GetString("Cancel"), ResponseType.Cancel);
ResponseType result = (ResponseType)md.Run();
md.Destroy();
return GtkHelper.GetResponse(result);
}
示例10: HandlePintaCoreActionsFileOpenActivated
private void HandlePintaCoreActionsFileOpenActivated(object sender, EventArgs e)
{
bool canceled = false;
if (PintaCore.Workspace.IsDirty) {
var primary = Catalog.GetString ("Save the changes to image \"{0}\" before opening a new image?");
var secondary = Catalog.GetString ("If you don't save, all changes will be permanently lost.");
var markup = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}\n";
markup = string.Format (markup, primary, secondary);
var md = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal,
MessageType.Question, ButtonsType.None, true,
markup,
System.IO.Path.GetFileName (PintaCore.Workspace.Filename));
md.AddButton (Catalog.GetString ("Continue without saving"), ResponseType.No);
md.AddButton (Stock.Cancel, ResponseType.Cancel);
md.AddButton (Stock.Save, ResponseType.Yes);
md.DefaultResponse = ResponseType.Cancel;
ResponseType response = (ResponseType)md.Run ();
md.Destroy ();
if (response == ResponseType.Yes) {
Save.Activate ();
}
else {
canceled = response == ResponseType.Cancel;
}
}
if (!canceled) {
var fcd = new Gtk.FileChooserDialog (Catalog.GetString ("Open Image File"), PintaCore.Chrome.MainWindow,
FileChooserAction.Open, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
Gtk.Stock.Open, Gtk.ResponseType.Ok);
// Add image files filter
FileFilter ff = new FileFilter ();
ff.AddPixbufFormats ();
ff.AddPattern ("*.ora");
ff.Name = Catalog.GetString ("Image files");
fcd.AddFilter (ff);
FileFilter ff2 = new FileFilter ();
ff2.Name = Catalog.GetString ("All files");
ff2.AddPattern ("*.*");
fcd.AddFilter (ff2);
fcd.SetCurrentFolder (lastDialogDir);
int response = fcd.Run ();
if (response == (int)Gtk.ResponseType.Ok) {
lastDialogDir = fcd.CurrentFolder;
if (OpenFile (fcd.Filename)) {
AddRecentFileUri (fcd.Uri);
PintaCore.Workspace.ActiveDocument.HasFile = true;
}
}
fcd.Destroy ();
}
}
示例11: HandlePintaCoreActionsFileExitActivated
private void HandlePintaCoreActionsFileExitActivated(object sender, EventArgs e)
{
bool canceled = false;
if (PintaCore.Workspace.IsDirty) {
var primary = Catalog.GetString ("Save the changes to image \"{0}\" before closing?");
var secondary = Catalog.GetString ("If you don't save, all changes will be permanently lost.");
var markup = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}\n";
markup = string.Format (markup, primary, secondary);
var md = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal,
MessageType.Question, ButtonsType.None, true,
markup,
System.IO.Path.GetFileName (PintaCore.Workspace.Filename));
md.AddButton (Catalog.GetString ("Close without saving"), ResponseType.No);
md.AddButton (Stock.Cancel, ResponseType.Cancel);
md.AddButton (Stock.Save, ResponseType.Yes);
// so that user won't accidentally overwrite
md.DefaultResponse = ResponseType.Cancel;
ResponseType response = (ResponseType)md.Run ();
md.Destroy ();
if (response == ResponseType.Yes) {
Save.Activate ();
}
else {
canceled = response == ResponseType.Cancel;
}
}
if (!canceled) {
if (BeforeQuit != null)
BeforeQuit (this, EventArgs.Empty);
PintaCore.History.Clear ();
(PintaCore.Layers.SelectionPath as IDisposable).Dispose ();
Application.Quit ();
}
}
示例12: HandleOpenRecentItemActivated
private void HandleOpenRecentItemActivated(object sender, EventArgs e)
{
bool canceled = false;
if (PintaCore.Workspace.IsDirty) {
var primary = Catalog.GetString ("Save the changes to image \"{0}\" before opening a new image?");
var secondary = Catalog.GetString ("If you don't save, all changes will be permanently lost.");
var markup = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}\n";
markup = string.Format (markup, primary, secondary);
var md = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal,
MessageType.Question, ButtonsType.None, true,markup,
System.IO.Path.GetFileName (PintaCore.Workspace.Filename));
md.AddButton (Catalog.GetString ("Continue without saving"), ResponseType.No);
md.AddButton (Stock.Cancel, ResponseType.Cancel);
md.AddButton (Stock.Save, ResponseType.Yes);
md.DefaultResponse = ResponseType.Cancel;
var response = (ResponseType)md.Run ();
md.Destroy ();
if (response == ResponseType.Yes) {
Save.Activate ();
}
else {
canceled = response == ResponseType.Cancel;
}
}
if (!canceled) {
string fileUri = (sender as RecentAction).CurrentUri;
OpenFile (new Uri (fileUri).LocalPath);
PintaCore.Workspace.ActiveDocument.HasFile = true;
}
}
示例13: ShowCertDialog
public UserResponse ShowCertDialog(String msg) {
Logger.Debug("Showing Cert Dialog: " + msg);
UserResponse ret = UserResponse.None;
ManualResetEvent ev = new ManualResetEvent(false);
#if __MonoCS__
Application.Invoke(delegate {
MessageDialog md = new MessageDialog (null, DialogFlags.Modal,
MessageType.Warning, ButtonsType.None, msg +
"\n\nDo you trust this certificate?") {
Title = "Untrusted Certificate"
};
md.AddButton("No", (int)UserResponse.CertDeny);
md.AddButton("Just now", (int)UserResponse.CertAcceptSession);
md.AddButton("Always", (int)UserResponse.CertAcceptAlways);
ret = (UserResponse)md.Run();
md.Destroy();
ev.Set();
});
#else
var r = MessageBox.Show(msg +
"\n\n"+ Properties_Resources.DoYouTrustTheCertificate,
Properties_Resources.UntrustedCertificate, MessageBoxButton.YesNoCancel, MessageBoxImage.Warning);
switch (r) {
case MessageBoxResult.Yes:
ret = UserResponse.CertAcceptAlways;
break;
case MessageBoxResult.No:
ret = UserResponse.CertDeny;
break;
case MessageBoxResult.Cancel:
ret = UserResponse.CertAcceptSession;
break;
}
ev.Set();
#endif
ev.WaitOne();
Logger.Debug("Cert Dialog return:" + ret.ToString());
return ret;
}
示例14: HandlerPintaCoreActionsEditPasteActivated
private void HandlerPintaCoreActionsEditPasteActivated(object sender, EventArgs e)
{
Document doc = PintaCore.Workspace.ActiveDocument;
PintaCore.Tools.Commit ();
Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
Path p;
// Don't dispose this, as we're going to give it to the history
Gdk.Pixbuf image = cb.WaitForImage ();
if (image == null)
return;
Gdk.Size canvas_size = PintaCore.Workspace.ImageSize;
// If the image being pasted is larger than the canvas size, allow the user to optionally resize the canvas
if (image.Width > canvas_size.Width || image.Height > canvas_size.Height)
{
string message = Catalog.GetString ("The image being pasted is larger than the canvas size. What would you like to do?");
var enlarge_dialog = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal, MessageType.Question, ButtonsType.None, message);
enlarge_dialog.AddButton (Catalog.GetString ("Expand canvas"), ResponseType.Accept);
enlarge_dialog.AddButton (Catalog.GetString ("Don't change canvas size"), ResponseType.Reject);
enlarge_dialog.AddButton (Stock.Cancel, ResponseType.Cancel);
enlarge_dialog.DefaultResponse = ResponseType.Accept;
ResponseType response = (ResponseType)enlarge_dialog.Run ();
enlarge_dialog.Destroy ();
if (response == ResponseType.Accept)
{
PintaCore.Workspace.ResizeCanvas (image.Width, image.Height, Pinta.Core.Anchor.Center);
PintaCore.Actions.View.UpdateCanvasScale ();
}
else if (response == ResponseType.Cancel || response == ResponseType.DeleteEvent)
{
return;
}
}
// Copy the paste to the temp layer
doc.CreateSelectionLayer ();
doc.ShowSelectionLayer = true;
using (Cairo.Context g = new Cairo.Context (doc.SelectionLayer.Surface)) {
g.DrawPixbuf (image, new Cairo.Point (0, 0));
p = g.CreateRectanglePath (new Rectangle (0, 0, image.Width, image.Height));
}
PintaCore.Tools.SetCurrentTool (Catalog.GetString ("Move Selected Pixels"));
Path old_path = doc.SelectionPath;
bool old_show_selection = doc.ShowSelection;
doc.SelectionPath = p;
doc.ShowSelection = true;
doc.Workspace.Invalidate ();
doc.History.PushNewItem (new PasteHistoryItem (image, old_path, old_show_selection));
}
示例15: ConfirmReplaceImage
private bool ConfirmReplaceImage()
{
bool canceled = false;
if (PintaCore.Workspace.IsDirty) {
var primary = Catalog.GetString ("Save the changes to image \"{0}\" before creating a new one?");
var secondary = Catalog.GetString ("If you don't save, all changes will be permanently lost.");
var markup = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}\n";
markup = string.Format (markup, primary, secondary);
var md = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal,
MessageType.Question, ButtonsType.None, true,
markup,
System.IO.Path.GetFileName (PintaCore.Workspace.Filename));
md.AddButton (Catalog.GetString ("Continue without saving"), ResponseType.No);
md.AddButton (Stock.Cancel, ResponseType.Cancel);
md.AddButton (Stock.Save, ResponseType.Yes);
md.DefaultResponse = ResponseType.Cancel;
md.AlternativeButtonOrder = new int[] { (int) ResponseType.Yes, (int) ResponseType.No, (int) ResponseType.Cancel };
ResponseType saveResponse = (ResponseType)md.Run ();
md.Destroy ();
if (saveResponse == ResponseType.Yes) {
PintaCore.Actions.File.Save.Activate ();
}
else {
canceled = saveResponse == ResponseType.Cancel;
}
}
return !canceled;
}