private void InitComboBox(EditableComboBox comboBox, ComboBoxInfo info) { comboBox.DataContext = new StringListViewModel(info.InitialItems); comboBox.TextChanged += (s, e) => { info.TextChanged(comboBox.Text); info.SearchFunction(false); }; comboBox.KeyDown += (s, e) => { if ((e.KeyboardDevice.Modifiers == ModifierKeys.None) && (e.Key == Key.Return || e.Key == Key.Enter)) { info.SearchFunction(true); } }; if (info.PreviousElement != null) { comboBox.PrePreviewKeyDown += (s, e) => { if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Up) { if (!comboBox.IsDropDownOpen) { info.PreviousElement.Focus(); e.Handled = true; } } }; } if (info.NextElement != null) { comboBox.PrePreviewKeyDown += (s, e) => { if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Down) { if (!comboBox.IsDropDownOpen) { info.NextElement.Focus(); e.Handled = true; } } }; } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { IDataSet item = this._cbDatasets.SelectedItem; if (item != null) { DataSet <IExportProvider> ds = new DataSet <IExportProvider>() { ListSource = item.UntypedGetList(true).Cast <object>().Where(z => z is IExportProvider).Cast <IExportProvider>() }; if (this._cbItems != null) { this._cbItems.Dispose(); } this._cbItems = ds.CreateComboBox(this.comboBox2, this.ctlButton3, EditableComboBox.EFlags.IncludeAll); this._cbItems.ClearSelection(); } }
private void InitializeComponent() { _hBox = new HorizontalBox() { AllowPadding = true }; this.Child = _hBox; _group = new Group("Numbers") { AllowMargins = true }; _hBox.Children.Add(_group, true); _vBox = new VerticalBox() { AllowPadding = true }; _group.Child = _vBox; _spinBox = new SpinBox(0, 100); _slider = new Slider(0, 100); _progressBar = new ProgressBar(); _spinBox.ValueChanged += (sender, args) => { var value = _spinBox.Value; _slider.Value = value; _progressBar.Value = value; }; _slider.ValueChanged += (sender, args) => { var value = _slider.Value; _spinBox.Value = value; _progressBar.Value = value; }; _vBox.Children.Add(_spinBox); _vBox.Children.Add(_slider); _vBox.Children.Add(_progressBar); _ip = new ProgressBar(); _ip.Value = -1; _vBox.Children.Add(_ip); _group = new Group("Lists") { AllowMargins = true }; _hBox.Children.Add(_group, true); _vBox = new VerticalBox() { AllowPadding = true }; _group.Child = _vBox; _comboBox = new ComboBox(); _comboBox.Add("Combobox Item 1", "Combobox Item 2", "Combobox Item 3"); _vBox.Children.Add(_comboBox); _editableComboBox = new EditableComboBox(); _editableComboBox.Add("Editable Item 1", "Editable Item 2", "Editable Item 3"); _vBox.Children.Add(_editableComboBox); _radioButtons = new RadioButtonList(); _radioButtons.Add("Radio Button 1", "Radio Button 2", "Radio Button 3"); _vBox.Children.Add(_radioButtons); }
public override void Setup() { view = new EditableComboBox(); }
public ComboBox(ControlBase parent) : base(parent) { VerticalLayout layout = new VerticalLayout(this); { Control.ComboBox combo = new Control.ComboBox(layout); combo.Margin = Margin.Five; combo.Width = 200; combo.AddItem("Option One", "one"); combo.AddItem("Number Two", "two"); combo.AddItem("Door Three", "three"); combo.AddItem("Four Legs", "four"); combo.AddItem("Five Birds", "five"); combo.ItemSelected += OnComboSelect; } { // Empty Control.ComboBox combo = new Control.ComboBox(layout); combo.Margin = Margin.Five; combo.Width = 200; } { // Lots of things Control.ComboBox combo = new Control.ComboBox(layout); combo.Margin = Margin.Five; combo.Width = 200; for (int i = 0; i < 500; i++) { combo.AddItem(String.Format("Option {0}", i)); } combo.ItemSelected += OnComboSelect; } { // Editable Control.EditableComboBox combo = new EditableComboBox(layout); combo.Margin = Margin.Five; combo.Width = 200; combo.AddItem("Option One", "one"); combo.AddItem("Number Two", "two"); combo.AddItem("Door Three", "three"); combo.AddItem("Four Legs", "four"); combo.AddItem("Five Birds", "five"); combo.ItemSelected += (s, a) => UnitPrint(String.Format("ComboBox: OnComboSelect: {0}", combo.SelectedItem.Text));; combo.TextChanged += (s, a) => UnitPrint(String.Format("ComboBox: OnTextChanged: {0}", combo.Text)); combo.SubmitPressed += (s, a) => UnitPrint(String.Format("ComboBox: OnSubmitPressed: {0}", combo.Text)); } { HorizontalLayout hlayout = new HorizontalLayout(layout); { // In-Code Item Change Control.ComboBox combo = new Control.ComboBox(hlayout); combo.Margin = Margin.Five; combo.Width = 200; MenuItem Triangle = combo.AddItem("Triangle"); combo.AddItem("Red", "color"); combo.AddItem("Apple", "fruit"); combo.AddItem("Blue", "color"); combo.AddItem("Green", "color", 12); combo.ItemSelected += OnComboSelect; //Select by Menu Item { Control.Button TriangleButton = new Control.Button(hlayout); TriangleButton.Text = "Triangle"; TriangleButton.Width = 100; TriangleButton.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { combo.SelectedItem = Triangle; }; } //Select by Text { Control.Button TestBtn = new Control.Button(hlayout); TestBtn.Text = "Red"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { combo.SelectByText("Red"); }; } //Select by Name { Control.Button TestBtn = new Control.Button(hlayout); TestBtn.Text = "Apple"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { combo.SelectByName("fruit"); }; } //Select by UserData { Control.Button TestBtn = new Control.Button(hlayout); TestBtn.Text = "Green"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { combo.SelectByUserData(12); }; } } } }
private FrmEditConfigurationCluster(Core core, ArgsClusterer def, bool readOnly, bool hideOptimise) : this() { this._core = core; this._ecbPeakFilter = DataSet.ForPeakFilter(core).CreateComboBox(this._lstPeakFilter, this._btnPeakFilter, EditableComboBox.EFlags.IncludeAll); this._ecbObsFilter = DataSet.ForObsFilter(core).CreateComboBox(this._lstObsFilter, this._btnObsFilter, EditableComboBox.EFlags.IncludeAll); this._ecbMethod = DataSet.ForClustererAlgorithms(core).CreateComboBox(this._lstMethod, this._btnNewStatistic, EditableComboBox.EFlags.CreateSelection); this._ecbMeasure = DataSet.ForMetricAlgorithms(core).CreateComboBox(this._lstMeasure, this._btnNewDistance, EditableComboBox.EFlags.IncludeNone); this._ecbSource = DataSet.ForMatrixProviders(core).CreateComboBox(this._lstSource, this._btnSource, EditableComboBox.EFlags.None); this._cbStatistics = DataSet.ForFlagsEnum <EClustererStatistics>(this._core, "Cluster Statistics").CreateConditionBox(this._txtStatistics, this._btnSetStatistics); this._readOnly = readOnly; if (def != null) { // Name this._txtName.Text = def.OverrideDisplayName; this._txtShortName.Text = def.OverrideShortName; // Comment this._comment = def.Comment; // Method this._ecbMethod.SelectedItem = (ClustererBase)def.GetAlgorithmOrNull(); // Params this._txtParams.Text = AlgoParameterCollection.ParamsToReversableString(def.Parameters, core); // PeakFilter this._ecbPeakFilter.SelectedItem = def.PeakFilter; // Distance this._ecbMeasure.SelectedItem = def.Distance != null ? (MetricBase)def.Distance.Args.GetAlgorithmOrNull() : null; // Distance params this._txtMeasureParams.Text = StringHelper.ArrayToString(def.Distance?.Args.Parameters); // Suppress distance this._cbStatistics.SelectedItems = EnumHelper.SplitEnum <EClustererStatistics>(def.Statistics); // Input vector this._ecbSource.SelectedItem = def.SourceProvider; // ObsFilter this._ecbObsFilter.SelectedItem = def.ObsFilter; // Seperate groups this._chkSepGroups.Checked = def.SplitGroups; } if (readOnly) { UiControls.MakeReadOnly(this); this._btnParameterOptimiser.Visible = false; this._btnComment.Enabled = true; this.ctlTitleBar1.Text = "View Clustering Algorithm"; } else if (def != null) { this.ctlTitleBar1.Text = "Edit Clustering Algorithm"; } else { this.ctlTitleBar1.Text = "New Clustering Algorithm"; } this.CheckAndChange(null, null); // UiControls.CompensateForVisualStyles(this); if (hideOptimise) { this._btnParameterOptimiser.Visible = false; this._btnOk.Text = "Continue"; } }
/// <summary> /// CONSTRUCTOR /// </summary> private FrmEditPeakFilterCondition(Form owner, Core core, PeakFilter.Condition defaults, bool readOnly) : this() { this._core = core; this._readOnly = readOnly; this.ctlTitleBar1.Text = readOnly ? "View Condition" : "Edit Condition"; // Setup boxes this._cbPeaks = DataSet.ForPeaks(core).CreateConditionBox(this._txtIsInSet, this._btnIsInSet); this._cbFlags = DataSet.ForUserFlags(core).CreateConditionBox(this._txtIsFlaggedWith, this._btnIsFlaggedWith); this._cbClusters = DataSet.ForClusters(core).CreateConditionBox(this._txtIsInCluster, this._btnIsInCluster); this._lsoFlags = EnumComboBox.Create(this._lstFlagComparator, Filter.ESetOperator.Any); this._lsoPats = EnumComboBox.Create(this._lstClusterComparator, Filter.ELimitedSetOperator.Any); this._lsoPeaks = EnumComboBox.Create(this._lstPeakComparator, Filter.EElementOperator.Is); this._lsoFilter = EnumComboBox.Create(this._lstFilterOp, Filter.EElementOperator.Is); this._lsoStats = EnumComboBox.Create(this._lstStatisticComparator, Filter.EStatOperator.LessThan); this._lstIsStatistic.Items.AddRange(IVisualisableExtensions.WhereEnabled(core.Statistics).ToArray()); this._ecbFilter = DataSet.ForPeakFilter(core).CreateComboBox(this._lstFilter, null, EditableComboBox.EFlags.IncludeAll); this._isInitialised = true; if (defaults == null) { this.checkBox1.Checked = false; this._radAnd.Checked = true; this._txtComp_TextChanged(null, null); } else { // Not this.checkBox1.Checked = defaults.Negate; this._radAnd.Checked = defaults.CombiningOperator == Filter.ELogicOperator.And; this._radOr.Checked = defaults.CombiningOperator == Filter.ELogicOperator.Or; if (defaults is PeakFilter.ConditionCluster) { PeakFilter.ConditionCluster def = (PeakFilter.ConditionCluster)defaults; List <Cluster> strong; if (!def.Clusters.TryGetStrong(out strong)) { this.ShowWeakFailureMessage("clusters"); } this._chkIsInCluster.Checked = true; this._lsoPats.SelectedItem = def.ClustersOp; this._cbClusters.SelectedItems = strong; } else if (defaults is PeakFilter.ConditionPeak) { PeakFilter.ConditionPeak def = (PeakFilter.ConditionPeak)defaults; List <Peak> strong; if (!def.Peaks.TryGetStrong(out strong)) { this.ShowWeakFailureMessage("peaks"); } this._chkIsInSet.Checked = true; this._lsoPeaks.SelectedItem = def.PeaksOp; this._cbPeaks.SelectedItems = strong; } else if (defaults is PeakFilter.ConditionFlags) { PeakFilter.ConditionFlags def = (PeakFilter.ConditionFlags)defaults; List <UserFlag> strong; if (!def.Flags.TryGetStrong(out strong)) { this.ShowWeakFailureMessage("peaks"); } this._chkIsFlaggedWith.Checked = true; this._lsoFlags.SelectedItem = def.FlagsOp; this._cbFlags.SelectedItems = strong; } else if (defaults is PeakFilter.ConditionStatistic) { PeakFilter.ConditionStatistic def = (PeakFilter.ConditionStatistic)defaults; ConfigurationStatistic strong; if (!def.Statistic.TryGetTarget(out strong)) { this.ShowWeakFailureMessage("statistics"); } ConfigurationStatistic stat = def.Statistic.GetTarget(); if (stat == null) { FrmMsgBox.ShowError(this, "The statistic specified when this condition was created has since been removed. Please select a different statistic."); } this._chkIsStatistic.Checked = true; this._lsoStats.SelectedItem = def.StatisticOp; this._lstIsStatistic.SelectedItem = stat; this._txtStatisticValue.Text = def.StatisticValue.ToString(); } else if (defaults is PeakFilter.ConditionFilter) { PeakFilter.ConditionFilter def = (PeakFilter.ConditionFilter)defaults; this._radFilter.Checked = true; this._lsoFilter.SelectedItem = def.FilterOp ? Filter.EElementOperator.Is : Filter.EElementOperator.IsNot; this._ecbFilter.SelectedItem = def.Filter; } else { throw new SwitchException(defaults.GetType()); } } if (readOnly) { UiControls.MakeReadOnly(this); } }