Press() public method

Presses the ToggleButton down and calls the onClick event.
public Press ( ) : void
return void
Beispiel #1
0
        /// <summary>
		/// Creates a new FileWindow.
		/// </summary>
		/// <remarks>
		/// By default, the save name TextBox is invisible making this a text box for loading.  Call
		/// SetToSave to make the box appear.
		/// </remarks>
		/// <param name="InpMan"></param>
		/// <param name="SprMan"></param>
		internal FileWindow(Cursor cursor) : 
            base(cursor)
        {
            #region Create the "settings" directory
            if (System.IO.Directory.Exists(ApplicationFolderForThisProgram + "settings") == false)
                System.IO.Directory.CreateDirectory(ApplicationFolderForThisProgram + "settings");
            #endregion

            #region Set "this" properties

            this.HasMoveBar = true;
			this.Closing += new GuiMessage(OnFileWindowClose);
			mScaleX = 20;
			mScaleY = 20;

            this.Resizable = true;
            this.Resizing += new GuiMessage(SetGUIPosition);
            this.OkClick += new GuiMessage(AddFileToRecent);
            this.Closing += OnClose;
            MinimumScaleX = 13;
            MinimumScaleY = 16;

            #endregion

            mFileTypes = new List<string>();

            #region Create the Texture display button

            mTextureDisplayButton = new Button(mCursor);
            AddWindow(mTextureDisplayButton);
            mTextureDisplayButton.ScaleY = 4;
            mTextureDisplayButton.ScaleX = 4;
            mTextureDisplayButton.Click += ShowChildTextureDisplayWindow;

            #endregion

            #region Create the Bookmark button

            mBookmarkToggleButton = new ToggleButton(mCursor);
            AddWindow(mBookmarkToggleButton);
            mBookmarkToggleButton.ScaleX = mBookmarkToggleButton.ScaleY = 1.3f;
            mBookmarkToggleButton.SetPositionTL(.5f + mBookmarkToggleButton.ScaleX, .5f + mBookmarkToggleButton.ScaleY);
            mBookmarkToggleButton.Click += BookmarkButtonClick;
            mBookmarkToggleButton.SetOverlayTextures(
                9, 3);

            #endregion

            #region CurrentDirectoryDisplay Combo Box
            mCurrentDirectoryDisplay = new ComboBox(mCursor);
            base.AddWindow(mCurrentDirectoryDisplay);
            mCurrentDirectoryDisplay.ItemClick += ChangeSelectedDirectory;
            mCurrentDirectoryDisplay.TextChange += ChangeSelectedDirectory;
            mCurrentDirectoryDisplay.AllowTypingInTextBox = true;
            ResetCurrentDirectoryComboBox();

            #endregion

            #region Create the ListBox

            mListBox = new ListBox(mCursor);
            AddWindow(mListBox);

            mListBox.SortingStyle = ListBoxBase.Sorting.None;
			mListBox.Highlight += new GuiMessage(OnListBoxClick);
			mListBox.StrongSelect += new GuiMessage(OnListBoxStrongSelect);
			mListBox.EscapeRelease += new GuiMessage(CloseFileWindow);
            mListBox.CurrentToolTipOption = ListBoxBase.ToolTipOption.CursorOver;

            #endregion

            #region Create the Ok Button

            mOkButton = new Button(mCursor);
            AddWindow(mOkButton);
            mOkButton.Text = "Ok";
			mOkButton.Click += new GuiMessage(OkButtonClick);

            #endregion

            #region Create the Cancel button

            mCancelButton = new Button(mCursor);
            AddWindow(mCancelButton);
            mCancelButton.Text = "Cancel";
            mCancelButton.Click += OnCancelClick;

            #endregion

            #region Create the Load Directory Button

            loadDirectory = new Button(mCursor);
            AddWindow(loadDirectory);

            loadDirectory.Text = "Load Dir";
			loadDirectory.Click += new GuiMessage(LoadDirClick);
            loadDirectory.Visible = false;

            #endregion

            //#region Create the "Add" button

            //addButton = new Button(mCursor);
            //AddWindow(addButton);
            //addButton.ScaleX = 4;
            //addButton.ScaleY = 1.5f;
            //addButton.Text = "Add";
            //addButton.Click += new GuiMessage(AddButtonClick);
            //addButton.Visible = false;

            //#endregion

            #region Create the Up Directory button

            mUpDirectory = new Button(mCursor);
            AddWindow(mUpDirectory);

#if FRB_MDX
            // This is always null in the new engines - not sure how this button gets its texture.
			mUpDirectory.SetOverlayTextures(GuiManager.mUpDirectory, null);
#endif
			mUpDirectory.ScaleY = 1;
			mUpDirectory.ScaleX = 1;
            mUpDirectory.Text = "Up One Directory";
            
            mUpDirectory.overlayTL = new FlatRedBall.Math.Geometry.Point(0.38281250, 0.6445312500);
            mUpDirectory.overlayTR = new FlatRedBall.Math.Geometry.Point(0.42968750, 0.6445312500);
            mUpDirectory.overlayBL = new FlatRedBall.Math.Geometry.Point(0.38281250, 0.687500000);
            mUpDirectory.overlayBR = new FlatRedBall.Math.Geometry.Point(0.42968750, 0.687500000);

            mUpDirectory.Click += this.UpOneDirectoryClick;

            #endregion

            mCreateNewDirectory = new Button(mCursor);
            base.AddWindow(mCreateNewDirectory);
            mCreateNewDirectory.SetOverlayTextures(5, 3);
            mCreateNewDirectory.ScaleX = 1;
            mCreateNewDirectory.ScaleY = 1;
            mCreateNewDirectory.Text = "Create New\nDirectory";
            mCreateNewDirectory.Click += AddDirectoryClick;

            saveName = new TextBox(mCursor);
            AddWindow(saveName);
			saveName.ScaleY = 1.4f;
            saveName.Visible = false;
            saveName.fixedLength = false;
			saveName.EnterPressed += new GuiMessage(OnSaveNameEnter);
			saveName.EscapeRelease += new GuiMessage(CloseFileWindow);

            Name = "Loading File";

//			displayTextureLoadedBefore = false;


            mShowFileHierarchy = new ToggleButton(mCursor);
            AddWindow(mShowFileHierarchy);
			mShowFileHierarchy.SetPositionTL(7.0f, 4.5f);
			mShowFileHierarchy.ScaleX = 5.5f;
			mShowFileHierarchy.Text = "File Hierarchy";
            mShowFileHierarchy.SetOneAlwaysDown(true);
			mShowFileHierarchy.Click += new GuiMessage(OnFileHierarchyClick);

            mAllRelativeToggleButton = new ToggleButton(mCursor);
            AddWindow(mAllRelativeToggleButton);
			mAllRelativeToggleButton.SetPositionTL(7.0f, 6.5f);
			mAllRelativeToggleButton.ScaleX = 5.5f;
			mAllRelativeToggleButton.Text = "All Relative";
			mAllRelativeToggleButton.Click += new GuiMessage(OnAllRelativeClick);
			mAllRelativeToggleButton.SetOneAlwaysDown(true);
			mAllRelativeToggleButton.AddToRadioGroup(mShowFileHierarchy);

            mShowRecent = new ToggleButton(mCursor);
            AddWindow(mShowRecent);

            mShowRecent.SetPositionTL(19, 4.5f);
            mShowRecent.ScaleX = 5.5f;
            mShowRecent.Text = "Recent Files";
            mShowRecent.Click += new GuiMessage(OnShowRecent);
            mShowRecent.SetOneAlwaysDown(true);
            mShowRecent.AddToRadioGroup(mShowFileHierarchy);

            // go here!!!
			mShowFileHierarchy.Press();

            mFileTypeBox = new ComboBox(mCursor);
            AddWindow(mFileTypeBox);
            mFileTypeBox.ItemClick += OnFileTypeChange;

#if XBOX360 || WINDOWS_PHONE || MONODROID
            SetDirectory();

#else
            SetDirectory(FileManager.MyDocuments);
#endif


            SetGUIPosition(null);

            
            LoadBookmarks();
        }
 private static void ShowSpriteRigOptionsFileWindow(Window callingWindow)
 {
     FileWindow tempFileWindow = GuiManager.AddFileWindow();
     tempFileWindow.Filter = "XML SpriteRig (*.srgx)|*.srgx";
     tempFileWindow.CurrentFileType = "srgx";
     tempFileWindow.SetToSave();
     tempFileWindow.OkClick += new GuiMessage(saveSpriteRig);
     ToggleButton relativeToggle = new ToggleButton(GuiManager.Cursor);
     tempFileWindow.AddWindow(relativeToggle);
     relativeToggle.Name = "scnRelativeAssets";
     relativeToggle.SetText("Not .scn-relative assets", ".scn-relative assets");
     relativeToggle.ScaleX = 9f;
     relativeToggle.SetPositionTL(22.5f, 6.5f);
     if (mAssetsRelativeToSpriteRig)
     {
         relativeToggle.Press();
     }
     else
     {
         relativeToggle.Unpress();
     }
 }
        public TextureCoordinatesSelectionWindow() : 
            base(GuiManager.Cursor)
        {
            // Victor says:  This class USED to
            // add itself to the GuiManager.  This
            // is no longer recommended as it makes
            // windows not as reusable.  Therefore, I
            // removed the automatic adding to the GuiManager.
            // This might break your code if you're using this,
            // so if your TextureCoordinatesSelectionWindow isn't
            // showing up, you might want to make sure you're adding
            // it to the GuiManager.

            #region Create "this" and add it to the GuiManager
            HasMoveBar = true;
            ScaleY = 12.5f;
            ScaleX = 11.4f;

            Resizable = true;
            MinimumScaleX = ScaleX;
            MinimumScaleY = ScaleY;

            this.Resizing += OnWindowResize;
            #endregion

            #region Create the texture display area

            mTextureDisplayArea = new Window(mCursor);
            AddWindow(mTextureDisplayArea);

            mTextureDisplayArea.DrawBorders = false;
            mTextureDisplayArea.Push += OnWindowPush;
            mTextureDisplayArea.Dragging += OnWindowDrag;
            mTextureDisplayArea.Click += OnWindowClick;
            mTextureDisplayArea.RollingOver += this.OnRollOver;
            mTextureDisplayArea.DoubleClick += OnWindowDoubleClick;

            mTextureDisplayArea.MouseWheelScroll += MouseWheelZoom;

            mTextureDisplayArea.SecondaryClick += RightClickMenu;

            #endregion

            mSelectedArea = new Window(mCursor);
            mTextureDisplayArea.AddWindow(mSelectedArea);
            mSelectedArea.ScaleX = 3;
            mSelectedArea.ScaleY = 3;
            mSelectedArea.BaseTexture = 
                FlatRedBallServices.Load<Texture2D>("genGfx/targetBox.bmp", GuiManager.InternalGuiContentManagerName);
            mSelectedArea.Enabled = false; // so it doesn't block input from the this (the parent Window)
            mSelectedArea.DrawBorders = false;
            mSelectedArea.Alpha = 127;

            mAddToListButton = new Button(mCursor);
            AddWindow(mAddToListButton);
            mAddToListButton.Text = "Add To List";
            mAddToListButton.Visible = false;

            #region Pixel Perfect ToggleButton and ComboBoxes

            mPixelPerfect = new ToggleButton(mCursor);
            AddWindow(mPixelPerfect);

            mPixelPerfect.ScaleX = 5;
            mPixelPerfect.SetText("Free", "Snapping");
            mPixelPerfect.Press();
            mPixelPerfect.Click += PixelPerfectClick;

            mMinimumXSelection = new ComboBox(mCursor);
            AddWindow(mMinimumXSelection);
            mMinimumXSelection.ScaleX = 3;
            mMinimumXSelection.AddItem("1");
            mMinimumXSelection.AddItem("4");
            mMinimumXSelection.AddItem("8");
            mMinimumXSelection.AddItem("16");
            mMinimumXSelection.AddItem("32");
            mMinimumXSelection.Text = "1";

            mMinimumYSelection = new ComboBox(mCursor);
            AddWindow(mMinimumYSelection);
            mMinimumYSelection.ScaleX = 3;
            mMinimumYSelection.AddItem("1");
            mMinimumYSelection.AddItem("4");
            mMinimumYSelection.AddItem("8");
            mMinimumYSelection.AddItem("16");
            mMinimumYSelection.AddItem("32");
            mMinimumYSelection.Text = "1";

            #endregion

            #region Create the ScrollBars
            mVerticalScrollBar = new ScrollBar(mCursor);
            AddWindow(mVerticalScrollBar);
            mVerticalScrollBar.UpButtonClick += AdjustToVerticalScrollBar;
            mVerticalScrollBar.DownButtonClick += AdjustToVerticalScrollBar;
            mVerticalScrollBar.PositionBarMove += AdjustToVerticalScrollBar;

            mHorizontalScrollBar = new ScrollBar(mCursor);
            AddWindow(mHorizontalScrollBar);
            mHorizontalScrollBar.UpButtonClick += AdjustToVerticalScrollBar;
            mHorizontalScrollBar.DownButtonClick += AdjustToVerticalScrollBar;
            mHorizontalScrollBar.PositionBarMove += AdjustToVerticalScrollBar;
            mHorizontalScrollBar.Alignment = ScrollBar.ScrollBarAlignment.Horizontal;
            mHorizontalScrollBar.ScaleY = 1;
            #endregion

            OnWindowResize(this);
        }
