|
@@ -15,6 +15,8 @@ using System.Net;
|
|
|
using System.Net.NetworkInformation;
|
|
|
using System.Net.Sockets;
|
|
|
using System.Windows.Forms;
|
|
|
+using DiskAccessLibrary;
|
|
|
+using SCSI;
|
|
|
using Utilities;
|
|
|
|
|
|
namespace ISCSIConsole
|
|
@@ -206,12 +208,6 @@ namespace ISCSIConsole
|
|
|
|
|
|
private void LoadConfigButton_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- if (0 != m_targets.Count)
|
|
|
- {
|
|
|
- MessageBox.Show("Remove all targets before load config");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
LoadFromConfig();
|
|
|
}
|
|
|
|
|
@@ -224,16 +220,10 @@ namespace ISCSIConsole
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- var arr = new ISCSITarget[entries.Length];
|
|
|
-
|
|
|
- for (int i = 0; i < arr.Length; i++)
|
|
|
- {
|
|
|
- arr[i] = entries[i].CreateTarget();
|
|
|
- }
|
|
|
-
|
|
|
- foreach (var target in arr)
|
|
|
+ foreach (var entry in entries)
|
|
|
{
|
|
|
- AddTarget(target);
|
|
|
+ if (m_targets.Any(p => p.TargetName == entry.Iqn)) continue;
|
|
|
+ AddTarget(entry.CreateTarget());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -244,5 +234,66 @@ namespace ISCSIConsole
|
|
|
if ("true" == ConfigurationManager.AppSettings["AutoLoadConfig"]) LoadFromConfig();
|
|
|
if ("true" == ConfigurationManager.AppSettings["AutoStart"]) btnStart_Click(null, null);
|
|
|
}
|
|
|
+
|
|
|
+ private void listTargets_DoubleClick(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (listTargets.SelectedIndices.Count == 0) return;
|
|
|
+
|
|
|
+ var targetIndex = listTargets.SelectedIndices[0];
|
|
|
+ var target = m_targets[targetIndex];
|
|
|
+
|
|
|
+ if (target.Target is VirtualSCSITarget v)
|
|
|
+ {
|
|
|
+ if (v.Disks.Count == 0)
|
|
|
+ {
|
|
|
+ MainContextMenuStrip.Items.Add("(no Disks)").Enabled = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var dic = new Dictionary<string, ToolStripItem[]>();
|
|
|
+
|
|
|
+ foreach (var disk in v.Disks)
|
|
|
+ {
|
|
|
+ switch (disk)
|
|
|
+ {
|
|
|
+ case BlockDifferencingDiskImage bdd:
|
|
|
+ if (false == bdd.IsNoBaseImage)
|
|
|
+ {
|
|
|
+ var toolStripMenuItem = new ToolStripMenuItem("Clean");
|
|
|
+ toolStripMenuItem.Click += (o, args) =>
|
|
|
+ {
|
|
|
+ var dr = MessageBox.Show($"Are you sure to clean `{bdd.Path}'", "Clean snapshot", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
|
|
|
+ if (dr == DialogResult.Yes) bdd.Clean();
|
|
|
+ };
|
|
|
+ dic[bdd.Path] = new ToolStripItem[] { toolStripMenuItem };
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dic.Count == 0) MainContextMenuStrip.Items.Add("(no option able Disks)").Enabled = false;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foreach (var item in dic)
|
|
|
+ {
|
|
|
+ var m = new ToolStripMenuItem(item.Key);
|
|
|
+ m.DropDownItems.AddRange(item.Value);
|
|
|
+ MainContextMenuStrip.Items.Add(m);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MainContextMenuStrip.Show(MousePosition);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MainContextMenuStrip.Items.Add("(non Virtual SCSI Target)").Enabled = false;
|
|
|
+ MainContextMenuStrip.Show(MousePosition);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void MainContextMenuStrip_Closed(object sender, ToolStripDropDownClosedEventArgs e)
|
|
|
+ {
|
|
|
+ MainContextMenuStrip.Items.Clear();
|
|
|
+ }
|
|
|
}
|
|
|
}
|