本文整理汇总了C#中Gtk.MessageDialog.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# MessageDialog.SetPosition方法的具体用法?C# MessageDialog.SetPosition怎么用?C# MessageDialog.SetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.MessageDialog
的用法示例。
在下文中一共展示了MessageDialog.SetPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunWarningDialog
public static void RunWarningDialog(string warning)
{
MessageDialog md = new MessageDialog (null,
DialogFlags.Modal,
MessageType.Warning,
ButtonsType.Ok,
warning);
md.SetPosition (WindowPosition.Center);
md.ShowAll ();
md.Run ();
md.Destroy ();
}
示例2: RunErrorDialog
public static void RunErrorDialog(string error)
{
MessageDialog md = new MessageDialog (null,
DialogFlags.Modal,
MessageType.Error,
ButtonsType.Ok,
error);
md.SetPosition (WindowPosition.Center);
md.ShowAll ();
md.Run ();
md.Destroy ();
}
示例3: RunQuestionDialog
public static bool RunQuestionDialog(string question)
{
MessageDialog md = new MessageDialog (null,
DialogFlags.Modal,
MessageType.Question,
ButtonsType.YesNo,
question);
md.SetPosition (WindowPosition.Center);
md.ShowAll ();
bool result = md.Run () == (int)ResponseType.Yes;
md.Destroy ();
return result;
}
示例4: ShowInfo
public static int ShowInfo(string message)
{
MessageDialog msg = new MessageDialog(null,
DialogFlags.Modal,
MessageType.Info,
ButtonsType.Ok,
message);
msg.ModifyBg(StateType.Normal, new Gdk.Color(0x54, 0xb8, 0x7b));
msg.SetPosition(WindowPosition.CenterOnParent);
msg.Modal = true;
msg.Title = "Info";
msg.Decorated = false;
msg.GrabFocus();
SetButtonRelief(msg);
int result = msg.Run();
msg.Destroy();
return result;
}
示例5: Show
public static ResponseType Show(Window parent, MessageType msgtype, ButtonsType buttontype, string format, params object[] args)
{
if(ComponentManager!=null && !ComponentManager.IsMainThread)
throw new Exception("message boxes may only be popped up from the main GUI thread, i.e., they need a surrounding Gtk.Application.Invoke(delegate {}); block");
if(ComponentManager!=null)
ComponentManager.MessageWriteLine(format, args);
#region treat batch mode case
if(ComponentManager!=null && ComponentManager.OperateInBatchMode && ComponentManager.Visible==false)
{
switch(buttontype)
{
case ButtonsType.None:
ComponentManager.MessageWriteLine("[NONE]");
return ResponseType.None;
case ButtonsType.Ok:
ComponentManager.MessageWriteLine("[OK]");
return ResponseType.Ok;
case ButtonsType.Close:
ComponentManager.MessageWriteLine("[CLOSE]");
return ResponseType.Close;
case ButtonsType.Cancel:
ComponentManager.MessageWriteLine("[CANCEL]");
return ResponseType.Cancel;
case ButtonsType.YesNo:
throw new Exception("sorry, but a yes/no messagebox cannot be decided in batch mode :(");
case ButtonsType.OkCancel:
#if true
throw new Exception("are we sure here we want an automatic [OK] click in batch mode???");
#else
// be BOLD and assume an automated "OK" in script mode???? hmmm........... might be dangerous.....
// "Do you really want to delete the internet? [OK]/[CANCEL]"......
ComponentManager.MessageWriteLine("[OK]");
return ResponseType.Ok;
#endif
}
throw new Exception("unknown message box button type");
}
#endregion
if(parent==null && ComponentManager!=null)
parent = ComponentManager;
MessageDialog md = new MessageDialog(parent, DialogFlags.Modal, msgtype, buttontype, format, args);
if(Platform.IsWindows) // replace Gtk's private icons by Windows standard icons
{
switch(msgtype)
{
case MessageType.Info: ((Gtk.Image) md.Image).Pixbuf = PIXBUF_INFO; break;
case MessageType.Warning: ((Gtk.Image) md.Image).Pixbuf = PIXBUF_WARNING; break;
case MessageType.Question: ((Gtk.Image) md.Image).Pixbuf = PIXBUF_QUESTION; break;
case MessageType.Error: ((Gtk.Image) md.Image).Pixbuf = PIXBUF_ERROR; break;
}
}
md.SetPosition(parent==null ? WindowPosition.Center : WindowPosition.CenterOnParent);
if(ComponentManager!=null)
{
md.Title = ComponentManager.ApplicationName;
md.Icon = ComponentManager.Icon;
}
else
{
md.Title = "";
md.Icon = null;
}
// localize button texts
foreach(Gtk.Widget w in md.ActionArea.Children)
{
Gtk.Button b = w as Gtk.Button;
if(b!=null)
b.Label = b.Label.Localized("Docking.Components");
}
ResponseType result = (ResponseType) md.Run();
md.Destroy();
return result;
}
示例6: RunInfoDialog
public static void RunInfoDialog(string message)
{
MessageDialog md = new MessageDialog (null,
DialogFlags.Modal,
MessageType.Info,
ButtonsType.Ok,
message);
md.SetPosition (WindowPosition.Center);
md.ShowAll ();
md.Run ();
md.Destroy ();
}