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

C# MouseState类代码示例

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

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



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

示例1: ProcessMouse

		public static void ProcessMouse(int oriX,int oriY){
			
			EventArgs evnt=null;
			var pressed = false;
			prevMouseState =curMouseState;
			curMouseState = Mouse.GetCursorState ();
            Gwen.Input.InputHandler.HoveredControl =input.m_Canvas.GetControlAt(curMouseState.X - oriX, curMouseState.Y - oriY);
            foreach (var mouseCode in mouseCodes)
				if (curMouseState[mouseCode]!=prevMouseState[mouseCode]){
                    evnt = new MouseButtonEventArgs(curMouseState.X - oriX, curMouseState.Y - oriY, mouseCode, true);//last param bugged
                    //evnt = new MouseButtonEventArgs (curMouseState.X, curMouseState.Y, mouseCode,true);//last param bugged
					if (curMouseState [mouseCode]) {
						pressed = true;
                        Gwen.Input.InputHandler.MouseFocus = Gwen.Input.InputHandler.HoveredControl;
                        OnMouseDown?.Invoke ((MouseButtonEventArgs)evnt);
					} else {
						OnMouseUp?.Invoke ((MouseButtonEventArgs)evnt);

					}
				}
			Vector2 delta =MainWindow.lastPos - new Vector2(curMouseState.X, curMouseState.Y);
			if (Math.Abs (delta.X) > 0 || Math.Abs (delta.Y) > 0) {
				
				evnt = new MouseMoveEventArgs (curMouseState.X-oriX, curMouseState.Y-oriY,(int)delta.X,(int)delta.Y);
				OnMouseMove?.Invoke (evnt as MouseMoveEventArgs);
			}
			input.ProcessMouseMessage (evnt,pressed);
			MainWindow.lastPos = new Vector2 (curMouseState.X, curMouseState.Y);
		}
开发者ID:BreyerW,项目名称:Sharp.Engine,代码行数:29,代码来源:InputHandler.cs


示例2: TrayIcon

 /// <summary>
 /// Initializes a new instance of the <see cref="EVEMon.TrayIcon"/> class with the specfied container.
 /// </summary>
 /// <param name="container">An <see cref="System.ComponentModel.IContainer"/> that represents the container for the <see cref="EVEMon.TrayIcon"/> control.</param>
 public TrayIcon(IContainer container)
 {
     if (container != null)
         container.Add(this);
     InitializeComponent();
     this.mouseState = new MouseStateOut(this);
 }
开发者ID:wow4all,项目名称:evemu_server,代码行数:11,代码来源:TrayIcon.cs


示例3: Update

 //Should be called at beginning of Update in Game
 public static void Update()
 {
     oldKeyState = keyState;
     keyState = Keyboard.GetState();
     oldMouseState = mouseState;
     mouseState = Mouse.GetState();
 }
开发者ID:ollesate,项目名称:TankGame,代码行数:8,代码来源:KeyMouseReader.cs


示例4: Update

        public void Update(MouseState mouseState)
        {
            _previousFrameMouseState = _currentFrameMouseState;
            _currentFrameMouseState = mouseState;

            CalculateRelativeMousePosition();
        }
开发者ID:HaKDMoDz,项目名称:ProceduralGeneration,代码行数:7,代码来源:MouseInputProcessor.cs


示例5: DoMouseInteraction

		public override void DoMouseInteraction(MouseState mouseState, System.Windows.Forms.MouseButtons mouseButtons, Vector2 mousePos, out bool shouldUpdate)
		{
			shouldUpdate = false;

			switch (mouseState)
			{
				case MouseState.ClickStart:
					if (Click == null)
					{
						Open();				
					}
					shouldUpdate = true; 					
					break;
				case MouseState.ClickEnd:
					if (Bounds.Contains(mousePos.X, mousePos.Y))
					{
						if (DoClick() == true)
						{
							Close();
						}
					}
					shouldUpdate = true; 
					break;
				default:
					base.DoMouseInteraction(mouseState, mouseButtons, mousePos, out shouldUpdate);
					break;
			}			
		}
开发者ID:RugCode,项目名称:drg-pt,代码行数:28,代码来源:MenuItem.cs


