/// <summary> /// 把000010000300002排序为000000000000123 /// /// 不把0的位置改变,这样可以保证顺序与属性定义的顺序一致。 /// </summary> internal static EntityPropertyViewMeta[] Order(IEnumerable <EntityPropertyViewMeta> properties) { //这个方法会打乱都是0的节点原有的顺序。 //properties.Sort((a, b) => a.OrderNo.CompareTo(b.OrderNo)); var res = new EntityPropertyViewMeta[properties.Count()]; var lesszerolist = properties.Where(p => p.OrderNo < 0).OrderBy(p => p.OrderNo).ToArray(); var zeroList = properties.Where(p => p.OrderNo == 0).ToArray(); var greaterzerolist = properties.Where(p => p.OrderNo > 0).OrderBy(p => p.OrderNo).ToArray(); int i = 0; foreach (var item in lesszerolist) { res[i++] = item; } foreach (var item in zeroList) { res[i++] = item; } foreach (var item in greaterzerolist) { res[i++] = item; } return(res); }
/// <summary> /// 设置该属性为动态检查是否可见 /// /// WPF Only /// </summary> /// <param name="meta"></param> /// <param name="indicator">动态根据此属性来检查是否可见。</param> /// <returns></returns> public static EntityPropertyViewMeta Visibility(this EntityPropertyViewMeta meta, IManagedProperty indicator) { meta.VisibilityIndicator.VisiblityType = VisiblityType.Dynamic; meta.VisibilityIndicator.Property = indicator; return(meta); }
internal void Config(EntityPropertyViewMeta property) { if (this.Label != null) { property.Label = this.Label; } if (this.ShowInWhere != null) { property.ShowInWhere = this.ShowInWhere.Value; } if (this.OrderNo != null) { property.OrderNo = this.OrderNo.Value; } }
internal void OnPropertyFound(EntityPropertyViewMeta property) { var handler = this.PropertyFound; if (handler != null) { handler(this, new PropertyFoundEventArgs(property)); } }
/// <summary> /// 为某个引用属性直接快速设置数据源 /// </summary> /// <param name="meta"></param> /// <param name="dataSourceProvier"></param> /// <returns></returns> public static EntityPropertyViewMeta UseDataSource(this EntityPropertyViewMeta meta, Func <object> dataSourceProvier) { var svm = meta.SelectionViewMeta; if (svm == null) { throw new InvalidOperationException("只有配置了 SelectionViewMeta 的属性才可以使用本方法为其设置数据源。"); } svm.DataSourceProvider = dataSourceProvier; return(meta); }
/// <summary> /// 为某个引用属性直接快速设置数据源 /// </summary> /// <param name="meta"></param> /// <param name="property"></param> /// <returns></returns> public static EntityPropertyViewMeta UseDataSource(this EntityPropertyViewMeta meta, IManagedProperty property) { var svm = meta.SelectionViewMeta; if (svm == null) { throw new InvalidOperationException("只有配置了 SelectionViewMeta 的属性才可以使用本方法为其设置数据源。"); } svm.DataSourceProperty = property; return(meta); }
/// <summary> /// 设置该属性可显示的范围 /// </summary> /// <param name="meta"></param> /// <param name="value"></param> /// <returns></returns> public static EntityPropertyViewMeta ShowIn(this EntityPropertyViewMeta meta, ShowInWhere value) { if (value == ShowInWhere.Hide) { meta.ShowInWhere = ShowInWhere.Hide; } else { meta.ShowInWhere |= value; } return(meta); }
/// <summary> /// 设置该属性是否为只读 /// </summary> /// <param name="meta"></param> /// <param name="value"></param> /// <returns></returns> public static EntityPropertyViewMeta Readonly(this EntityPropertyViewMeta meta, bool value = true) { if (meta is WebEntityPropertyViewMeta) { (meta as WebEntityPropertyViewMeta).Readonly(value); } else { (meta as WPFEntityPropertyViewMeta).Readonly(value); } return(meta); }
internal static ComboListConfig CreateComboList(EntityPropertyViewMeta property) { var comboList = new ComboListConfig(); comboList.model = ClientEntities.GetClientName(property.SelectionViewMeta.SelectionEntityType); var title = property.SelectionViewMeta.RefTypeDefaultView.TitleProperty; if (title != null) { comboList.displayField = title.Name; } var dsp = property.SelectionViewMeta.DataSourceProperty; if (dsp != null) { comboList.dataSourceProperty = dsp.Name; } return comboList; }
internal static FieldConfig GetTypeEditor(EntityPropertyViewMeta property) { var type = GetServerType(property.PropertyMeta.PropertyType); switch (type.JSType) { case JavascriptType.Int: case JavascriptType.Float: return new FieldConfig { xtype = "numberfield" }; case JavascriptType.Date: return new FieldConfig { xtype = "datefield" }; case JavascriptType.Boolean: return new FieldConfig { xtype = "checkbox" }; case JavascriptType.Reference: throw new InvalidOperationException("请调用 CreateComboList 方法。"); case JavascriptType.String: if (type.Name == SupportedServerType.Enum) { return new EnumBoxConfig(type.RuntimeType); } else { return new TextFieldConfig { allowBlank = type.IsNullable }; } default: return null; } }
public PropertyFoundEventArgs(EntityPropertyViewMeta property) { this.Property = property; }
public IEnumerable <EntityPropertyViewMeta> OrderedEntityProperties() { return(EntityPropertyViewMeta.Order(this.EntityProperties)); }
/// <summary> /// 具体指定某个属性的排序号 /// /// 一般使用在扩展视图中。 /// </summary> /// <param name="meta"></param> /// <param name="orderNo"></param> /// <returns></returns> public static EntityPropertyViewMeta HasOrderNo(this EntityPropertyViewMeta meta, double orderNo) { meta.OrderNo = orderNo; return(meta); }
/// <summary> /// 设置属性的显示名称 /// </summary> /// <param name="meta"></param> /// <param name="label"></param> /// <returns></returns> public static EntityPropertyViewMeta HasLabel(this EntityPropertyViewMeta meta, string label) { meta.Label = label; return(meta); }
/// <summary> /// 设置该属性为动态检查是否可见 /// /// WPF Only /// </summary> /// <param name="meta"></param> /// <param name="value">是否可见。</param> /// <returns></returns> public static EntityPropertyViewMeta Visibility(this EntityPropertyViewMeta meta, bool value = false) { meta.VisibilityIndicator.VisiblityType = value ? VisiblityType.AlwaysHide : VisiblityType.AlwaysShow; return(meta); }
/// <summary> /// 把000010000300002排序为000000000000123 /// /// 不把0的位置改变,这样可以保证顺序与属性定义的顺序一致。 /// </summary> internal static EntityPropertyViewMeta[] Order(IEnumerable<EntityPropertyViewMeta> properties) { //这个方法会打乱都是0的节点原有的顺序。 //properties.Sort((a, b) => a.OrderNo.CompareTo(b.OrderNo)); var res = new EntityPropertyViewMeta[properties.Count()]; var lesszerolist = properties.Where(p => p.OrderNo < 0).OrderBy(p => p.OrderNo).ToArray(); var zeroList = properties.Where(p => p.OrderNo == 0).ToArray(); var greaterzerolist = properties.Where(p => p.OrderNo > 0).OrderBy(p => p.OrderNo).ToArray(); int i = 0; foreach (var item in lesszerolist) res[i++] = item; foreach (var item in zeroList) res[i++] = item; foreach (var item in greaterzerolist) res[i++] = item; return res; }