Click here to Skip to main content
15,885,365 members
Articles / Programming Languages / C#

Developing a MultiSelector

Rate me:
Please Sign up or sign in to vote.
5.00/5 (18 votes)
3 Dec 2009BSD15 min read 65.1K   1.3K   45  
A MultiSelector-derived control that supports multiple selection modes, scoped selection, customizable lasso-tool and selection logic
using System.Collections.ObjectModel;
using System.Linq;

namespace SelectionAreaSample
{
    public sealed class DataItem : Observable
    {
        #region Constructors

        public DataItem()
        {
            Items = new ObservableCollection<DataItem>();
            PanelType = 1;
            LassoType = 1;
            SelectionType = 1;
        }

        #endregion Constructors

        #region Public Properties

        public ObservableCollection<DataItem> Items { get; private set; }

        public int Type { get; set; }

        public int PanelType
        {
            get
            {
                return panelType;
            }
            set
            {
                base.RaisePropertyChanged(() => PanelType, ref panelType, value);
            }
        }

        public int LassoType
        {
            get
            {
                return lassoType;
            }
            set
            {
                base.RaisePropertyChanged(() => LassoType, ref lassoType, value);
                Items.ToList().ForEach(a => a.LassoType = value);
            }
        }

        public int SelectionType
        {
            get
            {
                return selectionType;
            }
            set
            {
                base.RaisePropertyChanged(() => SelectionType, ref selectionType, value);
                Items.ToList().ForEach(a => a.SelectionType = value);
            }
        }

        public bool IsSelected
        {
            get
            {
                return isSelected;
            }
            set
            {
                base.RaisePropertyChanged(() => IsSelected, ref isSelected, value);
            }
        }

        public bool Scoped
        {
            get
            {
                return scoped;
            }
            set
            {
                base.RaisePropertyChanged(() => Scoped, ref scoped, value);
                Items.ToList().ForEach(a => { a.Scoped = value; a.IsSelected = false; });
            }
        }

        public double Left { get; set; }
        public double Top { get; set; }
        public double Width { get; set; }
        public double Height { get; set; }

        #endregion Public Properties

        #region Private Fields

        private int panelType;
        private int lassoType;
        private int selectionType;
        private bool isSelected;
        private bool scoped;

        #endregion Private Fields
    }
}

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 BSD License


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

Comments and Discussions