/// <summary> /// Переключить состояние узла /// </summary> /// <param name="node"></param> private void Toggle([NotNull] NetNode node) { _errorDetected = false; try { _pending = true; UpdateControls(); try { var arrsToBlock = new List <string>(); foreach (var netNode in _nodes) { var nodeMustBelocked = netNode == node ? netNode.State : !netNode.State; if (nodeMustBelocked) { arrsToBlock.Add(netNode.MacOrIp); } } RouterHelpers.WriteLockedMacsOrIps(arrsToBlock.ToArray()); ReReadStateInternal(); } finally { _pending = false; UpdateControls(); } } catch (Exception) { _errorDetected = true; _pending = false; UpdateControls(); } }
/// <summary> /// Перечитывание состояний без обновления экрана /// </summary> private void ReReadStateInternal() { var macsAndIps = new HashSet <string>(RouterHelpers.ReadLockedMacsAndIps()); foreach (var netNode in _nodes) { netNode.State = !macsAndIps.Contains(netNode.MacOrIp); } }