/* * OLVListSubItem - A single cell in an ObjectListView * * Author: Phillip Piper * Date: 31-March-2011 5:53 pm * * Change log: * 2011-03-31 JPP - Split into its own file * * Copyright (C) 2011-2014 Phillip Piper * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * If you wish to use this code in a closed source application, please contact phillip_piper@bigfoot.com. */ using System; using System.Collections.Generic; using System.Drawing; using System.Text; using System.Windows.Forms; using System.ComponentModel; namespace BrightIdeasSoftware { /// /// A ListViewSubItem that knows which image should be drawn against it. /// [Browsable(false)] public class OLVListSubItem : ListViewItem.ListViewSubItem { #region Constructors /// /// Create a OLVListSubItem /// public OLVListSubItem() { } /// /// Create a OLVListSubItem that shows the given string and image /// public OLVListSubItem(object modelValue, string text, Object image) { this.ModelValue = modelValue; this.Text = text; this.ImageSelector = image; } #endregion #region Properties /// /// Gets or sets how many pixels will be left blank around this cell /// /// This setting only takes effect when the control is owner drawn. public Rectangle? CellPadding { get { return this.cellPadding; } set { this.cellPadding = value; } } private Rectangle? cellPadding; /// /// Gets or sets how this cell will be vertically aligned /// /// This setting only takes effect when the control is owner drawn. public StringAlignment? CellVerticalAlignment { get { return this.cellVerticalAlignment; } set { this.cellVerticalAlignment = value; } } private StringAlignment? cellVerticalAlignment; /// /// Gets or sets the model value is being displayed by this subitem. /// public object ModelValue { get { return modelValue; } private set { modelValue = value; } } private object modelValue; /// /// Gets if this subitem has any decorations set for it. /// public bool HasDecoration { get { return this.decorations != null && this.decorations.Count > 0; } } /// /// Gets or sets the decoration that will be drawn over this item /// /// Setting this replaces all other decorations public IDecoration Decoration { get { return this.HasDecoration ? this.Decorations[0] : null; } set { this.Decorations.Clear(); if (value != null) this.Decorations.Add(value); } } /// /// Gets the collection of decorations that will be drawn over this item /// public IList Decorations { get { if (this.decorations == null) this.decorations = new List(); return this.decorations; } } private IList decorations; /// /// Get or set the image that should be shown against this item /// /// This can be an Image, a string or an int. A string or an int will /// be used as an index into the small image list. public Object ImageSelector { get { return imageSelector; } set { imageSelector = value; } } private Object imageSelector; /// /// Gets or sets the url that should be invoked when this subitem is clicked /// public string Url { get { return this.url; } set { this.url = value; } } private string url; #endregion #region Implementation Properties /// /// Return the state of the animatation of the image on this subitem. /// Null means there is either no image, or it is not an animation /// internal ImageRenderer.AnimationState AnimationState; #endregion } }