private void FTN_AddButton_Click(object sender, RoutedEventArgs e) { var routerName = FTN_RouterName.Text; var FEC = FTN_FEC.Text; var NHLFE_ID = FTN_NHLFE_ID.Text; if (routerName.Length == 0 || FEC.Length == 0 || NHLFE_ID.Length == 0) { return; } var isProperRule = CheckIfIsProperFTN_Entry(FEC, NHLFE_ID); if (!isProperRule || !Manager.RouterNameToFTN_Table.ContainsKey(routerName)) { AddLog("You are trying to add an incorrect rule!", LogType.Error); return; } var foundRow = FTN_Rows.Find(x => x.RouterName.Equals(routerName) && x.FEC.Equals(int.Parse(FEC))); if (foundRow != null) { AddLog("NHLFE ID for such FEC already exists!", LogType.Error); return; } var rule = new FtnTableRow(FEC + " " + NHLFE_ID); rule.RouterName = routerName; Manager.RouterNameToFTN_Table[routerName].Add(rule); FTN_Rows.Add(rule); Manager.SendRow(routerName, rule, ManagementActions.ADD_FTN_ENTRY); SortFtnRows(); FTN_Table.Items.Refresh(); FTN_RouterName.Clear(); FTN_FEC.Clear(); FTN_NHLFE_ID.Clear(); FTN_RouterName.Focus(); }
/// <summary> /// Compares whether FTN entries are identical. /// </summary> /// <param name="other">Second FTN entry.</param> /// <returns>True, if are identical; false, if otherwise.</returns> protected bool Equals(FtnTableRow other) { return(FEC == other.FEC && NHLFE_ID == other.NHLFE_ID); }