Пример #1
0
        // 自訂非同步解析作業完成時,所呼叫的方法
        private void ResolveCompletedCallback(object sender, ResolveCompletedEventArgs e)
        {
            progressBar.Visibility = Visibility.Hidden;

            if (lstPeerNameRecord.Items.Count == 0)
            {
                MessageBox.Show("No Peer Name Record Found", "Peer Name Resolver", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #2
0
 void peerNameResolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     if (e.Cancelled || e.Error != null || e.PeerNameRecordCollection == null)
     {
         return;
     }
     Records = e.PeerNameRecordCollection;
     ResolutionCompleted(this, e);
 }
Пример #3
0
 static void resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     if (!e.Cancelled && e.Error == null && e.PeerNameRecordCollection != null)
     {
         records = e.PeerNameRecordCollection;
         DisplayResults();
         isRunning = false;
     }
 }
Пример #4
0
        private void Pnr_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
        {
            var token = e.UserState as ResolveToken;

            if (null != e.Error)
            {
                CompletedException?.Invoke(token, e.Error);
            }

            Completed?.Invoke(token, GetDatas(e.PeerNameRecordCollection), e.Cancelled);
        }
Пример #5
0
 private void resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     if (PeerList.Items.Count == 0)
     {
         PeerList.Items.Add(new PeerEntry
         {
             DisplayString  = "Пиры не найдены.",
             ButtonsEnabled = false
         });
     }
     RefreshButton.IsEnabled = true;
 }
Пример #6
0
 public void resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     // error if cloud is empty
     //if (Vault.Peers.Count == 0)
     //{
     //    Vault.Peers.Add(
     //       new PeerEntry
     //       {
     //           DisplayString = "Peers not found",
     //       });
     //}
     //RefreshButton.IsEnabled = true;
 }
Пример #7
0
 void resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     // Сообщение об ошибке, если в облаке не найдены пиры
     //if (peerList.Count == 0)
     //{
     //peerList.Add(
     //   new PeerEntry
     //   {
     //       DisplayString = "Peers not found"
     //   });
     //Console.WriteLine("No Peers found");
     //}
 }
Пример #8
0
 void resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     // Сообщение об ошибке, если в облаке не найдены пиры
     if (PeerList.Items.Count == 0)
     {
         PeerList.Items.Add(
             new PeerEntry
         {
             DisplayString  = "Пиры не найдены.",
             ButtonsEnabled = false
         });
     }
     // Повторно включаем кнопку "обновить"
     RefreshButton.IsEnabled = true;
 }
Пример #9
0
 void resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     // Add failure message if necessary
     if (PeerList.Items.Count == 0)
     {
         PeerList.Items.Add(
             new PeerEntry
         {
             DisplayString  = "No peers found.",
             ButtonsEnabled = false
         });
     }
     // Reenable refresh button
     RefreshButton.IsEnabled = true;
 }
 void resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     // error is no peers
     if (PeerList.Items.Count == 0)
     {
         PeerList.Items.Add(
             new PeerEntry
         {
             DisplayString  = "No peers found",
             ButtonsEnabled = false
         });
     }
     // enable refresh
     RefreshButton.IsEnabled = true;
 }
Пример #11
0
        void ResolveCompleted(object sender, ResolveCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                throw e.Error;
            }

            try
            {
                this.endpointDiscoveryMetadata = e.Result.EndpointDiscoveryMetadata;
            }
            catch (Exception exception)
            {
                this.Complete(false, exception);
            }
        }
Пример #12
0
        private void Resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
        {
            if (_peerList.Count == 0)
            {
                lock (_peersLock)
                {
                    _peerList.Add(new PeerEntry
                    {
                        DisplayString  = "No peers found.",
                        ButtonsEnabled = false
                    });
                }
            }

            RefreshButton.IsEnabled = true;
        }
Пример #13
0
        private void ResolveCompleted(object sender, ResolveCompletedEventArgs e)
        {
            // Сообщение об ошибке, если в облаке не найдены пиры
            if (_home.ListPeerEntry.Count == 0)
            {
                _home.ListPeerEntryAdd(
                    new PeerEntry
                {
                    DisplayString  = "Пиры не найдены!",
                    ButtonsEnabled = false
                });
            }

            // Повторно включаем кнопку "обновить"
            _home.SetRefreshMenuEnabled(true);
        }
Пример #14
0
 private void resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     if (peerList.Count == 0)
     {
     }
 }
Пример #15
0
 void resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     Debug.WriteLine("Completed Count: " + e.PeerNameRecordCollection.Count.ToString());
     this.Records = e.PeerNameRecordCollection;
     this.IsReady = true;
 }
Пример #16
0
 void resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     CanRefreshPeers = true;
     ResolveCompleted();
 }
Пример #17
0
        private void OnPeerResolveComplete(object sender, ResolveCompletedEventArgs e)
        {
            var peerPanel = this.PeerListPanel;

            _uiSyncContex.Send(state =>
            {
                try
                {
                    _logger.Debug("Updating peer list...");

                    var existedEntries    = _peersByButtons.Values.ToList();
                    var newPeersByButtons = new Dictionary <Button, PeerContextData>();

                    var newEntries = new List <KeyValuePair <Button, PeerContextData> >();
                    foreach (var foundPeer in _foundPeers)
                    {
                        var entry = existedEntries.FirstOrDefault(x => x.PeerEntry.DisplayedName == foundPeer.DisplayedName);
                        if (entry == null) // new peer
                        {
                            var button = new Button()
                            {
                                Width      = peerPanel.Width,
                                Height     = 25,
                                Content    = foundPeer.DisplayedName,
                                Background = PEER_BUTTON_NO_MESSAGES_COLOR
                            };
                            button.Click += PeerButtonClick;

                            var entryContex = new PeerContextData(foundPeer, button);
                            newEntries.Add(new KeyValuePair <Button, PeerContextData>(button, entryContex));
                        }
                        else
                        {
                            newPeersByButtons.Add(_peersByButtons.First(x => x.Value == entry).Key, entry);
                        }
                    }
                    foreach (var newEntry in newEntries)
                    {
                        newPeersByButtons.Add(newEntry.Key, newEntry.Value);
                    }
                    var oldKeys = _peersByButtons.Keys.ToList();
                    if (_peersByButtons != null && _peersByButtons.Count > 0)
                    {
                        newPeersByButtons = newPeersByButtons.OrderBy(x => oldKeys.IndexOf(x.Key))
                                            .ToDictionary(x => x.Key, y => y.Value);
                    }

                    _peersByButtons = newPeersByButtons;
                    AvailablePeers  = _peersByButtons.Values.ToList();

                    if ((AvailablePeers.Any() && CurrentPeer == null) ||
                        (AvailablePeers.Any() && !AvailablePeers.Contains(CurrentPeer)))
                    {
                        CurrentPeer = AvailablePeers.First();
                        CurrentPeer.PeerButton.Background = PEER_BUTTON_CURRENT_COLOR;
                    }

                    RefreshPeerPanel();

                    _canUpdatePeers = true;
                    _logger.Debug($"Peer list update is completed. Number of peers: {_peersByButtons.Count}");
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, $"Cannot update peer list: {ex.Message}");
                }
            }, new object());
        }
Пример #18
0
 /// <summary>
 /// Обработка завершения разрешения
 /// </summary>
 void resolver_ResolveCompleted(object sender, ResolveCompletedEventArgs e)
 {
     InvokeCallbacks(e.Error);
 }