コード例 #1
0
        /// <summary>
        /// The thread that updates the list
        /// </summary>
        /// <param name="ovp">
        /// this overview page
        /// </param>
        public void PopulateListThread(OverviewPage ovp)
        {
            StationStatus selected = null;

            ovp.Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(delegate { selected = (StationStatus)stationGrid.SelectedItem; }));

            ovp.Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(delegate { UpdateLabel.Content = "Scanning..."; }));
            ovp.Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(delegate { LoadingBar.Visibility = System.Windows.Visibility.Visible; }));
            _ui.DiscoverPeers();

            ovp.Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { stationGrid.Items.Refresh(); }));

            ovp.Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { UpdateLabel.Content = string.Empty; }));
            ovp.Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(delegate { LoadingBar.Visibility = System.Windows.Visibility.Hidden; }));
            ovp.Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(delegate { RefreshButton.IsEnabled = true; UpdateControls(); }));
        }
コード例 #2
0
        /// <summary>
        /// The thread that updates the list
        /// </summary>
        /// <param name="ovp">this overview page</param>
        public void PopulateListThread(OverviewPage ovp)
        {
            ovp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { UpdateLabel.Content = "Opdaterer..."; }));
            ovp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { LoadingBar.Visibility = Visibility.Visible; }));
            IEnumerable <IPEndPoint> peerlist = _ui.GetPeerlist();

            if (peerlist != null)
            {
                var dataSource = (from ip in peerlist where _ui.IsStationActive(ip) select new StationStatus {
                    IpAdress = ip.Address.ToString(), Connected = true
                }).ToList();
                dataSource.AddRange(from ip in _ui.DiscoverPeers() where !peerlist.Contains(ip) select new StationStatus {
                    IpAdress = ip.Address.ToString(), Connected = false
                });

                ovp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { stationGrid.ItemsSource = dataSource; }));
                ovp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { stationGrid.Items.Refresh(); }));
            }
            ovp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { UpdateLabel.Content = ""; }));
            ovp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { LoadingBar.Visibility = Visibility.Hidden; }));
        }