public void OnAllPersonsChanged() { PersonsUpdateHistory.Append("Update: ").Append(PrintPersons()).AppendLine(); var accounts = new List <ViewerAccount>(); if (_showMan != null) { accounts.Add(_showMan); } try { AllPersons = accounts.Concat(_players).Concat(_viewers) .Where(account => account.IsConnected) .ToDictionary(account => account.Name); } catch (ArgumentException exc) { throw new Exception($"OnAllPersonsChanged error: {PersonsUpdateHistory}", exc); } if (!AllPersons.ContainsKey(Name)) { throw new Exception($"!AllPersons.ContainsKey({Name})! {string.Join(",", AllPersons.Keys)} {PersonsUpdateHistory}"); } }
private void RemovePersonFromPersonList(Person person) { if (person != null) { AllPersons.Remove(person); } }
private void AddPersonToPersonList(Person person) { if (person != null && !AllPersons.Contains(person)) { AllPersons.Add(person); } }
private void AddPerson() { Person p = DefaultManager.Instance.DefaultPerson; AllPersons.Add(p); CurrentPerson = p; OpenPerson(); }
private void DeleteCurrentPerson() { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(string.Format("Вы действительно хотите удалить {0}?", CurrentPerson.FullName), "Подтвердите удаление", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { DataManager.Instance.RemovePerson(CurrentPerson); AllPersons.Remove(CurrentPerson); OnPropertyChanged("AllPersons"); } // CurrentPerson = null; }
internal void Disconnect(bool shoudClearInfo = false) { _communicationManager.Disconnect(); //Обработка отключение от сервера if (shoudClearInfo) { CurrentPerson = null; SelectedPerson = null; AllPersons.Clear(); } IsConnected = false; }
public void SortPerson(string sortValue) { switch (sortValue) { case "Surname": SortedPerson = AllPersons.OrderBy(x => x.Surname); return; case "Year": SortedPerson = AllPersons.OrderBy(x => x.YearOfBirth); return; default: return; } }
private void InitializeInvalidationTimer() { InvalidationTimer = new Timer() { AutoReset = true, Interval = 5000, Enabled = false }; InvalidationTimer.Elapsed += (sender, e) => { if (CurrentIndex > 2) { return; } Persons.Add(AllPersons.ElementAt(CurrentIndex++)); InvalidateChildren(); }; InvalidationTimer.Start(); }
/// <summary> /// Подключение к серверу /// </summary> private void Connect() { Person person = new Person { Name = UserName }; try { var callback = new ChatServiceCallback(); callback.ChatCallbackEvent += Callback_ChatCallbackEvent; var joinResult = _communicationManager.Connect(serverIP: ServerIP, serverPort: ServerPort, person: person, callback: callback); if (!joinResult.Success) { Disconnect(); LogError(joinResult); return; } //Задается основной пользователь клиента CurrentPerson = person; AllPersons.Clear(); foreach (var per in joinResult.Result.OrderBy(x => x.Name)) { AllPersons.Add(per); } IsConnected = true; } catch (Exception ex) { LogError("Не получилось подключиться к серверу: " + ex.Message); IsConnected = false; } }