protected virtual void OnMouseButtonPressed(object sender, MouseButtonEventArgs e) { foreach (var w in Widgets) { w.Update(e.X, e.Y, true); } }
private void Window_MouseButtonPressed(object sender, SFML.Window.MouseButtonEventArgs e) { if (bottomSprite.GetGlobalBounds().Contains(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y)) { window.Close(); } else if (topSprite.GetGlobalBounds().Contains(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y)) { window.MouseButtonPressed -= Window_MouseButtonPressed; window.SetFramerateLimit(settingsMenu.FrameLimit); game.IsRunning = true; RunGame(); } if (settings.GetGlobalBounds().Contains(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y)) { window.MouseButtonPressed -= Window_MouseButtonPressed; settingsMenu.ActivateEvents(); ShowSettingsMenu(); } if (lBoard.GetGlobalBounds().Contains(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y)) { window.MouseButtonPressed -= Window_MouseButtonPressed; ShowLeaderBoardMenu(); } }
private void OnMouseButtonReleased(object sender, SFML.Window.MouseButtonEventArgs e) { Stopwatch stopwatch = this.buttonToStopwatch[e.Button]; stopwatch.Stop(); if (stopwatch.ElapsedMilliseconds < 200) { if (e.Button == Button.Left) { this.NotifyControlActivated(ControlEventType.MOUSE_LEFT_CLICK, "click"); } else if (e.Button == Button.Right) { this.NotifyControlActivated(ControlEventType.MOUSE_RIGHT_CLICK, "click"); } } if (e.Button == Button.Left) { this.NotifyControlActivated(ControlEventType.MOUSE_LEFT_CLICK, "released"); } else if (e.Button == Button.Right) { this.NotifyControlActivated(ControlEventType.MOUSE_RIGHT_CLICK, "released"); } this.buttonToStopwatch.Remove(e.Button); }
/// <summary> /// Handles when the CreateAccount button is clicked. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="SFML.Window.MouseButtonEventArgs"/> instance containing the event data.</param> void ClickButton_CreateAccount(object sender, MouseButtonEventArgs e) { // Manually check for invalid values before checking with the server if (!GameData.AccountName.IsValid(_cNameText.Text)) { SetError(GameMessageCollection.CurrentLanguage.GetMessage(GameMessage.CreateAccountInvalidName)); return; } if (!GameData.AccountPassword.IsValid(_cPasswordText.Text)) { SetError(GameMessageCollection.CurrentLanguage.GetMessage(GameMessage.CreateAccountInvalidPassword)); return; } if (!GameData.AccountEmail.IsValid(_cEmailText.Text)) { SetError(GameMessageCollection.CurrentLanguage.GetMessage(GameMessage.CreateAccountInvalidEmail)); return; } // Disconnect if already connected if (_sockets.IsConnected) _sockets.Disconnect(); // Start connecting to the server SetMessage("Connecting to server..."); _sockets.Connect(); }
/// <summary> /// Handle mouse released /// </summary> /// <param name="sender">Object sender</param> /// <param name="e">Event arguments</param> private void MouseButtonReleased(object sender, SFML.Window.MouseButtonEventArgs e) { //nice it's the right button ! //Or mabe the right left button ^^ //(in fact left is the right button to check !) // //OverControl can't be null, we can click on null ! if (e.Button == Mouse.Button.Left && GuiManager.OverControl != null) { //to perform a click, last press position must be in the control bounds !! if (GuiManager.OverControl.Bounds.Contains(this._pressPosition)) { //hey we click play my sound pls ! if (GuiManager.OverControl is IAudioable) { IAudioable audio = (IAudioable)GuiManager.OverControl; this._audioManager.PlaySound(audio.ClickSoundKey); } GuiManager.OverControl.OnClick(e); } //ok release is finish so switch last press position to null :) this._pressPosition = null; } }
public static void OnMouseButtonPressed(object sender, MouseButtonEventArgs e) { if (e.Button == Mouse.Button.Right) { EntityManager.Character.CurrentSkill.Cast(EntityManager.Character, e.X, e.Y); } }
public override bool MouseDown(MouseButtonEventArgs e) { if (!ClientArea.Contains(new Point((int)e.X, (int)e.Y))) return false; var spritePosition = new Point((int)e.X - Position.X + (int)_elementSprite.ImageOffset.X, (int)e.Y - Position.Y + (int)_elementSprite.ImageOffset.Y); // Image.ImageLockBox imgData = _elementSprite.Image.GetImageData(); //imgData.Lock(false); Color pixColour = Color.Red; //imgData.Dispose(); //imgData.Unlock(); if (pixColour.A != 0) { if (Clicked != null) Clicked(this); _clickPoint = new Point((int)e.X - Position.X, (int)e.Y - Position.Y); _selected = true; return true; } _selected = false; return false; }
public override bool MouseDown(MouseButtonEventArgs e) { if (!ClientArea.Contains(e.X, e.Y)) return false; TargetingDummyElement prevSelection = (from element in _elements where element.IsSelected() select element).FirstOrDefault(); foreach (TargetingDummyElement toClear in _elements) toClear.ClearSelected(); foreach (TargetingDummyElement current in _elements.ToArray()) //To array because list order changes in loop. { if (current.MouseDown(e)) { _elements = (from a in _elements orderby (a == current) ascending select a).ToList(); return true; } } if (prevSelection != null) prevSelection.Select(); return false; }
private static void Window_MouseButtonPressed(object sender, SFML.Window.MouseButtonEventArgs e) { if (Button.GetGlobalBounds().Contains(Mouse.GetPosition(Program.window).X, Mouse.GetPosition(Program.window).Y)) { GameSet.ActiveMenu = 1; } }
public override bool MouseUp(MouseButtonEventArgs e) { if (ClientArea.Contains(e.X, e.Y)) { return true; } return false; }
private void Window_MouseButtonPressed(object sender, SFML.Window.MouseButtonEventArgs e) { if (back.GetGlobalBounds().Contains(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y)) { window.MouseButtonPressed -= Window_MouseButtonPressed; IsFinished = true; } }
/// <summary> /// Handles when the Close button on the form is clicked. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="SFML.Window.MouseButtonEventArgs"/> instance containing the event data.</param> protected override void CloseButtonClicked(object sender, MouseButtonEventArgs e) { // Since we have to let the server know what our chat state is, we can't just close the window. Instead, // make a request to the server that we want to end the chat dialog. If the server allows it, then it // will eventually close. if (RequestEndDialog != null) RequestEndDialog.Raise(this, EventArgs.Empty); }
public override bool MouseDown(MouseButtonEventArgs e) { if (ClientArea.Contains(new Point((int) e.X, (int) e.Y))) { return true; } return false; }
public override bool MouseDown(MouseButtonEventArgs e) { if (ClientArea.Contains(new Point((int) e.X, (int) e.Y))) { if (Clicked != null) Clicked(this, associatedTemplate, associatedTemplateName); return true; } return false; }
public override bool MouseDown(MouseButtonEventArgs e) { if (ClientArea.Contains(e.X, e.Y)) { Value = !Value; return true; } return false; }
public override bool MouseDown(MouseButtonEventArgs e) { if (ClientArea.Contains(e.X, e.Y)) { if (Clicked != null) Clicked(this); return true; } return false; }
public override bool MouseDown(MouseButtonEventArgs e) { if (ClientArea.Contains(e.X, e.Y)) { ResetEntity(); return true; } return false; }
public override bool MouseDown(MouseButtonEventArgs e) { var mousePoint = new Vector2i(e.X, e.Y); if ((mousePoint - Position).LengthSquared() <= 3*3) dragging = true; return false; }
/// <summary> /// Funkcja wywoływana przez zdazrenie wcisniecia klawisza myszy /// </summary> /// <param name="sender">obiekt wysylajacy zdarzenie</param> /// <param name="e">argumenty zdarzenia</param> public virtual void Window_MouseButtonPressed(object sender, MouseButtonEventArgs e) { if ( InsideElement(e.X, e.Y) ) { EventHandler<MouseButtonEventArgs> handler = MouseButtonPressed; handler?.Invoke(sender, e); } if ( IsSelected ) { } }
/// <summary> /// Handles the Clicked event of the logOutLbl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="SFML.Window.MouseButtonEventArgs"/> instance containing the event data.</param> void logOutLbl_Clicked(object sender, MouseButtonEventArgs e) { if (e.Button != Mouse.Button.Left) return; if (ClickedLogOut != null) ClickedLogOut.Raise(this, EventArgs.Empty); IsVisible = !IsVisible; }
public override bool MouseUp(MouseButtonEventArgs e) { if (ClientArea.Contains(new Point((int) e.X, (int) e.Y)) && IoCManager.Resolve<IUserInterfaceManager>().DragInfo.IsActive) { if (Dropped != null) Dropped(this); return true; } return false; }
public override bool MouseDown(MouseButtonEventArgs e) { if (!base.MouseDown(e)) if (input.MouseDown(e)) { IoCManager.Resolve<IUserInterfaceManager>().SetFocus(input); return true; } return false; }
void ClickButton_DeleteCharacter(Control sender, MouseButtonEventArgs args) { var s = (CharacterSlotControl)sender; var ci = s.CharInfo; if (ci == null) return; var mb = new DeleteCharacterMessageBox(GUIManager, ci.Name, ci.Index) { Font = GameScreenHelper.DefaultChatFont }; mb.DeleteRequested += DeleteCharacterMsgBox_DeleteRequested; }
/// <summary> /// Returns event position of MouseButtonEvent where it would be if the window wasn't resized /// See Terminology above /// </summary> public MouseButtonEventArgs EventToWindowPos(MouseButtonEventArgs mouseButtonEvent) { Vector2i windowPos = (Vector2i)_window.MapPixelToCoords( new Vector2i((int)mouseButtonEvent.X, (int)mouseButtonEvent.Y), _interfaceView); MouseButtonEvent newMouseEvent = new MouseButtonEvent(); newMouseEvent.X = windowPos.X; newMouseEvent.Y = windowPos.Y; newMouseEvent.Button = mouseButtonEvent.Button; MouseButtonEventArgs eventArgsWindowPos = new MouseButtonEventArgs(newMouseEvent); return eventArgsWindowPos; }
public override bool MouseDown(MouseButtonEventArgs e) { if (!Available) return false; if (_buttonArea.Contains(e.X, e.Y)) { if (Clicked != null) Clicked(this); Selected = true; return true; } return false; }
private void Window_MouseButtonPressed(object sender, SFML.Window.MouseButtonEventArgs e) { if (size > 0 && okButton.GetGlobalBounds().Contains(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y)) { window.MouseButtonPressed -= Window_MouseButtonPressed; window.TextEntered -= Window_TextEntered; game.Controller.Score.Name = inputText; game.Leaderboard.Add(inputText, game.Controller.Score); IsFinished = true; } }
void _cScreen_Clicked(Control sender, SFML.Window.MouseButtonEventArgs e) { var keyComboPressed = Keyboard.IsKeyPressed(ClientSettings.Default.Keys_ClickWarp) && Keyboard.IsKeyPressed(ClientSettings.Default.Keys_ClickWarp2); if (ClickWarpMode || keyComboPressed) { Vector2 worldPos = Map.Camera.ToWorld(new Vector2(e.X, e.Y)); using (var pw = ClientPacket.ClickWarp(worldPos)) Socket.Send(pw, ClientMessageType.General); } }
public static void MouseButtonDownHandler(object sender, MouseButtonEventArgs e) { if (e.Button == Mouse.Button.Left && !Render.CoreRender.EventRun) { Render.CoreRender.EventRun = true; Render.CoreRender.x = e.X - 50; Render.CoreRender.y = e.Y - 120; Console.WriteLine(e.X + " " + e.Y); Console.WriteLine(Game_Objects.Player.Instanse.xPosition + " " + Game_Objects.Player.Instanse.yPosition); //events.Move(e.X, e.Y); } }
public override bool MouseUp(MouseButtonEventArgs e) { if (ClientArea.Contains(new Point((int) e.X, (int) e.Y))) { if (_userInterfaceManager.DragInfo.IsEntity && _userInterfaceManager.DragInfo.IsActive) { SetEntity(_userInterfaceManager.DragInfo.DragEntity); _userInterfaceManager.DragInfo.Reset(); return true; } } return false; }
public override void MouseClick(MouseButtonEventArgs e) { if(e.Button == Mouse.Button.Left) { //target = CurrentMap.PlayerShip; } else if(e.Button == Mouse.Button.Right) { WM.parent.RWindow.SetView(GameView); CurrentMap.PlayerShip.MoveTo(WM.parent.RWindow.MapPixelToCoords(Mouse.GetPosition(WM.parent.RWindow)).X, WM.parent.RWindow.MapPixelToCoords(Mouse.GetPosition(WM.parent.RWindow)).Y); WM.parent.RWindow.SetView(WM.parent.RWindow.DefaultView); } }
public override bool MouseDown(MouseButtonEventArgs e) { if (!IsVisible()) return false; if (clientAreaButton.Contains((int) e.X, (int) e.Y)) { dragging = true; return true; } else if (ClientArea.Contains((int) e.X, (int) e.Y)) { return true; } return false; }
public override bool MouseDown(MouseButtonEventArgs e) { if (ClientArea.Contains(new Point((int) e.X, (int) e.Y))) { var insidePos = new Vector2((int) e.X , (int) e.Y ); if ((insidePos - new Vector2(189, 9)).Length <= 5) { _uiMgr.RemoveComponent(this); Dispose(); } else if (insidePos.Y <= 18) dragging = true; return true; } return false; }
void ClickButton_CharacterSelection(object sender, MouseButtonEventArgs e) { var src = (CharacterSlotControl)sender; var slot = src.Slot; AccountCharacterInfo charInfo; if (!_sockets.PacketHandler.AccountCharacterInfos.TryGetInfo(slot, out charInfo)) ScreenManager.SetScreen<CreateCharacterScreen>(); else { using (var pw = ClientPacket.SelectAccountCharacter(slot)) { _sockets.Send(pw, ClientMessageType.System); } } }
/// <summary> /// Handles the <see cref="Control.MouseUp"/> event from the <see cref="EquippedItemPB"/>s /// on this form. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MouseButtonEventArgs"/> instance containing the event data.</param> void EquippedItemPB_OnMouseUp(object sender, MouseButtonEventArgs e) { if (UserEquipped == null) return; var slot = ((EquippedItemPB)sender).Slot; if (UserEquipped[slot] == null) return; switch (e.Button) { case MouseButton.Right: if (RequestUnequip != null) RequestUnequip.Raise(this, EventArgsHelper.Create(slot)); break; } }
void ClickButton_CreateCharacter(object sender, MouseButtonEventArgs e) { var name = _txtName.Text; if (!GameData.UserName.IsValid(name)) { SetError("Invalid character name."); return; } _btnCreateCharacter.IsEnabled = false; using (var pw = ClientPacket.CreateNewAccountCharacter(name)) { _sockets.Send(pw, ClientMessageType.System); } }
private void OnMouseDown(object sender, SFML.Window.MouseButtonEventArgs e) { Window selectedWindow = null; foreach (var window in windows) { if (window.GetBounds().Contains(App.MapPixelToCoords(new SFML.System.Vector2i(e.X, e.Y), window.WindowView ?? App.GetView()))) { selectedWindow = window; break; } } if (selectedWindow != null) { windows.Remove(selectedWindow); windows.Insert(0, selectedWindow); } }
private void HandleMouseButtonPress(object _, SFML.Window.MouseButtonEventArgs args) { Vector2u tile_coord = new Vector2u( (uint)System.Math.Ceiling((float)((args.X - WindowSize.X / 2) / Scale + Game.Player.Position.X) / (float)(TEXTURE_SIZE)-0.5), (uint)System.Math.Ceiling((float)((args.Y - WindowSize.Y / 2) / Scale + Game.Player.Position.Y) / (float)(TEXTURE_SIZE))); uint bound_north = 1; uint bound_west = 1; uint bound_east = (uint)Game.Tiles.GetLength(0) - 2; uint bound_south = (uint)Game.Tiles.GetLength(1) - 2; if (tile_coord.X < bound_north || tile_coord.Y < bound_west || tile_coord.X > bound_east || tile_coord.Y > bound_south) { return; } switch (args.Button) { case Mouse.Button.Left: if (Game.Tiles[tile_coord.X, tile_coord.Y].Kind == Tile.TKind.Lever) { Game.ActivateTile(tile_coord); } else { Game.PlaceTile(tile_coord, Game.Player.Hotbar.IndexTile); } break; case Mouse.Button.Right: Game.PlaceTile(tile_coord, new Tile(Tile.TKind.Void)); break; case Mouse.Button.Middle: Tile tile_under_cursor = Game.Tiles[tile_coord.X, tile_coord.Y]; tile_under_cursor.Activity = false; tile_under_cursor.Variant = 0; Game.Player.Hotbar.IndexTile = tile_under_cursor; // Pick tile break; } }
public override bool MouseDown(MouseButtonEventArgs e) { switch (e.Button) { case Mouse.Button.Right: if (handL.Contains(e.X, e.Y)) { SendSwitchHandTo(InventoryLocation.HandLeft); return true; } if (handR.Contains(e.X, e.Y)) { SendSwitchHandTo(InventoryLocation.HandRight); return true; } break; } return false; }
private void ClickEvent(object sender, SFML.Window.MouseButtonEventArgs e) { if (Program.window.HasFocus() && !editing && !Program.placingMode && e.Button == Mouse.Button.Left) { Vector2i posG = Mouse.GetPosition(Program.window); Vector2f pos = Program.window.MapPixelToCoords(posG); if (pos.X >= Position.X - Origin.X && pos.Y >= Position.Y - Origin.Y && pos.X <= Position.X + Size.X - Origin.X && pos.Y <= Position.Y + Size.Y - Origin.Y) { if (Keyboard.IsKeyPressed(Keyboard.Key.Subtract) || Keyboard.IsKeyPressed(Keyboard.Key.Delete) || Keyboard.IsKeyPressed(Keyboard.Key.D)) { toRemove = this; } else { OnClick(); } } } }
void ClickButton_CreateCharacter(object sender, MouseButtonEventArgs e) { var name = _txtName.Text; // Validate the name client-side before talking to the server if (!GameData.UserName.IsValid(name)) { SetError(_invalidCharacterNameMessage); return; } // Disable the button while we wait for a response _btnCreateCharacter.IsEnabled = false; // Send request to server using (var pw = ClientPacket.CreateNewAccountCharacter(name)) { _sockets.Send(pw, ClientMessageType.System); } }
private static void window_MouseButtonReleased(object sender, Window.MouseButtonEventArgs e) { if (e.Button != SFML.Window.Mouse.Button.Left) { return; } if (selectedCell.X == -1 || selectedCell.Y == -1) { if (e.X <= Offset.X) { running = !running; } return; } int x = selectedCell.X; int y = selectedCell.Y; switch (Cells[x][y].Key) { case LiveState.Emerging: Cells[x][y] = Switch(Cells[x][y], LiveState.Live); break; case LiveState.Live: Cells[x][y] = Switch(Cells[x][y], LiveState.Dying); break; case LiveState.Dying: Cells[x][y] = Switch(Cells[x][y], LiveState.Dead); break; case LiveState.Dead: Cells[x][y] = Switch(Cells[x][y], LiveState.Emerging); break; } }
private void OnMouseButtonPressed(object sender, SFML.Window.MouseButtonEventArgs e) { Stopwatch stopwatch = new Stopwatch(); if (this.buttonToStopwatch.TryGetValue(e.Button, out Stopwatch oldStopwatch)) { oldStopwatch.Stop(); this.buttonToStopwatch[e.Button] = stopwatch; } else { this.buttonToStopwatch.Add(e.Button, stopwatch); } stopwatch.Start(); if (e.Button == Button.Left) { this.NotifyControlActivated(ControlEventType.MOUSE_LEFT_CLICK, "pressed"); } else if (e.Button == Button.Right) { this.NotifyControlActivated(ControlEventType.MOUSE_RIGHT_CLICK, "pressed"); } }
private void RenderContext_MouseButtonPressed(object sender, SFML.Window.MouseButtonEventArgs e) { isZoom = true; _selectionStartPoint = new Vector2f(e.X, e.Y); }
public override void HandleInput(SFML.Window.MouseButtonEventArgs buttonEventArgs) { }
private void RenderContext_MouseButtonReleased(object sender, SFML.Window.MouseButtonEventArgs e) { isZoom = false; _selectionRect = new IntRect(); _selectionStartPoint = new Vector2f(); }
private void OnMouseButtonPressed(object sender, SFML.Window.MouseButtonEventArgs e) { }
private void RenderWindow_MouseButtonPressed(object sender, SFML.Window.MouseButtonEventArgs e) { this._circle.Position = new Vector2f(e.X, e.Y); }