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(); }
public ConversationViewModel(WTalk.Model.Conversation conversation, Client client):this(client) { this.Conversation = conversation; this.Conversation.NewMessageReceived += Conversation_NewMessageReceived; this.Contact = client.GetContactFromCache(conversation.Participants.Where(c => c.Key != client.CurrentUser.Id).FirstOrDefault().Key).Result; if (this.Contact != null) _name = this.Contact.DisplayName; else _name = "Unknown User"; }
public ConversationViewModel(WTalk.Model.Conversation conversationCache, Client client) { this.Participant = conversationCache.Participants.Values.FirstOrDefault(c=>c.Id != client.CurrentUser.id.chat_id); this.Messages = new ObservableCollection<Message>(conversationCache.MessagesHistory); _lastMessage = this.Messages.LastOrDefault(); this._conversationCache = conversationCache; this._client = client; this._client.NewConversationEventReceived += _client_NewConversationEventReceived; SendMessageCommand = new RelayCommand((p) => SendMessage(p.ToString())); SetFocusCommand = new RelayCommand((p) => SetFocus(_conversationCache.Id)); }
public ConversationViewModel(Client client):this() { _client = client; }
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); }); }