• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ButtonState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ButtonState的典型用法代码示例。如果您正苦于以下问题:C# ButtonState类的具体用法?C# ButtonState怎么用?C# ButtonState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ButtonState类属于命名空间,在下文中一共展示了ButtonState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Update

    void Update()
    {
        // pressing 1, 2 activate buttons in debug mode
        if (Activated && Config.Debug && Input.GetKeyDown(KeyCode.Alpha1)) {
            buttonState = ButtonState.LeftPressed;
            leftMat.color = leftPressed;
            rightMat.color = rightUnpressed;
            leftAnimator.SetTrigger(Animator.StringToHash("Push"));
            Debug.Log("Pressed left button");
        } else if (Activated && Config.Debug && Input.GetKeyDown(KeyCode.Alpha2)) {
            buttonState = ButtonState.RightPressed;
            leftMat.color = leftUnpressed;
            rightMat.color = rightPressed;
            rightAnimator.SetTrigger(Animator.StringToHash("Push"));
            Debug.Log("Pressed right button");
        }

        if (Activated && buttonState == ButtonState.LeftPressed) {
            leftMat.color = leftPressed;
            rightMat.color = rightUnpressed;
        } else if (Activated && buttonState == ButtonState.RightPressed) {
            leftMat.color = leftUnpressed;
            rightMat.color = rightPressed;
        }
    }
开发者ID:CatsFromMars,项目名称:TrolleyProblem,代码行数:25,代码来源:ControlPanel.cs


示例2: Update

        /// <summary>
        ///  This class performs an important function.
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            mouseState = Mouse.GetState();
            buttonState = mouseState.LeftButton;

            if (Contains(mouseState.X, mouseState.Y))
            {
                foreach (AnswerWidget tmp in AnswerListWidget)
                {
                    if (tmp.Contains(mouseState.X, mouseState.Y))
                    {
                        this.Scale = new Vector2(2, 1);
                        this.TintColor = Color.Red;
                        if ((buttonState == ButtonState.Pressed))
                        {
                            //Engine.Instance.ResolutionManager.ScreenSize = new Vector2(Width, Height);
                        }
                        else
                        {
                            this.Scale = new Vector2(1, 1);
                            this.TintColor = Color.Yellow;
                        }
                    }
                }
            }
        }
开发者ID:Lebby,项目名称:Develia,代码行数:30,代码来源:DefaultAnswerBlock.cs


