예제 #1
0
파일: Menu.cs 프로젝트: AIBrain/ochregui
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Construct a Menu instance from the given template.
        /// </summary>
        /// <param name="template"></param>
        public Menu(MenuTemplate template)
            : base(template)
        {
            HasFrame = template.HasFrameBorder;
            if (Size.Width < 3 || Size.Height < 3)
            {
                HasFrame = false;
            }

            HilightWhenMouseOver = template.HilightWhenMouseOver;
            CanHaveKeyboardFocus = template.CanHaveKeyboardFocus;

            LabelAlignment = template.LabelAlignment;
            Items = template.Items;
            mouseOverIndex = -1;

            CalcMetrics(template);
        }
예제 #2
0
파일: Menu.cs 프로젝트: AIBrain/ochregui
        private void CalcMetrics(MenuTemplate 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;
            }
        }