ILayoutCellEditor ListParamsRetriveCellEditor(object listItem, object value, ILayoutCell cell) { if (cell.Name == nameof(QParam.Value)) { QParam param = (QParam)listItem; ILayoutCellEditor editor = null; if (param != null && param.Column != null && !editors.TryGetValue(param, out editor)) { if ((param.Column.IsPrimaryKey || param.Column.IsReference) && param.Comparer.Type == CompareTypes.In) { if (!(param.Value is QQuery) && param.Column.IsReference && param.Value == null) { var sub = new QQuery(string.Empty, param.Column.ReferenceTable); sub.BuildColumn(param.Column.ReferenceTable.PrimaryKey); param.ValueRight = sub; } editor = new CellEditorQuery(); } else { editor = TableLayoutList.InitCellEditor(param.Column); if (param.Column.DataType == typeof(DateTime) && param.Comparer.Equals(CompareType.Between)) { ((CellEditorDate)editor).TwoDate = true; } } editors[param] = editor; } return(editor); } return(null); }
public static ILayoutCellEditor GetCellEditor(ILayoutCell cell) { var type = cell?.DataType; if (type == null) { return(null); } type = TypeHelper.CheckNullable(type); ILayoutCellEditor editor = null; if (CellEditorFabric.TryGetValue(type, out var generator)) { editor = generator(cell); } if (editor == null) { foreach (var entry in CellEditorFabric) { if (TypeHelper.IsBaseType(type, entry.Key)) { editor = entry.Value(cell); } } } //if (type.IsEnum) //{ // editor = new CellEditorEnum(); //} if (editor == null) { if (TypeHelper.IsList(type)) { editor = new CellEditorFields() { Header = type.Name }; } else if (GuiService.IsCompound(type)) { editor = new CellEditorFields() { Header = type.Name }; } else { editor = new CellEditorText() { Format = cell.Format, MultiLine = false, DropDownWindow = false }; } } editor.DataType = type; return(editor); }
public void Dispose() { editor = null; owner = null; categoryName = null; invoker = null; nodes.Clear(); nodes = null; }
protected override ILayoutCellEditor GetCellEditor(object listItem, object itemValue, ILayoutCell cell) { if (cell.Name == "Column" && cell.GetEditor(listItem) == null) { if (query.Table == null) { return(null); } return(new CellEditorList { DataSource = query.Table.Columns }); } if (cell == colValue) { QParam param = (QParam)listItem; ILayoutCellEditor editor = null; if (param.Column != null) { if ((param.Column.IsPrimaryKey || param.Column.IsReference) && param.Comparer.Type == CompareTypes.In) { if (param.Column.IsReference && param.Value == null) { param.ValueRight = new QQuery(string.Empty, param.Column.ReferenceTable); } editor = new CellEditorQuery(); } else { editor = TableLayoutList.InitCellEditor(param.Column); } return(editor); } } return(base.GetCellEditor(listItem, itemValue, cell)); }
static GuiEnvironment() { Instance.Themes.GenerateDefault(); CellEditorFabric[typeof(string)] = cell => { ILayoutCellEditor editor = null; if (cell.Name == nameof(object.ToString)) { editor = new CellEditorHeader(); } else if (cell.Format == "Path") { editor = new CellEditorPath(); } else if (cell.Password) { editor = new CellEditorPassword(); } else { editor = new CellEditorText { MultiLine = true }; } return(editor); }; CellEditorFabric[typeof(System.Security.SecureString)] = cell => { return(new CellEditorPassword()); }; CellEditorFabric[typeof(byte[])] = cell => { var editor = new CellEditorFile(); string property = cell.Name; int index = property.LastIndexOf(".", StringComparison.Ordinal); if (index >= 0) { property = property.Substring(index); } editor.PropertyFileName = property + "Name"; return(editor); }; CellEditorFabric[typeof(bool)] = CellEditorFabric[typeof(bool?)] = cell => { return(new CellEditorCheck { ValueTrue = true, ValueFalse = false, ValueNull = null, TreeState = false }); }; CellEditorFabric[typeof(DateTime)] = cell => { return(new CellEditorDate() { Format = cell.Format }); }; CellEditorFabric[typeof(DateInterval)] = cell => { return(new CellEditorDate() { Format = cell.Format, TwoDate = true }); }; CellEditorFabric[typeof(Xwt.CheckBoxState)] = cell => { return(new CellEditorCheck { ValueTrue = Xwt.CheckBoxState.On, ValueFalse = Xwt.CheckBoxState.Off, ValueNull = Xwt.CheckBoxState.Mixed, TreeState = true }); }; CellEditorFabric[typeof(CheckedState)] = cell => { return(new CellEditorCheck { ValueTrue = CheckedState.Checked, ValueFalse = CheckedState.Unchecked, ValueNull = CheckedState.Indeterminate, TreeState = true }); }; CellEditorFabric[typeof(System.Net.IPAddress)] = cell => { return(new CellEditorNetTree()); }; CellEditorFabric[typeof(System.Globalization.CultureInfo)] = cell => { return(new CellEditorList { DataSource = Locale.Instance.Cultures }); }; CellEditorFabric[typeof(System.Text.EncodingInfo)] = cell => { return(new CellEditorList { DataSource = System.Text.Encoding.GetEncodings() }); }; CellEditorFabric[typeof(Xwt.Drawing.Image)] = cell => { return(new CellEditorImage()); }; CellEditorFabric[typeof(Xwt.Drawing.Color)] = cell => { return(new CellEditorColor()); }; CellEditorFabric[typeof(Xwt.Drawing.Font)] = cell => { return(new CellEditorFont()); }; CellEditorFabric[typeof(Enum)] = cell => { return(new CellEditorEnum()); }; CellEditorFabric[typeof(CellStyle)] = cell => { return(new CellEditorListEditor() { DataSource = GuiEnvironment.Theme }); }; LocaleImage.ImageCache += (item) => { using (var stream = new MemoryStream(item.Data)) return(Xwt.Drawing.Image.FromStream(stream)); }; AppDomain.CurrentDomain.AssemblyLoad += OnAssemblyLoad; foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { OnAssemblyLoad(null, new AssemblyLoadEventArgs(assembly)); } }