Пример #1
0
        private Control[] DrawGrid()
        {
            Control[] ctls = new Control[CellCount];

            Point      lastButtonPoint = new Point(0, 0);
            List <int> lstLargeButton  = new List <int>();

            int loopCount = CellCount % ColumnCount == 0 ? CellCount / ColumnCount : CellCount / ColumnCount + 1;

            int          drawButtonIndex = 0;
            int          drawCellIndex   = 0;
            PanelControl cell            = null;

            for (int i = 0; i < loopCount; i++)
            {
                if (lastButtonPoint.Y + ButtonHeight > this.Height)
                {
                    this.Height += ButtonHeight;
                }

                for (int index = 0; index < ColumnCount; index++)
                {
                    Point location = lastButtonPoint;
                    if (index == 0)
                    {
                        location = new Point(0, lastButtonPoint.Y);
                    }
                    else
                    {
                        location = new Point(lastButtonPoint.X + CellMargin + ButtonWidth, lastButtonPoint.Y);
                    }
                    lastButtonPoint = location;

                    cell = GetNextCell(location, drawButtonIndex);

                    if (!CheckLargeButtonList(lstLargeButton, drawCellIndex))
                    {
                        if (cell != null)
                        {
                            ctls[drawButtonIndex] = cell;
                            cell = null;
                        }
                        ButtonContainerType btnType = GetButtonType(drawButtonIndex);
                        if (btnType == ButtonContainerType.Large)
                        {
                            lstLargeButton.Add(drawCellIndex);
                            lstLargeButton.Add(drawCellIndex + ColumnCount);
                        }
                        drawButtonIndex++;
                    }

                    drawCellIndex++;
                }
                lastButtonPoint = new Point(lastButtonPoint.X, lastButtonPoint.Y + ButtonHeight + CellMargin);
            }
            return(ctls);
        }
Пример #2
0
        public PanelControl NewButtonContainer(ButtonContainerType containerType)
        {
            PanelControl panel = new PanelControl();

            if (containerType == ButtonContainerType.Small)
            {
                panel.Size = _smallButtonSize;
            }
            else
            {
                panel.Size = _largeButtonSize;
            }

            panel.AllowDrop = _lockState;

            return(panel);
        }
Пример #3
0
        private ButtonContainerType GetButtonType(int idx)
        {
            ButtonContainerType type = ButtonContainerType.Small;

            if (idx < _lstButton.Count)
            {
                object cell = _lstButton[idx];
                if (cell != null)
                {
                    PanelControl panel = cell as PanelControl;
                    if (panel.Controls.Count > 0)
                    {
                        object ctrl = panel.Controls[0];
                        if (ctrl.GetType() == typeof(LargeButtonControl))
                        {
                            type = ButtonContainerType.Large;
                        }
                    }
                }
            }
            return(type);
        }