private void IP_FIB_DeleteButton_Click(object sender, RoutedEventArgs e) { int index = IP_FIB_Table.SelectedIndex; if (index == -1) // selected empty entry { return; } var selectedEntry = IP_FIB_Table.SelectedItems[0] as IpFibTableRow; var routerName = selectedEntry.RouterName; var destAddress = selectedEntry.DestAddress; var outPort = selectedEntry.OutPort; if (Manager.RouterNameToIP_FIB_Table.ContainsKey(routerName)) { try { // remove item from the list that is binded to GUI's listView var foundRow = IP_FIB_Rows.Find(x => x.RouterName.Equals(routerName) && x.DestAddress.Equals(destAddress) && x.OutPort.Equals(outPort)); Manager.SendRow(routerName, foundRow, ManagementActions.REMOVE_IP_FIB_ENTRY); IP_FIB_Rows.Remove(foundRow); // remove item from the list that is in dictionary var item = Manager.RouterNameToIP_FIB_Table[routerName].Find(x => x.RouterName.Equals(routerName) && x.DestAddress.Equals(destAddress) && x.OutPort.Equals(outPort)); Manager.RouterNameToIP_FIB_Table[routerName].Remove(item); IP_FIB_Table.Items.Refresh(); } catch (Exception) { AddLog($"Router {routerName} is not connected to MS!\n", LogType.Error); } } else { AddLog("Network topology does not contain such router!\n", LogType.Error); } }