예제 #1
0
        private void Box_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key != Key.Enter)
            {
                return;
            }
            if (Box.Text.Equals(""))
            {
                return;
            }
            UserC user = sw.GetUserById(Const.session, Const.IdFocus);

            sw.SendMessage(Const.session, user.userName, Box.Text);
            Box.Text = "";
        }
예제 #2
0
        public Info()
        {
            sw = new ServerWorks();
            InitializeComponent();
            BtnClose.Cursor = Cursors.Hand;
            BtnClose.MouseLeftButtonDown += Message.GlobalCanvas_MouseLeftButtonDown;
            GlobalInfo = this;
            UserC user = sw.GetUserById(Const.session, Const.IdFocus);

            Ellipse.Fill        = Const.secondColor;
            NameSurname.Content = user.name + " " + user.surname;
            SubName.Content     = (user.name[0] + "" + user.surname[0]).ToUpper();
            UserName.Content    = user.userName;
            Phone.Content       = user.phone;
            Email.Content       = user.email;
        }
예제 #3
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();
            }
        }
예제 #4
0
        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);
                    }
                }
            }
        }