public MainViewModel() { AuthenticateCommand = new RelayCommand(async () => await Authenticate()); SetPresenceCommand = new RelayCommand(() => SetPresence()); _authenticationManager = WTalk.AuthenticationManager.Current; _authenticationManager.Connect(); _client = new Client(); _client.ConversationHistoryLoaded += _client_ConversationHistoryLoaded; _client.NewConversationCreated += _client_NewConversationCreated; _client.UserInformationReceived += _client_UserInformationLoaded; _client.ConnectionEstablished += _client_OnConnectionEstablished; _client.NewMessageReceived += _client_NewMessageReceived; _client.UserInformationReceived += _client_UserInformationReceived; _client.UserPresenceChanged += _client_UserPresenceChanged; _client.ContactInformationReceived += _client_ContactInformationReceived; if(_authenticationManager.IsAuthenticated) _client.ConnectAsync(); ActiveContacts = new List<ConversationViewModel>(); App.Current.Dispatcher.Invoke(() => { System.Windows.Data.BindingOperations.EnableCollectionSynchronization(ActiveContacts, _lock); }); }
public MainViewModel() { OpenConversationCommand = new RelayCommand((p) => LoadConversation(p, true)); SetAuthenticationCodeCommand = new RelayCommand((p) => SetAuthenticationCode(p.ToString())); GetCodeCommand = new RelayCommand((p)=> GetCode()); SetPresenceCommand = new RelayCommand((p) => SetPresence()); _authenticationManager = new AuthenticationManager(); _authenticationManager.Connect(); _client = new Client(); _client.ContactListLoaded += _client_ContactListLoaded; _client.ConversationHistoryLoaded += _client_ConversationHistoryLoaded; _client.NewConversationCreated += _client_NewConversationCreated; _client.UserInformationReceived += _client_UserInformationLoaded; _client.ContactInformationReceived += _client_ContactInformationReceived; _client.ConnectionEstablished += _client_OnConnectionEstablished; _client.PresenceInformationReceived += _client_PresenceInformationReceived; if(_authenticationManager.IsAuthenticated) _client.Connect(); }