// ///////////////////////////////////////////////////////////////////////////////// /// <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); }
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; } }