示例#1
0
        /// <summary>
        /// Creates a custom spinner with a given SpinnerModel.
        /// </summary>
        /// <param name="model"></param>
        public G2DSpinner(SpinnerModel model)
            : base()
        {
            this.model                    = model;
            initialPressInterval          = 20;
            pressInterval                 = 5;
            pressCount                    = 0;
            initialPress                  = true;
            textField                     = new G2DTextField("" + model.Value);
            textField.HorizontalAlignment = GoblinEnums.HorizontalAlignment.Right;
            textField.Editable            = false;

            upArrowBound   = new Rectangle();
            downArrowBound = new Rectangle();

            upArrowPoints   = new List <Point>();
            downArrowPoints = new List <Point>();

            upPressed = downPressed = false;
            heldDown  = false;

            buttonColor    = Color.Turquoise;
            highlightColor = new Color((byte)0x99, (byte)255, (byte)255, (byte)255);
            arrowColor     = Color.Navy;

            name = "G2DSpinner";
        }
        private void CreateObject()
        {
            G2DPanel frame = new G2DPanel();
            frame.Bounds = new Rectangle(0, 0, 800, 600);
            frame.Border = GoblinEnums.BorderFactory.LineBorder;
            frame.Transparency = 1.0f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)
            frame.BackgroundColor = Color.Black;

            SpriteFont textBoxFont = Content.Load<SpriteFont>("TextBoxFont");
            SpriteFont textFont = Content.Load<SpriteFont>("TextFont");

            G2DLabel label = new G2DLabel();
            label.TextFont = textFont;
            label.TextColor = Color.Yellow;
            label.Bounds = new Rectangle(10, 100, 780, 200);
            label.Text = "Type Target ID and Press Enter";

            textF = new G2DTextField();
            textF.TextFont = textBoxFont;
            textF.TextColor = Color.Black;
            textF.Bounds = new Rectangle(10, 200, 780, 200);
            textF.Editable = false;
            textF.Text = "";

            frame.AddChild(label);
            frame.AddChild(textF);
            scene.UIRenderer.Add2DComponent(frame);
        }