Exemplo n.º 1
0
        public void GonewMessage()
        {
            while (true)
            {
                Thread.Sleep(2000);
                if (Const.IdFocus != -1)
                {
                    sw.UpdateNewMessage(Const.session, Const.IdFocus);

                    Dispatcher.BeginInvoke(new ThreadStart(delegate
                    {
                        if (sw.GetLastIdMessage(Const.session, Const.IdFocus) > Const.LastId)
                        {
                            cm.SetData();
                        }
                    }
                                                           ));
                }
            }
        }
Exemplo n.º 2
0
        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();
            }
        }