Click here to Skip to main content
15,894,291 members
Articles / Desktop Programming / Windows Forms

Controls Library: Extended ListView with Column Mapping

Rate me:
Please Sign up or sign in to vote.
4.86/5 (29 votes)
27 Mar 2014CPOL5 min read 83.1K   7.6K   110  
Docking windows container, extended listview, extended property editor.
using System;
using System.ComponentModel;
using System.Drawing;

namespace dwf.tool
{
    public class LayoutMapItem : ILayoutMapItem, IComparable, INotifyPropertyChanged
    {
        private static float min = 5;
        [DefaultValue((float)18)]
        protected float height = 18;
        [DefaultValue((float)120)]
        protected float width = 120;
        [DefaultValue((int)0)]
        protected int row = 0;
        [DefaultValue((int)0)]
        protected int col = 0;
        [DefaultValue(true)]
        protected bool visible = true;
        [DefaultValue(false)]
        protected bool fillW = false;
        [DefaultValue(false)]
        protected bool fillH = false;
        protected string name = null;
        [NonSerialized()]
        protected ILayoutMap map = null;
        [NonSerialized()]
        protected object tag;
        [NonSerialized()]
        protected RectangleF temp;

        public RectangleF Temp
        {
            get { return temp; }
            set { temp = value; }
        }

        public float Height
        {
            get { return height; }
            set
            {
                if (value == height || value < min)
                    return;
                height = value;
                OnPropertyChanged("Height");
            }
        }

        public float Width
        {
            get { return width; }
            set
            {
                if (value == width || value < min)
                    return;
                width = value;
                OnPropertyChanged("Width");
            }
        }

        public int Row
        {
            get { return row; }
            set
            {
                if (row == value)
                    return;
                row = value;
                OnPropertyChanged("Row");
            }
        }

        public int Col
        {
            get { return col; }
            set
            {
                if (col == value)
                    return;
                col = value;
                OnPropertyChanged("Col");
            }
        }

        public virtual bool Visible
        {
            get { return visible; }
            set
            {
                if (visible == value)
                    return;
                visible = value;
                OnPropertyChanged("Visible");
            }
        }

        public bool FillWidth
        {
            get { return fillW; }
            set
            {
                if (fillW == value)
                    return;
                fillW = value;
                OnPropertyChanged("FillWidth");
            }
        }

        public bool FillHeight
        {
            get { return fillH; }
            set
            {
                if (fillH == value)
                    return;
                fillH = value;
                OnPropertyChanged("FillHeight");
            }
        }

        public string Name
        {
            get { return name; }
            set
            {
                if (name == value)
                    return;
                name = value;
                OnPropertyChanged("Name");
            }
        }

        public ILayoutMap Map
        {
            get { return map; }
            set
            {
                if (map == value)
                    return;
                map = value;
                OnPropertyChanged("Map");
            }
        }

        public object Tag
        {
            get { return tag; }
            set
            {
                if (tag == value)
                    return;
                tag = value;
                OnPropertyChanged("Tag");
            }
        }

        public override string ToString()
        {
            return string.Format("({0},{1}) {2}", row , col , name);
        }

        #region IComparable implementation

        public int CompareTo(object obj)
        {
            return LayoutMapTool.Compare(this, obj as ILayoutMapItem);
        }

        #endregion

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string Property)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(Property));
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Kazakstan Kazakstan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions