diff --git a/NHSE.WinForms/Controls/ItemGrid.cs b/NHSE.WinForms/Controls/ItemGrid.cs index 98f239f..4be449e 100644 --- a/NHSE.WinForms/Controls/ItemGrid.cs +++ b/NHSE.WinForms/Controls/ItemGrid.cs @@ -39,7 +39,6 @@ private void Generate(int width, int height) int colWidth = sizeW; int rowHeight = sizeH; - Location = new Point(0, Location.Y); // prevent auto-expanding parent if position changes (centered) for (int row = 0; row < height; row++) { var y = padEdge + (row * (rowHeight + border)); @@ -60,8 +59,6 @@ private void Generate(int width, int height) ResumeLayout(); } - public void SetBackground(Image img) => BackgroundImage = img; - public static PictureBox GetControl(int width, int height) { return new PictureBox diff --git a/NHSE.WinForms/Controls/ItemGridEditor.Designer.cs b/NHSE.WinForms/Controls/ItemGridEditor.Designer.cs index 0d04f7b..31985ba 100644 --- a/NHSE.WinForms/Controls/ItemGridEditor.Designer.cs +++ b/NHSE.WinForms/Controls/ItemGridEditor.Designer.cs @@ -29,7 +29,7 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.itemGrid1 = new NHSE.WinForms.ItemGrid(); + this.ItemGrid = new NHSE.WinForms.ItemGrid(); this.B_Up = new System.Windows.Forms.Button(); this.B_Down = new System.Windows.Forms.Button(); this.L_Page = new System.Windows.Forms.Label(); @@ -38,23 +38,32 @@ private void InitializeComponent() this.Menu_View = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_Set = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_Delete = new System.Windows.Forms.ToolStripMenuItem(); + this.B_Clear = new System.Windows.Forms.Button(); + this.FLP_Controls = new System.Windows.Forms.FlowLayoutPanel(); + this.PAN_Navigation = new System.Windows.Forms.Panel(); this.CM_Hand.SuspendLayout(); + this.FLP_Controls.SuspendLayout(); + this.PAN_Navigation.SuspendLayout(); this.SuspendLayout(); // - // itemGrid1 + // ItemGrid // - this.itemGrid1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.itemGrid1.Location = new System.Drawing.Point(1, 27); - this.itemGrid1.Margin = new System.Windows.Forms.Padding(0); - this.itemGrid1.Name = "itemGrid1"; - this.itemGrid1.Size = new System.Drawing.Size(170, 142); - this.itemGrid1.TabIndex = 0; + this.ItemGrid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.ItemGrid.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.ItemGrid.Location = new System.Drawing.Point(0, 24); + this.ItemGrid.Margin = new System.Windows.Forms.Padding(0); + this.ItemGrid.Name = "ItemGrid"; + this.ItemGrid.Size = new System.Drawing.Size(163, 142); + this.ItemGrid.TabIndex = 0; // // B_Up // - this.B_Up.Location = new System.Drawing.Point(176, 53); + this.B_Up.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.B_Up.Location = new System.Drawing.Point(3, 3); this.B_Up.Name = "B_Up"; - this.B_Up.Size = new System.Drawing.Size(41, 30); + this.B_Up.Size = new System.Drawing.Size(64, 30); this.B_Up.TabIndex = 3; this.B_Up.Text = "↑\t"; this.B_Up.UseVisualStyleBackColor = true; @@ -63,9 +72,11 @@ private void InitializeComponent() // // B_Down // - this.B_Down.Location = new System.Drawing.Point(176, 106); + this.B_Down.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.B_Down.Location = new System.Drawing.Point(3, 59); this.B_Down.Name = "B_Down"; - this.B_Down.Size = new System.Drawing.Size(42, 29); + this.B_Down.Size = new System.Drawing.Size(64, 29); this.B_Down.TabIndex = 4; this.B_Down.Text = "↓"; this.B_Down.UseVisualStyleBackColor = true; @@ -74,22 +85,26 @@ private void InitializeComponent() // // L_Page // + this.L_Page.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.L_Page.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.L_Page.Location = new System.Drawing.Point(169, 84); + this.L_Page.Location = new System.Drawing.Point(3, 36); this.L_Page.Name = "L_Page"; - this.L_Page.Size = new System.Drawing.Size(56, 20); + this.L_Page.Size = new System.Drawing.Size(64, 20); this.L_Page.TabIndex = 5; this.L_Page.Text = "250/250"; this.L_Page.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // L_ItemName // - this.L_ItemName.AutoSize = true; - this.L_ItemName.Location = new System.Drawing.Point(3, 9); + this.L_ItemName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.L_ItemName.Location = new System.Drawing.Point(3, 0); this.L_ItemName.Name = "L_ItemName"; - this.L_ItemName.Size = new System.Drawing.Size(39, 13); + this.L_ItemName.Size = new System.Drawing.Size(233, 24); this.L_ItemName.TabIndex = 6; this.L_ItemName.Text = "(None)"; + this.L_ItemName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // CM_Hand // @@ -121,26 +136,58 @@ private void InitializeComponent() this.Menu_Delete.Text = "Delete"; this.Menu_Delete.Click += new System.EventHandler(this.ClickDelete); // + // B_Clear + // + this.B_Clear.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.B_Clear.Location = new System.Drawing.Point(3, 110); + this.B_Clear.Name = "B_Clear"; + this.B_Clear.Size = new System.Drawing.Size(64, 29); + this.B_Clear.TabIndex = 7; + this.B_Clear.Text = "Clear"; + this.B_Clear.UseVisualStyleBackColor = true; + this.B_Clear.Click += new System.EventHandler(this.B_Clear_Click); + // + // FLP_Controls + // + this.FLP_Controls.Controls.Add(this.L_ItemName); + this.FLP_Controls.Controls.Add(this.ItemGrid); + this.FLP_Controls.Controls.Add(this.PAN_Navigation); + this.FLP_Controls.Dock = System.Windows.Forms.DockStyle.Fill; + this.FLP_Controls.Location = new System.Drawing.Point(0, 0); + this.FLP_Controls.Name = "FLP_Controls"; + this.FLP_Controls.Size = new System.Drawing.Size(241, 197); + this.FLP_Controls.TabIndex = 8; + // + // PAN_Navigation + // + this.PAN_Navigation.Controls.Add(this.B_Up); + this.PAN_Navigation.Controls.Add(this.L_Page); + this.PAN_Navigation.Controls.Add(this.B_Down); + this.PAN_Navigation.Controls.Add(this.B_Clear); + this.PAN_Navigation.Location = new System.Drawing.Point(163, 24); + this.PAN_Navigation.Margin = new System.Windows.Forms.Padding(0); + this.PAN_Navigation.Name = "PAN_Navigation"; + this.PAN_Navigation.Size = new System.Drawing.Size(70, 142); + this.PAN_Navigation.TabIndex = 9; + // // ItemGridEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.L_ItemName); - this.Controls.Add(this.B_Down); - this.Controls.Add(this.B_Up); - this.Controls.Add(this.itemGrid1); - this.Controls.Add(this.L_Page); + this.Controls.Add(this.FLP_Controls); this.Name = "ItemGridEditor"; - this.Size = new System.Drawing.Size(224, 170); + this.Size = new System.Drawing.Size(241, 197); this.CM_Hand.ResumeLayout(false); + this.FLP_Controls.ResumeLayout(false); + this.PAN_Navigation.ResumeLayout(false); this.ResumeLayout(false); - this.PerformLayout(); } #endregion - private ItemGrid itemGrid1; + private ItemGrid ItemGrid; private System.Windows.Forms.Button B_Up; private System.Windows.Forms.Button B_Down; private System.Windows.Forms.Label L_Page; @@ -149,5 +196,8 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem Menu_View; private System.Windows.Forms.ToolStripMenuItem Menu_Set; private System.Windows.Forms.ToolStripMenuItem Menu_Delete; + private System.Windows.Forms.Button B_Clear; + private System.Windows.Forms.FlowLayoutPanel FLP_Controls; + private System.Windows.Forms.Panel PAN_Navigation; } } diff --git a/NHSE.WinForms/Controls/ItemGridEditor.cs b/NHSE.WinForms/Controls/ItemGridEditor.cs index 5388330..24db0c6 100644 --- a/NHSE.WinForms/Controls/ItemGridEditor.cs +++ b/NHSE.WinForms/Controls/ItemGridEditor.cs @@ -31,23 +31,34 @@ public ItemGridEditor(ItemEditor editor, IReadOnlyList items, string[] ite public void InitializeGrid(int width, int height) { ItemsPerPage = width * height; - itemGrid1.InitializeGrid(width, height, Sprites); + ItemGrid.InitializeGrid(width, height, Sprites); InitializeSlots(); } private void InitializeSlots() { - SlotPictureBoxes = itemGrid1.Entries; + SlotPictureBoxes = ItemGrid.Entries; foreach (var pb in SlotPictureBoxes) { pb.MouseEnter += Slot_MouseEnter; pb.MouseLeave += Slot_MouseLeave; pb.MouseClick += Slot_MouseClick; + pb.MouseWheel += Slot_MouseWheel; pb.ContextMenuStrip = CM_Hand; } ChangePage(); } + private void Slot_MouseWheel(object sender, MouseEventArgs e) + { + var delta = e.Delta < 0 ? 1 : -1; // scrolling down increases page # + var newpage = Math.Min(PageCount - 1, Math.Max(0, Page + delta)); + if (newpage == Page) + return; + Page = newpage; + ChangePage(); + } + public void Slot_MouseEnter(object? sender, EventArgs e) { if (!(sender is PictureBox pb)) @@ -191,5 +202,16 @@ public void LoadItems() SlotPictureBoxes[i].BackgroundImage = Sprites.GetImage(item, L_ItemName.Font); } } + + private void B_Clear_Click(object sender, EventArgs e) + { + for (int i = 0; i < SlotPictureBoxes.Count; i++) + { + var item = GetItem(i); + item.Delete(); + } + LoadItems(); + System.Media.SystemSounds.Asterisk.Play(); + } } } diff --git a/NHSE.WinForms/Subforms/PlayerItemEditor.Designer.cs b/NHSE.WinForms/Subforms/PlayerItemEditor.Designer.cs index 50feb71..a031329 100644 --- a/NHSE.WinForms/Subforms/PlayerItemEditor.Designer.cs +++ b/NHSE.WinForms/Subforms/PlayerItemEditor.Designer.cs @@ -37,7 +37,7 @@ private void InitializeComponent() // B_Cancel // this.B_Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.B_Cancel.Location = new System.Drawing.Point(244, 234); + this.B_Cancel.Location = new System.Drawing.Point(258, 228); this.B_Cancel.Name = "B_Cancel"; this.B_Cancel.Size = new System.Drawing.Size(72, 23); this.B_Cancel.TabIndex = 5; @@ -48,7 +48,7 @@ private void InitializeComponent() // B_Save // this.B_Save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.B_Save.Location = new System.Drawing.Point(322, 234); + this.B_Save.Location = new System.Drawing.Point(336, 228); this.B_Save.Name = "B_Save"; this.B_Save.Size = new System.Drawing.Size(72, 23); this.B_Save.TabIndex = 4; @@ -65,7 +65,7 @@ private void InitializeComponent() this.TC_Groups.Name = "TC_Groups"; this.TC_Groups.Padding = new System.Drawing.Point(9, 9); this.TC_Groups.SelectedIndex = 0; - this.TC_Groups.Size = new System.Drawing.Size(233, 219); + this.TC_Groups.Size = new System.Drawing.Size(247, 213); this.TC_Groups.TabIndex = 3; // // ItemEditor @@ -73,16 +73,16 @@ private void InitializeComponent() this.ItemEditor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); this.ItemEditor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.ItemEditor.Location = new System.Drawing.Point(244, 12); + this.ItemEditor.Location = new System.Drawing.Point(258, 12); this.ItemEditor.Name = "ItemEditor"; - this.ItemEditor.Size = new System.Drawing.Size(150, 216); + this.ItemEditor.Size = new System.Drawing.Size(150, 210); this.ItemEditor.TabIndex = 6; // // PlayerItemEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(406, 267); + this.ClientSize = new System.Drawing.Size(420, 261); this.Controls.Add(this.ItemEditor); this.Controls.Add(this.B_Cancel); this.Controls.Add(this.B_Save);