| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386 |
- // Permission is hereby granted, free of charge, to any person obtaining
- // a copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to
- // permit persons to whom the Software is furnished to do so, subject to
- // the following conditions:
- //
- // The above copyright notice and this permission notice shall be
- // included in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- //
- // Copyright (c) 2004 Novell, Inc. (http://www.novell.com)
- //
- // Author:
- // Ravindra ([email protected])
- //
- // $Revision: 1.3 $
- // $Modtime: $
- // $Log: ListView.cs,v $
- // Revision 1.3 2004/10/15 15:03:39 ravindra
- // Implemented Paint method and fixed coding style.
- //
- // Revision 1.2 2004/10/02 11:32:01 ravindra
- // Added attributes.
- //
- // Revision 1.1 2004/09/30 13:24:25 ravindra
- // Initial implementation.
- //
- //
- // NOT COMPLETE
- //
- using System.Collections;
- using System.ComponentModel;
- using System.ComponentModel.Design;
- using System.Drawing;
- using System.Runtime.InteropServices;
- namespace System.Windows.Forms
- {
- [DefaultEvent ("SelectedIndexChanged")]
- [DefaultProperty ("Items")]
- [Designer ("System.Windows.Forms.Design.ListViewDesigner, " + Consts.AssemblySystem_Design, typeof (IDesigner))]
- public class ListView : Control
- {
- private ItemActivation activation = ItemActivation.Standard;
- private ListViewAlignment alignment = ListViewAlignment.Top;
- private bool allow_column_reorder = false;
- private bool auto_arrange = true;
- private BorderStyle border_style = BorderStyle.Fixed3D;
- private bool check_boxes = false;
- private CheckedIndexCollection checked_indices;
- private CheckedListViewItemCollection checked_items;
- private ColumnHeaderCollection columns;
- private ListViewItem focused_item;
- private bool full_row_select = false;
- private bool grid_lines = false;
- private ColumnHeaderStyle header_style = ColumnHeaderStyle.Clickable;
- private bool hide_selection = true;
- private bool hover_selection = false;
- private ListViewItemCollection items;
- private bool label_edit = false;
- private bool label_wrap = true;
- internal ImageList large_image_list;
- private IComparer item_sorter;
- private bool multiselect = true;
- private bool redraw = true;
- private bool scrollable = true;
- private SelectedIndexCollection selected_indices;
- private SelectedListViewItemCollection selected_items;
- internal ImageList small_image_list;
- private SortOrder sort_order = SortOrder.None;
- private ImageList state_image_list;
- private bool updating = false;
- private View view = View.LargeIcon;
- #region Events
- public event LabelEditEventHandler AfterLabelEdit;
- [Browsable (false)]
- [EditorBrowsable (EditorBrowsableState.Never)]
- public new event EventHandler BackgroundImageChanged;
- public event LabelEditEventHandler BeforeLabelEdit;
- public event ColumnClickEventHandler ColumnClick;
- public event EventHandler ItemActivate;
- public event ItemCheckEventHandler ItemCheck;
- public event ItemDragEventHandler ItemDrag;
- [Browsable (false)]
- [EditorBrowsable (EditorBrowsableState.Never)]
- public new event PaintEventHandler Paint;
- public event EventHandler SelectedIndexChanged;
- [Browsable (false)]
- [EditorBrowsable (EditorBrowsableState.Never)]
- public new event EventHandler TextChanged;
- #endregion // Events
- #region Public Constructors
- public ListView ()
- {
- background_color = SystemColors.Window;
- checked_indices = new CheckedIndexCollection (this);
- checked_items = new CheckedListViewItemCollection (this);
- columns = new ColumnHeaderCollection (this);
- foreground_color = SystemColors.WindowText;
- items = new ListViewItemCollection (this);
- selected_indices = new SelectedIndexCollection (this);
- selected_items = new SelectedListViewItemCollection (this);
- // event handlers
- base.Paint += new PaintEventHandler (ListView_Paint);
- }
- #endregion // Public Constructors
- #region Protected Properties
- protected override CreateParams CreateParams {
- get { return base.CreateParams; }
- }
- protected override Size DefaultSize {
- get { return ThemeEngine.Current.ListViewDefaultSize; }
- }
- #endregion // Protected Properties
- #region Public Instance Properties
- [DefaultValue (ItemActivation.Standard)]
- public ItemActivation Activation {
- get { return activation; }
- set { activation = value; }
- }
- [DefaultValue (ListViewAlignment.Top)]
- [Localizable (true)]
- public ListViewAlignment Alignment {
- get { return alignment; }
- set { alignment = value; }
- }
- [DefaultValue (false)]
- public bool AllowColumnReorder {
- get { return allow_column_reorder; }
- set { allow_column_reorder = value; }
- }
- [DefaultValue (true)]
- public bool AutoArrange {
- get { return auto_arrange; }
- set { auto_arrange = value; }
- }
- public override Color BackColor {
- get { return base.BackColor; }
- set { base.BackColor = value; }
- }
- [Browsable (false)]
- [EditorBrowsable (EditorBrowsableState.Never)]
- public override Image BackgroundImage {
- get { return background_image; }
- set {
- if (value == background_image)
- return;
- background_image = value;
- if (BackgroundImageChanged != null)
- BackgroundImageChanged (this, new EventArgs ());
- }
- }
- [DefaultValue (BorderStyle.Fixed3D)]
- [DispId (-504)]
- public BorderStyle BorderStyle {
- get { return border_style; }
- set { border_style = value; }
- }
- [DefaultValue (false)]
- public bool CheckBoxes {
- get { return check_boxes; }
- set { check_boxes = value; }
- }
- [Browsable (false)]
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
- public CheckedIndexCollection CheckedIndices {
- get { return checked_indices; }
- }
- [Browsable (false)]
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
- public CheckedListViewItemCollection CheckedItems {
- get { return checked_items; }
- }
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
- [Localizable (true)]
- [MergableProperty (false)]
- public ColumnHeaderCollection Columns {
- get { return columns; }
- }
- [Browsable (false)]
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
- public ListViewItem FocusedItem {
- get { return focused_item; }
- }
- public override Color ForeColor {
- get { return base.ForeColor; }
- set { base.ForeColor = value; }
- }
- [DefaultValue (false)]
- public bool FullRowSelect {
- get { return full_row_select; }
- set { full_row_select = value; }
- }
- [DefaultValue (false)]
- public bool GridLines {
- get { return grid_lines; }
- set { grid_lines = value; }
- }
- [DefaultValue (ColumnHeaderStyle.Clickable)]
- public ColumnHeaderStyle HeaderStyle {
- get { return header_style; }
- set { header_style = value; }
- }
- [DefaultValue (true)]
- public bool HideSelection {
- get { return hide_selection; }
- set { hide_selection = value; }
- }
- [DefaultValue (false)]
- public bool HoverSelection {
- get { return hover_selection; }
- set { hover_selection = value; }
- }
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
- [Localizable (true)]
- [MergableProperty (false)]
- public ListViewItemCollection Items {
- get { return items; }
- }
- [DefaultValue (false)]
- public bool LabelEdit {
- get { return label_edit; }
- set { label_edit = value; }
- }
- [DefaultValue (false)]
- [Localizable (true)]
- public bool LabelWrap {
- get { return label_wrap; }
- set { label_wrap = value; }
- }
- [DefaultValue (null)]
- public ImageList LargeImageList {
- get { return large_image_list; }
- set { large_image_list = value; }
- }
- [Browsable (false)]
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
- public IComparer ListViewItemSorter {
- get { return item_sorter; }
- set { item_sorter = value; }
- }
- [DefaultValue (true)]
- public bool MultiSelect {
- get { return multiselect; }
- set { multiselect = value; }
- }
- [DefaultValue (true)]
- public bool Scrollable {
- get { return scrollable; }
- set { scrollable = value; }
- }
- [Browsable (false)]
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
- public SelectedIndexCollection SelectedIndices {
- get { return selected_indices; }
- }
- [Browsable (false)]
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
- public SelectedListViewItemCollection SelectedItems {
- get { return selected_items; }
- }
- [DefaultValue (null)]
- public ImageList SmallImageList {
- get { return small_image_list; }
- set { small_image_list = value; }
- }
- [DefaultValue (SortOrder.None)]
- public SortOrder Sorting {
- get { return sort_order; }
- set { sort_order = value; }
- }
- [DefaultValue (null)]
- public ImageList StateImageList {
- get { return state_image_list; }
- set { state_image_list = value; }
- }
- [Bindable (false)]
- [Browsable (false)]
- [EditorBrowsable (EditorBrowsableState.Never)]
- public override string Text {
- get { return text; }
- set {
- if (value == text)
- return;
- text = value;
- if (TextChanged != null)
- TextChanged (this, new EventArgs ());
- }
- }
- [Browsable (false)]
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
- public ListViewItem TopItem {
- get { return items [0]; }
- }
- [DefaultValue (View.LargeIcon)]
- public View View {
- get { return view; }
- set { view = value; }
- }
- #endregion // Public Instance Properties
- #region Internal Methods
- internal void Redraw (bool recalculate)
- {
- if (recalculate)
- CalculateListView ();
- redraw = true;
- }
- private void CalculateListView ()
- {
- // FIXME: TODO
- }
- private void ListView_Paint (object sender, PaintEventArgs pe)
- {
- if (this.Width <= 0 || this.Height <= 0 || this.Visible == false)
- return;
- if (redraw) {
- ThemeEngine.Current.DrawListView (this.DeviceContext, pe.ClipRectangle, this);
- redraw = false;
- }
- // paint on the screen
- pe.Graphics.DrawImage (this.ImageBuffer, pe.ClipRectangle, pe.ClipRectangle, GraphicsUnit.Pixel);
- if (Paint != null)
- Paint (this, pe);
- }
- #endregion // Internal Methods
- #region Protected Methods
- protected override void CreateHandle ()
- {
- base.CreateHandle ();
- }
- protected override void Dispose (bool disposing)
- {
- Clear ();
- }
- protected override bool IsInputKey (Keys keyData)
- {
- return base.IsInputKey (keyData);
- }
- protected virtual void OnAfterLabelEdit (LabelEditEventArgs e)
- {
- if (AfterLabelEdit != null)
- AfterLabelEdit (this, e);
- }
- protected virtual void OnBeforeLabelEdit (LabelEditEventArgs e)
- {
- if (BeforeLabelEdit != null)
- BeforeLabelEdit (this, e);
- }
- protected virtual void OnColumnClick (ColumnClickEventArgs e)
- {
- if (ColumnClick != null)
- ColumnClick (this, e);
- }
- protected override void OnEnabledChanged (EventArgs e)
- {
- base.OnEnabledChanged (e);
- }
- protected override void OnFontChanged (EventArgs e)
- {
- base.OnFontChanged (e);
- }
- protected override void OnHandleCreated (EventArgs e)
- {
- base.OnHandleCreated (e);
- }
- protected override void OnHandleDestroyed (EventArgs e)
- {
- base.OnHandleDestroyed (e);
- }
- protected virtual void OnItemActivate (EventArgs e)
- {
- if (ItemActivate != null)
- ItemActivate (this, e);
- }
- protected virtual void OnItemCheck (ItemCheckEventArgs ice)
- {
- if (ItemCheck != null)
- ItemCheck (this, ice);
- }
- protected virtual void OnItemDrag (ItemDragEventArgs e)
- {
- if (ItemDrag != null)
- ItemDrag (this, e);
- }
- protected virtual void OnSelectedIndexChanged (EventArgs e)
- {
- if (SelectedIndexChanged != null)
- SelectedIndexChanged (this, e);
- }
- protected override void OnSystemColorsChanged (EventArgs e)
- {
- base.OnSystemColorsChanged (e);
- }
- protected void RealizeProperties ()
- {
- // FIXME: TODO
- }
- protected void UpdateExtendedStyles ()
- {
- // FIXME: TODO
- }
- protected override void WndProc (ref Message m)
- {
- base.WndProc (ref m);
- }
- #endregion // Protected Methods
- #region Public Instance Methods
- public void ArrangeIcons ()
- {
- ArrangeIcons (ListViewAlignment.Default);
- }
- public void ArrangeIcons (ListViewAlignment alignment)
- {
- // Icons are arranged only if view is set to LargeIcon or SmallIcon
- if (view == View.LargeIcon || view == View.SmallIcon) {
- // FIXME: TODO
- }
- }
- public void BeginUpdate ()
- {
- // flag to avoid painting
- updating = true;
- }
- public void Clear ()
- {
- columns.Clear ();
- items.Clear ();
- }
- public void EndUpdate ()
- {
- // flag to avoid painting
- updating = false;
- }
- public void EnsureVisible (int index)
- {
- // FIXME: TODO
- }
-
- public ListViewItem GetItemAt (int x, int y)
- {
- foreach (ListViewItem item in items) {
- if (item.Bounds.Contains (x, y))
- return item;
- }
- return null;
- }
- public Rectangle GetItemRect (int index)
- {
- return GetItemRect (index, ItemBoundsPortion.Entire);
- }
- public Rectangle GetItemRect (int index, ItemBoundsPortion portion)
- {
- if (index < 0 || index >= items.Count)
- throw new IndexOutOfRangeException ("Invalid Index");
- return items [index].GetBounds (portion);
- }
- public void Sort ()
- {
- if (sort_order != SortOrder.None)
- items.list.Sort (item_sorter);
- if (sort_order == SortOrder.Descending)
- items.list.Reverse ();
- }
- public override string ToString ()
- {
- int count = this.Items.Count;
- if (count == 0)
- return string.Format ("System.Windows.Forms.ListView, Items.Count: 0");
- else
- return string.Format ("System.Windows.Forms.ListView, Items.Count: {0}, Items[0]: {1}", count, this.Items [0].ToString ());
- }
- #endregion // Public Instance Methods
- #region Subclasses
- public class CheckedIndexCollection : IList, ICollection, IEnumerable
- {
- internal ArrayList list;
- private ListView owner;
- #region Public Constructor
- public CheckedIndexCollection (ListView owner)
- {
- list = new ArrayList ();
- this.owner = owner;
- }
- #endregion // Public Constructor
- #region Public Properties
- [Browsable (false)]
- public virtual int Count {
- get { return list.Count; }
- }
- public virtual bool IsReadOnly {
- get { return true; }
- }
- public int this [int index] {
- get {
- if (index < 0 || index >= list.Count)
- throw new ArgumentOutOfRangeException ("Index out of range.");
- return (int) list [index];
- }
- }
- bool ICollection.IsSynchronized {
- get { return list.IsSynchronized; }
- }
- object ICollection.SyncRoot {
- get { return list.SyncRoot; }
- }
- bool IList.IsFixedSize {
- get { return list.IsFixedSize; }
- }
- object IList.this [int index] {
- get { return this [index]; }
- set { throw new NotSupportedException ("SetItem operation is not supported."); }
- }
- #endregion // Public Properties
- #region Public Methods
- public bool Contains (int checkedIndex)
- {
- return list.Contains (checkedIndex);
- }
- public virtual IEnumerator GetEnumerator ()
- {
- return list.GetEnumerator ();
- }
- void ICollection.CopyTo (Array dest, int index)
- {
- list.CopyTo (dest, index);
- }
- int IList.Add (object value)
- {
- throw new NotSupportedException ("Add operation is not supported.");
- }
- void IList.Clear ()
- {
- throw new NotSupportedException ("Clear operation is not supported.");
- }
- bool IList.Contains (object checkedIndex)
- {
- return list.Contains (checkedIndex);
- }
- int IList.IndexOf (object checkedIndex)
- {
- return list.IndexOf (checkedIndex);
- }
- void IList.Insert (int index, object value)
- {
- throw new NotSupportedException ("Insert operation is not supported.");
- }
- void IList.Remove (object value)
- {
- throw new NotSupportedException ("Remove operation is not supported.");
- }
- void IList.RemoveAt (int index)
- {
- throw new NotSupportedException ("RemoveAt operation is not supported.");
- }
- public int IndexOf (int checkedIndex)
- {
- return list.IndexOf (checkedIndex);
- }
- #endregion // Public Methods
- } // CheckedIndexCollection
- public class CheckedListViewItemCollection : IList, ICollection, IEnumerable
- {
- internal ArrayList list;
- private ListView owner;
- #region Public Constructor
- public CheckedListViewItemCollection (ListView owner)
- {
- list = new ArrayList ();
- this.owner = owner;
- }
- #endregion // Public Constructor
- #region Public Properties
- [Browsable (false)]
- public virtual int Count {
- get { return list.Count; }
- }
- public virtual bool IsReadOnly {
- get { return true; }
- }
- public ListViewItem this [int index] {
- get {
- if (index < 0 || index >= list.Count)
- throw new ArgumentOutOfRangeException ("Index out of range.");
- return (ListViewItem) list [index];
- }
- }
- bool ICollection.IsSynchronized {
- get { return list.IsSynchronized; }
- }
- object ICollection.SyncRoot {
- get { return list.SyncRoot; }
- }
- bool IList.IsFixedSize {
- get { return list.IsFixedSize; }
- }
- object IList.this [int index] {
- get { return this [index]; }
- set { throw new NotSupportedException ("SetItem operation is not supported."); }
- }
- #endregion // Public Properties
- #region Public Methods
- public bool Contains (ListViewItem item)
- {
- return list.Contains (item);
- }
- public virtual void CopyTo (Array dest, int index)
- {
- list.CopyTo (dest, index);
- }
- public virtual IEnumerator GetEnumerator ()
- {
- return list.GetEnumerator ();
- }
- int IList.Add (object value)
- {
- throw new NotSupportedException ("Add operation is not supported.");
- }
- void IList.Clear ()
- {
- throw new NotSupportedException ("Clear operation is not supported.");
- }
- bool IList.Contains (object item)
- {
- return list.Contains (item);
- }
- int IList.IndexOf (object item)
- {
- return list.IndexOf (item);
- }
- void IList.Insert (int index, object value)
- {
- throw new NotSupportedException ("Insert operation is not supported.");
- }
- void IList.Remove (object value)
- {
- throw new NotSupportedException ("Remove operation is not supported.");
- }
- void IList.RemoveAt (int index)
- {
- throw new NotSupportedException ("RemoveAt operation is not supported.");
- }
- public int IndexOf (ListViewItem item)
- {
- return list.IndexOf (item);
- }
- #endregion // Public Methods
- } // CheckedListViewItemCollection
- public class ColumnHeaderCollection : IList, ICollection, IEnumerable
- {
- internal ArrayList list;
- private ListView owner;
- #region Public Constructor
- public ColumnHeaderCollection (ListView owner)
- {
- list = new ArrayList ();
- this.owner = owner;
- }
- #endregion // Public Constructor
- #region Public Properties
- [Browsable (false)]
- public virtual int Count {
- get { return list.Count; }
- }
- public virtual bool IsReadOnly {
- get { return false; }
- }
- public virtual ColumnHeader this [int index] {
- get {
- if (index < 0 || index >= list.Count)
- throw new ArgumentOutOfRangeException ("Index out of range.");
- return (ColumnHeader) list [index];
- }
- }
- bool ICollection.IsSynchronized {
- get { return list.IsSynchronized; }
- }
- object ICollection.SyncRoot {
- get { return list.SyncRoot; }
- }
- bool IList.IsFixedSize {
- get { return list.IsFixedSize; }
- }
- object IList.this [int index] {
- get { return this [index]; }
- set { throw new NotSupportedException ("SetItem operation is not supported."); }
- }
- #endregion // Public Properties
- #region Public Methods
- public virtual int Add (ColumnHeader value)
- {
- return list.Add (value);
- }
- public virtual ColumnHeader Add (string str, int width, HorizontalAlignment textAlign)
- {
- ColumnHeader colHeader = new ColumnHeader (this.owner, str, textAlign, width);
- this.Add (colHeader);
- return colHeader;
- }
- public virtual void AddRange (ColumnHeader [] values)
- {
- foreach (ColumnHeader colHeader in values)
- this.Add (colHeader);
- }
- public virtual void Clear ()
- {
- list.Clear ();
- }
- public bool Contains (ColumnHeader value)
- {
- return list.Contains (value);
- }
- public virtual IEnumerator GetEnumerator ()
- {
- return list.GetEnumerator ();
- }
- void ICollection.CopyTo (Array dest, int index)
- {
- list.CopyTo (dest, index);
- }
- int IList.Add (object value)
- {
- if (! (value is ColumnHeader)) {
- throw new ArgumentException("Not of type ColumnHeader", "value");
- }
- return this.Add ((ColumnHeader) value);
- }
- bool IList.Contains (object value)
- {
- if (! (value is ColumnHeader)) {
- throw new ArgumentException("Not of type ColumnHeader", "value");
- }
- return this.Contains ((ColumnHeader) value);
- }
- int IList.IndexOf (object value)
- {
- if (! (value is ColumnHeader)) {
- throw new ArgumentException("Not of type ColumnHeader", "value");
- }
- return this.IndexOf ((ColumnHeader) value);
- }
- void IList.Insert (int index, object value)
- {
- if (! (value is ColumnHeader)) {
- throw new ArgumentException("Not of type ColumnHeader", "value");
- }
- this.Insert (index, (ColumnHeader) value);
- }
- void IList.Remove (object value)
- {
- if (! (value is ColumnHeader)) {
- throw new ArgumentException("Not of type ColumnHeader", "value");
- }
- this.Remove ((ColumnHeader) value);
- }
- public int IndexOf (ColumnHeader value)
- {
- return list.IndexOf (value);
- }
- public void Insert (int index, ColumnHeader value)
- {
- if (index < 0 || index >= list.Count)
- throw new ArgumentOutOfRangeException ("Index out of range.");
- list.Insert (index, value);
- }
- public void Insert (int index, string str, int width, HorizontalAlignment textAlign)
- {
- ColumnHeader colHeader = new ColumnHeader (this.owner, str, textAlign, width);
- this.Insert (index, colHeader);
- }
- public virtual void Remove (ColumnHeader column)
- {
- list.Remove (column);
- }
- public virtual void RemoveAt (int index)
- {
- if (index < 0 || index >= list.Count)
- throw new ArgumentOutOfRangeException ("Index out of range.");
- list.RemoveAt (index);
- }
- #endregion // Public Methods
- } // ColumnHeaderCollection
- public class ListViewItemCollection : IList, ICollection, IEnumerable
- {
- internal ArrayList list;
- private ListView owner;
- #region Public Constructor
- public ListViewItemCollection (ListView owner)
- {
- list = new ArrayList ();
- this.owner = owner;
- }
- #endregion // Public Constructor
- #region Public Properties
- [Browsable (false)]
- public virtual int Count {
- get { return list.Count; }
- }
- public virtual bool IsReadOnly {
- get { return false; }
- }
- public virtual ListViewItem this [int displayIndex] {
- get {
- if (displayIndex < 0 || displayIndex >= list.Count)
- throw new ArgumentOutOfRangeException ("Index out of range.");
- return (ListViewItem) list [displayIndex];
- }
- set {
- if (displayIndex < 0 || displayIndex >= list.Count)
- throw new ArgumentOutOfRangeException ("Index out of range.");
- value.owner = this.owner;
- list [displayIndex] = value;
- owner.Redraw (true);
- }
- }
- bool ICollection.IsSynchronized {
- get { return list.IsSynchronized; }
- }
- object ICollection.SyncRoot {
- get { return list.SyncRoot; }
- }
- bool IList.IsFixedSize {
- get { return list.IsFixedSize; }
- }
- object IList.this [int index] {
- get { return this [index]; }
- set {
- if (value is ListViewItem)
- this [index] = (ListViewItem) value;
- else
- this [index] = new ListViewItem (value.ToString ());
- }
- }
- #endregion // Public Properties
- #region Public Methods
- public virtual ListViewItem Add (ListViewItem value)
- {
- value.owner = this.owner;
- list.Add (value);
- if (owner.Sorting != SortOrder.None)
- owner.Sort ();
- owner.Redraw (true);
- return value;
- }
- public virtual ListViewItem Add (string text)
- {
- ListViewItem item = new ListViewItem (text);
- return this.Add (item);
- }
- public virtual ListViewItem Add (string text, int imageIndex)
- {
- ListViewItem item = new ListViewItem (text, imageIndex);
- return this.Add (item);
- }
- public void AddRange (ListViewItem [] values)
- {
- list.Clear ();
- foreach (ListViewItem item in values) {
- item.owner = this.owner;
- list.Add (item);
- }
- if (owner.Sorting != SortOrder.None)
- owner.Sort ();
- owner.Redraw (true);
- }
- public virtual void Clear ()
- {
- list.Clear ();
- owner.Redraw (true);
- }
- public bool Contains (ListViewItem item)
- {
- return list.Contains (item);
- }
- public virtual void CopyTo (Array dest, int index)
- {
- list.CopyTo (dest, index);
- }
- public virtual IEnumerator GetEnumerator ()
- {
- return list.GetEnumerator ();
- }
- int IList.Add (object item)
- {
- int result;
- ListViewItem li;
- if (item is ListViewItem)
- li = (ListViewItem) item;
- else
- li = new ListViewItem (item.ToString ());
- li.owner = this.owner;
- result = list.Add (li);
- owner.Redraw (true);
- return result;
- }
- bool IList.Contains (object item)
- {
- return list.Contains (item);
- }
- int IList.IndexOf (object item)
- {
- return list.IndexOf (item);
- }
- void IList.Insert (int index, object item)
- {
- if (item is ListViewItem)
- this.Insert (index, (ListViewItem) item);
- else
- this.Insert (index, item.ToString ());
- }
- void IList.Remove (object item)
- {
- if (list.Contains (item)) {
- list.Remove (item);
- owner.Redraw (true);
- }
- }
- public int IndexOf (ListViewItem item)
- {
- return list.IndexOf (item);
- }
- public ListViewItem Insert (int index, ListViewItem item)
- {
- if (index < 0 || index >= list.Count)
- throw new ArgumentOutOfRangeException ("Index out of range.");
- item.owner = this.owner;
- list.Insert (index, item);
- owner.Redraw (true);
- return item;
- }
- public ListViewItem Insert (int index, string text)
- {
- return this.Insert (index, new ListViewItem (text));
- }
- public ListViewItem Insert (int index, string text, int imageIndex)
- {
- return this.Insert (index, new ListViewItem (text, imageIndex));
- }
- public virtual void Remove (ListViewItem item)
- {
- if (list.Contains (item)) {
- list.Remove (item);
- owner.Redraw (true);
- }
- }
- public virtual void RemoveAt (int index)
- {
- if (index < 0 || index >= list.Count)
- throw new ArgumentOutOfRangeException ("Index out of range.");
- list.RemoveAt (index);
- owner.Redraw (false);
- }
- #endregion // Public Methods
- } // ListViewItemCollection
- public class SelectedIndexCollection : IList, ICollection, IEnumerable
- {
- internal ArrayList list;
- private ListView owner;
- #region Public Constructor
- public SelectedIndexCollection (ListView owner)
- {
- list = new ArrayList ();
- this.owner = owner;
- }
- #endregion // Public Constructor
- #region Public Properties
- [Browsable (false)]
- public virtual int Count {
- get { return list.Count; }
- }
- public virtual bool IsReadOnly {
- get { return true; }
- }
- public int this [int index] {
- get {
- if (index < 0 || index >= list.Count)
- throw new ArgumentOutOfRangeException ("Index out of range.");
- return (int) list [index];
- }
- }
- bool ICollection.IsSynchronized {
- get { return list.IsSynchronized; }
- }
- object ICollection.SyncRoot {
- get { return list.SyncRoot; }
- }
- bool IList.IsFixedSize {
- get { return list.IsFixedSize; }
- }
- object IList.this [int index] {
- get { return this [index]; }
- set { throw new NotSupportedException ("SetItem operation is not supported."); }
- }
- #endregion // Public Properties
- #region Public Methods
- public bool Contains (int selectedIndex)
- {
- return list.Contains (selectedIndex);
- }
- public virtual void CopyTo (Array dest, int index)
- {
- list.CopyTo (dest, index);
- }
- public virtual IEnumerator GetEnumerator ()
- {
- return list.GetEnumerator ();
- }
- int IList.Add (object value)
- {
- throw new NotSupportedException ("Add operation is not supported.");
- }
- void IList.Clear ()
- {
- throw new NotSupportedException ("Clear operation is not supported.");
- }
- bool IList.Contains (object selectedIndex)
- {
- return list.Contains (selectedIndex);
- }
- int IList.IndexOf (object selectedIndex)
- {
- return list.IndexOf (selectedIndex);
- }
- void IList.Insert (int index, object value)
- {
- throw new NotSupportedException ("Insert operation is not supported.");
- }
- void IList.Remove (object value)
- {
- throw new NotSupportedException ("Remove operation is not supported.");
- }
- void IList.RemoveAt (int index)
- {
- throw new NotSupportedException ("RemoveAt operation is not supported.");
- }
- public int IndexOf (int selectedIndex)
- {
- return list.IndexOf (selectedIndex);
- }
- #endregion // Public Methods
- } // SelectedIndexCollection
- public class SelectedListViewItemCollection : IList, ICollection, IEnumerable
- {
- internal ArrayList list;
- private ListView owner;
- #region Public Constructor
- public SelectedListViewItemCollection (ListView owner)
- {
- list = new ArrayList ();
- this.owner = owner;
- }
- #endregion // Public Constructor
- #region Public Properties
- [Browsable (false)]
- public virtual int Count {
- get { return list.Count; }
- }
- public virtual bool IsReadOnly {
- get { return true; }
- }
- public ListViewItem this [int index] {
- get {
- if (index < 0 || index >= list.Count)
- throw new ArgumentOutOfRangeException ("Index out of range.");
- return (ListViewItem) list [index];
- }
- }
- bool ICollection.IsSynchronized {
- get { return list.IsSynchronized; }
- }
- object ICollection.SyncRoot {
- get { return list.SyncRoot; }
- }
- bool IList.IsFixedSize {
- get { return list.IsFixedSize; }
- }
- object IList.this [int index] {
- get { return this [index]; }
- set { throw new NotSupportedException ("SetItem operation is not supported."); }
- }
- #endregion // Public Properties
- #region Public Methods
- public virtual void Clear ()
- {
- list.Clear ();
- }
- public bool Contains (ListViewItem item)
- {
- return list.Contains (item);
- }
- public virtual void CopyTo (Array dest, int index)
- {
- list.CopyTo (dest, index);
- }
- public virtual IEnumerator GetEnumerator ()
- {
- return list.GetEnumerator ();
- }
- int IList.Add (object value)
- {
- throw new NotSupportedException ("Add operation is not supported.");
- }
- bool IList.Contains (object item)
- {
- return list.Contains (item);
- }
- int IList.IndexOf (object item)
- {
- return list.IndexOf (item);
- }
- void IList.Insert (int index, object value)
- {
- throw new NotSupportedException ("Insert operation is not supported.");
- }
- void IList.Remove (object value)
- {
- throw new NotSupportedException ("Remove operation is not supported.");
- }
- void IList.RemoveAt (int index)
- {
- throw new NotSupportedException ("RemoveAt operation is not supported.");
- }
- public int IndexOf (ListViewItem item)
- {
- return list.IndexOf (item);
- }
- #endregion // Public Methods
- } // SelectedListViewItemCollection
- #endregion // Subclasses
- }
- }
|