本文整理汇总了C#中Gtk.Dialog.AddActionWidget方法的典型用法代码示例。如果您正苦于以下问题:C# Dialog.AddActionWidget方法的具体用法?C# Dialog.AddActionWidget怎么用?C# Dialog.AddActionWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Dialog
的用法示例。
在下文中一共展示了Dialog.AddActionWidget方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LaunchDialogue
public override void LaunchDialogue()
{
//dialogue and buttons
Dialog dialog = new Dialog ();
dialog.Title = "Expandable Object Editor ";
dialog.Modal = true;
dialog.AllowGrow = true;
dialog.AllowShrink = true;
dialog.Modal = true;
dialog.AddActionWidget (new Button (Stock.Cancel), ResponseType.Cancel);
dialog.AddActionWidget (new Button (Stock.Ok), ResponseType.Ok);
//propGrid
grid = new PropertyGrid (parentRow.ParentGrid.EditorManager);
grid.CurrentObject = parentRow.PropertyValue;
grid.WidthRequest = 200;
grid.ShowHelp = false;
dialog.VBox.PackStart (grid, true, true, 5);
//show and get response
dialog.ShowAll ();
ResponseType response = (ResponseType) dialog.Run();
dialog.Destroy ();
//if 'OK' put items back in collection
if (response == ResponseType.Ok)
{
}
//clean up so we start fresh if launched again
}
示例2: BuildUI
protected override void BuildUI ()
{
base.BuildUI ();
string title = Catalog.GetString ("Sharpen");
dialog = new Gtk.Dialog (title, (Gtk.Window) this,
DialogFlags.DestroyWithParent, new object [0]);
dialog.BorderWidth = 12;
dialog.VBox.Spacing = 6;
Gtk.Table table = new Gtk.Table (3, 2, false);
table.ColumnSpacing = 6;
table.RowSpacing = 6;
table.Attach (SetFancyStyle (new Gtk.Label (Catalog.GetString ("Amount:"))), 0, 1, 0, 1);
table.Attach (SetFancyStyle (new Gtk.Label (Catalog.GetString ("Radius:"))), 0, 1, 1, 2);
table.Attach (SetFancyStyle (new Gtk.Label (Catalog.GetString ("Threshold:"))), 0, 1, 2, 3);
SetFancyStyle (amount_spin = new Gtk.SpinButton (0.00, 100.0, .01));
SetFancyStyle (radius_spin = new Gtk.SpinButton (1.0, 50.0, .01));
SetFancyStyle (threshold_spin = new Gtk.SpinButton (0.0, 50.0, .01));
amount_spin.Value = .5;
radius_spin.Value = 5;
threshold_spin.Value = 0.0;
amount_spin.ValueChanged += HandleSettingsChanged;
radius_spin.ValueChanged += HandleSettingsChanged;
threshold_spin.ValueChanged += HandleSettingsChanged;
table.Attach (amount_spin, 1, 2, 0, 1);
table.Attach (radius_spin, 1, 2, 1, 2);
table.Attach (threshold_spin, 1, 2, 2, 3);
Gtk.Button cancel_button = new Gtk.Button (Gtk.Stock.Cancel);
cancel_button.Clicked += HandleCancelClicked;
dialog.AddActionWidget (cancel_button, Gtk.ResponseType.Cancel);
Gtk.Button ok_button = new Gtk.Button (Gtk.Stock.Ok);
ok_button.Clicked += HandleOkClicked;
dialog.AddActionWidget (ok_button, Gtk.ResponseType.Cancel);
Destroyed += HandleLoupeDestroyed;
table.ShowAll ();
dialog.VBox.PackStart (table);
dialog.ShowAll ();
}
示例3: LaunchDialogue
public override void LaunchDialogue ()
{
//the Type in the collection
IList collection = (IList) Value;
string displayName = Property.DisplayName;
//populate list with existing items
ListStore itemStore = new ListStore (typeof (object), typeof (int), typeof (string));
for (int i=0; i<collection.Count; i++)
itemStore.AppendValues(collection [i], i, collection [i].ToString ());
#region Building Dialogue
TreeView itemTree;
PropertyGrid grid;
TreeIter previousIter = TreeIter.Zero;
//dialogue and buttons
Dialog dialog = new Dialog () {
Title = displayName + " Editor",
Modal = true,
AllowGrow = true,
AllowShrink = true,
};
var toplevel = this.Container.Toplevel as Window;
if (toplevel != null)
dialog.TransientFor = toplevel;
dialog.AddActionWidget (new Button (Stock.Cancel), ResponseType.Cancel);
dialog.AddActionWidget (new Button (Stock.Ok), ResponseType.Ok);
//three columns for items, sorting, PropGrid
HBox hBox = new HBox ();
dialog.VBox.PackStart (hBox, true, true, 5);
//propGrid at end
grid = new PropertyGrid (base.EditorManager) {
CurrentObject = null,
WidthRequest = 200,
ShowHelp = false
};
hBox.PackEnd (grid, true, true, 5);
//followed by a ButtonBox
VBox buttonBox = new VBox ();
buttonBox.Spacing = 6;
hBox.PackEnd (buttonBox, false, false, 5);
//add/remove buttons
Button addButton = new Button (new Image (Stock.Add, IconSize.Button));
buttonBox.PackStart (addButton, false, false, 0);
if (types [0].IsAbstract)
addButton.Sensitive = false;
Button removeButton = new Button (new Gtk.Image (Stock.Remove, IconSize.Button));
buttonBox.PackStart (removeButton, false, false, 0);
//sorting buttons
Button upButton = new Button (new Image (Stock.GoUp, IconSize.Button));
buttonBox.PackStart (upButton, false, false, 0);
Button downButton = new Button (new Image (Stock.GoDown, IconSize.Button));
buttonBox.PackStart (downButton, false, false, 0);
//Third column has list (TreeView) in a ScrolledWindow
ScrolledWindow listScroll = new ScrolledWindow ();
listScroll.WidthRequest = 200;
listScroll.HeightRequest = 320;
hBox.PackStart (listScroll, false, false, 5);
itemTree = new TreeView (itemStore);
itemTree.Selection.Mode = SelectionMode.Single;
itemTree.HeadersVisible = false;
listScroll.AddWithViewport (itemTree);
//renderers and attribs for TreeView
CellRenderer rdr = new CellRendererText ();
itemTree.AppendColumn (new TreeViewColumn ("Index", rdr, "text", 1));
rdr = new CellRendererText ();
itemTree.AppendColumn (new TreeViewColumn ("Object", rdr, "text", 2));
#endregion
#region Events
addButton.Clicked += delegate {
//create the object
object instance = System.Activator.CreateInstance (types[0]);
//get existing selection and insert after it
TreeIter oldIter, newIter;
if (itemTree.Selection.GetSelected (out oldIter))
newIter = itemStore.InsertAfter (oldIter);
//or append if no previous selection
else
newIter = itemStore.Append ();
itemStore.SetValue (newIter, 0, instance);
//select, set name and update all the indices
itemTree.Selection.SelectIter (newIter);
UpdateName (itemStore, newIter);
UpdateIndices (itemStore);
//.........这里部分代码省略.........
示例4: OnConfigureButtonClicked
/// <summary>
/// Activated when the user clicks the "Configure" button. Opens a new dialog containing the configuration
/// widget of the selected plugin
/// </summary>
/// <param name="sender">
/// A <see cref="System.Object"/> -- not used
/// </param>
/// <param name="e">
/// A <see cref="EventArgs"/> -- not used
/// </param>
void OnConfigureButtonClicked(object sender, EventArgs e)
{
LiveRadioPluginListModel model = plugin_view.Model as LiveRadioPluginListModel;
ILiveRadioPlugin plugin = model[plugin_view.Model.Selection.FocusedIndex];
Dialog dialog = new Dialog ();
dialog.Title = String.Format ("LiveRadio Plugin {0} configuration", plugin.Name);
dialog.IconName = "gtk-preferences";
dialog.Resizable = false;
dialog.BorderWidth = 6;
dialog.ContentArea.Spacing = 12;
dialog.ContentArea.PackStart (plugin.ConfigurationWidget, false, false, 0);
Button save_button = new Button (Stock.Save);
Button cancel_button = new Button (Stock.Cancel);
dialog.AddActionWidget (cancel_button, 0);
dialog.AddActionWidget (save_button, 0);
cancel_button.Clicked += delegate { dialog.Destroy (); };
save_button.Clicked += delegate {
plugin.SaveConfiguration ();
dialog.Destroy ();
};
dialog.ShowAll ();
}
示例5: GetTextResponse
public string GetTextResponse (string question, string caption, string initialValue, bool isPassword)
{
string returnValue = null;
Dialog md = new Dialog (caption, rootWindow, DialogFlags.Modal | DialogFlags.DestroyWithParent);
try {
// add a label with the question
Label questionLabel = new Label(question);
questionLabel.UseMarkup = true;
questionLabel.Xalign = 0.0F;
md.VBox.PackStart(questionLabel, true, false, 6);
// add an entry with initialValue
Entry responseEntry = (initialValue != null) ? new Entry(initialValue) : new Entry();
md.VBox.PackStart(responseEntry, false, true, 6);
responseEntry.Visibility = !isPassword;
// add action widgets
md.AddActionWidget(new Button(Gtk.Stock.Cancel), ResponseType.Cancel);
md.AddActionWidget(new Button(Gtk.Stock.Ok), ResponseType.Ok);
md.VBox.ShowAll();
md.ActionArea.ShowAll();
md.HasSeparator = false;
md.BorderWidth = 6;
PlaceDialog (md, rootWindow);
int response = md.Run ();
md.Hide ();
if ((ResponseType) response == ResponseType.Ok) {
returnValue = responseEntry.Text;
}
return returnValue;
} finally {
md.Destroy ();
}
}
示例6: LaunchDialogue
public override void LaunchDialogue()
{
//the Type in the collection
IList collection = (IList) parentRow.PropertyValue;
string displayName = parentRow.PropertyDescriptor.DisplayName;
//populate list with existing items
itemStore = new ListStore (typeof (object), typeof (int), typeof (string));
for (int i=0; i<collection.Count; i++)
{
itemStore.AppendValues(collection [i], i, collection [i].ToString ());
}
#region Building Dialogue
//dialogue and buttons
Dialog dialog = new Dialog ();
dialog.Title = displayName + " Editor";
dialog.Modal = true;
dialog.AllowGrow = true;
dialog.AllowShrink = true;
dialog.Modal = true;
dialog.AddActionWidget (new Button (Stock.Cancel), ResponseType.Cancel);
dialog.AddActionWidget (new Button (Stock.Ok), ResponseType.Ok);
//three columns for items, sorting, PropGrid
HBox hBox = new HBox ();
dialog.VBox.PackStart (hBox, true, true, 5);
//propGrid at end
grid = new PropertyGrid (parentRow.ParentGrid.EditorManager);
grid.CurrentObject = null;
grid.WidthRequest = 200;
grid.ShowHelp = false;
hBox.PackEnd (grid, true, true, 5);
//followed by item sorting buttons in ButtonBox
VButtonBox sortButtonBox = new VButtonBox ();
sortButtonBox.LayoutStyle = ButtonBoxStyle.Start;
Button upButton = new Button ();
Image upImage = new Image (Stock.GoUp, IconSize.Button);
upImage.Show ();
upButton.Add (upImage);
upButton.Show ();
sortButtonBox.Add (upButton);
Button downButton = new Button ();
Image downImage = new Image (Stock.GoDown, IconSize.Button);
downImage.Show ();
downButton.Add (downImage);
downButton.Show ();
sortButtonBox.Add (downButton);
hBox.PackEnd (sortButtonBox, false, false, 5);
//Third column is a VBox
VBox itemsBox = new VBox ();
hBox.PackStart (itemsBox, false, false, 5);
//which at bottom has add/remove buttons
HButtonBox addRemoveButtons = new HButtonBox();
addRemoveButtons.LayoutStyle = ButtonBoxStyle.End;
Button addButton = new Button (Stock.Add);
addRemoveButtons.Add (addButton);
if (types [0].IsAbstract)
addButton.Sensitive = false;
Button removeButton = new Button (Stock.Remove);
addRemoveButtons.Add (removeButton);
itemsBox.PackEnd (addRemoveButtons, false, false, 10);
//and at top has list (TreeView) in a ScrolledWindow
ScrolledWindow listScroll = new ScrolledWindow ();
listScroll.WidthRequest = 200;
listScroll.HeightRequest = 320;
itemsBox.PackStart (listScroll, true, true, 0);
itemTree = new TreeView (itemStore);
itemTree.Selection.Mode = SelectionMode.Single;
itemTree.HeadersVisible = false;
listScroll.AddWithViewport (itemTree);
//renderers and attribs for TreeView
CellRenderer rdr = new CellRendererText ();
itemTree.AppendColumn (new TreeViewColumn ("Index", rdr, "text", 1));
rdr = new CellRendererText ();
itemTree.AppendColumn (new TreeViewColumn ("Object", rdr, "text", 2));
#endregion
#region Events
addButton.Clicked += new EventHandler (addButton_Clicked);
removeButton.Clicked += new EventHandler (removeButton_Clicked);
itemTree.Selection.Changed += new EventHandler (Selection_Changed);
upButton.Clicked += new EventHandler (upButton_Clicked);
downButton.Clicked += new EventHandler (downButton_Clicked);
#endregion
//show and get response
dialog.ShowAll ();
ResponseType response = (ResponseType) dialog.Run();
//.........这里部分代码省略.........
示例7: GetTextResponse
// call this method to show a dialog and get a response value
// returns null if cancel is selected
public string GetTextResponse(string question, string caption, string initialValue)
{
string returnValue = null;
using (Gtk.Dialog md = new Gtk.Dialog (caption, (Gtk.Window) WorkbenchSingleton.Workbench, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent)) {
// add a label with the question
Gtk.Label questionLabel = new Gtk.Label(question);
questionLabel.UseMarkup = true;
questionLabel.Xalign = 0.0F;
md.VBox.PackStart(questionLabel, true, false, 6);
// add an entry with initialValue
Gtk.Entry responseEntry = (initialValue != null) ? new Gtk.Entry(initialValue) : new Gtk.Entry();
md.VBox.PackStart(responseEntry, false, true, 6);
// add action widgets
md.AddActionWidget(new Gtk.Button(Gtk.Stock.Cancel), Gtk.ResponseType.Cancel);
md.AddActionWidget(new Gtk.Button(Gtk.Stock.Ok), Gtk.ResponseType.Ok);
md.VBox.ShowAll();
md.ActionArea.ShowAll();
md.HasSeparator = false;
md.BorderWidth = 6;
int response = md.Run ();
md.Hide ();
if ((Gtk.ResponseType) response == Gtk.ResponseType.Ok) {
returnValue = responseEntry.Text;
}
}
return returnValue;
}
示例8: CreateWidget
protected override Gtk.Widget CreateWidget(WindowContext context)
{
Window win;
if(HasAttribute("dialog"))
{
Dialog dialog = new Dialog();
dialog.AddAccelGroup(context.AccelGroup);
SetWindowAttribs(dialog);
if(Child != null)
dialog.VBox.Add(Child.Build(context));
foreach(string s in GetAttribute<Array>("dialog"))
{
string[] bits = s.Split(':');
string text = bits[0];
int response = 0;
if(bits.Length > 4)
throw new Exception("Neplatný počet parametrů tlačítka v poli tlačítek dialogu");
if(bits.Length > 1)
response = (int)IntLiteral.Parse(bits[1]);
Label l = new Label();
l.Markup = text;
Button btn;
if(bits.Length > 2 && !String.IsNullOrEmpty(bits[2]))
{
HBox hbox = new HBox(false, 0);
hbox.PackStart(ImageExpression.CreateImage(bits[2], IconSize.Button));
hbox.PackStart(l);
btn = new Button(hbox);
}
else
btn = new Button(l);
btn.ShowAll();
dialog.AddActionWidget(btn, response);
if(bits.Length > 3)
{
switch(bits[3].ToLower())
{
case "default":
btn.CanDefault = true;
dialog.Default = btn;
break;
case "cancel":
// set as cancel action - how?
break;
case "":
case "none":
break;
default:
throw new Exception("Neznámý příznak tlačítka dialogu");
}
}
}
win = dialog;
}
else
{
win = new Window(Gtk.WindowType.Toplevel);
win.AddAccelGroup(context.AccelGroup);
if(Child != null)
win.Add(Child.Build(context));
}
if(HasAttribute("iconset"))
{
IconSet icons = IconFactory.LookupDefault(GetAttribute<string>("iconset"));
List<Gdk.Pixbuf> list = new List<Gdk.Pixbuf>();
foreach(IconSize size in icons.Sizes)
{
list.Add(icons.RenderIcon(win.Style, TextDirection.Ltr, StateType.Normal, size, win, ""));
}
win.IconList = list.ToArray();
}
return win;
}
示例9: OnSignupEvent
//.........这里部分代码省略.........
split.PackEnd( right, true, true, 10 );
NameValueCollection fields =
(NameValueCollection)form[ "fields" ];
Hashtable data = (Hashtable)form[ "data" ];
foreach( string Key in fields.AllKeys )
{
Hashtable fd = (Hashtable)data[ Key ];
string Name = Key.Substring( 0, 1 ).ToUpper() +
Key.Substring( 1 ) + ":";
Label lbl = new Label( Name );
lbl.SetAlignment( 0, (float)0.5 );
left.PackStart( lbl, false, false, 5 );
if( fields[ Key ].Equals( "TextEditView" ) )
{
Entry ent = new Entry();
ent.Name = Key;
ent.ActivatesDefault = true;
if( fd[ "isPassword" ] != null )
ent.Visibility = false;
if( fd[ "value" ] != null )
ent.Text = (string)fd[ "value" ];
right.PackStart( ent, false, false, 5 );
}
else if( fields[ Key ].Equals( "PopupButtonView" ) )
{
ComboBox cbox = ComboBox.NewText();
cbox.WrapWidth = 5;
cbox.Name = Key;
if( fd[ "menuItems" ] != null )
{
string menuItems = (string)fd[ "menuItems" ];
foreach( string Value in menuItems.Split( ',' ) )
cbox.AppendText( Value );
if( fd[ "value" ] != null &&
(string)fd[ "value" ] != String.Empty )
{
cbox.Active = Convert.ToInt32( fd[ "value" ] ) - 1;
}
else
{
cbox.Active = 0;
}
}
right.PackStart( cbox, false, false, 5 );
}
else if( fields[ Key ].Equals( "ComboControlView" ) )
{
ComboBoxEntry cboxe = ComboBoxEntry.NewText();
cboxe.WrapWidth = 5;
cboxe.Name = Key;
if( fd[ "menuItems" ] != null )
{
string menuItems = (string)fd[ "menuItems" ];
foreach( string Value in menuItems.Split( ',' ) )
cboxe.AppendText( Value );
}
if( fd[ "value" ] != null )
((Entry)cboxe.Child).Text = (string)fd[ "value" ];
right.PackStart( cboxe, false, false, 5 );
}
else if( fields[ Key ].Equals( "CheckboxView" ) )
{
CheckButton cbtn = new CheckButton();
cbtn.Name = Key;
if( fd[ "value" ] != null &&
(string)fd[ "value" ] != String.Empty )
{
int v = Convert.ToInt32( (string)fd[ "value" ] );
cbtn.Active = v == 1;
}
right.PackStart( cbtn, false, false, 5 );
}
}
dlg.AddActionWidget( new Button( "Cancel" ),
ResponseType.Cancel );
Button btn = new Button( "Next" );
btn.CanDefault = true;
dlg.AddActionWidget( btn, ResponseType.Ok );
dlg.DefaultResponse = ResponseType.Ok;
dlg.Response += new ResponseHandler( OnSignupResponse );
dlg.TransientFor = this.MainWindow;
dlg.SetPosition( WindowPosition.CenterOnParent );
dlg.ShowAll();
if( form[ "redtext" ] != null )
new AlertDialog( dlg, AlertType.Warning,
(string)form[ "title" ],
(string)form[ "redtext" ] );
}
}
示例10: OnPreferences
private void OnPreferences( object o, EventArgs args )
{
if( prefsdlg == null )
{
Button btn;
HBox split;
VBox left, right;
Button songdirbtn;
prefsdlg = new Dialog();
prefsdlg.Modal = true;
prefsdlg.Title = "SharpMusique Preferences";
prefsdlg.SetSizeRequest( 500, -1 );
split = new HBox();
prefsdlg.VBox.Add( split );
left = new VBox( true, 0 );
right = new VBox( true, 0 );
split.PackStart( left, false, false, 5 );
split.PackEnd( right, true, true, 10 );
songdirbtn = new Button( "Song Folder: " );
songdirbtn.Clicked += new EventHandler( OnSongDirSelected );
songdirentry = new Entry();
left.PackStart( songdirbtn, false, false, 10 );
right.PackStart( songdirentry, false, false, 10 );
btn = new Button( "Cancel" );
prefsdlg.AddActionWidget( btn, ResponseType.Cancel );
btn = new Button( "Save" );
prefsdlg.AddActionWidget( btn, ResponseType.Ok );
prefsdlg.Response += new ResponseHandler( OnPreferencesResponse );
}
songdirentry.Text = strSongDir;
prefsdlg.TransientFor = this.MainWindow;
prefsdlg.SetPosition( WindowPosition.CenterOnParent );
prefsdlg.ShowAll();
prefsdlg.Run();
}