private void btnAddBlock_Click(object sender, EventArgs e) { var blockName = Interaction.InputBox("Please enter a name for the new block.", "New block"); if (blockName == "") return; // First need to find a new ID to use on the server for this block. var internalId = 0; var broke = false; foreach (var b in _blocks) { if (int.Parse(b.InternalId) - internalId > 1) { internalId += 1; broke = true; break; } internalId += 1; } if (!broke) internalId += 1; var newBlock = new Block(internalId.ToString(), blockName, "0", "0", "", "0", "0", "0", "0", "", "", "0", "0", "0", "0", "0", "-1"); _blocks.Add(newBlock); _blocks = _blocks.OrderBy(x => int.Parse(x.InternalId)).ToList(); lstBlock.Items.Clear(); foreach (var b in _blocks) { lstBlock.Items.Add(b.BlockName); } }
private void btnAddBlock_Click(object sender, EventArgs e) { string blockName = Microsoft.VisualBasic.Interaction.InputBox("Please enter a name for the new block.", "New block"); if (blockName == "") return; // First need to find a new ID to use on the server for this block. int internalID = 0; bool broke = false; foreach (Block b in blocks) { if (int.Parse(b.internalID) - internalID > 1) { internalID += 1; broke = true; break; } else { internalID += 1; } } if (!broke) internalID += 1; Block newBlock = new Block(internalID.ToString(), blockName, "0", "0", "", "0", "0", "0", "0", "", "", "0", "0", "0", "0", "0", "-1"); blocks.Add(newBlock); blocks = blocks.OrderBy(x => int.Parse(x.internalID)).ToList(); lstBlock.Items.Clear(); foreach (Block b in blocks) { lstBlock.Items.Add(b.blockName); } }