public void SetHolderState(int index, SlotState state)
        {
            Debug.Assert(index > -1 && index < _holderBtnArr.Count);

            (_holderBtnArr[index] as HolderButton).State = state;

            if (state == SlotState.extracted)
            {
                (_holderBtnArr[index] as HolderButton).SlotText = "";
                _holderBtnArr[index].Text = "";
            }

            _indexBtn[index].State = state;

            if (state == SlotState.extracted)
            {
                for (int i = index * CupNum; i < (index + 1) * CupNum; i++)
                {
                    CupButton cup = (_cupBtnArr[i] as CupButton);
                    cup.IsSlotOn = false;
                    cup.Enabled  = false;
                    cup.State    = TestState.Idle;
                }
            }
            else if (state == SlotState.inserted)
            {
                for (int i = index * CupNum; i < (index + 1) * CupNum; i++)
                {
                    CupButton cup = (_cupBtnArr[i] as CupButton);
                    cup.IsSlotOn = true;
                    cup.Enabled  = true;
                }
            }
            this.Invalidate();
        }
        public void SetCupInfo(int index, CupInfo info)
        {
            Debug.Assert(index > -1 && index < _cupBtnArr.Count);

            CupButton cup = _cupBtnArr[index] as CupButton;

            cup.CupInfo.SampleID = info.SampleID;
            cup.CupInfo.Barcode  = info.Barcode;
        }
        /// <summary>
        /// 初始化控件
        /// </summary>
        /// <param name="holderNum">盒个数</param>
        /// <param name="cupNum">每个盒的杯个数</param>
        /// <param name="hoverObj">捕获对象类型</param>
        virtual public void Init(int holderNum, int cupNum, HoverObject hoverObj)
        {
            if (holderNum < 1 || cupNum < 0)
            {
                throw new Exception("Invalid groupNum or cupNum");
            }

            if (hoverObj == HoverObject.CupHover)
            {
                _cupBtnArr    = _gpBtnArr;
                _holderBtnArr = new List <GraphicButton>();
            }
            else if (hoverObj == HoverObject.SlotHover)
            {
                _cupBtnArr    = new List <GraphicButton>();
                _holderBtnArr = _gpBtnArr;
            }
            else
            {
                _cupBtnArr    = new List <GraphicButton>();
                _holderBtnArr = new List <GraphicButton>();
            }

            _slotNum = holderNum;
            _cupNum  = cupNum;

            //int headerWidth = (this.Width - 2 * 5);				//指示区域总宽度
            int headerHeight = (this.Height - 2 * 5);                           //指示区域总宽度
            int headerWidth  = (int)(IndexHeightFactor * this.Width / 8);       //指示区域高度
            //int slotWidth = headerWidth / _slotNum;				//每一槽的宽度
            int slotWidth = this.Width - 20 * 2 - headerWidth;                  //每一槽的宽度
            //int headerHeight = (int)(IndexHeightFactor * this.Height / 8);					//指示区域高度


            int topOffset = 5;

            //int slotTop = 2 * topOffset + headerHeight;
            int slotTop    = topOffset;
            int slotHeight = (headerHeight - topOffset * holderNum) / holderNum;

            Rectangle indexRect = new Rectangle(10, topOffset, headerWidth, headerHeight);

            indexRect.Width = headerWidth;
            _titlePath      = CommonGraphic.CreateRoundRectPath(indexRect, 10, 10);

            _indexBtn = new HolderButton[_slotNum];

            float indexBtnSize = Math.Min(slotHeight, headerWidth) * IndexBtnSizeFactor;
            float indexOffsetX = (headerWidth - indexBtnSize) / 2.0f;
            float indexOffsetY = (slotHeight - indexBtnSize) / 2.0f;

            float flateVal = 0;

            if (slotHeight <= indexBtnSize)
            {
                flateVal = indexBtnSize / 10;
            }

            float roundSize = slotHeight * 24 / 42f;

            for (int i = 0; i < _slotNum; i++)
            {
                int slotLeft      = indexRect.Left * 2 + headerWidth;
                int slotTopOffset = slotTop * (i + 1) + i * slotHeight;

                RectangleF rect = new RectangleF(indexRect.Left * 2, slotTopOffset, indexBtnSize, indexBtnSize);
                rect.Offset(indexOffsetX, indexOffsetY);
                rect.Inflate(-flateVal, -flateVal);

                HolderButton indexBtn = new HolderButton();
                indexBtn.BtnRect = rect;
                indexBtn.BtnPath = new GraphicsPath();
                indexBtn.BtnPath.AddEllipse(rect);
                indexBtn.BtnRegion = new Region(indexBtn.BtnRect);
                indexBtn.Text      = "T" + (i + 1).ToString();
                indexBtn.HeaderBtn = true;
                _indexBtn[i]       = indexBtn;

                Rectangle slotRect = new Rectangle(slotLeft + 10, slotTopOffset, slotWidth, slotHeight);

                slotRect.Inflate(_slotOffsetX, 0);
                HolderButton holderBtn = new HolderButton();
                holderBtn.BtnRect   = slotRect;
                holderBtn.BtnPath   = CommonGraphic.CreateRoundRectPath(slotRect, roundSize, roundSize);
                holderBtn.BtnRegion = new Region(holderBtn.BtnPath);
                _holderBtnArr.Add(holderBtn);

                if (_cupNum > 0)
                {
                    int cupHeight   = slotHeight;
                    int offset      = (slotHeight - cupHeight) / 2;
                    int widthOffset = 0;
                    for (int j = 0; j < _cupNum; j++)
                    {
                        int        cupTop  = widthOffset + slotTop * (i + 1) + i * slotHeight;
                        int        cupLeft = slotLeft + 10 + (slotWidth - cupHeight * _cupNum) / (_cupNum + 1) + ((slotWidth - 2 * ((slotWidth - cupHeight * _cupNum) / (_cupNum + 1)) - cupHeight) / (_cupNum - 1)) * j;
                        RectangleF cupRect = new RectangleF(cupLeft, cupTop, slotHeight, cupHeight);
                        if (offset > 0)
                        {
                            cupRect.Inflate(-widthOffset - offset, -widthOffset);
                        }
                        else
                        {
                            cupRect.Inflate(-widthOffset, -widthOffset + offset);
                        }

                        CupButton cupBtn = new CupButton();
                        cupBtn.BtnRect = cupRect;
                        cupBtn.BtnPath = new GraphicsPath();
                        cupBtn.BtnPath.AddEllipse(cupRect);
                        cupBtn.BtnRegion = new Region(cupBtn.BtnPath);

                        _cupBtnArr.Add(cupBtn);
                    }
                }
            }
        }