本文整理汇总了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);
}
示例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);
}
示例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();
}
示例4: Update
public void Update(MouseState mouseState)
{
_previousFrameMouseState = _currentFrameMouseState;
_currentFrameMouseState = mouseState;
CalculateRelativeMousePosition();
}
示例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;
}
}
示例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 ();
}
}
示例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;
}
}
示例8: Initialize
/// <summary>
/// Initializes the input states
/// </summary>
public static void Initialize()
{
PreviousKeyboardState = CurrentKeyboardState =
Keyboard.GetState();
PreviousMouseState = CurrentMouseState =
Mouse.GetState();
}
示例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 ();
}
}
}
示例10: Update
public void Update()
{
previousMouseState = currentMouseState;
previousKeyboardState = currentKeyboardState;
currentMouseState = Mouse.GetState();
currentKeyboardState = Keyboard.GetState();
}
示例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;
}
示例12: Update
public void Update(GameTime t)
{
this.PreviousKeyboardState = this.KeyboardState;
this.PreviousMouseState = this.MouseState;
this.KeyboardState = Keyboard.GetState();
this.MouseState = Mouse.GetState();
}
示例13: Poll
/// <summary>
/// Check input device without check Floor Height
/// </summary>
public void Poll()
{
KeyState = KeyBoardDevice.GetCurrentKeyboardState();
KeyBoardJOBs();
MState = MouseDevice.CurrentMouseState;
MouseJOBs();
}
示例14: OnMouseDown
public void OnMouseDown(IInputElement relativeTo, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left && _selectionState == MouseState.WaitingForDown)
{
_selectionState = MouseState.WaitingForUp;
_selectDown = e.GetPosition(relativeTo);
}
}
示例15: Update
public static void Update()
{
previousMouseState = currentMouseState;
previousKeyboardState = currentKeyboardState;
currentMouseState = Mouse.GetState();
currentKeyboardState = Keyboard.GetState();
DetermineScale();
}