protected override void OnMouseMove(MouseEventArgs e) { if (_mouseLoc.X == e.X && _mouseLoc.Y == e.Y) { return; } _mouseMove = Helper.Now; MousePos mousePos = GetMousePos(e.Location); switch (mousePos) { case MousePos.Right: Cursor = Cursors.SizeWE; break; case MousePos.Bottom: Cursor = Cursors.SizeNS; break; case MousePos.BottomRight: Cursor = Cursors.SizeNWSE; break; default: Cursor = Cursors.Hand; if (MainForm.Conf.ShowOverlayControls) { var rBp = ButtonPanel; var toolTipLocation = new Point(e.Location.X, rBp.Y + rBp.Height + 1); int bpi = GetButtonIndexByLocation(e.Location); if (_ttind != bpi) { switch (bpi) { case 0: _toolTipFp.Show(LocRm.GetString("Edit"), this, toolTipLocation, 1000); _ttind = 0; break; case 1: if (Helper.HasFeature(Enums.Features.Access_Media)) { _toolTipFp.Show(LocRm.GetString("MediaoverTheWeb"), this, toolTipLocation, 1000); _ttind = 1; } break; } } } break; } base.OnMouseMove(e); }
/// <summary> /// Renders UI components to screen. /// </summary> public void Render() { IOrderedEnumerable <IGuiComponent> renderList = from IGuiComponent comp in _components where comp.IsVisible() orderby comp.Focus ascending orderby comp.ZDepth ascending select comp; foreach (IGuiComponent component in renderList) { component.Render(); if (moveMode) { /* * CluwneLib.Screen.BlendingMode = BlendingModes.Modulated; * CluwneLib.Screen.FilledRectangle(component.ClientArea.X, component.ClientArea.Y, * component.ClientArea.Width, component.ClientArea.Height, * Color.FromArgb(100, Color.Green)); * CluwneLib.Screen.Rectangle(component.ClientArea.X, component.ClientArea.Y, component.ClientArea.Width, * component.ClientArea.Height, Color.LightGreen); * CluwneLib.Screen.BlendingMode = BlendingModes.None; */ } } if (_console.IsVisible()) { _console.Render(); } if (showCursor) { if (targetingAction != null) { _cursorSprite = _resourceManager.GetSprite("cursor_target"); } else { _cursorSprite = DragInfo.DragSprite != null && DragInfo.IsActive ? DragInfo.DragSprite : _resourceManager.GetSprite("cursor"); } _cursorSprite.Position = MousePos.ToFloat(); _cursorSprite.Draw(); } }
// Update is called once per frame void Update() { switch (InputAct) { case TipoInput.Mouse: if (Habilitado) { gameObject.SendMessage("SetGiro", MousePos.Relation(MousePos.AxisRelation.Horizontal)); //debe ser reemplanado } break; case TipoInput.AWSD: if (Habilitado) { if (Input.GetKey(KeyCode.A)) { gameObject.SendMessage("SetGiro", -1); } if (Input.GetKey(KeyCode.D)) { gameObject.SendMessage("SetGiro", 1); } } break; case TipoInput.Arrows: if (Habilitado) { if (Input.GetKey(KeyCode.LeftArrow)) { gameObject.SendMessage("SetGiro", -1); } if (Input.GetKey(KeyCode.RightArrow)) { gameObject.SendMessage("SetGiro", 1); } } break; case TipoInput.Joystick: if (Habilitado) { gameObject.SendMessage("SetGiro", joystick.Horizontal); } break; } }
public static void StartFrame() { lastKeyState = currentKeyState; currentKeyState = Keyboard.GetState(); lastMouseState = currentMouseState; currentMouseState = Mouse.GetState(); MousePos = currentMouseState.Position; MouseWorldPos = Main.Camera.ScreenToWorldPosition(MousePos.ToVector2()); MouseInWindow = Screen.Contains(MousePos.X, MousePos.Y); MouseScrollDelta = currentMouseState.ScrollWheelValue - MouseScroll; MouseScroll = currentMouseState.ScrollWheelValue; tileUnderMouse = GetTileFromWorldPosition(MouseWorldPos); }
public void Update() { _prevKey = _curKey; _prevMouse = _curMouse; _curKey = Keyboard.GetState(); _curMouse = Mouse.GetState(); PrevMousePos = MousePos; MousePos = _curMouse.Position; MouseDeltaPos = MousePos - PrevMousePos; var camTransform = Components.Camera.main.CreateTransform(); CamRelativePrevMousePos = CamRelativeMousePos; CamRelativeMousePos = Vector2.Transform(MousePos.ToVector2(), Matrix.Invert(camTransform)); CamRelativeMouseDeltaPos = CamRelativeMousePos - CamRelativePrevMousePos; }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); IntPtr hwnd = Handle; if ((ResizeParent) && (Parent != null) && (Parent.IsHandleCreated)) { hwnd = Parent.Handle; } MousePos mousePos = GetMousePos(e.Location); switch (mousePos) { case MousePos.Right: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeE, IntPtr.Zero); } break; case MousePos.Bottom: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeS, IntPtr.Zero); } break; case MousePos.BottomRight: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeSe, IntPtr.Zero); } break; case MousePos.NoWhere: { if (e.Location.X > 0 && e.Location.Y > Height - 22) { //MessageBox.Show( // "Add a new iSpyServer microphone source to iSpy and use the address below to connect:\n\nhttp://" + // MainForm.AddressIPv4 + ":" + iSpyServer.Default.LANPort + "/?micid=" + Micobject.id); } } break; } }
private void Update(EvaluationContext context) { if (IsActve.GetValue(context)) { _maxPointCount = MaxPointCount.GetValue(context); if (TriggerReset.GetValue(context)) { Reset(); } var isMouseDown = IsMouseButtonDown.GetValue(context); if (!isMouseDown && _mouseWasDown) { if (_currentStrokeLength == 1 && _writeIndex > 0) // add to points for single click to make it visible as a dot { var lastPoint = _pointList.TypedElements[_writeIndex - 1]; lastPoint.Position = PointFromMousePos(context, _lastMousePos + new Vector2(0, 0.01f)); AppendPoint(lastPoint); } AppendPoint(Point.Separator()); _currentStrokeLength = 0; } else if (isMouseDown) { var mousePos = MousePos.GetValue(context); if (!_mouseWasDown || Vector2.Distance(_lastMousePos, mousePos) > 0.001f) { AppendPoint(new Point() { Position = PointFromMousePos(context, mousePos), Orientation = Quaternion.Identity, W = 1, }); AppendPoint(Point.Separator(), advanceIndex: false); _currentStrokeLength++; } _lastMousePos = mousePos; } _mouseWasDown = isMouseDown; } PointList.Value = _pointList; }
public static void StartFrame() { LastKeyState = CurrentKeyState; CurrentKeyState = Keyboard.GetState(); LastMouseState = CurrentMouseState; CurrentMouseState = Mouse.GetState(); MousePos = CurrentMouseState.Position; MouseWorldPos = JEngine.Camera.ScreenToWorldPosition(MousePos.ToVector2()); IsMouseInWindow = Screen.Contains((int)MousePos.X, (int)MousePos.Y); if (JEngine.TileMap != null) { MouseWorldTilePos = JEngine.TileMap.PixelToTileCoords((int)MouseWorldPos.X, (int)MouseWorldPos.Y); } MouseScrollDelta = CurrentMouseState.ScrollWheelValue - MouseScroll; MouseScroll = CurrentMouseState.ScrollWheelValue; }
//method to launch the food, and clear necesary local variables. public void CheckShoot() { if (triggers < -.5) { MousePos scriptref = this.gameObject.GetComponent <MousePos>(); float launchAngle = scriptref.RAngle; prisoner.Launched(launchAngle); BailPrisoner(); //sound FindObjectOfType <AudioManager>().Play("ThrowSound"); //animation anim.SetTrigger("throw"); //get stats to increment GOthrows this.GetComponent <StatsManager>().CountThrow(); } }
public void OnPointerDown(PointerEventData eventData) { startPos = eventData.position; RaycastHit hit = new RaycastHit(); Ray ray = camera.ScreenPointToRay(eventData.position); if (Physics.Raycast(ray, out hit, 500)) { var selectedGameObject = hit.transform.GetComponent <ISelectable>(); if (selectedGameObject != null) { if (!selectedGameObject.IsSelected) { selectedGameObject.Select(); } else { foreach (var initsObject in initsGameObjects) { if (selectedGameObject != initsObject) { initsObject.Deselect(); } } } mousePose = Vector3.zero; } if (selectedGameObject == null) { if (listSelected.Count != 0) { mousePose = hit.point; MousePos?.Invoke(mousePose); } } } }
private MousePos GetMousePos(Point location) { MousePos result = MousePos.NoWhere; int rightSize = Padding.Right; int bottomSize = Padding.Bottom; var testRect = new Rectangle(Width - rightSize, 0, Width - rightSize, Height - bottomSize); if (testRect.Contains(location)) { result = MousePos.Right; } testRect = new Rectangle(0, Height - bottomSize, Width - rightSize, Height); if (testRect.Contains(location)) { result = MousePos.Bottom; } testRect = new Rectangle(Width - rightSize, Height - bottomSize, Width, Height); if (testRect.Contains(location)) { result = MousePos.BottomRight; } return(result); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); MousePos mousePos = GetMousePos(e.Location); switch (mousePos) { case MousePos.Right: Cursor = Cursors.SizeWE; break; case MousePos.Bottom: Cursor = Cursors.SizeNS; break; case MousePos.BottomRight: Cursor = Cursors.SizeNWSE; break; default: Cursor = Cursors.Hand; break; } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (bSizable) { SetCursor(e); } if (e.Button == MouseButtons.Left) { Rectangle rect = parent.DesktopBounds; Point pt = PointToScreen(new Point(e.X, e.Y)); szTopLeft = new Size(pt.X - rect.Left, pt.Y - rect.Top); szBottomRight = new Size(rect.Right - pt.X, rect.Bottom - pt.Y); switch (Dock) { case DockStyle.Top: if (e.X >= Size.Width - gap) { pos = MousePos.TopRight; } else if (e.X <= gap) { pos = MousePos.TopLeft; } else { pos = MousePos.Top; } break; case DockStyle.Bottom: if (e.X >= Size.Width - gap) { pos = MousePos.BottomRight; } else if (e.X <= gap) { pos = MousePos.BottomLeft; } else { pos = MousePos.Bottom; } break; case DockStyle.Left: if (e.Y >= Size.Height - gap) { pos = MousePos.BottomLeft; } else if (e.Y <= gap) { pos = MousePos.TopLeft; } else { pos = MousePos.Left; } break; case DockStyle.Right: if (e.Y >= Size.Height - gap) { pos = MousePos.BottomRight; } else if (e.Y <= gap) { pos = MousePos.TopRight; } else { pos = MousePos.Right; } break; default: pos = MousePos.None; break; } bTracking = true; } else { Capture = false; } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); Select(); IntPtr hwnd = Handle; if ((ResizeParent) && (Parent != null) && (Parent.IsHandleCreated)) { hwnd = Parent.Handle; } if (e.Button == MouseButtons.Left) { MousePos mousePos = GetMousePos(e.Location); if (mousePos == MousePos.NoWhere) { if (MainForm.Conf.ShowOverlayControls) { int bpi = GetButtonIndexByLocation(e.Location); switch (bpi) { case -999: var layoutPanel = (LayoutPanel)Parent; layoutPanel?.ISpyControlDown(new Point(this.Left + e.X, this.Top + e.Y)); break; case 0: MainClass.EditFloorplan(Fpobject); break; case 1: throw new NotSupportedException("Website not supported exception"); } } } if (MainForm.LockLayout) { return; } switch (mousePos) { case MousePos.Right: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeE, IntPtr.Zero); } break; case MousePos.Bottom: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeS, IntPtr.Zero); } break; case MousePos.BottomRight: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeSe, IntPtr.Zero); } break; } } }
public override void mouse(MousePos mp) { Console.WriteLine ("mouse pos " + mp.x + " x " + mp.y); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); Select(); IntPtr hwnd = Handle; if ((ResizeParent) && (Parent != null) && (Parent.IsHandleCreated)) { hwnd = Parent.Handle; } if (e.Button == MouseButtons.Left) { MousePos mousePos = GetMousePos(e.Location); if (mousePos == MousePos.NoWhere) { if (MainForm.Conf.ShowOverlayControls) { int bpi = GetButtonIndexByLocation(e.Location); switch (bpi) { case -999: var layoutPanel = (LayoutPanel)Parent; layoutPanel?.ISpyControlDown(new Point(this.Left + e.X, this.Top + e.Y)); break; case 0: MainClass.EditFloorplan(Fpobject); break; case 1: if (Helper.HasFeature(Enums.Features.Access_Media)) { string url = MainForm.Webpage; if (WsWrapper.WebsiteLive && MainForm.Conf.ServicesEnabled) { MainForm.OpenUrl(url); } else { MainClass.Connect(url, false); } } break; } } } if (MainForm.LockLayout) { return; } switch (mousePos) { case MousePos.Right: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeE, IntPtr.Zero); } break; case MousePos.Bottom: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeS, IntPtr.Zero); } break; case MousePos.BottomRight: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeSe, IntPtr.Zero); } break; } } }
protected override void OnMouseMove(MouseEventArgs e) { if (_mouseLoc.X == e.X && _mouseLoc.Y == e.Y) { return; } _mouseMove = DateTime.Now; MousePos mousePos = GetMousePos(e.Location); switch (mousePos) { case MousePos.Right: Cursor = Cursors.SizeWE; break; case MousePos.Bottom: Cursor = Cursors.SizeNS; break; case MousePos.BottomRight: Cursor = Cursors.SizeNWSE; break; default: Cursor = Cursors.Hand; if (MainForm.Conf.ShowOverlayControls) { int leftpoint = Width / 2 - ButtonPanelWidth / 2; int ypoint = Height - 24 - ButtonPanelHeight; var toolTipLocation = new Point(e.Location.X, ypoint + ButtonPanelHeight + 1); if (e.Location.X > leftpoint && e.Location.X < leftpoint + ButtonPanelWidth && e.Location.Y > ypoint && e.Location.Y < ypoint + ButtonPanelHeight) { int x = e.Location.X - leftpoint; if (x < ButtonWidth + ButtonOffset) { //power if (_ttind != 0) { _toolTipFp.Show(LocRm.GetString("Edit"), this, toolTipLocation, 1000); _ttind = 0; } } else { if (x < (ButtonWidth + ButtonOffset) * 2) { //record if (_ttind != 1) { _toolTipFp.Show(LocRm.GetString("MediaoverTheWeb"), this, toolTipLocation, 1000); _ttind = 1; } } } } else { _toolTipFp.Hide(this); _ttind = -1; } } break; } base.OnMouseMove(e); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); Select(); IntPtr hwnd = Handle; if ((ResizeParent) && (Parent != null) && (Parent.IsHandleCreated)) { hwnd = Parent.Handle; } if (e.Button == MouseButtons.Left) { MousePos mousePos = GetMousePos(e.Location); if (mousePos == MousePos.NoWhere) { if (MainForm.Conf.ShowOverlayControls) { int leftpoint = Width / 2 - ButtonPanelWidth / 2; int ypoint = Height - 24 - ButtonPanelHeight; if (e.Location.X > leftpoint && e.Location.X < leftpoint + ButtonPanelWidth && e.Location.Y > ypoint && e.Location.Y < ypoint + ButtonPanelHeight) { int x = e.Location.X - leftpoint; if (x < ButtonWidth + ButtonOffset) { //settings if (TopLevelControl != null) { ((MainForm)TopLevelControl).EditFloorplan(Fpobject); } } else { string url = MainForm.Webserver + "/watch_new.aspx";// "?tab=2"; if (WsWrapper.WebsiteLive && MainForm.Conf.ServicesEnabled) { MainForm.OpenUrl(url); } else if (TopLevelControl != null) { ((MainForm)TopLevelControl).Connect(url, false); } } } } } if (MainForm.Conf.LockLayout) { return; } switch (mousePos) { case MousePos.Right: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeE, IntPtr.Zero); } break; case MousePos.Bottom: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeS, IntPtr.Zero); } break; case MousePos.BottomRight: { NativeCalls.ReleaseCapture(hwnd); NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeSe, IntPtr.Zero); } break; } } }
//根据鼠标位置改变光标形态 private void SetCursor(int x, int y) { Point point = new Point(x, y); if (!controlRect.Contains(point))//不在边框局域内直接退出 { Cursor.Current = Cursors.Arrow; return; } else if (smallRects[0].Contains(point))//左上 { Cursor.Current = Cursors.SizeNWSE; mousePos = MousePos.LeftTop; } else if (smallRects[1].Contains(point))//右上 { Cursor.Current = Cursors.SizeNESW; mousePos = MousePos.RightTop; } else if (smallRects[2].Contains(point))//左下 { Cursor.Current = Cursors.SizeNESW; mousePos = MousePos.LeftBottom; } else if (smallRects[3].Contains(point))//右下 { Cursor.Current = Cursors.SizeNWSE; mousePos = MousePos.RightBottom; } else if (smallRects[4].Contains(point))//上 { Cursor.Current = Cursors.SizeNS; mousePos = MousePos.Top; } else if (smallRects[6].Contains(point))//左 { Cursor.Current = Cursors.SizeWE; mousePos = MousePos.Left; } else if (smallRects[5].Contains(point))//下 { Cursor.Current = Cursors.SizeNS; mousePos = MousePos.Bottom; } else if (smallRects[7].Contains(point))//右 { Cursor.Current = Cursors.SizeWE; mousePos = MousePos.Right; } else if (borderRects[0].Contains(point) || borderRects[1].Contains(point) || borderRects[2].Contains(point) || borderRects[3].Contains(point)) { Cursor.Current = Cursors.SizeAll; mousePos = MousePos.Border; } else { Cursor.Current = Cursors.Arrow; } }
// Update is called once per frame void Update() { switch (InputAct) { case TipoInput.Mouse: if (Habilitado) { gameObject.SendMessage("SetGiro", MousePos.Relation(MousePos.AxisRelation.Horizontal)); //debe ser reemplanado } break; case TipoInput.Kinect: //print("Angulo: "+Angulo()); /* * if(ManoIzq.position.y > ManoDer.position.y) * { * DirAct = Sentido.Der; * Diferencia = ManoIzq.position.y - ManoDer.position.y; * } * else * { * DirAct = Sentido.Izq; * Diferencia = ManoDer.position.y - ManoIzq.position.y; * } */ if (ManoIzq.position.y > ManoDer.position.y) { DirAct = Sentido.Der; } else { DirAct = Sentido.Izq; } switch (DirAct) { case Sentido.Der: if (Angulo() <= MaxAng) { Giro = Angulo() / (MaxAng + DesSencibilidad); } else { Giro = 1; } if (Habilitado) { gameObject.SendMessage("SetGiro", Giro); //debe ser reemplanado } break; case Sentido.Izq: if (Angulo() <= MaxAng) { Giro = (Angulo() / (MaxAng + DesSencibilidad)) * (-1); } else { Giro = (-1); } if (Habilitado) { gameObject.SendMessage("SetGiro", Giro); //debe ser reemplanado } break; } break; case TipoInput.AWSD: if (Habilitado) { if (Input.GetKey(KeyCode.A)) { gameObject.SendMessage("SetGiro", -1); } if (Input.GetKey(KeyCode.D)) { gameObject.SendMessage("SetGiro", 1); } } break; case TipoInput.Arrows: if (Habilitado) { if (Input.GetKey(KeyCode.LeftArrow)) { gameObject.SendMessage("SetGiro", -1); } if (Input.GetKey(KeyCode.RightArrow)) { gameObject.SendMessage("SetGiro", 1); } } break; } }
// Start is called before the first frame update void Start() { mRigidbody2D = GetComponent <Rigidbody2D>(); mWall = new Wall(this); mMousePos = new MousePos(); }
void Awake() { _mp = GetComponent<MousePos>(); }