public ChatControl IniciarChat(Lbl.Personas.Persona personaRemota, string estacionRemota) { if (this.InvokeRequired) { object Res = this.Invoke((Func <object>)(delegate { return(this.IniciarChat(personaRemota, estacionRemota)); })); return(Res as ChatControl); } else { ChatControl NuevoCtrl = new ChatControl(); NuevoCtrl.Margin = new Padding(8); NuevoCtrl.Dock = DockStyle.Fill; NuevoCtrl.Visible = true; this.SuspendLayout(); this.Controls.Add(NuevoCtrl); this.ResumeLayout(true); NuevoCtrl.IniciarChat(personaRemota, estacionRemota); ToolStripButton Pestania = new ToolStripButton(personaRemota.ToString()); Pestania.Margin = new System.Windows.Forms.Padding(2); Pestania.Tag = NuevoCtrl; Pestania.Checked = true; this.Pestanias.Items.Add(Pestania); NuevoCtrl.Select(); Listado.Visible = false; return(NuevoCtrl); } }
public bool MostrarChat(string nombre) { bool Encontrado = false; foreach (System.Windows.Forms.ToolStripItem Btn in this.Pestanias.Items) { if (Btn is System.Windows.Forms.ToolStripButton) { ChatControl Ctrl = Btn.Tag as ChatControl; if (Ctrl.PersonaRemota.Nombre == nombre) { Ctrl.Visible = true; Encontrado = true; Ctrl.Select(); } else { Ctrl.Visible = false; } } } Listado.Visible = Encontrado == false; return(Encontrado); }
public void MensajeRecibido(Lbl.Notificaciones.INotificacion notif) { ChatControl Ctrl = null; bool Encontrado = false; foreach (System.Windows.Forms.ToolStripItem Btn in this.Pestanias.Items) { if (Btn is System.Windows.Forms.ToolStripButton) { Ctrl = Btn.Tag as ChatControl; if (Ctrl.PersonaRemota.Id == notif.Remitente.Id) { Encontrado = true; Ctrl.MensajeRecibido(notif); } } } if (Encontrado == false) { Ctrl = this.IniciarChat(notif.Remitente, notif.EstacionOrigen); Ctrl.MensajeRecibido(notif); } if (this.InvokeRequired) { this.Invoke(new MethodInvoker(delegate { this.ShowAndFlash(); })); } else { this.ShowAndFlash(); } }
public ChatControl IniciarChat(Lbl.Personas.Persona personaRemota, string estacionRemota) { if (this.InvokeRequired) { object Res = this.Invoke((Func<object>)(delegate { return this.IniciarChat(personaRemota, estacionRemota); })); return Res as ChatControl; } else { ChatControl NuevoCtrl = new ChatControl(); NuevoCtrl.Margin = new Padding(8); NuevoCtrl.Dock = DockStyle.Fill; NuevoCtrl.Visible = true; this.SuspendLayout(); this.Controls.Add(NuevoCtrl); this.ResumeLayout(true); NuevoCtrl.IniciarChat(personaRemota, estacionRemota); ToolStripButton Pestania = new ToolStripButton(personaRemota.ToString()); Pestania.Margin = new System.Windows.Forms.Padding(2); Pestania.Tag = NuevoCtrl; Pestania.Checked = true; this.Pestanias.Items.Add(Pestania); NuevoCtrl.Select(); Listado.Visible = false; return NuevoCtrl; } }
public void MostrarContactos() { if (Lbl.Notificaciones.Administrador.Principal != null) { Lbl.Notificaciones.Administrador.Principal.ActualizarUsuariosConectados(); List <ListViewItem> Eliminar = new List <ListViewItem>(); foreach (ListViewItem Itm in Listado.Items) { Eliminar.Add(Itm); } if (Lbl.Notificaciones.Administrador.Usuarios.Count > 0) { foreach (Lbl.Notificaciones.UsuarioConectado Usu in Lbl.Notificaciones.Administrador.Usuarios.Values) { string IdContacto = Usu.Id.ToString(); ListViewItem Itm; if (Listado.Items.ContainsKey(IdContacto)) { Itm = Listado.Items[IdContacto]; } else { Itm = Listado.Items.Add(IdContacto, Usu.Nombre, 0); } if (Usu.Estado == 0) { Itm.ForeColor = Color.Silver; Itm.ToolTipText = "Desconectado"; } else { Itm.ForeColor = Listado.ForeColor; Itm.ToolTipText = "Conectado en " + Usu.Estacion; } if (Eliminar.Contains(Itm)) { Eliminar.Remove(Itm); } Itm.Name = IdContacto; Itm.Text = Usu.Nombre; } } foreach (ListViewItem Itm in Eliminar) { Listado.Items.Remove(Itm); } // Actualizo las ventanas de chat foreach (System.Windows.Forms.ToolStripItem Btn in this.Pestanias.Items) { if (Btn is System.Windows.Forms.ToolStripButton) { ChatControl Ctrl = Btn.Tag as ChatControl; Ctrl.Offline = !Lbl.Notificaciones.Administrador.Usuarios.ContainsKey(Ctrl.PersonaRemota.Id); } } Listado.Sort(); } }