本文整理汇总了C#中Eto.Forms.Button类的典型用法代码示例。如果您正苦于以下问题:C# Button类的具体用法?C# Button怎么用?C# Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Button类属于Eto.Forms命名空间,在下文中一共展示了Button类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MenuForm
/// <summary>
/// Creates a new menu form.
/// </summary>
/// <param name="title">Window title.</param>
/// <param name="itemNames">Item names.</param>
/// <param name="actions">Actions.</param>
public MenuForm(string title, string[] itemNames, Action[] actions)
{
Title = title;
SelectedIndex = -1;
if (itemNames == null || actions == null)
return;
if (itemNames.Length != actions.Length)
return;
var stackLayout = new StackLayout {Orientation = Orientation.Vertical, HorizontalContentAlignment = HorizontalAlignment.Stretch };
for (int i = 0; i < itemNames.Length; i++)
{
var idx = i;
var button = new Button { Text = itemNames[idx], Size = new Size(240, 60) };
button.Click += (s, e) =>
{
actions[idx]();
SelectedIndex = idx;
this.Close();
};
stackLayout.Items.Add(new StackLayoutItem(button, true));
}
Content = stackLayout;
Size = new Size(-1, -1);
}
示例2: TestProperties
Control TestProperties()
{
var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5) };
DateTimePicker min, max, current, setValue;
Button setButton;
layout.AddRow("Min Value", min = new DateTimePicker());
layout.AddRow("Max Value", max = new DateTimePicker());
layout.BeginHorizontal();
layout.Add("Set to value");
layout.BeginVertical(Padding.Empty);
layout.BeginHorizontal();
layout.AddAutoSized(setValue = new DateTimePicker());
layout.Add(setButton = new Button { Text = "Set" });
layout.EndHorizontal();
layout.EndVertical();
layout.EndHorizontal();
layout.AddRow("Value", current = new DateTimePicker());
min.ValueChanged += (sender, e) => current.MinDate = min.Value ?? DateTime.MinValue;
max.ValueChanged += (sender, e) => current.MaxDate = max.Value ?? DateTime.MaxValue;
setButton.Click += (sender, e) => current.Value = setValue.Value;
LogEvents(current);
return layout;
}
示例3: TestProperties
Control TestProperties()
{
var layout = new DynamicLayout();
DateTimePicker min, max, current, setValue;
Button setButton;
layout.AddRow(new Label { Text = "Min Value" }, min = new DateTimePicker());
layout.AddRow(new Label { Text = "Max Value" }, max = new DateTimePicker());
layout.BeginHorizontal();
layout.Add(new Label { Text = "Set to value" });
layout.BeginVertical();
layout.BeginHorizontal();
layout.AddAutoSized(setValue = new DateTimePicker());
layout.Add(setButton = new Button { Text = "Set" });
layout.EndHorizontal();
layout.EndVertical();
layout.EndHorizontal();
layout.AddRow(new Label { Text = "Value" }, current = new DateTimePicker());
min.ValueChanged += (sender, e) => current.MinDate = min.Value ?? DateTime.MinValue;
max.ValueChanged += (sender, e) => current.MaxDate = max.Value ?? DateTime.MaxValue;
setButton.Click += (sender, e) => current.Value = setValue.Value;
LogEvents(current);
return layout;
}
示例4: ServerDialog
public ServerDialog (Server server, bool isNew, bool allowConnect)
{
this.isNew = isNew;
this.allowConnect = allowConnect && !isNew;
this.Server = server;
this.Title = "Add Server";
this.MinimumSize = new Size (300, 0);
this.DataContext = server;
var layout = new DynamicLayout (this);
layout.BeginVertical ();
layout.AddRow (new Label { Text = "Server Name"}, ServerName ());
// generate server-specific edit controls
server.GenerateEditControls (layout, isNew);
layout.AddRow (null, AutoConnectButton());
layout.EndBeginVertical ();
layout.AddRow (Connect (), Disconnect (), null, cancelButton = this.CancelButton (), this.OkButton ("Save", () => SaveData()));
layout.EndVertical ();
SetVisibility ();
}
示例5: StartStopButton
Control StartStopButton(ProgressBar bar)
{
var control = new Button { Text = "Start Timer" };
control.Click += delegate
{
if (timer == null)
{
timer = new UITimer { Interval = 0.5 };
timer.Elapsed += delegate
{
if (bar.Value < bar.MaxValue)
bar.Value += 50;
else
bar.Value = bar.MinValue;
};
timer.Start();
control.Text = "Stop Timer";
}
else
{
timer.Stop();
timer.Dispose();
timer = null;
control.Text = "Start Timer";
}
};
return control;
}
示例6: ToggleButton
Control ToggleButton ()
{
var control = new Button {
Text = "Add Columns To Table"
};
control.Click += delegate {
toggle = !toggle;
this.SuspendLayout ();
if (toggle) {
mainTable.Add (VerticalSection (), 0, 0);
rightSection.AddDockedControl (VerticalSection ());
middleTable.Add (HorizontalSection (), 0, 2);
topSection.AddDockedControl (HorizontalSection ());
control.Text = "Remove Columns";
}
else {
mainTable.Add (null, 0, 0);
rightSection.AddDockedControl (null);
middleTable.Add (null, 0, 2);
topSection.AddDockedControl (null);
control.Text = "Add Columns To Table";
}
this.ResumeLayout ();
};
return control;
}
示例7: Init
void Init()
{
//_textBoxUrl
_textBoxUrl = new TextBox();
//_buttonReadFile
_buttonReadFile = new Button { Text = StrRes.GetString("StrLoad", "Load") };
_buttonReadFile.Click += _buttonReadFile_Click;
//_buttonSaveFile
_buttonSaveFile = new Button {Text = StrRes.GetString("StrSave","Save")};
_buttonSaveFile.Click += _buttonSaveFile_Click;
//_textAreaBody
_textAreaBody = new TextArea();
var layout = new DynamicLayout { Padding = new Padding(5, 5), Spacing = new Size(5, 5) };
layout.BeginVertical();
layout.BeginHorizontal();
layout.AddCentered(_textBoxUrl, xscale: true, horizontalCenter: false);
layout.AddCentered(_buttonReadFile, horizontalCenter: false);
layout.AddCentered(_buttonSaveFile, horizontalCenter: false);
layout.EndBeginHorizontal();
layout.EndVertical();
layout.AddRow(_textAreaBody);
Content = layout;
}
示例8: Init
void Init()
{
_tbxShellData = new TextArea {Size = new Size(-1, 200)};
_tbxMsg = new TextBox();
_btnShowMsgInStatus = new Button {Text = "Show Msg In Status", Width = 150};
_btnShowMsgInStatus.Click+=btn_showMsgInStatus_Click;
_btnShowMessageBox = new Button { Text = "Show Msg In Message", Width = 150 };
_btnShowMessageBox.Click+=btn_showMessageBox_Click;
_btnCreateNewTabPage = new Button { Text = "Create New TabPage", Width = 150 };
_btnCreateNewTabPage.Click+=btn_createNewTabPage_Click;
// Test
var btnTest = new Button {Text = "Test", Width = 150};
btnTest.Click += btnTest_Click;
var layout = new DynamicLayout {Padding = new Padding(10, 10), Size = new Size(10, 10)};
layout.AddRow(new Label() { Text = "ShellData"});
layout.AddRow(_tbxShellData);
layout.AddSeparateRow(new Label() { Text = "Msg", VerticalAlign = VerticalAlign.Middle }, _tbxMsg, null);
layout.AddAutoSized(_btnShowMsgInStatus);
layout.AddAutoSized(_btnShowMessageBox);
layout.AddAutoSized(_btnCreateNewTabPage);
layout.AddAutoSized(btnTest);
layout.Add(null);
this.Content = layout;
}
示例9: ClearButton
Control ClearButton (ListBox list)
{
var control = new Button{ Text = "Clear" };
control.Click += delegate {
list.Items.Clear ();
};
return control;
}
示例10: LogEvents
protected virtual void LogEvents(Button control)
{
control.Click += delegate {
Log.Write (control, "Click");
};
LogEvents ((Control)control);
}
示例11: ShowSelectedText
Control ShowSelectedText (TextArea text)
{
var control = new Button { Text = "Show selected text" };
control.Click += (sender, e) => {
MessageBox.Show (this, string.Format ("Selected Text: {0}", text.SelectedText));
};
return control;
}
示例12: GetWindow
protected override Forms.Window GetWindow()
{
// Add splitters like this:
// |---------------------------
// | | | |
// | P0 | P2 | P4 |
// | -------| | | <== These are on MainPanel
// | P1 |------| |
// | | P3 | |
// |---------------------------
// | status0..4, | <== These are on StatusPanel
// ----------------------------
Label[] status = new Label[] { new Label(), new Label(), new Label(), new Label(), new Label() };
// Status bar
var statusPanel = new Panel { };
var statusLayout = new DynamicLayout(Padding.Empty, Size.Empty);
statusLayout.BeginHorizontal();
for (var i = 0; i < status.Length; ++i)
statusLayout.Add(status[i], xscale: true);
statusLayout.EndHorizontal();
statusPanel.Content = statusLayout;
// Splitter windows
Panel[] p = new Panel[] { new Panel(), new Panel(), new Panel(), new Panel(), new Panel() };
var colors = new Color[] { Colors.PaleTurquoise, Colors.Olive, Colors.NavajoWhite, Colors.Purple, Colors.Orange };
var count = 0;
for (var i = 0; i < p.Length; ++i)
{
var temp = i;
//p[i].BackgroundColor = colors[i];
var button = new Button { Text = "Click to update status " + i.ToString(), BackgroundColor = colors[i] };
button.Click += (s, e) => status[temp].Text = "New count: " + (count++).ToString();
p[i].Content = button;
}
var p0_1 = new Splitter { Panel1 = p[0], Panel2 = p[1], Orientation = SplitterOrientation.Vertical, Position = 200 };
var p2_3 = new Splitter { Panel1 = p[2], Panel2 = p[3], Orientation = SplitterOrientation.Vertical, Position = 200 };
var p01_23 = new Splitter { Panel1 = p0_1, Panel2 = p2_3, Orientation = SplitterOrientation.Horizontal, Position = 200};
var p0123_4 = new Splitter { Panel1 = p01_23, Panel2 = p[4], Orientation = SplitterOrientation.Horizontal, Position = 400 };
// Main panel
var mainPanel = new Panel();
mainPanel.Content = p0123_4;
// Form's content
var layout = new DynamicLayout();
layout.Add(mainPanel, yscale: true);
layout.Add(statusPanel);
layout.Generate();
var form = new Form
{
Size = new Size(800, 600),
Content = layout
};
return form;
}
示例13: RemoveRowsButton
Control RemoveRowsButton (ListBox list)
{
var control = new Button{ Text = "Remove Rows" };
control.Click += delegate {
if (list.SelectedIndex >= 0)
list.Items.RemoveAt (list.SelectedIndex);
};
return control;
}
示例14: AddRowsButton
Control AddRowsButton (ListBox list)
{
var control = new Button{ Text = "Add Rows" };
control.Click += delegate {
for (int i = 0; i < 10; i++)
list.Items.Add (new ListItem { Text = "Item " + list.Items.Count});
};
return control;
}
示例15: CloseButton
Control CloseButton()
{
var control = new Button{ Text = "Close" };
control.Click += delegate {
Close ();
};
this.DefaultButton = this.AbortButton = control;
return control;
}