ok
6d522173fc9eade079b6321e29ff6e709210130f
7 files changed
RedisGui/Form1.Designer.csRedisGui/Form1.csRedisGui/Form1.resxRedisGui/FormMain.Designer.csRedisGui/FormMain.csRedisGui/FormMain.resxRedisGui/Program.cs
diff --git a/RedisGui/Form1.cs b/RedisGui/Form1.cs
deleted file mode 100644
index 57af14b..0000000
--- a/RedisGui/Form1.cs
+++ /dev/null
@@ -1,190 +0,0 @@
-
-using StackExchange.Redis;
-using System.Diagnostics;
-using System.Net;
-using System.Text.Json;
-using System.Text.RegularExpressions;
-
-
-namespace RedisGui
-{
- public partial class Form1 : Form
- {
- private ConnectionMultiplexer? connection;
- private IServer? server;
- private IDatabase? db;
-
- public Form1()
- {
- InitializeComponent();
-
- //foreach (StockIconId icon in Enum.GetValues(typeof(StockIconId)))
- // imageList.Images.Add(icon.ToString(), SystemIcons.GetStockIcon(icon, 24));
-
- imageList1.Images.Add(SystemIcons.GetStockIcon(StockIconId.World, 24));
- imageList1.Images.Add(SystemIcons.GetStockIcon(StockIconId.NetworkConnect, 24));
- imageList1.Images.Add(SystemIcons.GetStockIcon(StockIconId.Key, 24));
-
- //toolStrip1.Items.AddRange(imageList.Images.Keys.Cast<string>().Select(x =>
- // new ToolStripButton(imageList.Images[x]) { ToolTipText = x }).ToArray());
- }
-
- private void Form1_Load(object sender, EventArgs e)
- {
- MakeConnection("127.0.0.1:6379");
- }
-
- private void AddConnectionToolStripMenuItem_Click(object sender, EventArgs e)
- {
- MakeConnection("127.0.0.1:6379");
- }
-
- private void MakeConnection(string ConnectionString)
- {
- this.connection = ConnectionMultiplexer.Connect(ConnectionString);
-
- EndPoint endPoint = connection.GetEndPoints().First();
-
- this.server = connection.GetServer(endPoint);
-
- this.db = connection.GetDatabase();
-
- var node = this.treeView1.Nodes.Add("", endPoint.ToString(), 1, 1);
-
- LoadKeys(node);
- }
-
- private void LoadKeys(TreeNode node)
- {
- if (this.server == null)
- return;
-
- try
- {
- RedisKey[] keys = this.server.Keys(pattern: "*").ToArray();
-
- node.Nodes.Clear();
-
- foreach (var key in keys)
- {
- node.Nodes.Add(new TreeNode(key, 2, 2));
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show($"Error loading keys: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
-
- private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
- {
- if (e.Node == null)
- return;
-
- var key = new RedisKey(e.Node.Text);
-
- if (this.db == null)
- return;
-
- if (e.Node.Parent == null)
- return;
-
- if (!db.KeyExists(key))
- {
- e.Node.Remove();
- return;
- }
-
- ShowValue(key);
-
- }
-
- public static string PrettyPrintJson(string json)
- {
- try
- {
- var jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
- var options = new JsonSerializerOptions { WriteIndented = true };
- return JsonSerializer.Serialize(jsonElement, options);
- }
- catch
- {
- return json;
- }
- }
-
- private void ShowValue(RedisKey key)
- {
- this.lblType.Text = "";
- this.lblKey.Text = "";
-
- this.listView1.Items.Clear();
- this.txtJson.Clear();
-
- if (this.db == null)
- return;
-
- if (!db.KeyExists(key))
- return;
-
- RedisType type = this.db.KeyType(key);
-
- this.lblType.Text = type.ToString();
-
- this.lblKey.Text = key.ToString();
-
- switch (type)
- {
- case RedisType.String:
- Debug.WriteLine($"String: {db.StringGet(key)}");
- break;
- case RedisType.Hash:
- foreach (var entry in db.HashGetAll(key))
- {
-
- var val = entry.Value.ToString();
- var name = entry.Name.ToString();
-
- if (name.Contains("absexp") && val != "-1")
- val = new DateTime(long.Parse(val)).ToString();
- if (name.Contains("sldexp") && val != "-1")
- val = TimeSpan.FromMilliseconds(long.Parse(val) / 10000).ToString();
-
- if (val.StartsWith('{') && val.EndsWith('}'))
- {
- this.txtJson.Text = Regex.Unescape(PrettyPrintJson(val));
- }
-
- this.listView1.Items.Add(new ListViewItem([entry.Name.ToString(), val]));
- }
- break;
- case RedisType.List:
- foreach (var item in db.ListRange(key))
- {
- Debug.WriteLine(item);
- }
- break;
- case RedisType.Set:
- foreach (var item in db.SetMembers(key))
- {
- Debug.WriteLine(item);
- }
- break;
- case RedisType.SortedSet:
- foreach (var item in db.SortedSetRangeByRankWithScores(key))
- {
- Debug.WriteLine($"{item.Element}: {item.Score}");
- }
- break;
- case RedisType.Stream:
- break;
- default:
- Debug.WriteLine($"Unknown type for key: {key}");
- break;
- }
-
- }
-
-
- }
-}
diff --git a/RedisGui/Form1.Designer.cs b/RedisGui/FormMain.Designer.cs
similarity index 67%
rename from RedisGui/Form1.Designer.cs
rename to RedisGui/FormMain.Designer.cs
index 8ceb390..950bbc3 100644
--- a/RedisGui/Form1.Designer.cs
+++ b/RedisGui/FormMain.Designer.cs
@@ -1,6 +1,6 @@
namespace RedisGui
{
- partial class Form1
+ partial class FormMain
{
/// <summary>
/// Required designer variable.
@@ -36,10 +36,7 @@
splitContainer1 = new SplitContainer();
splitContainer2 = new SplitContainer();
treeView1 = new TreeView();
- contextMenuStrip1 = new ContextMenuStrip(components);
- addConnectionToolStripMenuItem = new ToolStripMenuItem();
imageList1 = new ImageList(components);
- txtJson = new TextBox();
label3 = new Label();
label2 = new Label();
lblKey = new Label();
@@ -47,15 +44,25 @@
listView1 = new ListView();
columnHeader1 = new ColumnHeader();
columnHeader2 = new ColumnHeader();
+ txtData = new TextBox();
+ contextMenuStrip1 = new ContextMenuStrip(components);
+ addConnectionToolStripMenuItem = new ToolStripMenuItem();
+ contextMenuStrip2 = new ContextMenuStrip(components);
+ showInformationToolStripMenuItem = new ToolStripMenuItem();
+ showConfigurationToolStripMenuItem = new ToolStripMenuItem();
+ toolStripSeparator1 = new ToolStripSeparator();
+ closeConnectionToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout();
+ splitContainer1.Panel2.SuspendLayout();
splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer2).BeginInit();
splitContainer2.Panel1.SuspendLayout();
splitContainer2.Panel2.SuspendLayout();
splitContainer2.SuspendLayout();
contextMenuStrip1.SuspendLayout();
+ contextMenuStrip2.SuspendLayout();
SuspendLayout();
//
// menuStrip1
@@ -63,7 +70,7 @@
menuStrip1.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
- menuStrip1.Size = new Size(801, 24);
+ menuStrip1.Size = new Size(1034, 24);
menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip1";
//
@@ -82,9 +89,9 @@
//
// statusStrip1
//
- statusStrip1.Location = new Point(0, 428);
+ statusStrip1.Location = new Point(0, 474);
statusStrip1.Name = "statusStrip1";
- statusStrip1.Size = new Size(801, 22);
+ statusStrip1.Size = new Size(1034, 22);
statusStrip1.TabIndex = 1;
statusStrip1.Text = "statusStrip1";
//
@@ -98,8 +105,13 @@
// splitContainer1.Panel1
//
splitContainer1.Panel1.Controls.Add(splitContainer2);
- splitContainer1.Size = new Size(801, 404);
- splitContainer1.SplitterDistance = 322;
+ //
+ // splitContainer1.Panel2
+ //
+ splitContainer1.Panel2.Controls.Add(txtData);
+ splitContainer1.Size = new Size(1034, 450);
+ splitContainer1.SplitterDistance = 315;
+ splitContainer1.SplitterWidth = 10;
splitContainer1.TabIndex = 2;
//
// splitContainer2
@@ -114,41 +126,28 @@
//
// splitContainer2.Panel2
//
- splitContainer2.Panel2.Controls.Add(txtJson);
splitContainer2.Panel2.Controls.Add(label3);
splitContainer2.Panel2.Controls.Add(label2);
splitContainer2.Panel2.Controls.Add(lblKey);
splitContainer2.Panel2.Controls.Add(lblType);
splitContainer2.Panel2.Controls.Add(listView1);
- splitContainer2.Size = new Size(801, 322);
- splitContainer2.SplitterDistance = 266;
+ splitContainer2.Size = new Size(1034, 315);
+ splitContainer2.SplitterDistance = 343;
+ splitContainer2.SplitterWidth = 10;
splitContainer2.TabIndex = 0;
//
// treeView1
//
- treeView1.ContextMenuStrip = contextMenuStrip1;
treeView1.Dock = DockStyle.Fill;
treeView1.ImageIndex = 0;
treeView1.ImageList = imageList1;
treeView1.Location = new Point(0, 0);
treeView1.Name = "treeView1";
treeView1.SelectedImageIndex = 0;
- treeView1.Size = new Size(266, 322);
+ treeView1.Size = new Size(343, 315);
treeView1.TabIndex = 0;
- treeView1.AfterSelect += treeView1_AfterSelect;
- //
- // contextMenuStrip1
- //
- contextMenuStrip1.Items.AddRange(new ToolStripItem[] { addConnectionToolStripMenuItem });
- contextMenuStrip1.Name = "contextMenuStrip1";
- contextMenuStrip1.Size = new Size(171, 26);
- //
- // addConnectionToolStripMenuItem
- //
- addConnectionToolStripMenuItem.Name = "addConnectionToolStripMenuItem";
- addConnectionToolStripMenuItem.Size = new Size(170, 22);
- addConnectionToolStripMenuItem.Text = "Add Connection...";
- addConnectionToolStripMenuItem.Click += AddConnectionToolStripMenuItem_Click;
+ treeView1.AfterSelect += TreeView_AfterSelect;
+ treeView1.MouseUp += TreeView_MouseUp;
//
// imageList1
//
@@ -156,19 +155,6 @@
imageList1.ImageSize = new Size(24, 24);
imageList1.TransparentColor = Color.Transparent;
//
- // txtJson
- //
- txtJson.AcceptsReturn = true;
- txtJson.AcceptsTab = true;
- txtJson.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
- txtJson.Location = new Point(12, 190);
- txtJson.Multiline = true;
- txtJson.Name = "txtJson";
- txtJson.ReadOnly = true;
- txtJson.ScrollBars = ScrollBars.Both;
- txtJson.Size = new Size(507, 129);
- txtJson.TabIndex = 5;
- //
// label3
//
label3.AutoSize = true;
@@ -207,13 +193,13 @@
//
// listView1
//
- listView1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ listView1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
listView1.Columns.AddRange(new ColumnHeader[] { columnHeader1, columnHeader2 });
listView1.FullRowSelect = true;
listView1.GridLines = true;
listView1.Location = new Point(12, 79);
listView1.Name = "listView1";
- listView1.Size = new Size(507, 97);
+ listView1.Size = new Size(651, 233);
listView1.TabIndex = 0;
listView1.UseCompatibleStateImageBehavior = false;
listView1.View = View.Details;
@@ -221,28 +207,89 @@
// columnHeader1
//
columnHeader1.Text = "Field";
- columnHeader1.Width = 75;
+ columnHeader1.Width = 175;
//
// columnHeader2
//
columnHeader2.Text = "Value";
- columnHeader2.Width = 300;
+ columnHeader2.Width = 353;
+ //
+ // txtData
+ //
+ txtData.AcceptsReturn = true;
+ txtData.AcceptsTab = true;
+ txtData.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ txtData.Font = new Font("Courier New", 9F, FontStyle.Regular, GraphicsUnit.Point, 0);
+ txtData.Location = new Point(3, 3);
+ txtData.Multiline = true;
+ txtData.Name = "txtData";
+ txtData.ReadOnly = true;
+ txtData.ScrollBars = ScrollBars.Both;
+ txtData.Size = new Size(1019, 113);
+ txtData.TabIndex = 5;
+ //
+ // contextMenuStrip1
+ //
+ contextMenuStrip1.Items.AddRange(new ToolStripItem[] { addConnectionToolStripMenuItem });
+ contextMenuStrip1.Name = "contextMenuStrip1";
+ contextMenuStrip1.Size = new Size(171, 26);
+ //
+ // addConnectionToolStripMenuItem
+ //
+ addConnectionToolStripMenuItem.Name = "addConnectionToolStripMenuItem";
+ addConnectionToolStripMenuItem.Size = new Size(170, 22);
+ addConnectionToolStripMenuItem.Text = "Add Connection...";
+ addConnectionToolStripMenuItem.Click += AddConnectionToolStripMenuItem_Click;
+ //
+ // contextMenuStrip2
+ //
+ contextMenuStrip2.Items.AddRange(new ToolStripItem[] { showInformationToolStripMenuItem, showConfigurationToolStripMenuItem, toolStripSeparator1, closeConnectionToolStripMenuItem });
+ contextMenuStrip2.Name = "contextMenuStrip2";
+ contextMenuStrip2.Size = new Size(181, 76);
+ //
+ // showInformationToolStripMenuItem
+ //
+ showInformationToolStripMenuItem.Name = "showInformationToolStripMenuItem";
+ showInformationToolStripMenuItem.Size = new Size(180, 22);
+ showInformationToolStripMenuItem.Text = "Show Information";
+ showInformationToolStripMenuItem.Click += ShowInformationToolStripMenuItem_Click;
+ //
+ // showConfigurationToolStripMenuItem
+ //
+ showConfigurationToolStripMenuItem.Name = "showConfigurationToolStripMenuItem";
+ showConfigurationToolStripMenuItem.Size = new Size(180, 22);
+ showConfigurationToolStripMenuItem.Text = "Show Configuration";
+ showConfigurationToolStripMenuItem.Click += ShowConfigurationToolStripMenuItem_Click;
+ //
+ // toolStripSeparator1
+ //
+ toolStripSeparator1.Name = "toolStripSeparator1";
+ toolStripSeparator1.Size = new Size(177, 6);
+ //
+ // closeConnectionToolStripMenuItem
+ //
+ closeConnectionToolStripMenuItem.Name = "closeConnectionToolStripMenuItem";
+ closeConnectionToolStripMenuItem.Size = new Size(180, 22);
+ closeConnectionToolStripMenuItem.Text = "Close Connection";
+ closeConnectionToolStripMenuItem.Click += closeConnectionToolStripMenuItem_Click;
//
- // Form1
+ // FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(801, 450);
+ ClientSize = new Size(1034, 496);
Controls.Add(splitContainer1);
Controls.Add(statusStrip1);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
- Name = "Form1";
+ Name = "FormMain";
Text = "redisgui";
- Load += Form1_Load;
+ Load += Form_Load;
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
splitContainer1.Panel1.ResumeLayout(false);
+ splitContainer1.Panel2.ResumeLayout(false);
+ splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
splitContainer1.ResumeLayout(false);
splitContainer2.Panel1.ResumeLayout(false);
@@ -251,6 +298,7 @@
((System.ComponentModel.ISupportInitialize)splitContainer2).EndInit();
splitContainer2.ResumeLayout(false);
contextMenuStrip1.ResumeLayout(false);
+ contextMenuStrip2.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
@@ -274,6 +322,11 @@
private Label label3;
private Label label2;
private Label lblKey;
- private TextBox txtJson;
+ private TextBox txtData;
+ private ContextMenuStrip contextMenuStrip2;
+ private ToolStripMenuItem showConfigurationToolStripMenuItem;
+ private ToolStripMenuItem showInformationToolStripMenuItem;
+ private ToolStripSeparator toolStripSeparator1;
+ private ToolStripMenuItem closeConnectionToolStripMenuItem;
}
}
diff --git a/RedisGui/FormMain.cs b/RedisGui/FormMain.cs
new file mode 100644
index 0000000..a80997f
--- /dev/null
+++ b/RedisGui/FormMain.cs
@@ -0,0 +1,322 @@
+
+using StackExchange.Redis;
+using System.Diagnostics;
+using System.Net;
+using System.Text;
+using System.Text.Json;
+using System.Text.RegularExpressions;
+
+
+namespace RedisGui
+{
+ public partial class FormMain : Form
+ {
+ private ConnectionMultiplexer? connection;
+ private IServer? server;
+ private IDatabase? db;
+
+ public FormMain()
+ {
+ InitializeComponent();
+
+ imageList1.Images.Add(SystemIcons.GetStockIcon(StockIconId.World, 24));
+ imageList1.Images.Add(SystemIcons.GetStockIcon(StockIconId.NetworkConnect, 24));
+ imageList1.Images.Add(SystemIcons.GetStockIcon(StockIconId.Key, 24));
+
+ }
+
+ private void Form_Load(object sender, EventArgs e)
+ {
+ MakeConnection("127.0.0.1:6379");
+ }
+
+ private void AddConnectionToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ MakeConnection("127.0.0.1:6379");
+ }
+
+ private void MakeConnection(string ConnectionString)
+ {
+ this.connection = ConnectionMultiplexer.Connect(ConnectionString, x => x.AllowAdmin = true);
+
+ EndPoint endPoint = connection.GetEndPoints().First();
+
+ this.server = connection.GetServer(endPoint);
+
+ this.db = connection.GetDatabase();
+
+ var node = this.treeView1.Nodes.Add("", endPoint.ToString(), 1, 1);
+
+ LoadKeys(node);
+ }
+
+ private void LoadKeys(TreeNode node)
+ {
+ if (this.server == null)
+ return;
+
+ try
+ {
+ RedisKey[] keys = this.server.Keys(pattern: "*").ToArray();
+
+ node.Nodes.Clear();
+
+ foreach (var key in keys)
+ {
+ node.Nodes.Add(new TreeNode(key, 2, 2));
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"Error loading keys: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void TreeView_AfterSelect(object sender, TreeViewEventArgs e)
+ {
+ if (e.Node == null)
+ return;
+
+ var key = new RedisKey(e.Node.Text);
+
+ if (this.db == null)
+ return;
+
+ if (e.Node.Parent == null)
+ return;
+
+ if (!db.KeyExists(key))
+ {
+ e.Node.Remove();
+ return;
+ }
+
+ ShowValue(key);
+
+ }
+
+ private static string PrettyPrintJson(string json)
+ {
+ try
+ {
+ var jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
+ var options = new JsonSerializerOptions { WriteIndented = true };
+ return JsonSerializer.Serialize(jsonElement, options);
+ }
+ catch
+ {
+ return json;
+ }
+ }
+
+ private static string ConvertByteArrayToHexText(byte[] byteArray)
+ {
+ StringBuilder hexBuilder = new();
+
+ StringBuilder chars = new();
+
+ for (int i = 0; i < byteArray.Length; i++)
+ {
+ if (i % 32 == 0)
+ {
+ hexBuilder.Append(i.ToString("X4"));
+ hexBuilder.Append(" - ");
+ }
+ hexBuilder.Append(byteArray[i].ToString("X2"));
+ hexBuilder.Append(' ');
+
+ var c = (char)byteArray[i];
+ if (c < ' ' || c > 0x7f)
+ c = ' ';
+ chars.Append(c);
+
+ if ((i + 1) % 16 == 0)
+ {
+ hexBuilder.Append("- ");
+ }
+
+ if ((i + 1) % 32 == 0)
+ {
+ hexBuilder.AppendLine(chars.ToString());
+ chars = new();
+ }
+ }
+
+ var last = byteArray.Length % 32;
+ var todo = (32 * 3) - 3 * last + 2;
+ if (last < 16)
+ todo += 2;
+ if(todo>0)
+ {
+ for (int i = 0; i < todo; i++)
+ hexBuilder.Append(' ');
+ hexBuilder.AppendLine(chars.ToString());
+ }
+
+ return hexBuilder.ToString();
+ }
+
+ private void ShowValue(RedisKey key)
+ {
+ this.lblType.Text = "";
+ this.lblKey.Text = "";
+
+ this.listView1.Items.Clear();
+ this.txtData.Clear();
+
+ if (this.db == null)
+ return;
+
+ if (!db.KeyExists(key))
+ return;
+
+ RedisType type = this.db.KeyType(key);
+
+ this.lblType.Text = type.ToString();
+
+ this.lblKey.Text = key.ToString();
+
+ switch (type)
+ {
+ case RedisType.String:
+ Debug.WriteLine($"String: {db.StringGet(key)}");
+ break;
+ case RedisType.Hash:
+ foreach (HashEntry entry in db.HashGetAll(key))
+ {
+
+ var val = entry.Value.ToString();
+ var name = entry.Name.ToString();
+
+ if (val != "-1")
+ {
+ switch (name)
+ {
+ case "absexp":
+ val = new DateTime(long.Parse(val)).ToString();
+ break;
+ case "sldexp":
+ val = TimeSpan.FromMilliseconds(long.Parse(val) / 10000).ToString();
+ break;
+ case "data":
+ if (val.StartsWith('{') && val.EndsWith('}'))
+ this.txtData.Text = Regex.Unescape(PrettyPrintJson(val));
+ if (val[0]<0x10)
+ {
+ if(entry.Value.Box() is byte[] buffer)
+ {
+ this.txtData.Text = ConvertByteArrayToHexText(buffer);
+ }
+ }
+ break;
+ }
+ }
+
+ this.listView1.Items.Add(new ListViewItem([entry.Name.ToString(), val]));
+ }
+ break;
+ case RedisType.List:
+ foreach (var item in db.ListRange(key))
+ {
+ Debug.WriteLine(item);
+ }
+ break;
+ case RedisType.Set:
+ foreach (var item in db.SetMembers(key))
+ {
+ Debug.WriteLine(item);
+ }
+ break;
+ case RedisType.SortedSet:
+ foreach (var item in db.SortedSetRangeByRankWithScores(key))
+ {
+ Debug.WriteLine($"{item.Element}: {item.Score}");
+ }
+ break;
+ case RedisType.Stream:
+ break;
+ default:
+ Debug.WriteLine($"Unknown type for key: {key}");
+ break;
+ }
+
+ }
+
+ private async Task ShowServerPropertiesAsync()
+ {
+ this.lblType.Text = "";
+ this.lblKey.Text = "";
+
+ this.listView1.Items.Clear();
+
+ if (this.server == null)
+ return;
+
+ var kvs = await this.server.ConfigGetAsync("*");
+
+ foreach (var item in kvs)
+ {
+ this.listView1.Items.Add(new ListViewItem([item.Key, item.Value]));
+ }
+ }
+
+ private async Task ShowServerInfoAsync()
+ {
+ this.lblType.Text = "";
+ this.lblKey.Text = "";
+
+ this.listView1.Items.Clear();
+
+ if (this.server == null)
+ return;
+
+ var groups = await this.server.InfoAsync();
+
+ foreach (var group in groups)
+ {
+ this.listView1.Items.Add(new ListViewItem([group.Key, "======================"]));
+ foreach (var item in group)
+ {
+ this.listView1.Items.Add(new ListViewItem([item.Key, item.Value]));
+ }
+ }
+ }
+
+ async private void ShowConfigurationToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ await ShowServerPropertiesAsync();
+ }
+
+ async private void ShowInformationToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ await ShowServerInfoAsync();
+ }
+
+ private void TreeView_MouseUp(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ return;
+
+ TreeNode node = this.treeView1.GetNodeAt(e.Location);
+ if (node != null)
+ {
+ if (node.Parent == null)
+ this.contextMenuStrip2.Show(this.treeView1, e.Location);
+ return;
+ }
+
+ this.contextMenuStrip1.Show(this.treeView1, e.Location);
+
+ }
+
+ async private void closeConnectionToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ this.treeView1.SelectedNode.Remove();
+ this.db = null;
+ this.server = null;
+ if(this.connection != null)
+ await this.connection.CloseAsync();
+ this.connection = null;
+ }
+ }
+}
diff --git a/RedisGui/Form1.resx b/RedisGui/FormMain.resx
similarity index 96%
rename from RedisGui/Form1.resx
rename to RedisGui/FormMain.resx
index df28133..68ec561 100644
--- a/RedisGui/Form1.resx
+++ b/RedisGui/FormMain.resx
@@ -123,13 +123,16 @@
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>132, 17</value>
</metadata>
+ <metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>507, 17</value>
+ </metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>247, 17</value>
</metadata>
- <metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>507, 17</value>
+ <metadata name="contextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>618, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>25</value>
+ <value>99</value>
</metadata>
</root>
\ No newline at end of file
diff --git a/RedisGui/Program.cs b/RedisGui/Program.cs
index 00859c8..2d7a69f 100644
--- a/RedisGui/Program.cs
+++ b/RedisGui/Program.cs
@@ -11,7 +11,7 @@ namespace RedisGui
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ Application.Run(new FormMain());
}
}
}
\ No newline at end of file