Exemplo n.º 1
0
 /// <summary>
 /// Called when the standard-button is pressed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="gameTimeEventArgs">The <see cref="GameTimeEventArgs"/> instance containing the event data.</param>
 private void OnButtonPress(object sender, GameTimeEventArgs gameTimeEventArgs)
 {
     if (this.InfoLabel != null)
     {
         this.InfoLabel.ConfigText = "Click:" + GetTime();
     }
 }
 protected virtual void OnTick(GameTimeEventArgs e)
 {
     if (Tick != null)
     {
         Tick(this, e);
     }
 }
    public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
    {
        bool ticked = false;

        // Figure out how many Ticks we need.
        if (IsEnabled && this.Interval > TimeSpan.Zero)
        {
            var args = new GameTimeEventArgs(gameTime);
            ElapsedTime = ElapsedTime.Add(gameTime.ElapsedGameTime);
            while (IsEnabled && ElapsedTime >= Interval)
            {
                if (!ticked)
                {
                    ticked = true;
                    OnTickFirst(args);
                }
                ElapsedTime = ElapsedTime.Subtract(Interval);
                OnTick(args);
            }
            // If we know we ticked at least once during this Update, raise event that we're on the last Tick.
            if (ticked)
            {
                OnTickLast(args);
            }
        }
        base.Update(gameTime);
    }
Exemplo n.º 4
0
 /// <summary>
 /// Called when the remove-button is pressed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="gameTimeEventArgs">The <see cref="GameTimeEventArgs"/> instance containing the event data.</param>
 private void RemoveClicked(object sender, GameTimeEventArgs gameTimeEventArgs)
 {
     if (this.ListBox.ListBoxItems.Count > 0)
     {
         this.ListBox.RemoveListItem(this.ListBox.ListBoxItems[this.ListBox.ListBoxItems.Count - 1]);
     }
 }
Exemplo n.º 5
0
        protected override void OnGameUpdate(object sender, GameTimeEventArgs e)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            base.OnGameUpdate(sender, e);
        }
Exemplo n.º 6
0
        /// <summary>
        /// When the check event is been toggled
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="gameTimeEventArgs">The <see cref="GameTimeEventArgs"/> instance containing the event data.</param>
        private void HandleToggle(object sender, GameTimeEventArgs gameTimeEventArgs)
        {
            if (this.isChecked)
            {
                this.isChecked          = false;
                this.TickBox.ConfigText = string.Empty;
            }
            else
            {
                this.isChecked          = true;
                this.TickBox.ConfigText = "X";
            }

            Debug.WriteLine(this.Name + " checked = " + this.isChecked);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Called when a menu button was clicked to open a menu.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="GameTimeEventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.InvalidOperationException">Button tag was null</exception>
        private void OnButtonClicked(object sender, GameTimeEventArgs e)
        {
            // get the button that started this event
            var button = sender as Button;

            if (button == null)
            {
                return;
            }

            // get the tag out of the button , cause it contains the type of window that i want to show
            var typeName = button.Tag as string;

            if (string.IsNullOrEmpty(typeName))
            {
                throw new InvalidOperationException("Button tag was null");
            }

            var windowType = Type.GetType(typeName);

            // validate that we really have the type of window
            if (windowType == null)
            {
                Debug.WriteLine("Could not extract the type of window i should open.");
                return;
            }

            // create the window , by using the given type
            var shortName = windowType.Name;

            object[] par = { shortName };
            var      obj = Activator.CreateInstance(windowType, par);

            // validate that we really have the window
            var window = obj as Window;

            if (window == null)
            {
                Debug.WriteLine("Could not create the given type of window");
                return;
            }

            // show the window
            this.parent.AddControl(window);
            window.Config.PositionX = 100;
            window.Config.PositionY = 100;
            window.CentreToParent();
        }
Exemplo n.º 8
0
        /// <summary>
        /// React on when the mouse is down above the min button.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="gameTimeEventArgs">The <see cref="GameTimeEventArgs"/> instance containing the event data.</param>
        private void MinButtonLeftMousePressed(object sender, GameTimeEventArgs gameTimeEventArgs)
        {
            this.rapidScrollDelay = true;

            this.Scroll(-this.ConfigStep);
        }
Exemplo n.º 9
0
 /// <summary>
 /// React on when the mouse is up above the min button.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="gameTimeEventArgs">The <see cref="GameTimeEventArgs"/> instance containing the event data.</param>
 private void MinButtonLeftMouseReleased(object sender, GameTimeEventArgs gameTimeEventArgs)
 {
     this.rapidScrollDelay = true;
 }
Exemplo n.º 10
0
 protected override void OnGameDraw(object sender, GameTimeEventArgs e)
 {
     m_game.GraphicsDevice.Clear(Color.CornflowerBlue);
     base.OnGameDraw(sender, e);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Called when we clicked the close button.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="GameTimeEventArgs"/> instance containing the event data.</param>
 private void OnCloseClicked(object sender, GameTimeEventArgs e)
 {
     this.Parent.DestroyMe(this);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Called when the add-button is pressed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="gameTimeEventArgs">The <see cref="GameTimeEventArgs"/> instance containing the event data.</param>
 private void AddClicked(object sender, GameTimeEventArgs gameTimeEventArgs)
 {
     this.ListBox.AddListItem(new ListBoxItem("Test 2", "MyListItem6"));
 }