Skip to content

Commit

Permalink
adding row reordering to .Net Regex converter broke the Enabled check…
Browse files Browse the repository at this point in the history
…box editing
  • Loading branch information
bobeaton committed Oct 7, 2024
1 parent 5521347 commit d0988e4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/EncCnvtrs/EncCnvtrs 2010.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@
</EmbeddedResource>
<EmbeddedResource Include="NetRegexAutoConfigDialog.resx">
<DependentUpon>NetRegexAutoConfigDialog.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ImplTypeList.resx">
<DependentUpon>ImplTypeList.cs</DependentUpon>
Expand Down
1 change: 1 addition & 0 deletions src/EncCnvtrs/NetRegexAutoConfigDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 32 additions & 13 deletions src/EncCnvtrs/NetRegexAutoConfigDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,21 +384,40 @@ private void linkLabelOpenQuickReference_LinkClicked(object sender, LinkLabelLin
private int rowIndexFromMouseDown;
private int rowIndexOfItemUnderMouseToDrop;

private void dataGridViewRegularExpressions_MouseDown(object sender, MouseEventArgs e)
private void dataGridViewRegularExpressions_MouseDown(object sender, MouseEventArgs e)
{
// Get the index of the row to drag
rowIndexFromMouseDown = dataGridViewRegularExpressions.HitTest(e.X, e.Y).RowIndex;
if ((rowIndexFromMouseDown < 0) || (rowIndexFromMouseDown > dataGridViewRegularExpressions.Rows.Count - 2))
return;
System.Diagnostics.Debug.WriteLine($"Select row index: {rowIndexFromMouseDown}");
// Get the index of the row to drag
var hitTestInfo = dataGridViewRegularExpressions.HitTest(e.X, e.Y);
rowIndexFromMouseDown = hitTestInfo.RowIndex;
var columnIndex = hitTestInfo.ColumnIndex;

// make sure it's a valid row and column (don't process DragDrop for checkbox column
// or it won't toggle the Enabled checkbox)
if ((rowIndexFromMouseDown < 0) || (rowIndexFromMouseDown > dataGridViewRegularExpressions.Rows.Count - 2) ||
(columnIndex < 0) || dataGridViewRegularExpressions.Columns[columnIndex] is DataGridViewCheckBoxColumn)
{
return;
}

if (rowIndexFromMouseDown != -1)
{
dataGridViewRegularExpressions.DoDragDrop(dataGridViewRegularExpressions.Rows[rowIndexFromMouseDown], DragDropEffects.Move | DragDropEffects.Copy);
}
}
System.Diagnostics.Debug.WriteLine($"Select row index: {rowIndexFromMouseDown}");

if ((rowIndexFromMouseDown != -1) && (e.Button == MouseButtons.Left))
{
dataGridViewRegularExpressions.DoDragDrop(dataGridViewRegularExpressions.Rows[rowIndexFromMouseDown], DragDropEffects.Move | DragDropEffects.Copy);
}
}

private void dataGridViewRegularExpressions_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
// Toggle the checkbox value
var cell = dataGridViewRegularExpressions[e.ColumnIndex, e.RowIndex];
bool newValue = !(bool)(cell.Value ?? false); // Default to false if null
cell.Value = newValue;

controlChangedModified(null, null);
}

private void dataGridViewRegularExpressions_DragOver(object sender, DragEventArgs e)
private void dataGridViewRegularExpressions_DragOver(object sender, DragEventArgs e)
{
// Provide visual feedback during the drag operation
Point clientPoint = dataGridViewRegularExpressions.PointToClient(new Point(e.X, e.Y));
Expand Down Expand Up @@ -428,6 +447,6 @@ private void dataGridViewRegularExpressions_DragDrop(object sender, DragEventArg
IsModified = true;
}
}
}
}
}

6 changes: 3 additions & 3 deletions src/EncCnvtrs/NetRegexAutoConfigDialog.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 165</value>
<value>635, 17</value>
</metadata>
<metadata name="ColumnEnabled.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
Expand All @@ -139,10 +139,10 @@
<value>17, 17</value>
</metadata>
<metadata name="fontDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 91</value>
<value>338, 17</value>
</metadata>
<metadata name="contextMenuRegexChars.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 128</value>
<value>448, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>68</value>
Expand Down

0 comments on commit d0988e4

Please sign in to comment.