コード例 #1
0
ファイル: RadioBox.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////
        private void CalcMetrics(RadioGroupTemplate template)
        {
            itemsRect = this.LocalRect;
            if (HasFrame)
            {
                itemsRect = Rect.Inflate(itemsRect, -1, -1);
            }

            int delta = itemsRect.Size.Height - Items.Count;

            numberItemsDisplayed = Items.Count;

            if (delta < 0)
            {
                numberItemsDisplayed += delta;
            }

            if (RadioOnLeft)
            {
                radioRect = new Rect(itemsRect.UpperLeft, new Size(1, 1));
                labelRect = new Rect(radioRect.UpperRight.Shift(2, 0),
                                     itemsRect.UpperRight);
            }
            else
            {
                radioRect = new Rect(itemsRect.UpperRight, new Size(1, 1));
                labelRect = new Rect(itemsRect.UpperLeft,
                                     radioRect.LowerLeft.Shift(-2, 0));
            }
        }
コード例 #2
0
ファイル: RadioBox.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////
        #endregion
        #region Constructors
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Construct a RadioGroup from the specified templated.
        /// </summary>
        /// <param name="template"></param>
        public RadioGroup(RadioGroupTemplate template)
            : base(template)
        {
            HasFrame = template.HasFrameBorder;

            if (Size.Width < 3 || Size.Height < 3)
            {
                HasFrame = false;
            }

            HilightWhenMouseOver = false;

            HilightRadioMouseOver = template.HilightRadioMouseOver;
            CanHaveKeyboardFocus  = template.CanHaveKeyboardFocus;
            LabelAlignment        = template.LabelAlignment;
            Items          = template.Items;
            mouseOverIndex = -1;
            RadioOnLeft    = template.RadioOnLeft;

            CurrentSelected = template.InitialSelectedIndex;

            if (CurrentSelected < 0 || CurrentSelected >= Items.Count)
            {
                CurrentSelected = 0;
            }

            CalcMetrics(template);
        }