From 59c689b9a221447e7bec1cc00ef7fb2b7662c7ad Mon Sep 17 00:00:00 2001 From: Bitl Date: Mon, 30 Aug 2021 16:47:20 -0700 Subject: [PATCH] fixes --- .../Forms/SDK/XMLContentEditor.Designer.cs | 18 +++++++------ .../Forms/SDK/XMLContentEditor.cs | 27 ++++++++++++++++++- .../Forms/SDK/XMLContentEditor.resx | 2 +- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.Designer.cs b/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.Designer.cs index 1ab5c3e..4bc255f 100644 --- a/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.Designer.cs +++ b/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.Designer.cs @@ -35,12 +35,12 @@ this.partColorsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.XMLView = new System.Windows.Forms.DataGridView(); - this.ContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); + this.XMLContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.insertRowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.deleteRowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.XMLStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.XMLView)).BeginInit(); - this.ContextMenu.SuspendLayout(); + this.XMLContextMenuStrip.SuspendLayout(); this.SuspendLayout(); // // XMLStrip @@ -98,6 +98,7 @@ // // XMLView // + this.XMLView.AllowUserToOrderColumns = true; this.XMLView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); @@ -111,14 +112,15 @@ this.XMLView.Size = new System.Drawing.Size(800, 426); this.XMLView.TabIndex = 30; this.XMLView.CellMouseUp += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.XMLView_CellMouseUp); + this.XMLView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.XMLView_MouseClick); // - // ContextMenu + // XMLContextMenuStrip // - this.ContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.XMLContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.insertRowToolStripMenuItem, this.deleteRowToolStripMenuItem}); - this.ContextMenu.Name = "contextMenuStrip1"; - this.ContextMenu.Size = new System.Drawing.Size(134, 48); + this.XMLContextMenuStrip.Name = "contextMenuStrip1"; + this.XMLContextMenuStrip.Size = new System.Drawing.Size(134, 48); // // insertRowToolStripMenuItem // @@ -149,7 +151,7 @@ this.XMLStrip.ResumeLayout(false); this.XMLStrip.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.XMLView)).EndInit(); - this.ContextMenu.ResumeLayout(false); + this.XMLContextMenuStrip.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -163,7 +165,7 @@ private System.Windows.Forms.ToolStripMenuItem partColorsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; private System.Windows.Forms.DataGridView XMLView; - private System.Windows.Forms.ContextMenuStrip ContextMenu; + private System.Windows.Forms.ContextMenuStrip XMLContextMenuStrip; private System.Windows.Forms.ToolStripMenuItem insertRowToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem deleteRowToolStripMenuItem; } \ No newline at end of file diff --git a/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.cs b/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.cs index c7ade7e..bb80206 100644 --- a/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.cs +++ b/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.cs @@ -47,6 +47,11 @@ public partial class XMLContentEditor : Form private void saveToolStripMenuItem_Click(object sender, EventArgs e) { + if (XMLView.CurrentCell.IsInEditMode) + { + XMLView.EndEdit(); + } + //https://stackoverflow.com/questions/37145086/datagridview-remove-empty-rows-button for (int i = XMLView.Rows.Count - 1; i > -1; i--) { @@ -152,7 +157,7 @@ public partial class XMLContentEditor : Form XMLView.Rows[e.RowIndex].Selected = true; rowIndex = e.RowIndex; XMLView.CurrentCell = XMLView.Rows[e.RowIndex].Cells[1]; - ContextMenu.Show(Cursor.Position); + XMLContextMenuStrip.Show(Cursor.Position); } } @@ -171,6 +176,20 @@ public partial class XMLContentEditor : Form XMLView.Rows.Insert(rowIndex, 1); } } + + //https://stackoverflow.com/questions/14431936/how-to-force-datagridviewcell-to-end-edit-when-row-header-is-clicked/14498870 + private void XMLView_MouseClick(object sender, MouseEventArgs e) + { + if (XMLView.HitTest(e.X, e.Y).Type == DataGridViewHitTestType.RowHeader) + { + XMLView.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2; + XMLView.EndEdit(); + } + else + { + XMLView.EditMode = DataGridViewEditMode.EditOnEnter; + } + } #endregion #region Functions @@ -217,16 +236,22 @@ public partial class XMLContentEditor : Form { XMLView.ColumnCount = 3; XMLView.Columns[0].Name = "Name"; + XMLView.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable; XMLView.Columns[1].Name = "URL"; + XMLView.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable; XMLView.Columns[2].Name = "Icon File"; + XMLView.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; ListType = XMLContentType.ContentProviders; } else if (loaderList.OfType().Any()) { XMLView.ColumnCount = 3; XMLView.Columns[0].Name = "Name"; + XMLView.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable; XMLView.Columns[1].Name = "ID"; + XMLView.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable; XMLView.Columns[2].Name = "RGB Value"; + XMLView.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; ListType = XMLContentType.PartColors; } diff --git a/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.resx b/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.resx index 776c5c0..20e8908 100644 --- a/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.resx +++ b/Novetus/NovetusLauncher/Forms/SDK/XMLContentEditor.resx @@ -120,7 +120,7 @@ 17, 17 - + 118, 17