Пример #1
0
        /// <summary>
        /// The create.
        /// </summary>
        /// <param name="attribute">
        /// The attribute.
        /// </param>
        /// <returns>
        /// The <see cref="DateTimeFieldOptions"/>.
        /// </returns>
        public static DateTimeFieldOptions Create(DateTimeFormatAttribute attribute)
        {
            var result = new DateTimeFieldOptions();
            if (attribute == null)
            {
                result.Format = DateTimeFormat.DateTime;
            }
            else
            {
                DateTimeFormat format;
                if (Enum.TryParse(attribute.Value, out format))
                {
                    result.Format = format;
                }
            }

            switch (result.Format)
            {
                case DateTimeFormat.Date:
                    result.Patterns = new[] { CultureInfo.InvariantCulture.DateTimeFormat.ShortDatePattern };
                    break;
                case DateTimeFormat.Time:
                    result.Patterns = new[] { CultureInfo.InvariantCulture.DateTimeFormat.LongTimePattern };
                    break;
                case DateTimeFormat.DateTime:
                    result.Patterns = CultureInfo.InvariantCulture.DateTimeFormat.GetAllDateTimePatterns();
                    break;
            }

            return result;
        }
Пример #2
0
        /// <summary>
        /// Gets the date time field value.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="property">The property.</param>
        /// <param name="formatAttribute">The format attribute.</param>
        /// <param name="isHtml">if set to <c>true</c> [is HTML].</param>
        /// <returns>System.String.</returns>
        private static string GetDateTimeFieldValue(IDynamicObject item, PropertyInfo property, DateTimeFormatAttribute formatAttribute, bool isHtml)
        {
            var value = (DateTime?)item.GetValueByPropertyName(property.Name);

            if (value == null)
                return string.Empty;

            var dtFormat = (DateTimeFormat)Enum.Parse(typeof(DateTimeFormat), formatAttribute.Value, true);

            switch (dtFormat)
            {
                case DateTimeFormat.Date:
                    return Encode(value.Value.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern, CultureInfo.InvariantCulture), isHtml);

                case DateTimeFormat.Time:
                    return Encode(value.Value.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern, CultureInfo.InvariantCulture), isHtml);

                default:
                    return
                        Encode(
                            value.Value.ToString(
                                CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern + " " + CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern, CultureInfo.InvariantCulture),
                            isHtml);
            }
        }
 /// <summary>
 /// Gets the date time field vm.
 /// </summary>
 /// <param name="prop">The property.</param>
 /// <param name="model">The model.</param>
 /// <param name="dateAttr">The date attribute.</param>
 /// <param name="promptAttr">The prompt attribute.</param>
 /// <param name="display">The display.</param>
 /// <param name="fieldEditorAttr">The field editor attribute.</param>
 /// <returns></returns>
 private DateTimeFieldViewModel GetDateTimeFieldVM(PropertyInfo prop, IEditableRoot model, DateTimeFormatAttribute dateAttr, PromptAttribute promptAttr, DisplayAttribute display, FieldEditorAttribute fieldEditorAttr)
 {
     var vm = DateTimeFieldViewModelFactory.CreateExport().Value;
     vm.InputMode = dateAttr.Value;
     SetupField(prop, promptAttr, display, vm, model);
     vm.FieldType = GetFieldEditor(prop, fieldEditorAttr);
     return vm;
 }
Пример #4
0
 private IFieldViewModel SetupDateTimeFieldViewModel(PropertyInfo prop, IEditableRoot model,
                                                     IDetailsViewModel detailsViewModel, DateTimeFormatAttribute dateAttr,
                                                     FieldEditorAttribute fieldEditorAttr,
                                                     CommonSettingsAttribute commonSettingsAttr,
                                                     DocumentationAttribute docAttr, PromptAttribute promptAttr,
                                                     object display)
 {
     var vm = DateTimeFieldViewModelFactory.CreateExport().Value;
     vm.InputMode = dateAttr.Value;
     vm.FieldType = GetFieldEditor(prop, fieldEditorAttr);
     SetupField(prop, commonSettingsAttr, docAttr, promptAttr, display, vm, model, detailsViewModel);
     return vm;
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldParametres"/> class.
 /// </summary>
 public FieldParametres()
 {
     SectionName = string.Empty;
     FieldPosition = 0;
     WidthPercentage = 0;
     DisplayName = string.Empty;
     FieldEditor = string.Empty;
     IsSingleCrossRef = false;
     IsMultiCrossRef = false;
     DisplayFieldList = new List<string>();
     CrossRefProcessName = string.Empty;
     IsReverseCrossRef = false;
     IsMultiReverseCrossRef = false;
     ImageFieldSize = new PictureOptionsAttribute(96, 96, 320, 240, false);
     UndefinedLabel = new UndefinedLabelAttribute(null);
     TrueLabel = new TrueLabelAttribute(null);
     FalseLabel = new FalseLabelAttribute(null);
     DateTimeFormat = new DateTimeFormatAttribute(Cebos.Veyron.SharedTypes.DateTimeFormat.DateTime.ToString());
     Numeric = new NumericAttribute();
     FieldType = new FieldTypeAttribute(ColumnTypes.String);
 }