当前位置: 首页>>代码示例>>C#>>正文


C# MouseState类代码示例

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


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


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