Beispiel #4
0
            /*
             * This is the basic constructor for the GeometryWindow. It uses ToggleButtons instead of Buttons for a functionality aspect.
             * The desire was to have a single click on the button create 1 geometric shape, and then have the button
             * reset itself to the off position. The Button class may be used, but as of August 2nd, 2008, I don't believe has the
             * support for the desired functionality - Aaron
            */
            public GeometryWindow()
                : base()
            {
                base.mName = "Geometry";
                NumberOfRows = 5;

                this.X = SpriteManager.Camera.XEdge * 2 - this.ScaleX;
                this.Y = 19.0f;

                this.ExtraSpacingBetweenSameRowButtons = .2f;

                #region Add AxisAlignedRectangle
                this.mAxisAlignedRectangleButton = AddButton(Keys.P);
                this.mAxisAlignedRectangleButton.Text = "AxisAlignedRectangle (P)";
                mAxisAlignedRectangleButton.SetOverlayTextures(FlatRedBallServices.Load<Texture2D>(@"Assets\UI\AxisAlignedRectangle.png"), null);
                mAxisAlignedRectangleButton.Click += AddAxisAlignedRectangle;
                #endregion

                #region Add Circle
                this.mCircleButton = AddButton(Keys.O);
                this.mCircleButton.Text = "Circle (O)";
                mCircleButton.SetOverlayTextures(FlatRedBallServices.Load<Texture2D>(@"Assets\UI\Circle.png"), null);
                mCircleButton.Click += AddCircle;
                #endregion

                #region Add Polygon (Rectangle)

                this.mRectanglePolygonButton = AddButton(Keys.I);
                this.mRectanglePolygonButton.Text = "Rectangle Polygon (I)";
                mRectanglePolygonButton.SetOverlayTextures(FlatRedBallServices.Load<Texture2D>(@"Assets\UI\RectanglePolygon.png"), null);
                mRectanglePolygonButton.Click += AddRectanglePolygon;

                #endregion

                #region Add AxisAlignedCube

                this.mAxisAlignedCubeButton = AddButton(Keys.U);
                this.mAxisAlignedCubeButton.Text = "AxisAlignedCube (U)";
                mAxisAlignedCubeButton.SetOverlayTextures(FlatRedBallServices.Load<Texture2D>(@"Assets\UI\AxisAlignedCube.png"), null);
                mAxisAlignedCubeButton.Click += AddAxisAlignedCube;

                #endregion

                #region Add Sphere

                this.mSphereButton = AddButton(Keys.Y);
                this.mSphereButton.Text = "Sphere (Y)";
                mSphereButton.SetOverlayTextures(FlatRedBallServices.Load<Texture2D>(@"Assets\UI\Sphere.png"), null);
                mSphereButton.Click += AddSphere;

                #endregion

                #region Edit AxisAlignedRectangle

                mEditAxisAlignedRectangleButton = AddToggleButton();
                mEditAxisAlignedRectangleButton.SetText("Currently NOT editing Axis Aligned Rectangles", "Currently editing Axis Aligned Rectangles");
                Texture2D texture = FlatRedBallServices.Load<Texture2D>(@"Assets\UI\EditAxisAlignedRectangle.png");
                mEditAxisAlignedRectangleButton.SetOverlayTextures(
                    FlatRedBallServices.Load<Texture2D>(@"Assets\UI\NoEditAxisAlignedRectangle.png"),
                    texture
                    );
                mEditAxisAlignedRectangleButton.Press();
                #endregion

                #region Edit Circle
                mEditCircleButton = AddToggleButton();
                mEditCircleButton.SetText("Currently NOT editing Circles", "Currently editing Circles");
                texture = FlatRedBallServices.Load<Texture2D>(@"Assets\UI\EditCircle.png");
                mEditCircleButton.SetOverlayTextures(FlatRedBallServices.Load<Texture2D>(@"Assets\UI\NoEditCircle.png"), texture);
                mEditCircleButton.Press();
                #endregion

                #region Edit Polygon
                mEditPolygonButton = AddToggleButton();
                mEditPolygonButton.SetText("Currently NOT editing Polygons", "Currently editing Polygons");
                texture = FlatRedBallServices.Load<Texture2D>(@"Assets\UI\EditPolygon.png");
                mEditPolygonButton.SetOverlayTextures(FlatRedBallServices.Load<Texture2D>(@"Assets\UI\NoEditPolygon.png"), texture);
                mEditPolygonButton.Press();
                #endregion

                #region Edit AxisAlignedCube
                mEditAxisAlignedCubeButton = AddToggleButton();
                mEditAxisAlignedCubeButton.SetText("Currently NOT editing Axis Aligned Cubes", "Currently editing Axis Aligned Cubes");
                texture = FlatRedBallServices.Load<Texture2D>(@"Assets\UI\EditAxisAlignedCube.png");
                mEditAxisAlignedCubeButton.SetOverlayTextures(FlatRedBallServices.Load<Texture2D>(@"Assets\UI\NoEditAxisAlignedCube.png"), texture);
                mEditAxisAlignedCubeButton.Press();
                #endregion

                #region Edit Sphere
                mEditSphereButton = AddToggleButton();
                mEditSphereButton.SetText("Currently NOT editing Spheres", "Currently editing Spheres");
                texture = FlatRedBallServices.Load<Texture2D>(@"Assets\UI\EditSphere.png");
                mEditSphereButton.SetOverlayTextures(FlatRedBallServices.Load<Texture2D>(@"Assets\UI\NoEditSphere.png"), texture);
                mEditSphereButton.Press();
                #endregion

            }