public Menu() { UserC user = (UserC)Unpackage <UserC> .Upackage(sw.GetMyData(Const.session)); InitializeComponent(); tName.Content = user.name + " " + user.surname; tPhone.Content = user.phone; tEmai.Content = user.email; elipse.Fill = Brushes.BlueViolet; tSubname.Content = ("" + user.name[0] + user.surname[0]).ToUpper(); GMenu = this; LAutor.Cursor = Cursors.Hand; Contacts.Cursor = Cursors.Hand; Settings.Cursor = Cursors.Hand; Exit.Cursor = Cursors.Hand; Contacts.MouseEnter += Contacts_MouseEnter; Contacts.MouseLeave += Contacts_MouseLeave; Settings.MouseEnter += Contacts_MouseEnter; Settings.MouseLeave += Contacts_MouseLeave; Exit.MouseEnter += Contacts_MouseEnter; Exit.MouseLeave += Contacts_MouseLeave; Contacts.MouseLeftButtonDown += InformMouseLeftButtonDown; LAutor.MouseLeftButtonDown += Settings_MouseLeftButtonDown; Exit.MouseLeftButtonDown += Exit_MouseLeftButtonDown; Settings.MouseLeftButtonDown += Origin_MouseLeftButtonDown; }
public UserC GetUserById(string hach, int id) { ArrayList user = Service.GetUserById(hach, id); UserC u = (UserC)Unpackage <UserC> .Upackage(user); return(u); }
private static void Exit_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ServerWorks server = new ServerWorks(); UserC user = (UserC)Unpackage <UserC> .Upackage(server.GetMyData(Const.session)); using (FileStream fstream = File.Open(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "session.txt"), FileMode.Create)) { } server.RemoveHach(user.userName); MessageBox.Show("Всего хорошего!"); Environment.Exit(0); }
public List <UserC> GetSearchResult(string hach, string search) { try { List <ArrayList> list = Service.GetSearchResult(hach, search); return(Unpackage <UserC> .Upackage(list)); } catch (Exception) { return(null); } }
public List <MessageC> GetAllMessageUser(string hach, int id) { try { List <MessageC> list = Unpackage <MessageC> .Upackage(Service.GetAllUserMessage(hach, id)); return(list); } catch (Exception) { return(null); } }
public void UpdateMessage() { while (true) { Thread.Sleep(2000); Dispatcher.BeginInvoke(new ThreadStart(delegate { if (sw.GetLastIdLastUser(Const.session) > Const.LastIdLastUser && string.IsNullOrEmpty(tBox.Text)) { List <LastMessageC> list = Unpackage <LastMessageC> .Upackage(sw.GetLastMessageUser(Const.session)); if (list != null) { StackPanel.Children.Clear(); foreach (var l in list) { UserC user = new UserC(); user = sw.GetUserById(Const.session, swh.GetIdSecondUser(l)); DateTime dt = DateTime.Parse(l.time); CustomButton bt = new CustomButton { IdUser = swh.GetIdSecondUser(l), Template = (ControlTemplate)this.TryFindResource("BtTemplate") }; if (l.idUserMessage == l.idSender) { bt.TextMessage = "Вы: " + l.message; bt.StatusMessage = -1; } else { bt.TextMessage = l.message; bt.StatusMessage = l.status; } bt.TextName = user.name + " " + user.surname; bt.TextSubname = ("" + user.name[0] + user.surname[0]).ToUpper(); bt.TextTime = dt.TimeOfDay.ToString(); bt.ColorMessage = new SolidColorBrush(System.Windows.Media.Color.FromRgb(168, 168, 168)); bt.ColorName = new SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 34, 34)); bt.ColorTime = new SolidColorBrush(System.Windows.Media.Color.FromRgb(168, 168, 168)); bt.CountNewMessage = l.CountNewMessage.ToString(); StackPanel.Children.Add(bt); Const.LastIdLastUser = sw.GetLastIdLastUser(Const.session); } } } })); } }
public void SetData() { Message.GStackPanel.Children.Clear(); SolidColorBrush scbS = swh.RandomColor(); SolidColorBrush scbR = swh.RandomColor(); sw.UpdateNewMessage(Const.session, Const.IdFocus); List <MessageC> list = sw.GetAllMessageUser(Const.session, Const.IdFocus); if (list != null) { ServerWorksHelper.GetMessageLastId(list); foreach (var m in list) { UserC c = sw.GetUserById(Const.session, Const.IdFocus); UserC user = (UserC)Unpackage <UserC> .Upackage(sw.GetMyData(Const.session)); CustomMessage bt = new CustomMessage(); DateTime dt = DateTime.Parse(m.time); bt.TextTime = dt.TimeOfDay.ToString(); if (m.idReseiver == Const.IdFocus) { bt.ColorBackgroundMessage = new SolidColorBrush(System.Windows.Media.Color.FromRgb(239, 253, 222)); bt.ColorBackgroundCircle = scbS; bt.TextSub = ("" + user.name[0] + user.surname[0]).ToUpper(); } else { bt.ColorBackgroundMessage = Brushes.White; bt.ColorBackgroundCircle = scbR; bt.TextSub = ("" + c.name[0] + c.surname[0]).ToUpper(); } bt.TextMessage = m.message; bt.CheckImageSource = m.status == 1 ? new BitmapImage(new Uri("/icons/statusone.png", UriKind.Relative)) : new BitmapImage(new Uri("/icons/statustwo.png", UriKind.Relative)); bt.Template = (ControlTemplate)(this.TryFindResource("Bt2Template")); Message.GStackPanel.Children.Add(bt); } Message.GsViewer.ScrollToEnd(); } }
private void TBox_TextChanged(object sender, TextChangedEventArgs e) { if (!string.IsNullOrEmpty(tBox.Text)) { var children = StackPanel.Children.OfType <UIElement>().ToList(); foreach (UIElement s in children) { if (((CustomButton)s).TextMessage.Contains(tBox.Text) || ((CustomButton)s).TextName.Contains(tBox.Text)) { } else { StackPanel.Children.Remove(((CustomButton)s)); } } } else { List <LastMessageC> list = Unpackage <LastMessageC> .Upackage(sw.GetLastMessageUser(Const.session)); if (list != null) { StackPanel.Children.Clear(); foreach (var l in list) { UserC user = new UserC(); user = sw.GetUserById(Const.session, swh.GetIdSecondUser(l)); DateTime dt = DateTime.Parse(l.time); CustomButton bt = new CustomButton { IdUser = swh.GetIdSecondUser(l), Template = (ControlTemplate)this.TryFindResource("BtTemplate") }; if (l.idUserMessage == l.idSender) { bt.TextMessage = "Вы: " + l.message; bt.StatusMessage = -1; } else { bt.TextMessage = l.message; bt.StatusMessage = l.status; } bt.TextName = user.name + " " + user.surname; bt.TextSubname = ("" + user.name[0] + user.surname[0]).ToUpper(); bt.TextTime = dt.TimeOfDay.ToString(); bt.ColorMessage = new SolidColorBrush(System.Windows.Media.Color.FromRgb(168, 168, 168)); bt.ColorName = new SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 34, 34)); bt.ColorTime = new SolidColorBrush(System.Windows.Media.Color.FromRgb(168, 168, 168)); bt.CountNewMessage = l.CountNewMessage.ToString(); StackPanel.Children.Add(bt); Const.LastIdLastUser = sw.GetLastIdLastUser(Const.session); } } } }