public void Click(RefClickEventArgs e) { if (this.Clicked != null) { this.Clicked(this, e); } }
public void Click(MainForm sender, MouseEventArgs e) { RectangleF guiRect = this.GetGuiRect(sender.ClientSize); if (this.Clicked != null) { RefClickEventArgs newEventArgs = new RefClickEventArgs(e.Button, (e.X - guiRect.X) / guiRect.Width, (e.Y - guiRect.Y) / guiRect.Width); this.Clicked(sender, newEventArgs); } if (!this.GetGuiRect(sender.ClientSize).Contains(new Point(e.X, e.Y))) { sender.CurrentGui = null; } }
public void Click(MainForm sender, MouseEventArgs e, Point prefferedLocation, float prefferedWidth) { PointF clickRefLocation = new PointF((e.X - prefferedLocation.X) / prefferedWidth, (e.Y - prefferedLocation.Y) / prefferedWidth); RefClickEventArgs newEventArgs = new RefClickEventArgs(e.Button, clickRefLocation.X, clickRefLocation.Y); if (this.Clicked != null) { this.Clicked(this, newEventArgs); } RectangleF[] placedItemsRects = new RectangleF[this.PlacedItems.Length]; for (int i = 0; i < this.RefPlacedLocations.Length; i++) { placedItemsRects[i] = new RectangleF(this.RefPlacedLocations[i], new SizeF(1 / (float)3, 1 / (float)3)); } for (int i = 0; i < placedItemsRects.Length; i++) { if (placedItemsRects[i].Contains(clickRefLocation)) { if (this.PlacedItems[i] != null) { RefClickEventArgs placedItemClickEventArgs = new RefClickEventArgs(e.Button, (clickRefLocation.X - this.RefPlacedLocations[i].X) / 3, (clickRefLocation.Y - this.RefPlacedLocations[i].Y) / 3); this.PlacedItems[i].Click(placedItemClickEventArgs); if (e.Button == MouseButtons.Right && this.PlacedItems[i] is IGui) { sender.CurrentGui = (this.PlacedItems[i] as IGui).Gui; } } else { if (sender.HeldItem is IPlacable) { this.PlacedItems[i] = (sender.HeldItem as IPlacable).NewPlacedItem; sender.HeldItem = null; } } } } }
public void Click(object sender, RefClickEventArgs e) { float slotSize = 1 / (float)this.Width; if (e.X > 0 && e.X < 1 && e.Y > slotSize && e.Y < (this.Height + 1) / (float)this.Width) { float inSlotLocationX = e.X % slotSize; float inSlotLocationY = e.Y % slotSize; if (inSlotLocationX > slotSize / 16 && inSlotLocationX < slotSize - slotSize / 16 && inSlotLocationY > slotSize / 16 && inSlotLocationY < slotSize - slotSize / 16) { int slotX = (int)Math.Floor(e.X / slotSize); int slotY = (int)Math.Floor(e.Y / slotSize) - 1; int slotsInLastRow = this.Items.Length % this.Width; if (!(slotY == this.Height - 1 && slotX > slotsInLastRow - 1 && slotsInLastRow != 0)) { int slotIndex = slotX + slotY * this.Width; MainForm form = sender as MainForm; Item oldHeldItem = form.HeldItem; form.HeldItem = this.Items[slotIndex]; this.Items[slotIndex] = oldHeldItem; } } } }