コード例 #1
0
 private void CreateUsersUI()
 {
     _globalControls.Clear();
     MyStack.Children.Clear();
     foreach (var item in _dal.GetAllUsers())
     {
         if (item.NickName != MyUserName.Content.ToString() &&
             item.NickName != _dal.CanCreateAdmin().NickName)
         {
             UserControl_ShowUser control = new UserControl_ShowUser();
             control.UserControl_Circle_Online.Foreground = ChangeUserStatusColor(item);
             control.UserControl_Name.Text = item.NickName;
             control.Height = (this.Height * 0.7205) / 12;
             _globalControls.Add(control);
             Button newUser = new Button()
             {
                 Content     = control,
                 Tag         = item.NickName,
                 Foreground  = Brushes.Black,
                 Background  = Brushes.Transparent,
                 BorderBrush = Brushes.Transparent,
                 Height      = 60 + this.Height / 90,
                 HorizontalContentAlignment = HorizontalAlignment.Left,
                 Margin = new Thickness(0, 0, 20, 0)
             };
             newUser.Click += new RoutedEventHandler(UserClick);
             MyStack.Children.Add(newUser);
         }
     }
 }
コード例 #2
0
        private void FillUserInfo(Client_Cursova.ServiceReference1.User user, UserControl_ShowUser control)
        {
            var timeuser = _dal.GetUserLog(user.NickName).LastOrDefault().Date;//!!!!!
            var timenow  = DateTime.Now;

            if (user.IsOnline == false)
            {
                if (timenow.Day - timeuser.Day <= 0)
                {
                    if (timenow.Hour - timeuser.Hour <= 0)
                    {
                        if (timenow.Minute - timeuser.Minute <= 0)
                        {
                            control.UserControl_Text_Online.Text = $"left {timenow.Second - timeuser.Second} second ago";
                        }
                        else
                        {
                            control.UserControl_Text_Online.Text = $"left {timenow.Minute - timeuser.Minute} min ago";
                        }
                    }
                }
                else
                {
                    control.UserControl_Text_Online.Text = $"left {timenow.Day - timeuser.Day} day ago";
                }
            }
            else
            {
                control.UserControl_Text_Online.Text = "online";
            }
            control.UserControl_Circle_Online.Foreground = ChangeUserStatusColor(user);
        }