Exemple #1
0
        void OnClick(Window callingWindow)
        {
            if (MenuItems.Count != 0)
            {
                #region Create the new ListBox and store it in mChildPerishableListBox

                mChildPerishableListBox = GuiManager.AddPerishableListBox();

                mChildPerishableListBox.SortingStyle = ListBoxBase.Sorting.None;


                mChildPerishableListBox.ScaleX = 5;
                mChildPerishableListBox.ScaleY = 5;

                mChildPerishableListBox.ScrollBarVisible = false;
                #endregion

                #region Add the MenuItems to the new ListBox

                foreach (MenuItem menuItem in MenuItems)
                {
                    CollapseItem item = mChildPerishableListBox.AddItem(menuItem.Text, menuItem);
                    menuItem.mParentListBox = this.mChildPerishableListBox;
                    item.Enabled            = menuItem.Enabled;
                }

                #endregion

                #region Scale the new ListBox for the contents

                mChildPerishableListBox.SetScaleToContents(3);

                float maximumScale = GuiManager.YEdge - (MenuStrip.MenuStripHeight / 2.0f);

                if (mChildPerishableListBox.ScaleY > maximumScale)
                {
                    mChildPerishableListBox.ScrollBarVisible = true;
                    mChildPerishableListBox.ScaleY           = maximumScale;
                }

                #endregion

                if (this.mParentListBox != null)
                {
                    GuiManager.PersistPerishableThroughNextClick(mChildPerishableListBox);
                }

                mChildPerishableListBox.Click += ListBoxClick;

                if (this.mParentListBox != null)
                {
                    mChildPerishableListBox.X = mParentListBox.ScaleX +
                                                mParentListBox.WorldUnitX + GuiManager.UnmodifiedXEdge + mChildPerishableListBox.ScaleX;

                    int indexofHighlighted = mParentListBox.GetFirstHighlightedIndex();

                    float extraDistanceDown = mParentListBox.DistanceBetweenLines * indexofHighlighted;

                    mChildPerishableListBox.Y =
                        -(mParentListBox.WorldUnitY - GuiManager.UnmodifiedYEdge) + mChildPerishableListBox.ScaleY - mParentListBox.ScaleY +
                        mTextScale + extraDistanceDown - mChildPerishableListBox.FirstItemDistanceFromTop / 2.0f;
                }
                else
                {
                    mChildPerishableListBox.X = X + mChildPerishableListBox.ScaleX;
                    mChildPerishableListBox.Y = Y + mChildPerishableListBox.ScaleY + mTextScale;
                }
                mChildPerishableListBox.HighlightOnRollOver = true;
            }
        }