also delete key (without warning)

alphons <alphons@heijden.com> 11 Jan 2025, 10:51
1b6914f1622328d96ec5c38bc86dd5f1fcfd0a79
3 files changed
  • RedisGui/FormMain.Designer.cs
  • RedisGui/FormMain.cs
  • RedisGui/FormMain.resx
diff --git a/RedisGui/FormMain.Designer.cs b/RedisGui/FormMain.Designer.cs
index 2b5c261..9efd140 100644
--- a/RedisGui/FormMain.Designer.cs
+++ b/RedisGui/FormMain.Designer.cs
@@ -54,6 +54,8 @@
toolStripSeparator1 = new ToolStripSeparator();
closeConnectionToolStripMenuItem = new ToolStripMenuItem();
timer1 = new System.Windows.Forms.Timer(components);
+ contextMenuStrip3 = new ContextMenuStrip(components);
+ deleteKeyToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
statusStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
@@ -66,6 +68,7 @@
splitContainer2.SuspendLayout();
contextMenuStrip1.SuspendLayout();
contextMenuStrip2.SuspendLayout();
+ contextMenuStrip3.SuspendLayout();
SuspendLayout();
//
// menuStrip1
@@ -87,7 +90,7 @@
// exitToolStripMenuItem
//
exitToolStripMenuItem.Name = "exitToolStripMenuItem";
- exitToolStripMenuItem.Size = new Size(180, 22);
+ exitToolStripMenuItem.Size = new Size(93, 22);
exitToolStripMenuItem.Text = "Exit";
exitToolStripMenuItem.Click += ExitToolStripMenuItem_Click;
//
@@ -211,7 +214,7 @@
listView1.GridLines = true;
listView1.Location = new Point(12, 79);
listView1.Name = "listView1";
- listView1.Size = new Size(609, 233);
+ listView1.Size = new Size(603, 233);
listView1.TabIndex = 0;
listView1.UseCompatibleStateImageBehavior = false;
listView1.View = View.Details;
@@ -238,7 +241,7 @@
txtData.Name = "txtData";
txtData.ReadOnly = true;
txtData.ScrollBars = ScrollBars.Both;
- txtData.Size = new Size(1019, 71);
+ txtData.Size = new Size(1019, 65);
txtData.TabIndex = 5;
//
// contextMenuStrip1
@@ -284,13 +287,26 @@
closeConnectionToolStripMenuItem.Name = "closeConnectionToolStripMenuItem";
closeConnectionToolStripMenuItem.Size = new Size(180, 22);
closeConnectionToolStripMenuItem.Text = "Close Connection";
- closeConnectionToolStripMenuItem.Click += closeConnectionToolStripMenuItem_Click;
+ closeConnectionToolStripMenuItem.Click += CloseConnectionToolStripMenuItem_Click;
//
// timer1
//
timer1.Interval = 5000;
timer1.Tick += Timer_Tick;
//
+ // contextMenuStrip3
+ //
+ contextMenuStrip3.Items.AddRange(new ToolStripItem[] { deleteKeyToolStripMenuItem });
+ contextMenuStrip3.Name = "contextMenuStrip3";
+ contextMenuStrip3.Size = new Size(181, 48);
+ //
+ // deleteKeyToolStripMenuItem
+ //
+ deleteKeyToolStripMenuItem.Name = "deleteKeyToolStripMenuItem";
+ deleteKeyToolStripMenuItem.Size = new Size(180, 22);
+ deleteKeyToolStripMenuItem.Text = "Delete Key";
+ deleteKeyToolStripMenuItem.Click += DeleteKeyToolStripMenuItem_Click;
+ //
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
@@ -319,6 +335,7 @@
splitContainer2.ResumeLayout(false);
contextMenuStrip1.ResumeLayout(false);
contextMenuStrip2.ResumeLayout(false);
+ contextMenuStrip3.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
@@ -351,5 +368,7 @@
private System.Windows.Forms.Timer timer1;
private ToolStripSplitButton toolStripSplitButton1;
private ToolStripStatusLabel toolStripStatusLabel1;
+ private ContextMenuStrip contextMenuStrip3;
+ private ToolStripMenuItem deleteKeyToolStripMenuItem;
}
}
diff --git a/RedisGui/FormMain.cs b/RedisGui/FormMain.cs
index 4e80532..d1cda20 100644
--- a/RedisGui/FormMain.cs
+++ b/RedisGui/FormMain.cs
@@ -257,19 +257,21 @@ public partial class FormMain : Form
return;
TreeNode node = this.treeView1.GetNodeAt(e.Location);
- if (node != null)
+ if (node == null)
{
- this.treeView1.SelectedNode = node;
- if (node.Parent == null)
- this.contextMenuStrip2.Show(this.treeView1, e.Location);
+ this.contextMenuStrip1.Show(this.treeView1, e.Location);
return;
}
- this.contextMenuStrip1.Show(this.treeView1, e.Location);
+ this.treeView1.SelectedNode = node;
+ if (node.Parent == null)
+ this.contextMenuStrip2.Show(this.treeView1, e.Location);
+ else
+ this.contextMenuStrip3.Show(this.treeView1, e.Location);
}
- async private void closeConnectionToolStripMenuItem_Click(object sender, EventArgs e)
+ async private void CloseConnectionToolStripMenuItem_Click(object sender, EventArgs e)
{
this.treeView1.SelectedNode.Remove();
this.db = null;
@@ -329,4 +331,20 @@ public partial class FormMain : Form
{
this.Close();
}
+
+ private async void DeleteKeyToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (this.db == null)
+ return;
+
+ if (this.treeView1.SelectedNode == null)
+ return;
+
+ var key = this.treeView1.SelectedNode.Text;
+
+ await this.db.KeyDeleteAsync(new RedisKey(key));
+
+ this.treeView1.SelectedNode.Remove();
+
+ }
}
diff --git a/RedisGui/FormMain.resx b/RedisGui/FormMain.resx
index 2b5d210..9a0074f 100644
--- a/RedisGui/FormMain.resx
+++ b/RedisGui/FormMain.resx
@@ -135,6 +135,9 @@
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>773, 17</value>
</metadata>
+ <metadata name="contextMenuStrip3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>861, 17</value>
+ </metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>99</value>
</metadata>