public Popup(PopupStyle Style, IEnumerable<MenuItem> Items) { this._Style = Style; double y = 0.0; double width = 0.0; this._Items = new List<_Item>(); foreach (MenuItem mi in Items) { _Item i = new _Item(Style, mi, y); Point size = i.Size; y += size.Y; width = Math.Max(width, size.X); this._Items.Add(i); } this.Size = new Point(width, y) + new Point(this._Style.Margin, this._Style.Margin) * 2.0; }
/// <summary> /// Calls up a popup in the container at the offset (which becomes the topleft point). /// </summary> public static Popup Call(LayerContainer Container, Point Offset, IEnumerable<MenuItem> Items, PopupStyle Style) { Popup p = new Popup(Style, Items); Call(Container, Offset, p); return p; }
public PopupContainer(Control Client) : base(Client) { this._Style = new PopupStyle(); this._ShowOnRightClick = true; }
/// <summary> /// Renders the item to the specified location. /// </summary> public void Render(GUIRenderContext Context, PopupStyle Style, Rectangle Area) { CommandMenuItem cmi = Source as CommandMenuItem; if (cmi != null) { Context.DrawText(Style.TextColor, this.Sample, Area); } CompoundMenuItem cpmi = Source as CompoundMenuItem; if (cpmi != null) { Context.DrawText(Style.TextColor, this.Sample, Area); Point arrowsize = Style.CompoundArrowSize; Context.DrawSurface( Style.Skin.GetSurface(Style.CompoundArrow, arrowsize), new Point(Area.Location.X + Area.Size.X - arrowsize.X, Area.Location.Y + Area.Size.Y * 0.5 - arrowsize.Y * 0.5)); } SeperatorMenuItem smi = Source as SeperatorMenuItem; if (smi != null) { Context.DrawSurface( Style.Skin.GetSurface(Style.Seperator, new Point(Area.Size.X, Style.SeperatorHeight)), Area.Location + new Point(0.0, Style.SeperatorPadding)); } }
public _Item(PopupStyle Style, MenuItem Source, double Y) { this.Source = Source; this.Y = Y; TextMenuItem tmi = Source as TextMenuItem; if (tmi != null) { this.Sample = Style.Font.CreateSample(tmi.Text, null, TextAlign.Left, TextAlign.Center, TextWrap.Ellipsis); } CommandMenuItem cmi = Source as CommandMenuItem; if (cmi != null) { this.Size = new Point(this.Sample.Size.X, Style.StandardItemHeight); } CompoundMenuItem cpmi = Source as CompoundMenuItem; if (cpmi != null) { this.Size = new Point(this.Sample.Size.X + Style.CompoundArrowSize.X, Style.StandardItemHeight); } SeperatorMenuItem smi = Source as SeperatorMenuItem; if (smi != null) { this.Size = new Point(0.0, Style.SeperatorHeight + Style.SeperatorPadding * 2.0); } }