Ejemplo n.º 1
0
 public virtual void Stop()
 {
     if (Stoped)
     {
         return;
     }
     Stoped     = true;
     Connected  = false;
     Connecting = false;
     lock (OpenConnectionsLocker)
         OpenConnections.Remove(this);
 }
        void Connections_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            //notify that the closed collection list is changed
            RaisePropertyChanged(ClosedConnectionsPropertyName);

            //whenever a new connectionview is added, set up the event so that when it is disconnected, it is removed from the open connection list
            if (e.NewItems != null && e.NewItems.Count > 0)
            {
                e.NewItems.Cast <ConnectionViewModel>().ToList().ForEach(cn =>
                {
                    cn.Disconnected += (s, se) => OpenConnections.Remove(s as ConnectionViewModel);
                });
            }
        }