/// <summary> /// Abre una ventana de chat /// </summary> private void OpenChatWindow(ContactNodeViewModel nodeContact) { if (nodeContact != null) { OpenChatWindow(nodeContact.GetConnectionNode()?.Connection, nodeContact.Contact, null); } }
/// <summary> /// Comprueba si se puede ejecutar una acción /// </summary> protected override bool CanExecuteAction(string action, object parameter) { JabberConnection connection = Tree.GetSelectedConnection(); ContactNodeViewModel nodeContact = Tree.GetSelectedContact(); switch (action) { case nameof(NewContactCommand): case nameof(NewGroupCommand): return((connection != null && connection.IsConnected) || nodeContact != null || Tree.GetSelectedGroup() != null); case nameof(DeleteCommand): return(connection != null || nodeContact != null); case nameof(StartChatCommand): return(connection != null); case nameof(ConnectCommand): return(connection != null && !connection.IsConnected); case nameof(DisconnectCommand): case nameof(SetUserStatusCommand): return(connection != null && connection.IsConnected); case nameof(RefreshCommand): return(true); default: return(false); } }
/// <summary> /// Elimina un contacto /// </summary> private void DeleteContact(ContactNodeViewModel nodeContact) { if (nodeContact != null && BauMessengerViewModel.Instance.ControllerWindow.ShowQuestion($"¿Realmente desea eliminar el contacto {nodeContact.Contact.FullJid}?")) { JabberConnection connection = nodeContact.GetConnectionNode()?.Connection; if (connection == null) { BauMessengerViewModel.Instance.ControllerWindow.ShowMessage("No se encuentra la conexión del contacto"); } else { connection.DeleteContact(nodeContact.Contact); } } }