public EthernetPortSettings(EthernetPortProcess process) { _process = process; _name = new TextBox(); _name.Bind( tb => tb.Text, _process, proc => proc.Name, DualBindingMode.TwoWay); _processId = new NumericUpDown(); _processId.Bind( nud => nud.Value, _process, proc => proc.ProcessId, DualBindingMode.TwoWay); _deviceName = new ComboBox(); _deviceName.DataStore = LibPcapLiveDeviceList.Instance.Where(dev => dev.Interface != null); _deviceName.KeyBinding = new PropertyBinding<string>("Name"); _deviceName.TextBinding = new PropertyBinding<string>("Description"); _deviceName.SelectedValueChanged += _deviceNameChanged; this.BeginVertical(); this.AddRow(new Label() { Text = Constants.ProcessNameLabel }, _name); this.AddRow(new Label() { Text = Constants.ProcessIdLabel }, _processId); this.AddRow(new Label() { Text = Constants.DeviceNameLabel }, _deviceName); this.EndVertical(); this.AddRow(); }
void Init() { _comboBoxServices = new ComboBox(); _comboBoxServices.SelectedIndexChanged += _comboBoxServices_SelectedIndexChanged; _textAreaInfo = new TextArea{Size=new Size(-1,200)}; _textAreaInfo.Enabled = false; _textAreaResult = new TextArea(); _textAreaResult.Text = "If you wanna call one service, you can do like this:\n" + "dynamic ToBase64 = PluginServiceProvider.GetService(\"ToBase64\");\n" + "var result = ToBase64(new PluginParameter(\"str\", \"Test\"));\n" + "//result=\"VGVzdA==\""; _textAreaResult.Enabled = false; var layout = new DynamicLayout {Padding = new Padding(10, 10)}; layout.AddSeparateRow( new Label {Text = "The Registered Services", VerticalAlign = VerticalAlign.Middle}, _comboBoxServices); layout.AddSeparateRow(_textAreaInfo); layout.AddSeparateRow(_textAreaResult); Content = layout; Title = "Developer Tool"; Size = new Size(400, 400); }
Control ClearButton (ComboBox list) { var control = new Button{ Text = "Clear" }; control.Click += delegate { list.Items.Clear (); }; return control; }
Control RemoveRowsButton (ComboBox list) { var control = new Button{ Text = "Remove Rows" }; control.Click += delegate { if (list.SelectedIndex >= 0) list.Items.RemoveAt (list.SelectedIndex); }; return control; }
Control AddRowsButton (ComboBox 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; }
ComboBox Items () { var control = new ComboBox (); LogEvents (control); for (int i = 0; i < 20; i++) { control.Items.Add (new ListItem{ Text = "Item " + i}); } return control; }
Control ComboBoxControl() { var control = new ComboBox { }; control.Items.Add (new ListItem{ Text = "Item 1" }); control.Items.Add (new ListItem{ Text = "Item 2" }); control.Items.Add (new ListItem{ Text = "Item 3" }); LogEvents (control); return control; }
Control ClearSelected(ComboBox list) { var control = new Button { Text = "Clear Selected" }; control.Click += delegate { list.SelectedIndex = -1; }; return control; }
public void InitialValuesShouldBeCorrect() { TestUtils.Invoke(() => { var comboBox = new ComboBox(); Assert.IsFalse(comboBox.AutoComplete, "AutoComplete should be false"); Assert.IsFalse(comboBox.ReadOnly, "Should not be initially read only"); Assert.IsTrue(comboBox.Enabled, "Should be enabled"); }); }
Control SetSelected(ComboBox list) { var control = new Button { Text = "Set Selected" }; control.Click += delegate { if (list.Items.Count > 0) list.SelectedIndex = new Random().Next(list.Items.Count - 1); }; return control; }
Control Default() { var control = new ComboBox(); LogEvents(control); var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5) }; layout.Add(TableLayout.AutoSized(control)); layout.AddSeparateRow(AddRowsButton(control), RemoveRowsButton(control), ClearButton(control), SetSelected(control), ClearSelected(control), null); layout.AddSeparateRow(GetEnabled(control), GetReadOnly(control), AutoComplete(control), ShowComboText(control), SetComboText(control), null); return layout; }
Control Default() { var control = new ComboBox(); LogEvents(control); var layout = new DynamicLayout(); layout.Add(TableLayout.AutoSized(control)); layout.BeginVertical(); layout.AddRow(null, AddRowsButton(control), RemoveRowsButton(control), ClearButton(control), SetSelected(control), ClearSelected(control), null); layout.EndVertical(); return layout; }
public void TextNotMatchingItemsShouldNotHaveSelectedItem() { TestUtils.Invoke(() => { int selectedIndexChanged = 0; var comboBox = new ComboBox { Items = { "Item 1", "Item 2", "Item 3" } }; comboBox.SelectedIndexChanged += (sender, args) => selectedIndexChanged++; Assert.AreEqual(-1, comboBox.SelectedIndex, "Should not have an initially selected item"); comboBox.Text = "Item Not In List"; Assert.AreEqual(0, selectedIndexChanged, "Setting text to something not in list should not fire SelectedIndexChanged event"); comboBox.Text = "Item 1"; Assert.AreEqual(1, selectedIndexChanged, "Setting text to an item in the list should fire a SelectedIndexChanged event"); }); }
void Init() { _checkBoxIsRandom = new CheckBox { Text = AltStrRes.IsUserAgentRandom }; _comboBoxUserAgentList = new ComboBox {Width = 300}; var layout = new DynamicLayout { Padding = new Padding(20, 20), Spacing = new Size(10, 10) }; layout.AddRow(_checkBoxIsRandom); layout.AddRow(new Label { Text = AltStrRes.UserAgentList }); layout.AddRow(_comboBoxUserAgentList, null); layout.Add(null); this.Content = layout; }
Control DashStyleControl() { var control = new ComboBox(); control.Items.Add(new DashStyleItem { Text = "Solid", Style = DashStyles.Solid }); control.Items.Add(new DashStyleItem { Text = "Dash", Style = DashStyles.Dash }); control.Items.Add(new DashStyleItem { Text = "Dot", Style = DashStyles.Dot }); control.Items.Add(new DashStyleItem { Text = "Dash Dot", Style = DashStyles.DashDot }); control.Items.Add(new DashStyleItem { Text = "Dash Dot Dot", Style = DashStyles.DashDotDot }); control.SelectedIndex = 0; control.SelectedIndexChanged += (sender, e) => { this.DashStyle = ((DashStyleItem)control.SelectedValue).Style; Refresh(sender, e); }; return control; }
Control BrushControl() { var control = new ComboBox(); control.Items.Add(new BrushItem { Text = "Solid", Brush = solidBrush }); control.Items.Add(new BrushItem { Text = "Texture", Brush = textureBrush, SupportsMatrix = true }); control.Items.Add(new BrushItem { Text = "Gradient", Brush = gradientBrush, SupportsMatrix = true, SupportsGradient = true }); control.SelectedValue = control.Items.OfType<BrushItem>().First(r => r.Brush == brush); control.SelectedValueChanged += (sender, e) => { var item = (BrushItem)control.SelectedValue; SetItem(item); }; LoadComplete += (sender, e) => SetItem(control.SelectedValue as BrushItem); control.SelectedValueChanged += Refresh; return control; }
public SessionCreator() { _session = new Session(); _session.Processes.Add(new PortManagerProcess()); _session.Processes.Add(new RouterProcess()); _session.Processes.Add(new HostProcess()); _session.Processes.Add(new DeviceFinderProcess ()); _session.Processes.Add(new NetworkDatabaseProcess()); var left = new TableLayout(1, 3); _processesList = new ListBox(); _processesList.Size = new Size(250, -1); _processesList.DataStore = _session.Processes; _processesList.SelectedValueChanged += _selectedProcessChanged; left.Add(_processesList, 0, 0); _portTypesCombo = new ComboBox(); foreach (var portType in PortType.All()) { _portTypesCombo.Items.Add(portType); } _addPortButton = new Button(); _addPortButton.Text = Constants.AddPortButtonText; _addPortButton.Click += _addPortButtonClicked; var newPortLayout = new DynamicLayout(); newPortLayout.Padding = Eto.Drawing.Padding.Empty; newPortLayout.AddRow(_portTypesCombo, _addPortButton); left.Add(newPortLayout, 0, 1); _contentPanel = new Panel(); _contentPanel.Content = new SessionSettings(_session); _createSessionButton = new Button(); _createSessionButton.Text = Constants.CreateSessionButtonText; _createSessionButton.Click += _createSessionButtonClicked; this.BeginVertical(padding:null, xscale: true, yscale: true); this.AddRow(left, _contentPanel); this.EndVertical(); this.BeginVertical(padding:null, xscale: true, yscale: false); this.AddRow(null, _createSessionButton); this.EndVertical(); }
Control GetReadOnly(ComboBox list) { var control = new CheckBox { Text = "ReadOnly" }; control.CheckedBinding.Bind(list, l => l.ReadOnly); return control; }
void InitUi() { // input _textBoxName = new TextBox { PlaceholderText = "*Name", Width = 200}; _comboBoxLevel = new ComboBox {Width = 100}; _dropDownScritpType = new DropDown {Width = 120}; _textBoxShellPath = new TextBox {PlaceholderText = "*Shell Url", Width = 300}; _textBoxShellPass = new TextBox { PlaceholderText = "*Pass" }; _textBoxRemark = new TextBox { PlaceholderText = "Remark" }; // _buttonAdd _buttonAdd = new Button { Text = StrRes.GetString("StrAdd", "Add") }; _buttonAdd.Click += buttonAdd_Click; // _buttonAlter _buttonAlter = new Button { Text = StrRes.GetString("StrAlter", "Alter") }; _buttonAlter.Click += _buttonAlter_Click; // _buttonAdvanced _buttonAdvanced = new Button { Text = StrRes.GetString("StrAdvanced","Advanced") }; _buttonAdvanced.Click += _buttonAdvanced_Click; var codeList = new List<IListItem> { new ListItem {Text = "UTF-8"}, new ListItem {Text = "GB2312"} }; _dropDownServerCoding = new DropDown(); _dropDownServerCoding.Items.AddRange(codeList); _dropDownServerCoding.SelectedIndex = 0; _dropDownWebCoding = new DropDown(); _dropDownWebCoding.Items.AddRange(codeList); _dropDownWebCoding.SelectedIndex = 0; // _buttonDefault _buttonDefault = new Button { Text = "Default" }; _buttonDefault.Click += _buttonDefault_Click; // _richTextBoxSetting _richTextBoxSetting = new TextArea {Wrap = false}; // _panelAdvanced _panelAdvanced = new DynamicLayout { Padding = new Padding(5, 5), Spacing = new Size(5, 5) }; _panelAdvanced.BeginVertical(); _panelAdvanced.BeginHorizontal(); _panelAdvanced.AddAutoSized(new Label { Text = StrRes.GetString("StrServerCoding", "ServerCoding"), VerticalAlign = VerticalAlign.Middle }, centered: true); _panelAdvanced.AddAutoSized(_dropDownServerCoding, centered: true); _panelAdvanced.AddAutoSized(new Label { Text = StrRes.GetString("StrWebCoding", "WebCoding"), VerticalAlign = VerticalAlign.Middle }, centered: true); _panelAdvanced.AddAutoSized(_dropDownWebCoding, centered: true); _panelAdvanced.Add(null); _panelAdvanced.AddAutoSized(_buttonDefault, centered: true); _panelAdvanced.EndHorizontal(); _panelAdvanced.EndVertical(); //_panelAdvanced.AddSeparateRow(new Label { Text = StrRes.GetString("StrServerCoding", "ServerCoding"), VerticalAlign = VerticalAlign.Middle }, _dropDownServerCoding); //_panelAdvanced.AddSeparateRow(new Label { Text = StrRes.GetString("StrWebCoding", "WebCoding"), VerticalAlign = VerticalAlign.Middle }, _dropDownWebCoding); _panelAdvanced.AddSeparateRow(_richTextBoxSetting); var panel1 = new DynamicLayout { Padding = new Padding(5, 5), Spacing = new Size(5, 5) }; //line 1 panel1.BeginVertical(); panel1.BeginHorizontal(); panel1.Add(_textBoxName, xscale: true); panel1.Add(_comboBoxLevel); panel1.Add(_dropDownScritpType); panel1.EndHorizontal(); panel1.EndVertical(); //line 2 panel1.BeginVertical(); panel1.BeginHorizontal(); panel1.Add(_textBoxShellPath, true); panel1.Add(_textBoxShellPass); panel1.EndHorizontal(); panel1.EndVertical(); //line 3 panel1.AddRow(_textBoxRemark); //line 4 panel1.BeginVertical(); panel1.BeginHorizontal(); panel1.Add(_buttonAdvanced); panel1.Add(null, true); panel1.Add(_buttonAdd); panel1.Add(_buttonAlter); panel1.EndHorizontal(); panel1.EndVertical(); //line 5 panel1.Add(_panelAdvanced, false, true); _panelAdvanced.Visible = false; //_p12 = new Splitter //{ // Panel1 = panel1, // Panel2 = _panelAdvanced, // Orientation = SplitterOrientation.Vertical, // Position = 130, //}; //_p12.FixedPanel = SplitterFixedPanel.Panel1; //_p12.Panel2.Visible = false; Content = panel1; ClientSize = new Size(500, 130); Title = "Edit Shell"; Icon = Application.Instance.MainForm.Icon; }
void LogEvents(ComboBox control) { control.SelectedIndexChanged += delegate { Log.Write(control, "SelectedIndexChanged, Value: {0}", control.SelectedIndex); }; }
/// <summary> /// Raises the text changed event. /// </summary> public void OnTextChanged(ComboBox widget, EventArgs e) { widget.Platform.Invoke(() => widget.OnTextChanged(e)); }
void LogEvents(ComboBox control) { control.SelectedIndexChanged += (sender, e) => Log.Write(control, "SelectedIndexChanged, Value: {0}", control.SelectedIndex); control.TextChanged += (sender, e) => Log.Write(control, "TextChanged, Value: {0}", control.Text); }
Control SetComboText(ComboBox list) { var control = new Button { Text = "Set ComboText" }; control.Click += delegate { list.Text = "New ComboText"; }; return control; }
Control ShowComboText(ComboBox list) { var control = new Button { Text = "Show ComboText" }; control.Click += delegate { MessageBox.Show(list.Text); }; return control; }
static ComboBox ComboWithItems() { var combo = new ComboBox(); combo.Items.Add("hello"); combo.Items.Add("there"); return combo; }
Control GetEnabled(ComboBox list) { var control = new CheckBox { Text = "Enabled" }; control.CheckedBinding.Bind(list, l => l.Enabled); return control; }
Control AutoComplete(ComboBox list) { var control = new CheckBox { Text = "AutoComplete" }; control.CheckedBinding.Bind(list, l => l.AutoComplete); return control; }
private TabPage CreateFromDeviceTab() { var deviceTab = new TabPage { Text = FromDeviceTabName }; var deviceLayout = new DynamicLayout(deviceTab); var selectDeviceLabel = new Label { Text = "Select Device: ", Size = new Size(150, 20) }; _deviceSelectBox = new ComboBox { Size = new Size(480, 20) }; var refreshButton = new Button { Text = "Refresh" }; refreshButton.Click += refreshButton_Click; deviceLayout.BeginVertical(); deviceLayout.BeginHorizontal(); deviceLayout.AddRow(selectDeviceLabel, _deviceSelectBox, refreshButton); deviceLayout.EndHorizontal(); deviceLayout.EndVertical(); return deviceTab; }