示例#1
0
文件: ComboBox.cs 项目: xxy1991/cozy
        /// <summary>
        /// Called when the drop down button is pressed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="buttonStateEventArgs">The <see cref="ButtonStateEventArgs"/> instance containing the event data.</param>
        private void OnToggleDropDown(object sender, ButtonStateEventArgs buttonStateEventArgs)
        {
            var state = buttonStateEventArgs.ButtonState;
            if (state == ButtonState.On)
            {
                // Display the drop down list
                this.DropDownList.Config.PositionY = this.Config.Height;

                // DropDownList.State.DrawPosition = new DVector2(State.DrawPosition.X, State.DrawPosition.Y + State.Height);
                this.Manager.AddForegroundControl(this.DropDownList);

                this.dropDownListShown = true;

                this.DropDownList.Config.Visible = true;

                if (this.OnShowHide != null)
                {
                    this.OnShowHide(this, new BooleanEventArgs(true));
                }
            }
            else
            {
                this.DropDownList.Config.Visible = false;

                this.Manager.ForegroundSceneNodes.Children.Remove(this.DropDownList);

                if (this.dropDownListShown)
                {
                    this.dropDownListShown = false;
                }

                if (this.OnShowHide != null)
                {
                    this.OnShowHide(this, new BooleanEventArgs(false));
                }
            }
        }
示例#2
0
 /// <summary>
 /// Called when the toggle-button is pressed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="buttonStateEventArgs">The <see cref="ButtonStateEventArgs"/> instance containing the event data.</param>
 private void OnTogglePress(object sender, ButtonStateEventArgs buttonStateEventArgs)
 {
     var state = buttonStateEventArgs.ButtonState;
     this.InfoLabel.ConfigText = "Toggle:" + state + ":" + GetTime();
 }
示例#3
0
        /// <summary>Reacts to when there is a toggle event</summary>
        /// <param name="sender">The sender.</param>
        /// <param name="stateEventArgs">The <see cref="ButtonStateEventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.ArgumentNullException">StateEventArgs can not be null.</exception>
        public void Toggle(object sender, ButtonStateEventArgs stateEventArgs)
        {
#if DEBUG
            if (stateEventArgs == null)
            {
                throw new ArgumentNullException("stateEventArgs");
            }
#endif
            var state = stateEventArgs.ButtonState;
            if (state == ButtonState.On)
            {
                this.Config.HoverColorsEnabled = false;
                this.Theme.BorderWidth = 2;
                this.ButtonState = ButtonState.On;
                this.CurrentTextureName = this.textureHovered;
            }
            else
            {
                this.Config.HoverColorsEnabled = true;
                this.Theme.BorderWidth = 1;
                this.ButtonState = ButtonState.Off;
                this.CurrentTextureName = this.TextureNameDefault;
            }
        }