示例#1
0
            public ContextMenuShowMenu(List <ContextMenuItemEntry> list)
            {
                WantUpdateSize = false;
                ControlInfo.ModalClickOutsideAreaClosesThisControl = true;
                ControlInfo.IsModal = true;
                ControlInfo.Layer   = UILayer.Over;

                CanMove          = true;
                AcceptMouseInput = true;



                AlphaBlendControl background = new AlphaBlendControl(0.3f);

                Add(background);

                int y = 0;

                for (int i = 0; i < list.Count; i++)
                {
                    var item = new ContextMenuItem(list[i]);
                    if (i > 0)
                    {
                        item.Y = y;
                    }

                    if (background.Width < item.Width)
                    {
                        background.Width = item.Width;
                    }

                    background.Height += item.Height;

                    Add(item);

                    y += item.Height;
                }


                foreach (var mitem in FindControls <ContextMenuItem>())
                {
                    if (mitem.Width < background.Width)
                    {
                        mitem.Width = background.Width;
                    }
                }


                Width  = background.Width;
                Height = background.Height;
            }
        public ContextMenuShowMenu(List <ContextMenuItemEntry> list) : base(0, 0)
        {
            WantUpdateSize = true;
            ModalClickOutsideAreaClosesThisControl = true;
            IsModal    = true;
            LayerOrder = UILayer.Over;

            CanMove          = false;
            AcceptMouseInput = true;


            _background = new AlphaBlendControl(0.3f);
            Add(_background);

            int y = 0;

            for (int i = 0; i < list.Count; i++)
            {
                ContextMenuItem item = new ContextMenuItem(this, list[i]);

                if (i > 0)
                {
                    item.Y = y;
                }

                if (_background.Width < item.Width)
                {
                    _background.Width = item.Width;
                }

                _background.Height += item.Height;

                Add(item);

                y += item.Height;
            }


            foreach (ContextMenuItem mitem in FindControls <ContextMenuItem>())
            {
                if (mitem.Width < _background.Width)
                {
                    mitem.Width = _background.Width;
                }
            }
        }