Exemplo n.º 1
0
 public CheckBox()
 {
     base.Width           = 56f;
     base.Height          = 56f;
     this.sprt            = new UISprite(1);
     this.sprt.ShaderType = ShaderType.Texture;
     base.RootUIElement.AddChildLast(this.sprt);
     this.ButtonState         = CheckBox.CheckBoxState.Normal;
     this.Enabled             = true;
     this.Checked             = false;
     this.CustomCheckBoxImage = null;
     this.Style           = CheckBoxStyle.CheckBox;
     this.needUpdateFlag  = true;
     this.PriorityHit     = true;
     this.images          = new ImageAsset[Enum.GetValues(typeof(CheckBoxStyle)).Length, Enum.GetValues(typeof(CheckBox.CheckBoxState)).Length, 2];
     this.images[0, 0, 0] = new ImageAsset(SystemImageAsset.CheckBoxUncheckedNormal);
     this.images[0, 0, 1] = new ImageAsset(SystemImageAsset.CheckBoxCheckedNormal);
     this.images[0, 1, 0] = new ImageAsset(SystemImageAsset.CheckBoxUncheckedPressed);
     this.images[0, 1, 1] = new ImageAsset(SystemImageAsset.CheckBoxCheckedPressed);
     this.images[0, 2, 0] = new ImageAsset(SystemImageAsset.CheckBoxUncheckedDisabled);
     this.images[0, 2, 1] = new ImageAsset(SystemImageAsset.CheckBoxCheckedDisabled);
     this.images[1, 0, 0] = new ImageAsset(SystemImageAsset.RadioButtonUncheckedNormal);
     this.images[1, 0, 1] = new ImageAsset(SystemImageAsset.RadioButtonCheckedNormal);
     this.images[1, 1, 0] = new ImageAsset(SystemImageAsset.RadioButtonUncheckedPressed);
     this.images[1, 1, 1] = new ImageAsset(SystemImageAsset.RadioButtonCheckedPressed);
     this.images[1, 2, 0] = new ImageAsset(SystemImageAsset.RadioButtonUncheckedDisabled);
     this.images[1, 2, 1] = new ImageAsset(SystemImageAsset.RadioButtonCheckedDisabled);
 }
Exemplo n.º 2
0
        protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
        {
            base.OnTouchEvent(touchEvents);
            if (this.ButtonState == CheckBox.CheckBoxState.Disabled)
            {
                return;
            }
            switch (touchEvents.PrimaryTouchEvent.Type)
            {
            case TouchEventType.Up:
                if (this.buttonState == CheckBox.CheckBoxState.Pressed)
                {
                    if (this.style == CheckBoxStyle.RadioButton && this.Checked)
                    {
                        this.ButtonState    = CheckBox.CheckBoxState.Normal;
                        this.needUpdateFlag = true;
                        return;
                    }
                    this.ButtonState    = CheckBox.CheckBoxState.Normal;
                    this.Checked        = !this.Checked;
                    this.needUpdateFlag = true;
                    if (this.CheckedChanged != null)
                    {
                        this.CheckedChanged.Invoke(this, new TouchEventArgs(touchEvents));
                        return;
                    }
                }
                break;

            case TouchEventType.Down:
                this.ButtonState = CheckBox.CheckBoxState.Pressed;
                return;

            case TouchEventType.Move:
                break;

            case TouchEventType.Enter:
                this.ButtonState = CheckBox.CheckBoxState.Pressed;
                return;

            case TouchEventType.Leave:
                this.ButtonState = CheckBox.CheckBoxState.Normal;
                break;

            default:
                return;
            }
        }
Exemplo n.º 3
0
 protected internal override void OnResetState()
 {
     base.OnResetState();
     this.ButtonState = (this.Enabled ? CheckBox.CheckBoxState.Normal : CheckBox.CheckBoxState.Disabled);
 }