示例3: HalfPadState

        public HalfPadState(ControlSide side, PlayerIndex controllerIndex)
        {
            GamePadState gamePadState = GamePad.GetState(controllerIndex);
            if (side == ControlSide.left)
            {
                stick1 = new Stick(gamePadState.ThumbSticks.Left);
                stick2 = new Stick(gamePadState.DPad.Up,
                                   gamePadState.DPad.Down,
                                   gamePadState.DPad.Left,
                                   gamePadState.DPad.Right);

                Btn1 = gamePadState.Buttons.LeftShoulder;
                Btn2 = (gamePadState.Triggers.Left < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test
                Btn2AsTrigger = gamePadState.Triggers.Left;
                Btn3 = gamePadState.Buttons.LeftStick;

                BtnStart = gamePadState.Buttons.Back;
            }
            else //if (side == ControlSide.right)
            {
                stick1 = new Stick(gamePadState.ThumbSticks.Right);
                stick2 = new Stick(gamePadState.Buttons.Y,
                                   gamePadState.Buttons.A,
                                   gamePadState.Buttons.X,
                                   gamePadState.Buttons.B);

                Btn1 = gamePadState.Buttons.RightShoulder;
                Btn2 = (gamePadState.Triggers.Right < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test
                Btn2AsTrigger = gamePadState.Triggers.Right;
                Btn3 = gamePadState.Buttons.RightStick;

                BtnStart = gamePadState.Buttons.Start;
            }
        }
开发者ID:GameMakersUnion,项目名称:BoulderDash-OrbIt,代码行数:34,代码来源:Controller.cs


示例4: FlickGesture

 public FlickGesture()
 {
     AngleThreshold = 0.35f;
     DistanceThreshold = 0.05f;
     _previousState = ButtonState.Up;
     _pointData = new List<PointF>();
 }
开发者ID:PhilipBrockmeyer,项目名称:UxbTransform,代码行数:7,代码来源:FlickGesture.cs


示例5: GamePadDPad

		public GamePadDPad (
         ButtonState upValue,
         ButtonState downValue,
         ButtonState leftValue,
         ButtonState rightValue )
		{
		}
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:7,代码来源:GamePadDPad.cs


示例6: InputState

 /*public InputState(Stick LeftStick_WASD, Stick RightStick_Mouse,
                   ButtonState A_1, ButtonState X_2, ButtonState B_3, ButtonState Y_4,
                   ButtonState Dpad_UpArrow, ButtonState Dpad_DownArrow, ButtonState Dpad_RightArrow, ButtonState Dpad_LeftArrow,
                   ButtonState Select_TAB, ButtonState Start_ESC,
                   ButtonState LeftBumper_Q, ButtonState RightBumper_E,
                   ButtonState LeftTrigger_Mouse2, ButtonState RightTrigger_Mouse1,
                   float LeftTriggerAnalog = 0, float RightTriggerAnalog = 0)
 {
     this.LeftStick_WASD = LeftStick_WASD;
     this.RightStick_Mouse = RightStick_Mouse;
     this.A_1 = A_1;
     this.X_2 = X_2;
     this.B_3 = B_3;
     this.Y_4 = Y_4;
     this.Dpad_UpArrow = Dpad_UpArrow;
     this.Dpad_DownArrow = Dpad_DownArrow;
     this.Dpad_RightArrow = Dpad_RightArrow;
     this.Dpad_LeftArrow = Dpad_LeftArrow;
     this.Select_TAB = Select_TAB;
     this.Start_ESC = Start_ESC;
     this.LeftBumper_Q = LeftBumper_Q;
     this.RightBumper_E = RightBumper_E;
     this.LeftTrigger_Mouse2 = LeftTrigger_Mouse2;
     this.RightTrigger_Mouse1 = RightTrigger_Mouse1;
     this.LeftTriggerAnalog = LeftTriggerAnalog;
     this.RightTriggerAnalog = RightTriggerAnalog;
 }*/
 //keyboard/mouse
 public InputState(Stick LeftStick_WASD, Stick RightStick_Mouse,
                   ButtonState LeftTrigger_Mouse2, ButtonState RightTrigger_Mouse1,
                   bool A_1, bool X_2, bool B_3, bool Y_4,
                   bool Dpad_UpArrow, bool Dpad_DownArrow, bool Dpad_RightArrow, bool Dpad_LeftArrow,
                   bool Select_TAB, bool Start_ESC,
                   bool LeftBumper_Q, bool RightBumper_E,
                   float LeftTriggerAnalog = 0, float RightTriggerAnalog = 0)
 {
     this.LeftStick_WASD = LeftStick_WASD;
     this.RightStick_Mouse = RightStick_Mouse;
     this.LeftTrigger_Mouse2 = LeftTrigger_Mouse2;
     this.RightTrigger_Mouse1 = RightTrigger_Mouse1;
     this.A_1 = A_1 ? ButtonState.Pressed : ButtonState.Released;
     this.X_2 = X_2 ? ButtonState.Pressed : ButtonState.Released;
     this.B_3 = B_3 ? ButtonState.Pressed : ButtonState.Released;
     this.Y_4 = Y_4 ? ButtonState.Pressed : ButtonState.Released;
     this.Dpad_UpArrow = Dpad_UpArrow ? ButtonState.Pressed : ButtonState.Released;
     this.Dpad_DownArrow = Dpad_DownArrow ? ButtonState.Pressed : ButtonState.Released;
     this.Dpad_RightArrow = Dpad_RightArrow ? ButtonState.Pressed : ButtonState.Released;
     this.Dpad_LeftArrow = Dpad_LeftArrow ? ButtonState.Pressed : ButtonState.Released;
     this.Select_TAB = Select_TAB ? ButtonState.Pressed : ButtonState.Released;
     this.Start_ESC = Start_ESC ? ButtonState.Pressed : ButtonState.Released;
     this.LeftBumper_Q = LeftBumper_Q ? ButtonState.Pressed : ButtonState.Released;
     this.RightBumper_E = RightBumper_E ? ButtonState.Pressed : ButtonState.Released;
     this.LeftTriggerAnalog = LeftTriggerAnalog;
     this.RightTriggerAnalog = RightTriggerAnalog;
 }
开发者ID:GameMakersUnion,项目名称:BoulderDash-OrbIt,代码行数:55,代码来源:Input.cs


示例7: StateChangedMethod

 protected void StateChangedMethod(ButtonState prevState, ButtonState currState)
 {
     var backButtonTex = Resources.Load<Texture2D>(String.Format(@"Buttons/{0}", gameObject.GetComponent<SpriteRenderer>().sprite.texture.name.Replace(prevState.ToString(), currState.ToString())));
     if (!backButtonTex) return;
     gameObject.GetComponent<SpriteRenderer>().sprite = Sprite.Create(backButtonTex,
         new Rect(0, 0, backButtonTex.width, backButtonTex.height), new Vector2(0, 0));
 }
开发者ID:Lindet,项目名称:DiabloClickerWiP,代码行数:7,代码来源:ButtonBaseMouseEvents.cs


示例8: OnMouseUpAsButton

 protected void OnMouseUpAsButton()
 {
     if (_State == ButtonState.Disabled) return;
     _State = ButtonState.Over;
     if(MethodOnClick != null)
         MethodOnClick.DynamicInvoke();
 }
开发者ID:Lindet,项目名称:DiabloClickerWiP,代码行数:7,代码来源:ButtonBaseMouseEvents.cs


示例9: ConvertFromButtonState

 internal static RadioButtonState ConvertFromButtonState(ButtonState state, bool isHot)
 {
     if ((state & ButtonState.Checked) == ButtonState.Checked)
     {
         if ((state & ButtonState.Pushed) == ButtonState.Pushed)
         {
             return RadioButtonState.CheckedPressed;
         }
         if ((state & ButtonState.Inactive) == ButtonState.Inactive)
         {
             return RadioButtonState.CheckedDisabled;
         }
         if (isHot)
         {
             return RadioButtonState.CheckedHot;
         }
         return RadioButtonState.CheckedNormal;
     }
     if ((state & ButtonState.Pushed) == ButtonState.Pushed)
     {
         return RadioButtonState.UncheckedPressed;
     }
     if ((state & ButtonState.Inactive) == ButtonState.Inactive)
     {
         return RadioButtonState.UncheckedDisabled;
     }
     if (isHot)
     {
         return RadioButtonState.UncheckedHot;
     }
     return RadioButtonState.UncheckedNormal;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:RadioButtonRenderer.cs


示例10: Update

        public void Update()
        {
            if (ft)
            {
                ft = false;
                return;
            }
            state = Mouse.GetState();
            if (mousePos.X != state.X || mousePos.Y != state.Y)
                moved = true;
            else
                moved = false;
            mousePos.X = state.X;
            mousePos.Y = state.Y;

            d_mouse = new Vector2(state.X - lastState.X, state.Y - lastState.Y);

            scrollWheelDelta = scrollWheelValue - state.ScrollWheelValue;
            scrollWheelValue = state.ScrollWheelValue;

            lmbState = state.LeftButton;
            rmbState = state.RightButton;
            isJustPressed = isJustReleased = false;
            if (lmblastState == ButtonState.Pressed && lmbState == ButtonState.Released)
                isJustReleased = true;
            else if (lmblastState == ButtonState.Released && lmbState == ButtonState.Pressed)
                isJustPressed = true;

            lastState = state;
        }
开发者ID:KatekovAnton,项目名称:Game,代码行数:30,代码来源:MouseManager.cs


示例11: UpdateInput

 public void UpdateInput(object sender, MouseInputEventArgs e)
 {
     if (MouseMode != e.Mode)
         e.Mode = MouseMode;
     X -= e.X;
     Y -= e.Y;
     WheelDelta += e.WheelDelta;
     if (e.ButtonFlags == MouseButtonFlags.LeftDown)
         LeftButton = ButtonState.Pressed;
     if (e.ButtonFlags == MouseButtonFlags.LeftUp)
         LeftButton = ButtonState.Released;
     if (e.ButtonFlags == MouseButtonFlags.RightDown)
         RightButton = ButtonState.Pressed;
     if (e.ButtonFlags == MouseButtonFlags.RightUp)
         RightButton = ButtonState.Released;
     if (e.ButtonFlags == MouseButtonFlags.MiddleDown)
         MiddleButton = ButtonState.Pressed;
     if (e.ButtonFlags == MouseButtonFlags.MiddleUp)
         MiddleButton = ButtonState.Released;
     if (e.ButtonFlags == MouseButtonFlags.Button4Down)
         Button4 = ButtonState.Pressed;
     if (e.ButtonFlags == MouseButtonFlags.Button4Up)
         Button4 = ButtonState.Released;
     if (e.ButtonFlags == MouseButtonFlags.Button5Down)
         Button5 = ButtonState.Pressed;
     if (e.ButtonFlags == MouseButtonFlags.Button5Up)
         Button5 = ButtonState.Released;
 }
开发者ID:RomanHodulak,项目名称:DeferredLightingD3D11,代码行数:28,代码来源:MouseInput.cs


示例12: Update

 public void Update(ButtonState up, ButtonState down, ButtonState left, ButtonState right)
 {
     this.Up = up == ButtonState.Pressed;
     this.Down = down == ButtonState.Pressed;
     this.Left = left == ButtonState.Pressed;
     this.Right = right == ButtonState.Pressed;
 }
开发者ID:TryCatch22,项目名称:JoystickTest,代码行数:7,代码来源:DPadPane.cs


示例13: IsClicked

 public bool IsClicked()
 {
     MouseState tmp = Mouse.GetState();
         bool b = ButtonState.Released == tmp.LeftButton && leftButtonState == ButtonState.Pressed;
         leftButtonState = tmp.LeftButton;
         return b && tmp.X >= X && tmp.X <= X + Texture.Width && tmp.Y >= Y && tmp.Y <= Y + Texture.Height;
 }
开发者ID:EmilGedda,项目名称:Storm-Pounder---First-Contact,代码行数:7,代码来源:MenuItem.cs


示例14: Update

        /// <summary>
        /// Update method that will trigger click events as needed
        /// </summary>
        /// <param name="state"></param>
        public void Update(ButtonState state)
        {
            if (state == ButtonState.Pressed && previousState != ButtonState.Pressed)
            {
                if (Pressed != null)
                {
                    Pressed(this);
                }
            }
            else if (state == ButtonState.Released && previousState == ButtonState.Pressed)
            {
                // For now, define a click as a release. In the future, maybe
                // have click be more restrictive or even driven by components
                // rather than a generic input handler
                if (Clicked != null)
                {
                    Clicked(this);
                }

                if (Released != null)
                {
                    Released(this);
                }
            }

            previousState = state;
        }
开发者ID:HotPrawns,项目名称:Jiemyu_Unity,代码行数:31,代码来源:MouseButton.cs


示例15: ThreadButtonState

        internal void ThreadButtonState()
        {
            int LastSearchTime = Config.ButtonStateUpdateInterval;
            while (true)
            {
                if (Form.NTRConnection.HardwarePID != null)
                {
                    SearchCriteria Criteria = new SearchCriteria();
                    Criteria.ProcessID = BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(Form.NTRConnection.HardwarePID), 0);
                    Criteria.DataType = DataTypeExact.Bytes1;
                    Criteria.StartAddress = BUTTON_STATES_START;
                    Criteria.Length = BUTTON_STATES_SIZE;
                    Criteria.SearchType = SearchTypeBase.Unknown;
                    Criteria.SearchValue = new byte[] { 0 };
                    Criteria.Size = 1;
                    Criteria.HideSearch = true;
                    Form.NTRConnection.SearchCriteria.Add(Criteria);

                    Form.NTRConnection.SendReadMemoryPacket(Criteria);

                    ButtonState = (ButtonState)Criteria.AddressesFound[BUTTON_STATES_START + Offset_Button][0];
                    ShoulderState = (ShoulderState)Criteria.AddressesFound[BUTTON_STATES_START + Offset_Shoulder][0];
                    StickState = (StickState)Criteria.AddressesFound[BUTTON_STATES_START + Offset_Stick][0];
                    StickHoriz = Criteria.AddressesFound[BUTTON_STATES_START + Offset_Horiz][0];
                    StickVert = Criteria.AddressesFound[BUTTON_STATES_START + Offset_Vert][0];

                    LastSearchTime = Math.Max(LastSearchTime, (int)Criteria.Duration);

                    Form.NTRConnection.SetCurrentOperationText2 = ButtonState.ToString() + "|" + ShoulderState.ToString() + "|" + StickState.ToString() + "|" + StickHoriz + "|" + StickVert + "|" + LastSearchTime;
                }

                Thread.Sleep(LastSearchTime * 2);
            }
        }
开发者ID:valarnin,项目名称:NTRRemoteDebugger,代码行数:34,代码来源:MainFormThreadButtonState.cs


示例16: DrawSelectionFrame

		//render using new style
		protected override void DrawSelectionFrame(PaintEventArgs e, Rectangle rct, ButtonState state)
		{
			if (state == ButtonState.Checked ||
			    state == ButtonState.Pushed) {
				e.Graphics.PixelOffsetMode = PixelOffsetMode.None;
				e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
				rct.Width--;
				rct.Height--;
				using (GraphicsPath pth = CreateRoundedRect(2, rct)) {
					using (LinearGradientBrush brs = new LinearGradientBrush(
						new Point(0, rct.Bottom), new Point(0, rct.Y),
						Color.Black, Color.White)) {
						ColorBlend colorblnd = new ColorBlend();
						colorblnd.Positions = new float[]
						                      	{
						                      		0F, 0.5F, 0.50F, 1F
						                      	};
						colorblnd.Colors = new Color[]
						                   	{
						                   		Color.FromArgb(255, 236, 181),
						                   		Color.FromArgb(255, 236, 181),
						                   		Color.FromArgb(255, 243, 207),
						                   		Color.FromArgb(255, 252, 242)
						                   	};
						//
						brs.InterpolationColors = colorblnd;
						e.Graphics.FillPath(brs, pth);
					}
					using (Pen pn = new Pen(Color.FromArgb(229, 195, 101)))
						e.Graphics.DrawPath(pn, pth);
				}
			}
		}
开发者ID:stewmc,项目名称:vixen,代码行数:34,代码来源:ActionList.cs


示例17: Update

        public virtual void Update(Microsoft.Xna.Framework.Vector2 position)
        {
            position = Screen.RelationToPosition(position-offset);
            var pos = Mouse.GetState();
            if (pos.X > position.X && pos.X < position.X + Width
                &&
                pos.Y > position.Y && pos.Y < position.Y + Height)
            {
                if (focus != this)
                {
                    if (MouseEnter != null)
                        MouseEnter(this, new EventArgs());
                }
                focus = this;

                if (pos.LeftButton == ButtonState.Pressed
                    && msButState != pos.LeftButton)
                {
                    if (MouseClick != null)
                        MouseClick(this, new EventArgs());
                }
                msButState = pos.LeftButton;
            }
            else
            {
                if (focus == this)
                {
                    focus = null;
                    if (MouseLeave != null)
                        MouseLeave(this, new EventArgs());
                }
            }
        }
开发者ID:Kcanavrin,项目名称:tesseract,代码行数:33,代码来源:UIElement.cs


示例18: ErrorDialog

        /// <summary>
        /// Initializes a new instance of the <see cref="ErrorDialog"/> class.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="message">The message.</param>
        /// <param name="exception">The exception.</param>
        /// <param name="buttons">The buttons.</param>
        public ErrorDialog(string title, string message, Exception exception, ButtonState buttons)
            : this()
        {
            ErrorTitle = title;
            ErrorMessage = message;
            ErrorException = exception;

            switch (buttons)
            {
                case ButtonState.CloseContinue:
                    btnContinue.Visible = true;
                    btnClose.Visible = true;
                    btnOk.Visible = false;
                    btnCancel.Visible = false;
                    break;
                case ButtonState.OkCancel:
                    btnContinue.Visible = false;
                    btnClose.Visible = false;
                    btnOk.Visible = true;
                    btnCancel.Visible = true;
                    break;
                case ButtonState.OkOnly:
                    btnContinue.Visible = false;
                    btnClose.Visible = false;
                    btnOk.Visible = true;
                    btnCancel.Visible = false;
                    break;
            }
        }
开发者ID:smst,项目名称:turtlemine,代码行数:36,代码来源:ErrorDialog.cs


示例19: ButtonCell

		public ButtonCell()
		{
			title = "Button";
			buttonType = ButtonType.MomentaryLight;
			bezelStyle = BezelStyle.Rounded;
			buttonState = ButtonState.Unchecked;
		}
开发者ID:nagyist,项目名称:monoxide,代码行数:7,代码来源:ButtonCell.cs


示例20: Update

        public override void Update(GameTime gameTime)
        {
            if (!Visible) return;
            Text = Width + " x " + Height;
            mouseState = Mouse.GetState();
            buttonState = mouseState.LeftButton;

            base.Update(gameTime);
            if (Contains(mouseState.X, mouseState.Y) )
            {
                this.Scale = new Vector2(2, 1);
                this.TintColor = Color.Red;
                if ((buttonState == ButtonState.Pressed) )
                {
                    Engine.Instance.ResolutionManager.ScreenSize = new Vector2(Width, Height);
                    //Engine.Instance.ResolutionManager.FullScreen = !Engine.Instance.ResolutionManager.FullScreen;
                }

            }
            else
            {
                this.Scale = new Vector2(1, 1);
                this.TintColor = Color.Yellow;
            }
        }
开发者ID:Lebby,项目名称:Develia,代码行数:25,代码来源:ResolutionScreen.cs



注:本文中的ButtonState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ButtonType类代码示例发布时间:2022-05-24
下一篇:
C# ButtonPressedEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap