Exemple #1
0
        /// <summary>
        /// 设置该属性为动态检查是否只读
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="indicator">动态根据此属性来检查是否只读。</param>
        /// <returns></returns>
        public static WPFEntityPropertyViewMeta Readonly(this WPFEntityPropertyViewMeta meta, IManagedProperty indicator)
        {
            meta.ReadonlyIndicator.Status   = ReadOnlyStatus.Dynamic;
            meta.ReadonlyIndicator.Property = indicator;

            return(meta);
        }
Exemple #2
0
        /// <summary>
        /// 设置该属性需要显示在列表中,并设置其列表中的信息
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="gridWidth">
        /// 用于初始化表格控件的宽度属性
        /// </param>
        /// <returns></returns>
        public static WPFEntityPropertyViewMeta ShowInList(this WPFEntityPropertyViewMeta meta, double?gridWidth = null)
        {
            meta.ShowInWhere |= ShowInWhere.List;
            meta.GridWidth    = gridWidth;

            return(meta);
        }
Exemple #3
0
        /// <summary>
        /// 设置该属性可显示的范围
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static WPFEntityPropertyViewMeta ShowIn(this WPFEntityPropertyViewMeta meta, ShowInWhere value)
        {
            if (value == ShowInWhere.Hide)
            {
                meta.ShowInWhere = ShowInWhere.Hide;
            }
            else
            {
                meta.ShowInWhere |= value;
            }

            return(meta);
        }
Exemple #4
0
        /// <summary>
        /// 设置该属性在表单中显示时的详细信息
        ///
        /// 注意,并不是所有属性在所有模式下都有用,所以请选择性设置。
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="contentWidth">
        /// 表单中该属性所占的格子宽度。
        ///
        /// 如果值在 0 到 1 之间,表示百分比,只有 DetailLayoutMode.AutoGrid 模式下可用。
        /// 否则表示绝对值。
        ///
        /// 不指定,则使用系统默认值。
        /// </param>
        /// <param name="height">
        /// 表单中该属性所占的总高度
        /// 不指定,则使用系统默认宽度。
        /// </param>
        /// <param name="labelSize">
        /// 在 DetailPanel 中显示的 Label 的宽度或者高度。
        /// 不指定,则使用系统默认值。
        /// </param>
        /// <param name="asHorizontal">
        /// 配置 DetailPanel 中 Label 与 Editor 的布局方向。true:横向;false:竖向。
        /// 不指定,则使用系统默认值。
        /// </param>
        /// <param name="needNewLine">
        /// 指定某个属性在表单中是否需要开启新行。
        /// 此属性只在 DetailLayoutMode.Wrapping 下有用。
        /// </param>
        /// <param name="columnSpan">
        /// 表单中该属性所占的列数。
        /// 只在 DetailLayoutMode.AutoGrid 模式下有用。
        /// </param>
        /// <returns></returns>
        public static WPFEntityPropertyViewMeta ShowInDetail(this WPFEntityPropertyViewMeta meta,
                                                             //common
                                                             double?contentWidth = null, double?height = null, double?labelSize = null, bool?asHorizontal = null,
                                                             //WrappingMode
                                                             bool needNewLine = false,
                                                             //AutoGridMode
                                                             int?columnSpan = null
                                                             )
        {
            meta.ShowInWhere |= ShowInWhere.Detail;

            meta.DetailLabelSize    = labelSize;
            meta.DetailContentWidth = contentWidth;
            meta.DetailHeight       = height;
            meta.DetailColumnsSpan  = columnSpan;
            meta.DetailNewLine      = needNewLine;
            meta.DetailAsHorizontal = asHorizontal;

            return(meta);
        }
Exemple #5
0
        /// <summary>
        /// 设置该属性为导航项。
        /// 此时,如果该属性变更,会自动触发导航查询
        /// </summary>
        /// <param name="meta"></param>
        /// <returns></returns>
        public static NavigationPropertyMeta FireNavigation(this WPFEntityPropertyViewMeta meta)
        {
            meta.NavigationMeta = new NavigationPropertyMeta();

            return(meta.NavigationMeta);
        }
Exemple #6
0
 /// <summary>
 /// 如果这是一个引用属性,则可以指定一个额外的冗余属性来进行显示。
 /// </summary>
 /// <param name="meta"></param>
 /// <param name="refDelegate"></param>
 /// <returns></returns>
 public static WPFEntityPropertyViewMeta DisplayRefBy(this WPFEntityPropertyViewMeta meta, IManagedProperty refDelegate)
 {
     meta.DisplayDelegate = refDelegate;
     return(meta);
 }
Exemple #7
0
 /// <summary>
 /// 设置属性的编辑器
 /// </summary>
 /// <param name="meta"></param>
 /// <param name="editorName"></param>
 /// <returns></returns>
 public static WPFEntityPropertyViewMeta UseEditor(this WPFEntityPropertyViewMeta meta, string editorName)
 {
     meta.EditorName = editorName;
     return(meta);
 }
Exemple #8
0
 public static bool? GetNeedSummary(WPFEntityPropertyViewMeta meta)
 {
     return meta.GetPropertyOrDefault<bool?>(PropertyMetaNeedSummary);
 }
