/// <summary> /// Validates whether <paramref name="value"/> is can be used to resolve an instance of <see cref="Type"/>. /// </summary> /// <remarks> /// The <paramref name="value"/> is interpreted from within the designers application domain.<br/> /// Therefore results cannot be guaranteed to be accurate and warnings are reported, rather than errors. /// </remarks> /// <param name="property">The Property that declares the <paramref name="value"/>.</param> /// <param name="value">Value to validate</param> /// <param name="results">The collection to wich any results that occur during the validation can be added.</param> protected override void ValidateCore(ViewModel.Property property, string value, IList <ValidationResult> results) { if (string.IsNullOrEmpty(value)) { return; } Type type = Type.GetType(value, false, true); if (type == null) { results.Add(new PropertyValidationResult(property, string.Format(CultureInfo.CurrentCulture, Resources.ValidationTypeNotLocatable, value), true)); } }
public ViewModel.Property CreateProperty(Model.Property Property, System.Boolean SubstitueStringForText) { ViewModel.Property viewmodelproperty = this.CreateProperty(Property.Type, SubstitueStringForText); viewmodelproperty.Binding = Property; return(viewmodelproperty); }
public ViewModel.Property CreateProperty(Model.PropertyType PropertyType, System.Boolean SubstitueStringForText) { ViewModel.Property viewmodelproperty = null; switch (PropertyType.GetType().Name) { case "String": viewmodelproperty = new Properties.String(this, (Model.PropertyTypes.String)PropertyType); break; case "Federated": viewmodelproperty = new Properties.Federated(this, (Model.PropertyTypes.Federated)PropertyType); break; case "Integer": viewmodelproperty = new Properties.Integer(this, (Model.PropertyTypes.Integer)PropertyType); break; case "Float": viewmodelproperty = new Properties.Float(this, (Model.PropertyTypes.Float)PropertyType); break; case "Sequence": viewmodelproperty = new Properties.Sequence(this, (Model.PropertyTypes.Sequence)PropertyType); break; case "Item": viewmodelproperty = new Properties.Item(this, (Model.PropertyTypes.Item)PropertyType); break; case "Decimal": viewmodelproperty = new Properties.Decimal(this, (Model.PropertyTypes.Decimal)PropertyType); break; case "Date": viewmodelproperty = new Properties.Date(this, (Model.PropertyTypes.Date)PropertyType); break; case "Text": if (SubstitueStringForText) { viewmodelproperty = new Properties.String(this, (Model.PropertyTypes.Text)PropertyType); } else { viewmodelproperty = new Properties.Text(this, (Model.PropertyTypes.Text)PropertyType); } break; case "Boolean": viewmodelproperty = new Properties.Boolean(this, (Model.PropertyTypes.Boolean)PropertyType); break; case "List": viewmodelproperty = new Properties.List(this, (Model.PropertyTypes.List)PropertyType); break; default: throw new Model.Exceptions.ArgumentException("PropertyType not implmented: " + PropertyType.GetType().Name); } return(viewmodelproperty); }
public Filters(Control Parent, IEnumerable <Model.PropertyType> PropertyTypes) : base(Parent) { // Store PropertyTypes this.PropertyTypes = PropertyTypes; // Create Commands this.ApplyFilter = new FilterCommand(this); this.ClearFilter = new ClearCommand(this); // Set Title this.Title = "Search Filters"; // Create Layout this.Layout = new Containers.BorderContainer(this.Session); this.Content = this.Layout; this.Layout.Children.NotifyListChanged = false; // Build Toolbar this.Toolbar = new Containers.Toolbar(this.Session); this.Toolbar.Region = Regions.Top; this.Layout.Children.Add(this.Toolbar); this.Toolbar.Children.NotifyListChanged = false; // Add Filter Button this.FilterButton = new Button(this.Session); this.Toolbar.Children.Add(this.FilterButton); this.FilterButton.Icon = "Search"; this.FilterButton.Tooltip = "Apply Filters"; this.FilterButton.Command = this.ApplyFilter; // Add Clear Button this.ClearButton = new Button(this.Session); this.Toolbar.Children.Add(this.ClearButton); this.ClearButton.Icon = "ClearFilter"; this.ClearButton.Tooltip = "Clear Filters"; this.ClearButton.Command = this.ClearFilter; this.Toolbar.Children.NotifyListChanged = true; // Build Table this.Table = new Containers.TableContainer(this.Session); this.Table.Columns = NoColumns; this.Table.Children.NotifyListChanged = false; foreach (Model.PropertyType proptype in this.PropertyTypes) { ViewModel.Property viewmodelproperty = this.Session.CreateProperty(proptype, true); viewmodelproperty.IntermediateChanges = true; viewmodelproperty.Enabled = true; this.Table.Children.Add(viewmodelproperty); } this.Table.Children.NotifyListChanged = true; this.Table.Region = Regions.Center; this.Layout.Children.Add(this.Table); this.Layout.Children.NotifyListChanged = true; // Set Width and Height this.Width = 600; this.Height = (((this.PropertyTypes.Count() / NoColumns) + (this.PropertyTypes.Count() % NoColumns > 0 ? 1 : 0)) * RowHeight) + ToolbarHeight; }