public Belt(Widget parent) : base(parent) { slots = new List <BeltSlot>(SlotCount); int w = 0; int h = 0; var layout = new GridLayout(); for (int i = 0; i < SlotCount; i++) { int index = i; int keyIndex = (i + 1) % 10; var slot = new BeltSlot(this); slot.Label = keyIndex.ToString(); slot.Click += OnSlotClick; slot.Drop += OnSlotDrop; slot.ItemDrop += OnSlotItemDrop; slots.Add(slot); int column = layout.ColumnCount; layout.AddWidget(slot, 0, column); layout.SetColumnWidth(column, slot.Width - 1); w += slot.Width - 1; h = Math.Max(h, slot.Height); Host.Hotkeys.Register(Key.Number1 + keyIndex - 1, () => Click.Raise(new BeltClickEvent(index, MouseButton.Left, 0))); } layout.Spacing = -1; layout.UpdateGeometry(0, 0, 0, 0); this.Resize(w, h); }
public virtual bool Update(float deltaTime, InputDevice inputDevice) { if (!IsEnabled) { return(false); } var position = inputDevice.Position; var shape = GetBoundingRectangle(); var previouslyPressed = IsPressed; IsPressed = inputDevice.IsTouching && shape.Contains(position); if (!previouslyPressed && IsPressed) { Pressed.Raise(this, EventArgs.Empty); } if (previouslyPressed && !IsPressed) { Released.Raise(this, EventArgs.Empty); if (shape.Contains(position)) { Click.Raise(this, EventArgs.Empty); } } return(true); }
protected override void OnMouseButtonDown(MouseButtonEvent e) { if (e.Button == MouseButton.Left) { Click.Raise(this, EventArgs.Empty); } }
private void OnSlotClick(object sender, MouseButtonEvent e) { int index = slots.IndexOf((BeltSlot)sender); if (index != -1) { Click.Raise(new BeltClickEvent(index, e.Button, e.Modifiers)); } }
protected override void OnRelease(Rectangle shape, Vector2 touchPosition) { IsPressed = false; if (shape.Contains(touchPosition)) { Click.Raise(this, EventArgs.Empty); } }
protected override void OnMouseButtonUp(MouseButtonEvent e) { if (e.Button == MouseButton.Left) { if (isPressed) { isPressed = false; Host.ReleaseMouse(); Click.Raise(this, e); } } }
protected override void OnMouseButtonUp(MouseButtonEvent e) { Host.ReleaseMouse(); isPressed = false; // button released outside of borders? var p = MapFromScreen(e.Position); if (CheckHit(p.X + X, p.Y + Y)) { Click.Raise(); } e.Handled = true; }
protected override void OnMouseButtonDown(MouseButtonEvent e) { if (e.Button == MouseButton.Left) { if (e.Modifiers.HasShift()) { Transfer.Raise(); } else { Click.Raise(); } e.Handled = true; } }
protected override void OnMouseButtonUp(MouseButtonEvent e) { if (e.Button != MouseButton.Left) { return; } Host.ReleaseMouse(); isPressed = false; // button released outside of borders? var p = MapFromScreen(e.Position); if (Rect.FromLTRB(0, 0, Width, Height).Contains(p)) { Click.Raise(); } e.Handled = true; }
private void OnAvatarClick(AvatarView sender, MouseButtonEvent e) { Click.Raise(new CombatRelationClickEvent(e.Button, this)); }
protected override void OnMouseButtonDown(MouseButtonEvent e) { Click.Raise(e); }
private void OnButtonClick(object sender, EventArgs e) { var button = (TabButton)sender; Click.Raise(buttons.IndexOf(button)); }
private void OnRelationClick(CombatRelationClickEvent e) { Click.Raise(e); }