Exemple #9
0
        /// <summary>
        /// 显式指明一个属性是否需要进行合计。
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="value">true: 合计; false: 不合计; null:根据类型来判断。</param>
        /// <returns></returns>
        public static WPFEntityPropertyViewMeta Summarize(this WPFEntityPropertyViewMeta meta, bool?value)
        {
            TreeColumn.SetNeedSummary(meta, value);

            return(meta);
        }
Exemple #10
0
        /// <summary>
        /// 设置该属性是否为只读
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static WPFEntityPropertyViewMeta Readonly(this WPFEntityPropertyViewMeta meta, bool value = true)
        {
            meta.ReadonlyIndicator.Status = value ? ReadOnlyStatus.ReadOnly : ReadOnlyStatus.None;

            return(meta);
        }
Exemple #11
0
        /// <summary>
        /// 检测某个实体对象的某个实体属性是否可以只读。
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="property"></param>
        /// <returns></returns>
        internal static bool CheckIsReadOnly(Entity entity, WPFEntityPropertyViewMeta property)
        {
            //类指明为只读
            var indicator = property.ReadonlyIndicator;
            if (indicator.Status == ReadOnlyStatus.ReadOnly || property.Owner.NotAllowEdit) { return true; }

            //检测动态属性
            if (indicator.Status == ReadOnlyStatus.Dynamic && entity != null)
            {
                return (bool)entity.GetProperty(indicator.Property);
            }

            return false;
        }
        protected virtual string ReadProperty(WPFEntityPropertyViewMeta property)
        {
            var data = string.Empty;

            try
            {
                if (property.IsReference)
                {
                    var displayPath = property.DisplayPath();
                    var value = ObjectHelper.GetPropertyValue(this._currentRow, displayPath);
                    if (value != null) data = value.ToString();
                }
                else
                {
                    var mp = property.PropertyMeta.ManagedProperty;
                    if (mp != null)
                    {
                        var value = this._currentRow.GetProperty(mp);
                        if (value != null)
                        {
                            if (TypeHelper.IsEnumNullable(mp.PropertyType))
                            {
                                data = EnumViewModel.EnumToLabel((Enum)value).Translate();
                            }
                            else
                            {
                                data = value.ToString();
                            }
                        }
                    }
                }
            }
            catch
            {
                //尽量尝试读取值,读取出错,则忽略错误。
            }

            return data;
        }
Exemple #13
0
 internal static void SetNeedSummary(WPFEntityPropertyViewMeta meta, bool? value)
 {
     meta.SetExtendedProperty(PropertyMetaNeedSummary, value);
 }
Exemple #14
0
        /// <summary>
        /// 在所有控件生成后,为他们的可见性进行属性绑定
        /// </summary>
        private void BindVisibility(WPFEntityPropertyViewMeta meta)
        {
            var visibilityIndicator = meta.VisibilityIndicator;
            if (visibilityIndicator.IsDynamic)
            {
                Binding visibleBinding = new Binding(visibilityIndicator.Property.Name);
                visibleBinding.Mode = BindingMode.OneWay;
                visibleBinding.Converter = new BooleanToVisibilityConverter();

                this.SetBinding(UIElement.VisibilityProperty, visibleBinding);
            }
        }
Exemple #15
0
 /// <summary>
 /// 设置属性的显示名称
 /// </summary>
 /// <param name="meta"></param>
 /// <param name="label"></param>
 /// <returns></returns>
 public static WPFEntityPropertyViewMeta HasLabel(this WPFEntityPropertyViewMeta meta, string label)
 {
     meta.Label = label;
     return(meta);
 }
Exemple #16
0
        private void SetLayoutValues(DetailLogicalView detailView, WPFEntityPropertyViewMeta property)
        {
            if (property.DetailAsHorizontal != null)
            {
                var direction = property.DetailAsHorizontal.Value ? Orientation.Horizontal : Orientation.Vertical;
                this.SetIfNonLocal(OrientationProperty, direction);
            }

            if (property.DetailColumnsSpan != null)
            {
                this.SetIfNonLocal(Grid.ColumnSpanProperty, property.DetailColumnsSpan.Value);
            }

            var labelSize = property.DetailLabelSize ?? detailView.Meta.DetailLabelSize;
            if (labelSize != null)
            {
                if (this.Orientation == Orientation.Horizontal)
                {
                    this.SetIfNonLocal(LabelWidthProperty, labelSize.Value);
                }
                else
                {
                    this.SetIfNonLocal(LabelHeightProperty, labelSize.Value);
                }
            }

            if (property.DetailContentWidth != null)
            {
                if (!this.IsLocalValue(ContentWidthProperty))
                {
                    var value = property.DetailContentWidth.Value;

                    //0-1 之间表示相对值,否则表示绝对值。
                    if (value > 0 && value < 1)
                    {
                        value = value / (1 - value);
                        this.ContentWidth = new GridLength(value, GridUnitType.Star);
                    }
                    else
                    {
                        this.ContentWidth = new GridLength(value);
                    }
                }
            }

            if (property.DetailHeight != null)
            {
                this.SetIfNonLocal(HeightProperty, property.DetailHeight.Value);
            }
        }
Exemple #17
0
 protected internal virtual void Initialize(WPFEntityPropertyViewMeta propertyInfo)
 {
     this.Meta = propertyInfo;
 }