示例6: ClickOutput

 public void ClickOutput(AC.Menu _menu, MouseState _mouseState)
 {
     if (items.Count > 0)
     {
         if (_mouseState == MouseState.SingleClick)
         {
             if (KickStarter.runtimeInventory.selectedItem == null)
             {
                 // Pick up created item
                 if (activeRecipe.onCreateRecipe == OnCreateRecipe.SelectItem)
                 {
                     KickStarter.runtimeInventory.PerformCrafting (activeRecipe, true);
                 }
                 else if (activeRecipe.onCreateRecipe == OnCreateRecipe.RunActionList)
                 {
                     KickStarter.runtimeInventory.PerformCrafting (activeRecipe, false);
                     if (activeRecipe.invActionList != null)
                     {
                         AdvGame.RunActionListAsset (activeRecipe.invActionList);
                     }
                 }
                 else
                 {
                     KickStarter.runtimeInventory.PerformCrafting (activeRecipe, false);
                 }
             }
         }
         PlayerMenus.ResetInventoryBoxes ();
     }
 }
开发者ID:IJkeB,项目名称:Ekster_Final,代码行数:30,代码来源:MenuCrafting.cs


示例7: HandleInput

        public void HandleInput(MouseState mouseState, KeyboardState keyboardState)
        {
            KeyboardState = keyboardState;

            if (MouseOverRenderArea && mouseState.LeftButton == ButtonState.Pressed)
            {
                if (!MouseDragging)
                {
                    MouseDragging = true;
                    MousePreviousPosition = new Vector2(mouseState.X, mouseState.Y);
                }

                var mouseNewCoords = new Vector2(mouseState.X, mouseState.Y);

                MouseDelta.X = mouseNewCoords.X - MousePreviousPosition.X;
                MouseDelta.Y = mouseNewCoords.Y - MousePreviousPosition.Y;

                MousePreviousPosition = mouseNewCoords;
            }

            if (!MouseOverRenderArea || mouseState.LeftButton == ButtonState.Released)
            {
                MouseDragging = false;
            }
        }
开发者ID:SteamDatabase,项目名称:ValveResourceFormat,代码行数:25,代码来源:Camera.cs


示例8: Initialize

 /// <summary>
 /// Initializes the input states
 /// </summary>
 public static void Initialize()
 {
     PreviousKeyboardState = CurrentKeyboardState =
         Keyboard.GetState();
     PreviousMouseState = CurrentMouseState =
         Mouse.GetState();
 }
开发者ID:ravikamath,项目名称:CPI311,代码行数:10,代码来源:Input.cs


示例9: ClickContainer

        public void ClickContainer(MouseState _mouseState, int _slot, Container container)
        {
            if (container == null || KickStarter.runtimeInventory == null) return;

            KickStarter.runtimeInventory.SetFont (font, GetFontSize (), fontColor, textEffects);

            if (_mouseState == MouseState.SingleClick)
            {
                if (KickStarter.runtimeInventory.selectedItem == null)
                {
                    if (container.items.Count > (_slot+offset) && container.items [_slot+offset] != null)
                    {
                        ContainerItem containerItem = container.items [_slot + offset];
                        KickStarter.runtimeInventory.Add (containerItem.linkedID, containerItem.count, selectItemsAfterTaking, -1);
                        container.items.Remove (containerItem);
                    }
                }
                else
                {
                    // Placing an item inside the container
                    container.InsertAt (KickStarter.runtimeInventory.selectedItem, _slot+offset);
                    KickStarter.runtimeInventory.Remove (KickStarter.runtimeInventory.selectedItem);
                }
            }

            else if (_mouseState == MouseState.RightClick)
            {
                if (KickStarter.runtimeInventory.selectedItem != null)
                {
                    KickStarter.runtimeInventory.SetNull ();
                }
            }
        }
开发者ID:IJkeB,项目名称:Ekster_Final,代码行数:33,代码来源:MenuInventoryBox.cs


示例10: Update

 public void Update()
 {
     previousMouseState = currentMouseState;
     previousKeyboardState = currentKeyboardState;
     currentMouseState = Mouse.GetState();
     currentKeyboardState = Keyboard.GetState();
 }
开发者ID:TheHappyCow,项目名称:TickTick,代码行数:7,代码来源:InputHelper.cs


