Ejemplo n.º 1
0
        private void CalculatePattern()
        {
            // Horizontal 
            PointF loc = HorizontalSlider.Position;
            if (loc.X > Width) loc.X = Width;
            int hCount = (int)Math.Ceiling(loc.X / _blockSize.Width);
            loc.X = hCount * _blockSize.Width;
            HorizontalSlider.Position = loc;
            List<SquareButton> newButtonsH = new List<SquareButton>();
            int start = 1;
            if (_horizontalButtons != null)
            {
                int minLen = Math.Min(_horizontalButtons.Count, hCount-1);
                for (int i = 0; i < minLen; i++)
                {
                    newButtonsH.Add(_horizontalButtons[i]);
                }
                start = minLen+1;
            }
            for (int j = start; j < hCount; j++)
            {
                SquareButton sq = new SquareButton();
                sq.Bounds = new RectangleF(j * _blockSize.Width, 0, _blockSize.Width, _blockSize.Height);
                sq.ColorDownDark = _buttonDownDarkColor;
                sq.ColorDownLit = _buttonDownLitColor;
                sq.ColorUpDark = _buttonUpDarkColor;
                sq.ColorUpLit = _butttonUpLitColor;
                sq.IsDown = true;
                newButtonsH.Add(sq);
            }
            _horizontalButtons = newButtonsH;
           

            // Vertical 
            loc = VerticalSlider.Position;
            if (loc.Y > Height) loc.Y = Height;
            int vCount = (int)Math.Ceiling(loc.Y / _blockSize.Height);
            loc.Y = (vCount) * _blockSize.Height;
            VerticalSlider.Position = loc;
            List<SquareButton> buttons = new List<SquareButton>();
            start = 1;
            if (_verticalButtons != null)
            {
                int minLen = Math.Min(_verticalButtons.Count, vCount-1);
                for (int i = 0; i < minLen; i++)
                {
                    buttons.Add(_verticalButtons[i]);
                }
                start = minLen+1;
            }
            for (int j = start; j < vCount; j++)
            {
                SquareButton sq = new SquareButton();
                sq.Bounds = new RectangleF(0, j * _blockSize.Height, _blockSize.Width, _blockSize.Height);
                sq.ColorDownDark = _buttonDownDarkColor;
                sq.ColorDownLit = _buttonDownLitColor;
                sq.ColorUpDark = _buttonUpDarkColor;
                sq.ColorUpLit = _butttonUpLitColor;
                sq.IsDown = true;
                buttons.Add(sq);
            }
            _verticalButtons = buttons;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Sets the vertical pattern for this control
 /// </summary>
 /// <param name="buttonPattern"></param>
 protected virtual void SetVerticalPattern(bool[] buttonPattern)
 {
     _verticalSlider.Position = new PointF(0, (buttonPattern.Length+1) * _blockSize.Width);
     _verticalButtons = new List<SquareButton>();
     for (int i = 0; i < buttonPattern.Length; i++)
     {
         SquareButton sq = new SquareButton();
         sq.Bounds = new RectangleF(0, (i+1) * _blockSize.Width, _blockSize.Width, _blockSize.Height);
         sq.ColorDownDark = _buttonDownDarkColor;
         sq.ColorDownLit = _buttonDownLitColor;
         sq.ColorUpDark = _buttonUpDarkColor;
         sq.ColorUpLit = _butttonUpLitColor;
         sq.IsDown = buttonPattern[i];
         _verticalButtons.Add(sq);
     }
 }