예제 #1
0
 /// <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();
     }
 }
예제 #2
0
        /// <summary>
        /// Перечитывание состояний без обновления экрана
        /// </summary>
        private void ReReadStateInternal()
        {
            var macsAndIps = new HashSet <string>(RouterHelpers.ReadLockedMacsAndIps());

            foreach (var netNode in _nodes)
            {
                netNode.State = !macsAndIps.Contains(netNode.MacOrIp);
            }
        }