Exemplo n.º 1
0
        /// <summary>
        /// Create columns for the listview based on what properties are available in the data source
        /// </summary>
        /// <remarks>
        /// <para>This method will not replace existing columns.</para>
        /// </remarks>
        protected virtual void CreateColumnsFromSource()
        {
            if (currencyManager == null || Columns.Count != 0)
            {
                return;
            }

            PropertyDescriptorCollection properties = currencyManager.GetItemProperties();

            if (properties.Count == 0)
            {
                return;
            }

            for (int i = 0; i < properties.Count; i++)
            {
                // Make a stack variable to hold the property so it can be used in the AspectGetter delegate
                PropertyDescriptor property = properties[i];

                // Relationships to other tables turn up as IBindibleLists. Don't make columns to show them.
                // CHECK: Is this always true? What other things could be here? Constraints? Triggers?
                if (property.PropertyType == typeof(IBindingList))
                {
                    continue;
                }

                // Create a column
                var column = new OLVColumn(property.DisplayName, property.Name);
                column.Width        = 0; // zero-width since we will resize it once we have some data
                column.AspectGetter = delegate(object row) { return(property.GetValue(row)); };
                // If our column is a BLOB, it could be an image, so assign a renderer to draw it.
                // CONSIDER: Is this a common enough case to warrant this code?
                if (property.PropertyType == typeof(Byte[]))
                {
                    column.Renderer = new ImageRenderer();
                }

                // Add it to our list
                Columns.Add(column);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Generate aspect getters and putters for any columns that are missing them (and for which we have
 /// enough information to actually generate a getter)
 /// </summary>
 protected virtual void CreateMissingAspectGettersAndPutters()
 {
     for (int i = 0; i < Columns.Count; i++)
     {
         OLVColumn column = GetColumn(i);
         if (column.AspectGetter == null && !String.IsNullOrEmpty(column.AspectName))
         {
             column.AspectGetter = delegate(object row)
             {
                 // In most cases, rows will be DataRowView objects
                 var drv = row as DataRowView;
                 if (drv != null)
                 {
                     return(drv[column.AspectName]);
                 }
                 else
                 {
                     return(column.GetAspectByName(row));
                 }
             };
         }
         if (column.IsEditable && column.AspectPutter == null && !String.IsNullOrEmpty(column.AspectName))
         {
             column.AspectPutter = delegate(object row, object newValue)
             {
                 // In most cases, rows will be DataRowView objects
                 var drv = row as DataRowView;
                 if (drv != null)
                 {
                     drv[column.AspectName] = newValue;
                 }
                 else
                 {
                     column.PutAspectByName(row, newValue);
                 }
             };
         }
     }
 }
Exemplo n.º 3
0
 public virtual int SearchText(string value, int first, int last, OLVColumn column)
 {
     return(AbstractVirtualListDataSource.DefaultSearchText(value, first, last, column, this));
 }
Exemplo n.º 4
0
 public TypedColumn(OLVColumn column)
 {
     this.column = column;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Searches the text.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="first">The first.</param>
 /// <param name="last">The last.</param>
 /// <param name="column">The column.</param>
 /// <returns></returns>
 public override int SearchText(string value, int first, int last, OLVColumn column)
 {
     return(DefaultSearchText(value, first, last, column, this));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Sort the model objects in the data source.
 /// </summary>
 /// <param name="column"></param>
 /// <param name="order"></param>
 public virtual void Sort(OLVColumn column, SortOrder order)
 {
 }
Exemplo n.º 7
0
 /// <summary>
 /// Find the first row that "matches" the given text in the given range.
 /// </summary>
 /// <param name="value">The text typed by the user</param>
 /// <param name="first">Start searching from this index. This may be greater than the 'to' parameter,
 /// in which case the search should descend</param>
 /// <param name="last">Do not search beyond this index. This may be less than the 'from' parameter.</param>
 /// <param name="column">The column that should be considered when looking for a match.</param>
 /// <returns>
 /// Return the index of row that was matched, or -1 if no match was found
 /// </returns>
 public virtual int SearchText(string value, int first, int last, OLVColumn column)
 {
     return(-1);
 }
Exemplo n.º 8
0
 public ColumnComparer(OLVColumn col, SortOrder order)
 {
     this.column    = col;
     this.sortOrder = order;
 }
Exemplo n.º 9
0
 public ModelObjectComparer(OLVColumn col, SortOrder order)
 {
     this.column    = col;
     this.sortOrder = order;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Find the first row in the given range of rows that prefix matches the string value of the given column.
 /// </summary>
 /// <param name="text"></param>
 /// <param name="first"></param>
 /// <param name="last"></param>
 /// <param name="column"></param>
 /// <returns>The index of the matched row, or -1</returns>
 protected override int FindMatchInRange(string text, int first, int last, OLVColumn column)
 {
     return(DataSource.SearchText(text, first, last, column));
 }