Click here to Skip to main content
15,884,986 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 82.6K   7.6K   110  
Docking windows container, extended listview, extended property editor.
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Threading;

namespace dwf.tool
{
    public enum SizingAligment
    {
        None,
        Bootom,
        BootomLeft,
        BootomRight,
        Top,
        TopLeft,
        TopRight,
        Left,
        Right
    }

    public enum CheckedState
    {
        Unchecked = 0,
        Checked = 1,
        Indeterminate = 2
    }

    public enum ToolShowMode
    {
        Default,
        Dialog,
        AutoHide,
        ToolTip,
        Modal
    }

    public enum LogicType
    {
        Undefined,
        And,
        Or,
        AndNot,
        OrNot,
        Not
    }

    public enum CompareType
    {
        Undefined,
        Equal,
        NotEqual,
        In,
        NotIn,
        IsNull,
        IsNot,
        IsNotNull,
        Like,
        NotLike,
        Greater,
        GreaterOrEqual,
        Less,
        LessOrEqual,
        Between,
        Not,
        Is,
        Null
    }

    public enum EditListState
    {
        ReadOnly,
        Edit,
        EditAny
    }

    public enum DockType
    {
        Content,
        Left,
        Right,
        RightBottom,
        Top,
        Bottom
    }

    public enum CellDisplayState
    {
        Default,
        Alternate,
        Selected,
        Hover,
        Pressed
    }

    public enum StatusType
    {
        Information,
        Warning,
        Error,
    }

    public enum EditModes
    {
        None,
        ByClick,
        ByF2
    }

    public enum PListState
    {
        Default,
        MoveColumn,
        DragDrop,
        SizeColumWidth,
        SizeColumHeight,
        SizeHeaderWidth,
        Select
    }

    public enum PListHitTestLocation
    {
        None,
        Column,
        Cell,
        Header,
        Group,
        Intermediate
    }

    public enum PListHitTestLocationCell
    {
        None,
        Image,
        Check,
        Glyph,
        Text,
        Sort,
        Filter
    }

    public enum DBStatus
    {
        Empty = 0,
        Actual = 1,
        New = 2,
        Edit = 3,
        Delete = 4,
        Archive = 5,
        Error = 6
    }

    public interface IStatus
    {
        DBStatus Status { get; set; }
    }

    public interface ILayoutMapItem
    {
        //RectangleF Temp { get; set; }

        float Height { get; set; }

        float Width { get; set; }

        int Row { get; set; }

        int Col { get; set; }

        bool Visible { get; set; }

        bool FillWidth { get; }
        
        bool FillHeight { get; }

        string Name { get; }

        ILayoutMap Map { get; set; }
    }

    public interface ILayoutMap : ILayoutMapItem
    {
        LayoutItems Items { get; }

        bool Contains(ILayoutMapItem item);

        void Sort();

        float Scale { get; set; }
    }

    public class LayoutItems : ListExtend<ILayoutMapItem>
    {
        [NonSerialized()]
        private ILayoutMap map;

        public LayoutItems(ILayoutMap map)
        {
            this.map = map;
        }

        public override void Add(ILayoutMapItem item)
        {
            item.Map = map;
            base.Add(item);
        }
        
        public override void Insert(int index, ILayoutMapItem item)
        {
            item.Map = map;
            base.Insert(index, item);
        }

        public override bool Remove(ILayoutMapItem item)
        {
            item.Map = null;
            return base.Remove(item);
        }

        public override void Clear()
        {
            foreach (var item in _items)
                item.Map = null;
            base.Clear();
        }
    }

    public interface IProjectEditor
    {
        ProjectHandler Project { get; set; }

        void Reload();
    }

    public interface IDockContainer
    {
        IDockContainer DockParent { get; }

        List<IDockContainer> Docks { get; }

        bool ContainsControl(object c);

        bool Delete(object control);

        void Put(object control);

        void Put(object control, DockType type);

        List<object> GetControls();

        object Find(string name);
    }

    public interface IDocked
    {
        IDockContainer DockPanel { get; }
    }

    public interface IDockMain : IDocked, ILocalizable
    {
        void SetStatus(StateInfo info);
        
        void SetStatusAdd(string info);

        void ShowProperty(object sender, object item, bool onTop);

        ProjectHandler CurrentProject { get; set; }

        void AddTask(object sender, TaskExecutor task);
    }

    public interface IDockContent : ILocalizable, IPicture
    {
        DockType DockType { get; }

        bool HideOnClose { get; }
    }

    public interface IComparerList : IComparer
    {
        void Add(IComparer comparer);
    }
    
    public interface IComparerList<T> : IComparer<T>
    {
        void Add(IComparer<T> comparer);
    }

    public interface IStringConverter
    {
        string FormatObject(object val);
        object ParceObjcet(string val, Type type);
    }

    public interface IExecutable
    {
        object Execute(Dictionary<string, object> parameters);
    }
    
    

    public interface IEditable
    {
        void Refresh();

        void Save();

        void Reject();

        void Accept();

        bool IsChanged { get; }
    }

    public interface IListExtend : IList
    {
        event ListChangedEventHandler ListChanged;

        void RaiseListChanged(ListChangedType type, int index);

        void ApplySort(IComparer comparer);

        //IComparer Comparer { get; }

        object NewItem();

        Type ItemType { get; }

        void RemoveSort();
    }

    public interface IListQuery : IListExtend
    {
        IList Select(ListQuery checkers);
        //IList Select(string property, object value, Comparer compare);
    }

    public interface ICheck
    {
        bool Check { get; set; }
    }

    public interface IGroup : IComparable
    {
        bool ParentsExpand { get; }

        IGroup Group { get; set; }

        bool Expand { get; set; }

        bool IsCompaund { get; }
    }

    public interface IPicture
    {
        Image Image { get; }
    }

    public interface IFSerialize
    {
        void SaveFile(string file);

        void SaveDirectory(string path);

        void LoadFile(string file);

        void LoadDirectory(string path);

        string FileName
        { get; set; }
    }

    public interface ILocalizable
    {
        void Localizing();
    }

    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
    public sealed class ProjectAttribute : Attribute
    {
        // This is a positional argument
        public ProjectAttribute(Type type, string fileFilter)
            : base()
        {
            Type = type;
            FileFilter = fileFilter;
        }

        public Type Type { get; internal set; }

        public string FileFilter { get; internal set; }

    }

    public class ProjectType
    {
        private Type editor;
        private Type project;
        private string filter;
        
        public ProjectType()
        { }
        
        public ProjectType(Type typeEditor, Type typeProject, string filter)
        {
            this.editor = typeEditor;
            this.project = typeProject;
            this.filter = filter;
        }

        public ProjectType(Type typeEditor, ProjectAttribute attribute)
            : this(typeEditor, attribute.Type, attribute.FileFilter)
        {
        }

        public Type Editor { get { return editor; } }
        public Type Project { get { return project; } }
        public string Filter { get { return filter; } }

        public string Name
        {
            get
            {
                return Localize.Get(this.project.FullName, this.project.Name);
            }
        }
    }

    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
    public sealed class ModuleAttribute : Attribute
    {
        readonly bool isModule = false;

        public ModuleAttribute(bool isModule)
        {
            this.isModule = isModule;
        }

        public bool IsModule
        {
            get { return isModule; }
        }
    }
}

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