SetScaleToContents() public method

public SetScaleToContents ( float minimumScale ) : void
minimumScale float
return void
Esempio n. 1
0
        /// <summary>
        /// Event clicked when the dropDownButton is clicked.  If the ListBox is not visible
        /// it will appear.
        /// </summary>
        /// <param name="callingWindow"></param>
        void OnDropDownButtonClick(Window callingWindow)
        {
            if (mListBox.Visible)
            {
                return;
            }

            // The ListBox is not visible, so "expand" it.

            GuiManager.AddPerishableWindow(mListBox);
            mListBox.Visible = true;

            if (mListBox.SpriteFrame != null)
            {
                SpriteManager.AddSpriteFrame(mListBox.SpriteFrame);
            }

//                listBox.SetPositionTL(ScaleX, ScaleY + 4);
            mListBox.SetScaleToContents(ScaleX);
            mListBox.SetPositionTL(ScaleX, ScaleY + mListBox.ScaleY + 1);

            mListBox.HighlightOnRollOver = true;

            mListBox.UpdateDependencies();


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

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

            if (mListBox.WorldUnitY - mListBox.ScaleY < -GuiManager.Camera.YEdge)
            {
                mListBox.Y -= -GuiManager.Camera.YEdge - (mListBox.WorldUnitY - mListBox.ScaleY);
            }

            if (mListBox.WorldUnitX + mListBox.ScaleX > GuiManager.Camera.XEdge)
            {
                mListBox.X -= (mListBox.WorldUnitX + mListBox.ScaleX) - GuiManager.Camera.XEdge;
            }

            if (mListBox.WorldUnitX - mListBox.ScaleX < -GuiManager.Camera.XEdge)
            {
                mListBox.X += -GuiManager.Camera.XEdge - (mListBox.WorldUnitX - mListBox.ScaleX);
            }

            mListBox.HighlightItem(mSelectionDisplay.Text);
        }
Esempio n. 2
0
        public CollapseListBox(Cursor cursor) :
            base(cursor)
        {
            mListBox = new ListBox(mCursor);
            mListBox.AddItem("Expand All");
            mListBox.AddItem("Collapse All");
            mListBox.SetScaleToContents(0);
            mListBox.HighlightOnRollOver = true;
            mListBox.ScrollBarVisible    = false;
            mListBox.Click += PopupListBoxClick;


            SecondaryClick += OnRightClick;
        }
Esempio n. 3
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;
            }


        }
Esempio n. 4
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;
            }
        }
Esempio n. 5
0
        public CollapseListBox(Cursor cursor) : 
            base(cursor)
		{
            mListBox = new ListBox(mCursor);
            mListBox.AddItem("Expand All");
            mListBox.AddItem("Collapse All");
            mListBox.SetScaleToContents(0);
            mListBox.HighlightOnRollOver = true;
            mListBox.ScrollBarVisible = false;
            mListBox.Click += PopupListBoxClick;


            SecondaryClick += OnRightClick;
        }