private void Init(string value, LayoutHint hint) { if (_control != null) { return; } BrowserHint browserHint = hint as BrowserHint; TextBoxHint tbHint = hint as TextBoxHint; if (browserHint != null) { FileDirBrowserCtrl fbc = new FileDirBrowserCtrl(); fbc.AutoSize = true; fbc.Options = browserHint.BrowserOptions; _control = fbc; } else if (tbHint != null) { MaskedTextBoxEx tb = new MaskedTextBoxEx(); if (tbHint.CharsAccepted != null) { tb.CharsAccepted = tbHint.CharsAccepted; } if (tbHint.CharsNotAccepted != null) { tb.CharsNotAccepted = tbHint.CharsNotAccepted; } if (tbHint.RowCount > 1) { tb.Multiline = true; } if (tbHint.IsReadonly) { tb.ReadOnly = true; } _control = tb; } else { TextBox tb = new TextBox(); tb.AutoSize = true; _control = tb; } _control.Anchor = UIConst.AutoSize; Value = value; }
private void Init(IEnumerable collection, LayoutHint hint) { if (_control != null) { return; } Button btn = new Button(); btn.AutoSize = true; btn.Anchor = AnchorStyles.Left; btn.Text = "Collection..."; btn.Click += new System.EventHandler(OnClick); _control = btn; Value = collection; }
public TextBoxBinder(string value, LayoutHint hint) { Init(value, hint); }
public ObjCollectionBinder(IEnumerable collection, LayoutHint hint) { Init(collection, hint); }
private void BuildLeafCtrl(PropertyInfo pi, Type tp, object parentObj, ObjIdentifier parentId) { PropertyCtrlInfo ci = BuildControlInfo(pi, parentObj); Page page = (ci.Layout.IsAdvanced) ? Macros.SafeGet(ref _advancedPage) : _mainPage; object piValue = (parentObj == null) ? null : pi.GetValue(parentObj, null); if (TypeInterrogator.IsNumericType(tp)) { DecimalPCV converter = new DecimalPCV(tp); ci.Converter = converter; NumericUpDownHint upDownHint = AttributeInterrogator.GetAttribute <NumericUpDownHint>(pi); if (upDownHint != null) { ci.Binder = new NumericUpDownSingleBinder((piValue == null) ? Decimal.MinValue : Decimal.Parse(piValue.ToString()), upDownHint); } else { TextBoxHint tbHint = AttributeInterrogator.GetAttribute <TextBoxHint>(pi); if (tbHint == null) { tbHint = new TextBoxHint(); } tbHint.CharsAccepted = TextBoxHint.Numbers; ci.Binder = new TextBoxBinder((piValue == null) ? null : piValue.ToString(), tbHint); } } else if (TypeInterrogator.IsBoolType(tp)) { ci.Binder = new CheckBoxBinder(ci.Layout.Label, (piValue == null) ? false : (bool)piValue); ci.Layout.Label = null; ci.Layout.Section = Section.Footer; } else if (TypeInterrogator.IsDateTimeType(tp)) { ci.Binder = new DateTimePickerBinder((piValue == null) ? DateTime.Today : (DateTime)piValue, null); } else if (TypeInterrogator.IsEnumType(tp)) { const int MaxRadioButtonCount = 3; IEnumerable <string> names = EnumConverter.ToNames(tp, true); if (CollConverter.GetCount(names) <= MaxRadioButtonCount) { ci.Binder = new RadioButtonBinder(tp, (piValue == null) ? -1 : (int)piValue); } else { EnumPCV converter = new EnumPCV(tp); ci.Binder = new ComboBoxBinder(piValue.ToString(), names, ComboBoxStyle.DropDownList); ci.Converter = converter; } } else if (TypeInterrogator.IsStringType(tp)) { if (_objHints.ValueHints != null && _objHints.ValueHints.ContainsKey(pi.Name)) { ci.Binder = new ComboBoxBinder((piValue == null) ? null : piValue.ToString(), _objHints.ValueHints[pi.Name], ComboBoxStyle.DropDown); } else { LayoutHint lhint = AttributeInterrogator.GetAttribute <LayoutHint>(pi); ci.Binder = new TextBoxBinder((piValue == null) ? null : piValue.ToString(), lhint); } } else if (tp == typeof(System.Data.DataTable)) { ci.Binder = new DataGridViewBinder((piValue == null) ? null : piValue as System.Data.DataTable); ci.Layout.ColumnCount = 2; } else if (TypeInterrogator.IsDictionaryType(tp)) { DictionaryPCV converter = new DictionaryPCV(); Dictionary <string, string> converted = (piValue == null) ? null : converter.ToControlValue(piValue); ci.Binder = new DictionaryCtrlBinder(converted, _objHints.DictionaryHint); ci.Converter = converter; ci.Layout.Label = null; ci.Layout.ColumnCount = 2; ci.Layout.RowCount = (converted != null) ? (int)((converted.Count + 1) * 1.5) : 2; } AddControlInfo(page, ci, parentId); }