Esempio n. 1
0
 public int FindIndex(TableColumn column)
 {
     return items.FindIndex(x => x == column);
 }
Esempio n. 2
0
        public void Remove(TableColumn column)
        {
            if (column.control != null)
                column.control.Dispose();
            items.Remove(column);

            owner.UpdateColumns();
        }
Esempio n. 3
0
 public void Add(TableColumn column)
 {
     items.Add(column);
 }
Esempio n. 4
0
        public void Add(string columnName, string headerText)
        {
            TableColumn column = new TableColumn(this);
            column.Name = columnName;
            column.HeaderText = headerText;
            Add(column);

            owner.UpdateColumn(column);
        }
Esempio n. 5
0
        public virtual void Sort(TableColumn column, ListSortDirection direction)
        {
            if (column == null) return;

            int columnIndex = Columns.FindIndex(column);
            Dictionary<TableRow, object[]> items = new Dictionary<TableRow, object[]>();
            for (int i = 0; i < Rows.Count; i++)
            {
                var r = Rows[i];
                items.Add(r, r.Items);
            }

            var itemsList = items.ToList();
            if (direction == ListSortDirection.Ascending)
                itemsList.Sort((x, y) =>
                {
                    var v1 = x.Value[columnIndex];
                    var v2 = y.Value[columnIndex];

                    if (v1 == null && v2 == null)
                        return 0;

                    if (v1 == null)
                        return -1;
                    if (v2 == null)
                        return 1;

                    var we = v1.ToString().CompareTo(v2.ToString());
                    return we;
                });
            else
                itemsList.Sort((x, y) =>
                {
                    var v1 = x.Value[columnIndex];
                    var v2 = y.Value[columnIndex];

                    if (v1 == null && v2 == null)
                        return 0;

                    if (v1 == null)
                        return 1;
                    if (v2 == null)
                        return -1;

                    var we = v1.ToString().CompareTo(v2.ToString());
                    return -we;
                });

            Rows.ClearList();

            for (int i = 0; i < itemsList.Count; i++)
                Rows.Add(itemsList[i].Key);

            AlignRows();

            if (lastSortedColumn != null)
                lastSortedColumn.control.Padding = new Padding(8, 0, 8, 0);
            lastSortedColumn = column;
            lastSortedColumn.control.Padding = new Padding(24, 0, 8, 0);
        }
Esempio n. 6
0
        internal void UpdateColumn(TableColumn column)
        {
            CreateTopLeftButton();

            if (column.control == null)
            {
                var cButton = new TableColumnButton(this, ColumnsStyle);
                cButton.column = column;
                cButton.EnableHorizontalResizing = true;
                cButton.Name = column.Name;
                cButton.table = this;
                cButton.Text = column.HeaderText;

                column.control = cButton;
                Controls.Add(cButton);
            }

            column.control.Visible = !columnHeadersHidden;
        }
Esempio n. 7
0
        public virtual void Sort(TableColumn column, ListSortDirection direction)
        {
            if (column == null)
            {
                return;
            }

            int columnIndex = Columns.FindIndex(column);
            Dictionary <TableRow, object[]> items = new Dictionary <TableRow, object[]>();

            for (int i = 0; i < Rows.Count; i++)
            {
                var r = Rows[i];
                items.Add(r, r.Items);
            }

            var itemsList = items.ToList();

            if (direction == ListSortDirection.Ascending)
            {
                itemsList.Sort((x, y) =>
                {
                    var v1 = x.Value[columnIndex];
                    var v2 = y.Value[columnIndex];

                    if (v1 == null && v2 == null)
                    {
                        return(0);
                    }

                    if (v1 == null)
                    {
                        return(-1);
                    }
                    if (v2 == null)
                    {
                        return(1);
                    }

                    var we = v1.ToString().CompareTo(v2.ToString());
                    return(we);
                });
            }
            else
            {
                itemsList.Sort((x, y) =>
                {
                    var v1 = x.Value[columnIndex];
                    var v2 = y.Value[columnIndex];

                    if (v1 == null && v2 == null)
                    {
                        return(0);
                    }

                    if (v1 == null)
                    {
                        return(1);
                    }
                    if (v2 == null)
                    {
                        return(-1);
                    }

                    var we = v1.ToString().CompareTo(v2.ToString());
                    return(-we);
                });
            }

            Rows.ClearList();

            for (int i = 0; i < itemsList.Count; i++)
            {
                Rows.Add(itemsList[i].Key);
            }

            AlignRows();

            if (lastSortedColumn != null)
            {
                lastSortedColumn.control.Padding = new Padding(8, 0, 8, 0);
            }
            lastSortedColumn = column;
            lastSortedColumn.control.Padding = new Padding(24, 0, 8, 0);
        }
Esempio n. 8
0
 public int FindIndex(TableColumn column)
 {
     return(items.FindIndex(x => x == column));
 }
Esempio n. 9
0
 public void Add(TableColumn column)
 {
     items.Add(column);
 }