Exemple #1
0
        private void UserIcon_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var ofg = new OpenFileDialog
            {
                Title       = "选择一张图片:",
                Filter      = "图片文件 (.jpg, .png, .gif, .bmp)|*.jpg;*.png;*.gif;*.bmp",
                Multiselect = false
            };

            if (ofg.ShowDialog() == true)
            {
                if (!string.IsNullOrEmpty(ofg.FileName))
                {
                    var fi = new FileInfo(ofg.FileName);
                    if (fi.Length > 1048576)
                    {
                        MessageBox.Show("图片大小不能超过 1 MB", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    ofg.OpenFile();
                    var fs = new FileStream(ofg.FileName, FileMode.Open, FileAccess.Read,
                                            FileShare.Read);
                    _myInfo.Icon    = ByteImageConverter.ImageToByte(fs);
                    UserIcon.Source = ByteImageConverter.ByteToImage(Convert.FromBase64String(_myInfo.Icon));
                }
            }
        }
Exemple #2
0
        private void ShowUserInfo()
        {
            Task.Run(() =>
            {
                while (!Connection.IsExited)
                {
                    if (UserHelper.CurrentUser.IsChanged ?? false)
                    {
                        UserHelper.CurrentUser.IsChanged = false;
                        string idnty = null;
                        switch (UserHelper.CurrentUser.Type)
                        {
                        case 1:
                            idnty = "BOSS";
                            break;

                        case 2:
                            idnty = "管理员";
                            break;

                        case 3:
                            idnty = "教师";
                            break;

                        case 4:
                            idnty = "选手";
                            break;
                        }
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            Identity.Content = $"{UserHelper.CurrentUser.UserName},欢迎回来!当前身份:{idnty}";
                        }));
                        if (!string.IsNullOrEmpty(UserHelper.CurrentUser.Icon))
                        {
                            Dispatcher.BeginInvoke(new Action(() =>
                            {
                                UserIcon.Source =
                                    ByteImageConverter.ByteToImage(
                                        Convert.FromBase64String(UserHelper.CurrentUser.Icon));
                            }));
                        }
                        else
                        {
                            Dispatcher.BeginInvoke(new Action(() =>
                            {
                                UserIcon.Source = ByteImageConverter.ByteToImage(Convert.FromBase64String(
                                                                                     "iVBORw0KGgoAAAANSUh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ZTo6SGVpZ2h0ADUyOTNy2coAAAAXdEVYdFRodW1iOjpJbWFnZTo6V2lkdGgANTI5oIOJlwAAABl0RVh0VGh1bWI6Ok1pbWV0eXBlAGltYWdlL3BuZz+yVk4AAAAXdEVYdFRodW1iOjpNVGltZQAxNDY0MTk1NTYxyN1ubAAAABJ0RVh0VGh1bWI6OlNpemUAMjIuNktCSPcP1AAAAF90RVh0VGh1bWI6OlVSSQBmaWxlOi8vL2hvbWUvd3d3cm9vdC9zaXRlL3d3dy5lYXN5aWNvbi5uZXQvY2RuLWltZy5lYXN5aWNvbi5jbi9zcmMvMTIwMTQvMTIwMTQwOS5wbmdgVPHMAAAAAElFTkSuQmCC"));
                            }));
                        }
                    }
                    Thread.Sleep(1000);
                }
            });
        }
Exemple #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _myInfo = new UserInfo
            {
                UserName     = UserHelper.CurrentUser.UserName,
                Achievement  = UserHelper.CurrentUser.Achievement,
                UserId       = UserHelper.CurrentUser.UserId,
                Icon         = UserHelper.CurrentUser.Icon,
                Password     = UserHelper.CurrentUser.Password,
                RegisterDate = UserHelper.CurrentUser.RegisterDate,
                Type         = UserHelper.CurrentUser.Type
            };
            UserName.Text = _myInfo.UserName;
            if (!string.IsNullOrEmpty(_myInfo.Icon))
            {
                UserIcon.Source = ByteImageConverter.ByteToImage(Convert.FromBase64String(_myInfo.Icon));
            }
            Id.Content = _myInfo.UserId;
            switch (_myInfo.Type)
            {
            case 1:
                Identity.Content = "BOSS";
                break;

            case 2:
                Identity.Content = "管理员";
                break;

            case 3:
                Identity.Content = "教师";
                break;

            case 4:
                Identity.Content = "选手";
                break;
            }
        }