From 5080d85a47370b2882af0afa8891e61a21de0515 Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Fri, 21 Oct 2016 13:47:35 +0800 Subject: [PATCH] prevent users from deleting system assets --- AntSharesUI/UI/MainForm.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/AntSharesUI/UI/MainForm.cs b/AntSharesUI/UI/MainForm.cs index b28c4cf276..902ea3e4f1 100644 --- a/AntSharesUI/UI/MainForm.cs +++ b/AntSharesUI/UI/MainForm.cs @@ -520,7 +520,12 @@ private void 删除DToolStripMenuItem_Click(object sender, EventArgs e) private void contextMenuStrip2_Opening(object sender, CancelEventArgs e) { - 删除DToolStripMenuItem1.Enabled = listView2.SelectedIndices.Count > 0; + bool enabled = listView2.SelectedIndices.Count > 0; + if (enabled) + { + enabled = listView2.SelectedItems.OfType().Select(p => (RegisterTransaction)p.Tag).All(p => p.AssetType != AssetType.AntShare && p.AssetType != AssetType.AntCoin); + } + 删除DToolStripMenuItem1.Enabled = enabled; } private void 删除DToolStripMenuItem1_Click(object sender, EventArgs e)