本文整理汇总了C#中Gtk.Image.SetFromStock方法的典型用法代码示例。如果您正苦于以下问题:C# Image.SetFromStock方法的具体用法?C# Image.SetFromStock怎么用?C# Image.SetFromStock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Image
的用法示例。
在下文中一共展示了Image.SetFromStock方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ActionMenuItem
public ActionMenuItem (TileAction action) : base (action.Name)
{
this.action_delegate = action.Action;
if (action.Stock != null) {
Gtk.Image image = new Gtk.Image ();
image.SetFromStock (action.Stock, IconSize.Menu);
image.Show ();
this.Image = image;
}
}
示例2: ErrorAlert
public static void ErrorAlert(string primary, string secondary, Gtk.Window parent)
{
Gtk.Image image = new Gtk.Image();
image.SetFromStock(Gtk.Stock.DialogError, Gtk.IconSize.Dialog);
Gtk.Dialog dialog = Alert(primary, secondary, image, parent);
// prepare error dialog
dialog.AddButton(Gtk.Stock.Ok, ResponseType.Ok);
dialog.ShowAll();
// run dialog
dialog.Run();
dialog.Destroy();
}
示例3: iFolderExceptionDialog
public iFolderExceptionDialog( Gtk.Window parent,
System.Exception exception)
: base()
{
this.Title = Util.GS("iFolder Error");
this.HasSeparator = true;
this.Resizable = false;
this.Modal = true;
this.ex = exception;
if(parent != null)
this.TransientFor = parent;
HBox h = new HBox();
h.BorderWidth = 10;
h.Spacing = 10;
Image i = new Image();
i.SetFromStock(Gtk.Stock.DialogError, IconSize.Dialog);
i.SetAlignment(0.5F, 0);
h.PackStart(i, false, false, 0);
VBox v = new VBox();
v.BorderWidth = 10;
v.Spacing = 10;
Label l = new Label("<span weight=\"bold\" size=\"larger\">" +
GLib.Markup.EscapeText(exception.Message) + "</span>");
l.LineWrap = true;
l.UseMarkup = true;
l.UseUnderline = false;
l.Selectable = true;
l.Xalign = 0; l.Yalign = 0;
v.PackStart(l);
dButton = new Button(Util.GS("Show Details"));
dButton.Clicked += new EventHandler(ButtonPressed);
HBox bhbox = new HBox();
bhbox.PackStart(dButton, false, false, 0);
v.PackEnd(bhbox, false, false, 0);
details = new Label(Util.GS("Click \"Show Details\" below to get the full message returned with this error"));
details.LineWrap = true;
details.Selectable = true;
details.Xalign = 0; details.Yalign = 0;
v.PackEnd(details);
h.PackEnd(v);
h.ShowAll();
this.VBox.Add(h);
this.AddButton(Stock.Close, ResponseType.Ok);
}
示例4: NotifyWindow
public NotifyWindow(Gtk.Widget parent, string message, string details,
Gtk.MessageType messageType, uint timeout)
: base(Gtk.WindowType.Popup)
{
this.AppPaintable = true;
parentWidget = parent;
this.timeout = timeout;
activeBackgroundColor = new Gdk.Color(249, 253, 202);
inactiveBackgroundColor = new Gdk.Color(255, 255, 255);
Gtk.HBox outBox = new HBox();
this.Add(outBox);
outBox.BorderWidth = (uint)wbsize;
Gtk.VBox closeBox = new VBox();
closeBox.BorderWidth = 3;
outBox.PackEnd(closeBox, true, true, 0);
EventBox eBox = new EventBox();
eBox.ButtonPressEvent +=
new ButtonPressEventHandler(OnCloseEvent);
Gtk.Image closeImg = new Gtk.Image();
closeImg.SetFromStock(Gtk.Stock.Close,
IconSize.Menu);
eBox.Add(closeImg);
closeBox.PackStart(eBox, false, false, 0);
Label padder = new Label("");
outBox.PackStart(padder, false, false, 5);
Gtk.VBox vbox = new VBox();
outBox.PackStart(vbox, true, true, 0);
vbox.BorderWidth = 10;
Gtk.HBox hbox = new HBox();
hbox.Spacing = 5;
vbox.PackStart(hbox, false, false, 0);
VBox iconVBox = new VBox();
hbox.PackStart(iconVBox, false, false, 0);
Gtk.Image msgImage = new Gtk.Image();
switch(messageType)
{
case Gtk.MessageType.Info:
msgImage.SetFromStock(Gtk.Stock.DialogInfo,
IconSize.Button);
break;
case Gtk.MessageType.Warning:
msgImage.SetFromStock(Gtk.Stock.DialogWarning,
IconSize.Button);
break;
case Gtk.MessageType.Question:
msgImage.SetFromStock(Gtk.Stock.DialogQuestion,
IconSize.Button);
break;
case Gtk.MessageType.Error:
msgImage.SetFromStock(Gtk.Stock.DialogError,
IconSize.Button);
break;
}
iconVBox.PackStart(msgImage, false, false, 0);
VBox messageVBox = new VBox();
hbox.PackStart(messageVBox, true, true, 0);
Label l = new Label();
l.Markup = "<span size=\"small\" weight=\"bold\">" + message + "</span>";
l.LineWrap = false;
l.UseMarkup = true;
l.Selectable = false;
l.Xalign = 0;
l.Yalign = 0;
l.LineWrap = true;
l.Wrap = true;
l.WidthRequest = messageTextWidth;
messageVBox.PackStart(l, false, true, 0);
detailsTextView = new LinkTextView(details);
detailsTextView.Editable = false;
detailsTextView.CursorVisible = false;
detailsTextView.WrapMode = WrapMode.Word;
detailsTextView.SizeAllocate(new Gdk.Rectangle(0, 0, messageTextWidth, 600));
detailsTextView.LinkClicked +=
new LinkClickedEventHandler(OnLinkClicked);
messageVBox.PackStart(detailsTextView, false, false, 3);
Label spacer = new Label();
spacer.UseMarkup = true;
spacer.Markup = "<span size=\"xx-small\"> </span>";
messageVBox.PackEnd(spacer, false, false, 0);
closeWindowTimeoutID = 0;
}
示例5: TrocaLabel
protected void TrocaLabel(object sender, System.EventArgs e)
{
Image img = new Image();
img.SetFromStock(Stock.SortAscending, IconSize.Button);
if (botaoOrdena.Label == "Ordem natural")
{
vetor = JanelaPrincipal.copiaBruta;
botaoOrdena.Label = "Ordenar lista";
botaoOrdena.Image = img;
vetorEscolhido = 'C';
}
else
{
vetor = JanelaPrincipal.vetorDT;
botaoOrdena.Label = "Ordem natural";
botaoOrdena.Image = img;
vetorEscolhido = 'V';
}
Atualiza();
}
示例6: Init
internal void Init(Gtk.Window parent,
DialogType type,
ButtonSet buttonSet,
string title,
string statement,
string secondaryStatement,
string details)
{
this.Title = title;
this.HasSeparator = false;
this.Resizable = false;
this.Modal = true;
if(parent != null)
this.TransientFor = parent;
HBox h = new HBox();
h.BorderWidth = 10;
h.Spacing = 10;
dialogImage = new Image();
switch(type)
{
case DialogType.Error:
dialogImage.SetFromStock(Gtk.Stock.DialogError, IconSize.Dialog);
break;
case DialogType.Question:
dialogImage.SetFromStock(Gtk.Stock.DialogQuestion, IconSize.Dialog);
break;
case DialogType.Warning:
dialogImage.SetFromStock(Gtk.Stock.DialogWarning, IconSize.Dialog);
break;
default:
case DialogType.Info:
dialogImage.SetFromStock(Gtk.Stock.DialogInfo, IconSize.Dialog);
break;
}
dialogImage.SetAlignment(0.5F, 0);
h.PackStart(dialogImage, false, false, 0);
VBox v = new VBox();
v.Spacing = 10;
Label l = new Label();
l.LineWrap = true;
l.UseMarkup = true;
l.Selectable = false;
l.CanFocus = false;
l.Xalign = 0; l.Yalign = 0;
l.Markup = "<span weight=\"bold\" size=\"larger\">" + GLib.Markup.EscapeText(statement) + "</span>";
v.PackStart(l);
l = new Label(secondaryStatement);
l.LineWrap = true;
l.Selectable = false;
l.CanFocus = false;
l.Xalign = 0; l.Yalign = 0;
v.PackStart(l, true, true, 8);
if (details != null)
{
detailsExpander = new Expander(Util.GS("_Details"));
v.PackStart(detailsExpander, false, false, 0);
TextView textView = new TextView();
textView.Editable = false;
textView.WrapMode = WrapMode.Char;
TextBuffer textBuffer = textView.Buffer;
textBuffer.Text = details;
showDetailsScrolledWindow = new ScrolledWindow();
detailsExpander.Add(showDetailsScrolledWindow);
showDetailsScrolledWindow.AddWithViewport(textView);
showDetailsScrolledWindow.Visible = false;
}
extraWidgetVBox = new VBox(false, 0);
v.PackStart(extraWidgetVBox, false, false, 0);
extraWidgetVBox.NoShowAll = true;
extraWidget = null;
h.PackEnd(v);
h.ShowAll();
this.VBox.Add(h);
Widget defaultButton;
switch(buttonSet)
{
default:
case ButtonSet.Ok:
defaultButton = this.AddButton(Stock.Ok, ResponseType.Ok);
break;
case ButtonSet.OkCancel:
this.AddButton(Stock.Cancel, ResponseType.Cancel);
defaultButton = this.AddButton(Stock.Ok, ResponseType.Ok);
break;
case ButtonSet.YesNo:
this.AddButton(Stock.No, ResponseType.No);
defaultButton = this.AddButton(Stock.Yes, ResponseType.Yes);
break;
}
defaultButton.CanDefault = true;
defaultButton.GrabFocus();
}
示例7: RemoveAccountDialog
public RemoveAccountDialog(DomainInformation domainInfo)
: base()
{
this.Title = "";
this.Resizable = false;
this.HasSeparator = false;
HBox h = new HBox();
h.BorderWidth = 10;
h.Spacing = 10;
Image i = new Image();
i.SetFromStock(Gtk.Stock.DialogQuestion, IconSize.Dialog);
i.SetAlignment(0.5F, 0);
h.PackStart(i, false, false, 0);
VBox v = new VBox();
Label l = new Label("<span weight=\"bold\" size=\"larger\">" +
Util.GS("Remove this iFolder account?") + "</span>");
l.LineWrap = true;
l.UseMarkup = true;
l.Selectable = false;
l.Xalign = 0; l.Yalign = 0;
v.PackStart(l, false, false, 10);
Table table = new Table(3, 2, false);
table.RowSpacing = 0;
table.ColumnSpacing = 10;
table.Homogeneous = false;
l = new Label(Util.GS("System Name:"));
l.Xalign = 1;
table.Attach(l, 0,1, 0,1,
AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
l = new Label(domainInfo.Name);
l.UseUnderline = false;
l.Xalign = 0;
table.Attach(l, 1,2, 0,1,
AttachOptions.Fill | AttachOptions.Expand, 0,0,0);
l = new Label(Util.GS("Server:"));
l.Xalign = 1;
table.Attach(l, 0,1, 1,2,
AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
l = new Label(domainInfo.Host);
l.Xalign = 0;
table.Attach(l, 1,2, 1,2,
AttachOptions.Fill | AttachOptions.Expand, 0,0,0);
l = new Label(Util.GS("Username:"));
l.Xalign = 1;
table.Attach(l, 0,1, 2,3,
AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
l = new Label(domainInfo.MemberName);
l.UseUnderline = false;
l.Xalign = 0;
table.Attach(l, 1,2, 2,3,
AttachOptions.Fill | AttachOptions.Expand, 0,0,0);
v.PackEnd(table, true, true, 0);
h.PackEnd(v);
this.VBox.PackStart(h, true, true, 0);
cbutton = new CheckButton(Util.GS("_Remove my iFolders and files from the server"));
this.VBox.PackStart(cbutton, false, false, 10);
cbutton.Toggled +=
new EventHandler(OnRemoveiFoldersToggled);
if (!domainInfo.Active || !domainInfo.Authenticated)
{
cbutton.Sensitive = false;
}
this.VBox.ShowAll();
Button noButton = new Button(Stock.No);
noButton.CanFocus = true;
noButton.CanDefault = true;
noButton.ShowAll();
this.AddActionWidget(noButton, ResponseType.No);
this.AddButton(Stock.Yes, ResponseType.Yes);
this.DefaultResponse = ResponseType.No;
this.FocusChild = noButton;
}
示例8: HandleGeneratebuttonClicked
void HandleGeneratebuttonClicked(object sender, EventArgs e)
{
Dialog d = new Dialog ("Generate Seed", this.window, DialogFlags.DestroyWithParent,
Stock.Ok, ResponseType.Ok, Stock.Cancel, ResponseType.Cancel);
HBox hbox1 = new HBox (false, 0);
Image icon = new Image ();
icon.SetFromStock (Stock.DialogQuestion, IconSize.Dialog);
Label l1 = new Label ();
l1.Text = "<span weight=\"bold\" size=\"x-large\">Enter in a seed for the random name generator below.</span>";
l1.UseMarkup = true;
hbox1.PackStart (icon, false, true, 0);
hbox1.PackEnd (l1, false, true, 0);
HBox hbox2 = new HBox (false, 0);
Random r = new Random (DateTime.Now.Millisecond);
Entry entry = new Entry (r.Next ().ToString ());
hbox2.PackStart (new Label ("Enter seed integer:"), false, true, 0);
hbox2.PackEnd (entry);
d.VBox.PackStart (hbox1, false, true, 0);
d.VBox.PackEnd (hbox2, true, true, 0);
d.ShowAll ();
int result = d.Run ();
if ((ResponseType)result == ResponseType.Ok)
{
try
{
int seed = Convert.ToInt32 (entry.Text);
this.HandleGenerateName (seed);
}
catch (ArgumentNullException ex)
{
this.ReportError (ex);
}
catch (FormatException ex)
{
this.ReportError (ex);
}
catch (OverflowException ex)
{
this.ReportError (ex);
}
}
d.Hide ();
d.Destroy ();
}
示例9: ReportError
public void ReportError(Exception ex)
{
Dialog d = new Dialog (ex.GetType ().ToString (), this.window, DialogFlags.DestroyWithParent,
Stock.Ok, ResponseType.Ok);
Image icon = new Image ();
icon.SetFromStock (Stock.DialogError, IconSize.Dialog);
Label l1 = new Label ();
l1.Text = "<span weight=\"bold\" size=\"x-large\">" + ex.GetType ().ToString () + "</span>";
l1.UseMarkup = true;
HBox hbox = new HBox (false, 0);
hbox.PackStart (icon, false, true, 0);
hbox.PackEnd (l1, true, true, 0);
d.VBox.PackStart (hbox, false, true, 0);
d.VBox.PackStart (new Label (ex.Message), false, true, 0);
d.VBox.PackStart (new Label (ex.Source), false, true, 0);
ScrolledWindow sw = new ScrolledWindow ();
TextView tv = new TextView ();
tv.Editable = false;
tv.Buffer.Text = ex.StackTrace;
sw.Add (tv);
d.VBox.PackEnd (sw, true, true, 0);
d.ShowAll ();
d.Run ();
d.Hide ();
d.Destroy ();
}