Ejemplo n.º 1
0
 public bool AddHost(String value)
 {
     foreach (IHostProvider hostProvider in this.hostProviders)
     {
         if (hostProvider.ValidHostValue(value))
         {
             try {
                 BasicHost host = hostProvider.Host(value, this);
                 if (host != null)
                 {
                     lock (addHostLock) {
                         this.mainWindow.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => {
                             if (hosts.Count == 0)
                             {
                                 this.updateDispatchTimer.Start();
                                 this.pingDispatchTimer.Start();
                             }
                             hosts.Add(host);
                             host.Ping().Start();
                         }));
                     }
                 }
                 return(true);
             } catch (BasicHostAllReadyExistsException e) {
                 return(true);
             } catch (Exception e) {
                 System.Diagnostics.Debug.WriteLine(e.ToString());
             }
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        private void btnRemoveHost_Click(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("MainWindow.btnRemoveHost_Click()");
            BasicHost host = (BasicHost)(((Button)sender).DataContext);

            this.HostsManager.RemoveHost(host);
        }
Ejemplo n.º 3
0
 public void RemoveHost(BasicHost host)
 {
     host.RemoveHost();
     hosts.Remove(host);
     if (hosts.Count == 0)
     {
         this.updateDispatchTimer.Stop();
         this.pingDispatchTimer.Stop();
     }
 }
Ejemplo n.º 4
0
 public void ToggleHostPause(BasicHost host)
 {
     if (host.IsPaused)
     {
         host.UnPause();
     }
     else
     {
         host.Pause();
     }
 }