示例11: HandleInput

        // Method that check if our mouse input is over our button position.
        // if it is we change the color and the text.
        // when click we see the state to clicked.
        // finally check if any new events should be fired.
        internal void HandleInput(MouseState mouseState)
        {
            Sprite.Color = DefeaultSpriteColor;
            Text.Color = DefaultTextColor;

            if (ContainsPosition(new Vector2(mouseState.X, mouseState.Y)))
            {
                Sprite.Color = HoverSpriteColor;
                Text.Color = HoverTextColor;

                m_currentButtonState = ButtonState.Hovered;

                if(mouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
                {
                    m_currentButtonState = ButtonState.Clicked;
                }
            }
            else
            {
                m_currentButtonState = ButtonState.None;
            }

            FireEvents();
            m_previousButtonState = m_currentButtonState;
        }
开发者ID:John078,项目名称:INFDEV02-1_0907498,代码行数:29,代码来源:Button.cs


示例12: Update

    public void Update(GameTime t)
    {
        this.PreviousKeyboardState = this.KeyboardState;
        this.PreviousMouseState = this.MouseState;

        this.KeyboardState = Keyboard.GetState();
        this.MouseState = Mouse.GetState();
    }
开发者ID:jlvermeulen,项目名称:bunka,代码行数:8,代码来源:InputManager.cs


示例13: Poll

        /// <summary>
        /// Check input device without check Floor Height 
        /// </summary>
        public void Poll()
        {
            KeyState = KeyBoardDevice.GetCurrentKeyboardState();
            KeyBoardJOBs();

            MState = MouseDevice.CurrentMouseState;
            MouseJOBs();
        }
开发者ID:Behzadkhosravifar,项目名称:Museum-3D,代码行数:11,代码来源:InputToolBox.cs


示例14: OnMouseDown

 public void OnMouseDown(IInputElement relativeTo, MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Left && _selectionState == MouseState.WaitingForDown)
     {
         _selectionState = MouseState.WaitingForUp;
         _selectDown = e.GetPosition(relativeTo);
     }
 }
开发者ID:RMommaerts,项目名称:SharpMarker,代码行数:8,代码来源:CropTool.cs


示例15: Update

 public static void Update()
 {
     previousMouseState = currentMouseState;
     previousKeyboardState = currentKeyboardState;
     currentMouseState = Mouse.GetState();
     currentKeyboardState = Keyboard.GetState();
     DetermineScale();
 }
开发者ID:Suwappertjes,项目名称:Project-Bromied,代码行数:8,代码来源:InputHelper.cs


示例16: Presenter

 /// <summary>
 /// Initializes a new instance of the Presenter class.
 /// </summary>
 /// <param name="view">View interface</param>
 /// <param name="factory">Path finder factory service</param>
 public Presenter(IView view, IPathFinderFactory factory)
 {
     this.View = view;
      this.View.Presenter = this;
      this.View.SetDrawing(this.Surface);
      this.CurrentMouseState = MouseState.Default;
      this.Factory = factory;
 }
开发者ID:dlidstrom,项目名称:PathFinder,代码行数:13,代码来源:Presenter.cs


示例17: MeasureTool

        public MeasureTool(ImageCanvas canvas)
        {
            _lineOverlay = null;
            _mouseDownText = null;
            _mouseFollowText = null;

            _canvas = canvas;
            _mouseState = MouseState.WaitingForDown;
        }
开发者ID:RMommaerts,项目名称:SharpMarker,代码行数:9,代码来源:MeasureTool.cs


示例18: InputSystem

 public InputSystem()
 {
     CurrentKeyboardState = new KeyboardState();
     PreviousKeyboardState = new KeyboardState();
     CurrentGamepadState = new GamePadState();
     PreviousGamepadState = new GamePadState();
     CurrentMouseState = new MouseState();
     PreviousMouseState = new MouseState();
 }
开发者ID:jasongdove,项目名称:MonoGameEngine,代码行数:9,代码来源:InputSystem.cs


示例19: GetState

		public static MouseState GetState ()
		{
			MouseState ms = new MouseState(_x,_y);
			ms.LeftButton = _leftButton;
			ms.RightButton = _rightButton;
			ms.MiddleButton = _middleButton;
			
			return ms;
		}
开发者ID:nikoware,项目名称:MonoGame,代码行数:9,代码来源:Mouse.cs


示例20: Update

 /// <summary>Update player inputs.</summary>
 public void Update()
 {
     previousMouseState = currentMouseState;
     previousKeyboardState = currentKeyboardState;
     previousControlerState = currentControlerState;
     currentMouseState = Mouse.GetState();
     currentKeyboardState = Keyboard.GetState();
     currentControlerState = GamePad.GetState(PlayerIndex.One);
 }
开发者ID:alikimoko,项目名称:Practicum3.Platformer,代码行数:10,代码来源:InputHelper.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Move类代码示例发布时间:2022-05-24
下一篇:
C# MouseOrTouch类代码示例发布时间: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