private static GridViewColumn CreateColumn(EntityCustomField customField)
        {
            var template = new DataTemplate {
                DataType = typeof(string)
            };
            var fef = new FrameworkElementFactory(typeof(TextBlock));

            fef.SetBinding(TextBlock.TextProperty, new Binding("[" + customField.Name + "]")
            {
                StringFormat = customField.EditingFormat
            });
            template.VisualTree = fef;
            var c = new GridViewColumn {
                Header = customField.Name, CellTemplate = template
            };

            ProportionalColumn.ApplyWidth(c, 1);
            return(c);
        }
예제 #2
0
        bool CustomDataValueUpdating(EntityCustomField entityCustomField, string oldValue, string newValue)
        {
            var handled = false;

            if (entityCustomField.IsQuery && !string.IsNullOrEmpty(entityCustomField.EditingFormat) && entityCustomField.EditingFormat.Contains('='))
            {
                var value = entityCustomField.Values.FirstOrDefault(x => x.Contains(string.Format("\"{0}\"", newValue)));
                if (value != null)
                {
                    var valueParts = ParseCsv(value);
                    var format     = entityCustomField.EditingFormat;

                    for (var i = 0; i < valueParts.Count; i++)
                    {
                        format = format.Replace("$" + (i + 1), valueParts[i]);
                    }

                    var index = valueParts.Count;
                    while (valueParts.Contains("$") && index < 20)
                    {
                        format = format.Replace("$" + index, "");
                        index++;
                    }

                    format = format.Replace("\r", Environment.NewLine);
                    var formatParts = format.Split(';');

                    foreach (var fieldParts in formatParts.Where(x => x.Contains('=')).Select(formatPart => formatPart.Split(new[] { '=' }, 2)))
                    {
                        var field = CustomData.FirstOrDefault(x => x.Name == fieldParts[0]);
                        if (field == null)
                        {
                            continue;
                        }
                        field.SetValue(fieldParts[1]);
                        handled = true;
                    }
                }
            }
            return(handled);
        }
예제 #3
0
 public EntityCustomFieldViewModel(EntityCustomField model)
 {
     Model = model;
 }