예제 #1
0
        /// <summary>Create resize process from column list, active (hovered) column and side (left or right) of resize.</summary>
        public static ColumnResizeProcess FromActiveColumn(IList<CustomListBoxColumn> columns, int activeIndex, ColumnResizeSide side, Point mouseDownLocation)
        {
            Assert.IsNotNull(columns);

            var activeColumn = columns[activeIndex];

            int autoSizeId = int.MaxValue;
            for(int i = 0; i < columns.Count; ++i)
            {
                if(columns[i].IsVisible && columns[i].SizeMode == ColumnSizeMode.Fill)
                {
                    autoSizeId = i;
                    break;
                }
            }
            switch(side)
            {
                case ColumnResizeSide.Left:
                    var prevColumn = columns.FindPrevious(activeIndex, column => column.IsVisible);
                    if(prevColumn != null && activeIndex <= autoSizeId)
                    {
                        if(prevColumn.SizeMode == ColumnSizeMode.Sizeable)
                        {
                            return new ColumnResizeProcess(prevColumn, 1, mouseDownLocation);
                        }
                    }
                    if(activeColumn.SizeMode != ColumnSizeMode.Sizeable)
                    {
                        return null;
                    }
                    return new ColumnResizeProcess(activeColumn, -1, mouseDownLocation);
                case ColumnResizeSide.Right:
                    if(activeColumn.SizeMode != ColumnSizeMode.Sizeable || activeIndex > autoSizeId)
                    {
                        var nextColumn = columns.FindNext(activeIndex, column => column.IsVisible);
                        if(nextColumn != null)
                        {
                            return new ColumnResizeProcess(nextColumn, -1, mouseDownLocation);
                        }
                        else
                        {
                            return null;
                        }
                    }
                    else
                    {
                        return new ColumnResizeProcess(activeColumn, 1, mouseDownLocation);
                    }

                default:
                    throw new ArgumentException("Invalid column resize side.", "side");
            }
        }
예제 #2
0
        /// <summary>Create resize process from column list, active (hovered) column and side (left or right) of resize.</summary>
        public static ColumnResizeProcess FromActiveColumn(IList <CustomListBoxColumn> columns, int activeIndex, ColumnResizeSide side, Point mouseDownLocation)
        {
            Assert.IsNotNull(columns);

            var activeColumn = columns[activeIndex];

            int autoSizeId = int.MaxValue;

            for (int i = 0; i < columns.Count; ++i)
            {
                if (columns[i].IsVisible && columns[i].SizeMode == ColumnSizeMode.Fill)
                {
                    autoSizeId = i;
                    break;
                }
            }
            switch (side)
            {
            case ColumnResizeSide.Left:
                var prevColumn = columns.FindPrevious(activeIndex, column => column.IsVisible);
                if (prevColumn != null && activeIndex <= autoSizeId)
                {
                    if (prevColumn.SizeMode == ColumnSizeMode.Sizeable)
                    {
                        return(new ColumnResizeProcess(prevColumn, 1, mouseDownLocation));
                    }
                }
                if (activeColumn.SizeMode != ColumnSizeMode.Sizeable)
                {
                    return(null);
                }
                return(new ColumnResizeProcess(activeColumn, -1, mouseDownLocation));

            case ColumnResizeSide.Right:
                if (activeColumn.SizeMode != ColumnSizeMode.Sizeable || activeIndex > autoSizeId)
                {
                    var nextColumn = columns.FindNext(activeIndex, column => column.IsVisible);
                    if (nextColumn != null)
                    {
                        return(new ColumnResizeProcess(nextColumn, -1, mouseDownLocation));
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(new ColumnResizeProcess(activeColumn, 1, mouseDownLocation));
                }

            default:
                throw new ArgumentException("Invalid column resize side.", "side");
            }
        }
예제 #3
0
 private void HandleHeaderResizerMouseDown(int itemIndex, ColumnResizeSide resizeSide, MouseEventArgs e)
 {
     _columnResizeProcess = ColumnResizeProcess.FromActiveColumn(Columns, itemIndex, resizeSide, e.Location);
 }