public SendImageParams(string mid, User user, WhatsApp wa, string phoneNum, string sendFileName) { this.mid = mid; this.user = user; this.wa = wa; this.phoneNum = phoneNum; this.sendFileName = sendFileName; }
private void Window_Unloaded(object sender, RoutedEventArgs e) { if (this.typingTimer != null && this.typingTimer.IsEnabled) { this.typingTimer.Stop(); } if (this.wa != null) { this.wa.WhatsSendHandler.SendPaused(this.user.WhatsUser.GetFullJid()); } WpfsApp.MainWindow.MessageEvent -= MainWindow_MessageEvent; this.user = null; this.wa = null; this.phoneNum = null; this.messages = null; this.patternEmojis = null; Properties.Settings.Default.mwidth = this.Width; Properties.Settings.Default.mheight = this.Height; Properties.Settings.Default.mleft = this.Left; Properties.Settings.Default.mtop = this.Top; Properties.Settings.Default.Save(); }
public static Dictionary<string, User> Users(string phoneNum) { lock (oneLock) { Dictionary<string, User> _userList = new Dictionary<string, User>(); SQLiteConnection sql_con = new SQLiteConnection("Data Source=WpfsApp.db;Version=3;New=False;Compress=False;"); sql_con.Open(); SQLiteCommand command = new SQLiteCommand("SELECT DISTINCT(mfrom) FROM message WHERE muser = '******' ORDER BY mt ASC", sql_con); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { try { if (reader["mfrom"] == null || reader["mfrom"].Equals("")) continue; string jid = reader["mfrom"].ToString().Substring(0, 11); string phone = reader["mfrom"].ToString().Substring(2, 9); string name = phone; SQLiteCommand command2 = new SQLiteCommand("SELECT mname FROM message WHERE mname <> '' AND mfrom = '" + reader["mfrom"] + "' ORDER BY mt ASC LIMIT 1", sql_con); SQLiteDataReader reader2 = command2.ExecuteReader(); if (reader2.Read()) { name = reader2["mname"].ToString(); } reader2.Close(); User tmpUser = new User(phone, name, jid); _userList.Add(jid, tmpUser); } catch (Exception e) { Console.WriteLine("Users() ERROR:" + e.Message); throw; } } reader.Close(); sql_con.Close(); return _userList; } }
private void ShowMessages(User user) { if (!MainWindow.msgWins.ContainsKey(user.Jid)) { Mensajes msgs = new Mensajes(this.phoneNum, user, this.wa); msgs.Owner = this; MainWindow.msgWins.Add(user.Jid, msgs); msgs.Show(); msgs.Activate(); this.PrintUsers(); } else { Mensajes msgs; MainWindow.msgWins.TryGetValue(user.Jid, out msgs); if (!msgs.IsLoaded) { MainWindow.msgWins.Remove(user.Jid); msgs = null; ShowMessages(user); return; } msgs.Show(); if (msgs.WindowState == WindowState.Minimized) { msgs.WindowState = WindowState.Normal; } msgs.Activate(); } }
private ListBoxItem MakeItem(User user) { int unreadMessages = Database.MessagesUnread(this.phoneNum, user.WhatsUser.GetFullJid()); ListBoxItem item = new ListBoxItem(); Image img = new Image(); img.Height = 64; img.Width = 64; if (user.Img == null) { img.Source = Utils.ImageFromResource(Properties.Resources.icon); } else { BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = new MemoryStream(user.Img); bi.EndInit(); img.Source = bi; } item.Content = img; item.Margin = new Thickness(0, 0, 5, 0); item.IsEnabled = false; TextBlock txtblock = new TextBlock(); txtblock.Text = user.UserName; if (unreadMessages > 0) { txtblock.Text = user.UserName + " (" + unreadMessages + ")"; } txtblock.FontFamily = new FontFamily("Segoe UI"); txtblock.FontSize = 14; txtblock.FontWeight = FontWeights.Bold; txtblock.Padding = new Thickness(0, 10, 0, 0); TextBlock txtblock2 = new TextBlock(); txtblock2.Text = user.PhoneNumber; txtblock2.FontFamily = new FontFamily("Segoe UI"); txtblock2.FontSize = 11; txtblock2.Foreground = Brushes.Gray; TextBlock txtblock3 = new TextBlock(); txtblock3.Text = user.Last; if (user.Last == "") { txtblock3.Text = "Cargando..."; } txtblock3.FontFamily = new FontFamily("Segoe UI"); txtblock3.FontSize = 11; StackPanel panel2 = new StackPanel(); panel2.Orientation = Orientation.Vertical; panel2.Children.Add(txtblock); panel2.Children.Add(txtblock2); panel2.Children.Add(txtblock3); StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Horizontal; panel.Children.Add(item); panel.Children.Add(panel2); ListBoxItem bigItem = new ListBoxItem(); bigItem.Content = panel; bigItem.Tag = user; bigItem.MouseDoubleClick += bigItem_MouseDoubleClick; bigItem.ContextMenu = this.menuContacts; return bigItem; }
public Mensajes(string phoneNum, User user, WhatsApp wa) { this.user = user; this.wa = wa; this.phoneNum = phoneNum; InitializeComponent(); WpfsApp.MainWindow.MessageEvent += MainWindow_MessageEvent; this.typingTimer = new DispatcherTimer(); this.typingTimer.Tick += new EventHandler(typingTimer_Tick); this.typingTimer.Interval = new TimeSpan(0, 0, 5); this.patternEmojis = Utils.GetEmojiCompletePattern(); // Ocultar this.lblUser.Visibility = Visibility.Collapsed; this.imgUser.Visibility = Visibility.Collapsed; if (user.Img != null) { BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = new MemoryStream(user.Img); bi.EndInit(); this.imgUser.Source = bi; this.lblUser.Content = user.UserName; this.imgUser.Visibility = Visibility.Visible; this.lblUser.Visibility = Visibility.Visible; } }