public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data) { var kbp = new KanbanItemProperty { Name = property.Name }; SetColor(kbp, setting.Color); JObject jObj = JObject.FromObject(task); string uid = JTokenHelper.GetPropertyValue <string>(jObj, property.Key); if (!string.IsNullOrEmpty(uid)) { var avatar = AvatarHelper.GetAvatar(uid, AvatarSize.X40); if (property.RawKey == "assignee") { kanban.Due = avatar; } else { kbp.Value = avatar.DisplayName; kanban.Properties.Add(kbp); } } }
public async Task <CurrentUserProfileModel> GetCurrentUserProfleAsync() { var cp = _httpContextAccessor.HttpContext.User; var user = await _userManager.FindByNameAsync(cp.Identity.Name); var roles = await _userManager.GetRolesAsync(user); var permissions = await _roleManager.GetRolesPermissionsAsync(roles.ToArray()); var model = new CurrentUserProfileModel() { DisplayName = user.DisplayName, PhoneNumber = user.PhoneNumber, Bio = user.Bio, UserDescription = user.UserDescription, Email = user.Email, Roles = roles, Permissions = permissions, AvatarUrl = AvatarHelper.GetSrc(user.Email), }; #if DEBUG model.IdentityName = cp.Identity.Name; model.AuthenticationType = cp.Identity.AuthenticationType; model.Claims = cp.Claims.Select(t => new IdentityClaim(t.Type, t.Value)).ToArray(); #endif return(model); }
public void GotANewFriend(User newFriend) { ListViewItem item = _displayFriends.ToList().Find(x => (x.Content as DisplayUser).Username == newFriend.Username); DisplayUser user = item.Content as DisplayUser; user.UserType = UserType.Friends; user.IsOnline = newFriend.IsOnline; if (user.IsOnline == true) { item.ContentTemplate = (DataTemplate)this.FindResource("OnlineTemplate"); } else { item.ContentTemplate = (DataTemplate)this.FindResource("OfflineTemplate"); } ICollectionView view = CollectionViewSource.GetDefaultView(lvFriends.ItemsSource); view.Refresh(); if (pnReceiveRequest.Visibility == Visibility.Visible || pnSentRequest.Visibility == Visibility.Visible) { CollapseAllPanels(); pnChat.Visibility = Visibility.Visible; pnChat.Visibility = Visibility.Visible; txtblNameCurFriend.Text = newFriend.Name; txtblUsernameCurFriend.Text = newFriend.Username; AvatarHelper.LoadAvatarFromLocal(imgCurFriend, newFriend.Username); lvChatMessages.ItemsSource = _displayMessages[newFriend.Username]; txtblIsWritting.Text = ""; } NotificationHelper.NotifyInfo(newFriend.Name + " is your friend now!"); }
/// <summary> /// 设置默认邮箱 /// </summary> /// <param name="defaultMail"></param> public void SetDefautMail(string defaultMail) { mailTextBox.Text = defaultMail; string userInputMail = mailTextBox.Text == string.Empty ? "*****@*****.**" : mailTextBox.Text; userImgBox.Fill = new ImageBrush(AvatarHelper.GetAvatarByEmail(userInputMail)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string valueStr = value as string; string userInputMail = valueStr == string.Empty ? "*****@*****.**" : valueStr; return(new ImageBrush(AvatarHelper.GetAvatarByEmail(userInputMail))); }
public UpdateInformation(ZolaService.User user) { InitializeComponent(); this._curUser = user; this.txtUsername.Text = user.Username; this.txtName.Text = user.Name; if (_curUser.IsMale == true) { cbMale.IsChecked = true; } if (_curUser.IsMale == false) { cbFemale.IsChecked = true; } string avatarPath = AvatarHelper.GetAvatarPath(user.Username); if (avatarPath != null) { imgAvatar.Source = new BitmapImage(new Uri(avatarPath, UriKind.Absolute)); } openFile.Filter = "Image Files (*.png, *.jpg, *.jpeg)|*.png;*.jpg;*.jpeg"; openFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); openFile.Multiselect = false; btnUpdateImage.IsEnabled = false; }
// GET: Address/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var address = await _context.Addresses .FirstOrDefaultAsync(m => m.Id == id); if (address == null) { return(NotFound()); } if (address.Avatar != null) { ViewData["Avatar"] = AvatarHelper.GetImage(address.Avatar, address.FileName); } else { ViewData["Avatar"] = "../../Images/icons8-cat-profile-50.png"; } return(View(address)); }
public async Task <IActionResult> Create([Bind("FirstName,LastName,Email,ImagePath,ImageData,Address1,Address2,City,State,ZipCode,PhoneNumber,Created,Updated,Note")] AddressRecord addressRecord, IFormFile imageData) { if (ModelState.IsValid) { if (imageData != null) { addressRecord.ImagePath = imageData.FileName; addressRecord.ImageData = AvatarHelper.EncodeImage(imageData); } addressRecord.Created = DateTime.Now; var truncPhone = addressRecord.PhoneNumber .Replace(" ", "") .Replace("(", "") .Replace(")", "") .Replace("-", ""); var formatedPhone = $"({truncPhone.Substring(0, 3)}) {truncPhone.Substring(3, 3)}-{truncPhone.Substring(6, 4)}"; addressRecord.PhoneNumber = formatedPhone; _context.Add(addressRecord); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(addressRecord)); }
public async void LoadProfile() { ApiResponse response = await ApiHelper.Get <ProfileViewModel>("api/user/myprofile", true); if (response.IsSuccess) { var profile = (ProfileViewModel)response.Content; UserLogged.FullName = profile.FullName; UserLogged.Phone = profile.Phone; UserLogged.Address = profile.Address; if (profile.Sex.HasValue) { UserLogged.Sex = profile.Sex.Value ? 1 : 0; this.viewModel.SexOption = this.viewModel.SexOptions.SingleOrDefault(x => x.Id == UserLogged.Sex); } else { UserLogged.Sex = -1; } if (profile.Birthday.HasValue) { UserLogged.Birthday = profile.Birthday.Value.AddDays(1); viewModel.Birthday = UserLogged.Birthday; } EntryName.Text = profile.FullName; EntryPhone.Text = profile.Phone; EntryEmail.Text = profile.Email; EntryAddress.Text = profile.Address; if (string.IsNullOrEmpty(profile.Email)) { EntryEmail.IsEnabled = true; } lblDefaultAvatar.Text = AvatarHelper.NameToAvatarText(UserLogged.FullName); if (profile.Avatar != null && profile.Avatar.Length > 0) { UserLogged.AvatarUrl = AvatarHelper.ToAvatarUrl(profile.Avatar); ImageSource avatarImageSource = new UriImageSource() { Uri = new Uri(UserLogged.AvatarUrl), CachingEnabled = false, }; SetAvatar(avatarImageSource); } gridLoading.IsVisible = false; } else { await DisplayAlert("", "Không lấy được thông tin cá nhân", "Đóng"); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null) { var x = AvatarHelper.ToAvatarUrl(value.ToString()); return(x); } return(""); }
public ProxiesController(ProxyDataContext db, IConfiguration cfg, DiscordHelper discordHelper, AvatarHelper avatarHelper, ILogger <ProxiesController> logger) { this.db = db; this.cfg = cfg; this.discordHelper = discordHelper; this.avatarHelper = avatarHelper; this.logger = logger; }
public DatabaseHelperProvider(VoteMystContext context, AvatarHelper avatarHelper) { Context = context; Authorization = new AuthorizationHelper(context); Users = new UserAccountHelper(context, avatarHelper); Entries = new EntryHelper(context); Events = new EventHelper(context); Votes = new VoteHelper(context); }
public async Task <IActionResult> RemoveAvatar(string username) { var user = await _userManager.GetUserAsync(HttpContext.User); if (user != null) { user.Avatar = AvatarHelper.GetRandomAvatar(); await _userManager.UpdateAsync(user); } return(Ok(user.Avatar)); }
public void SpawnKingBoss() { currentBoss = bossScenarios.list[Random.Range(0, bossScenarios.list.Count)]; currentChar = BossScript.avaList[Random.Range(0, BossScript.avaList.Count)]; string con = currentBoss.eventMsg.Replace("%name%", names.nounList[Random.Range(0, names.nounList.Count)]).Replace("%item%", items.nounList[Random.Range(0, items.nounList.Count)]).Replace("%place%", places.nounList[Random.Range(0, places.nounList.Count)]); con = con.Replace("%test%", names.nounList[Random.Range(0, names.nounList.Count)]); bossKillText.text = con; bossName.text = "Król z dynastii " + currentLand.name.ToString(); bossAvatar.sprite = currentChar.avatarImg; bossBackground.color = LandColor; }
private void FindFriendAvatar_DoWork(object sender, DoWorkEventArgs e) { ZolaService.DataFile avatar = null; string username = e.Argument.ToString(); if (App.Proxy.IsUserHasAvatar(username)) { avatar = App.Proxy.GetAvatarFile(username); AvatarHelper.SaveAvatar(username, avatar); } e.Result = username; }
public static void ForShowEntity(this Entity entity) { entity.Avatar = new TethysAvatar { DisplayName = entity.CreatedBy.DisplayName, Background = AvatarHelper.GetColorBrush(entity.CreatedBy.DisplayName), Source = AvatarHelper.GetAvatarBitmap(entity.CreatedBy.Avatar, AvatarSize.X40, FromType.User) }; entity.Icon = WtFileHelper.GetFileIcon(entity.Addition.Ext); entity.IsEnableDelete = entity.CreatedBy.Uid == DataSource.ApiUserMeData.Me.Uid; entity.IsEnableDownload = entity.Addition.Path != null && !(entity.Addition.Path.StartsWith("http://") || entity.Addition.Path.StartsWith("https://")) && (entity.Type == MessageType.File || entity.Type == MessageType.Image); }
private void AvatarWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { string username = e.Result.ToString(); if (AvatarHelper.GetAvatarPath(username) == null) { return; } DisplayUser user = _displayUsers.ToList().Find(x => (x.Content as DisplayUser).Username == username).Content as DisplayUser; user.AvatarUrl = null; user.AvatarUrl = AvatarHelper.GetAvatarPath(username); }
private void FindFriendAvatar_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { string username = e.Result.ToString(); DisplayUser user = _displayFriends.ToList().Find(x => (x.Content as DisplayUser).Username == username).Content as DisplayUser; user.AvatarUrl = null; string avatarPath = AvatarHelper.GetAvatarPath(username); if (avatarPath == null) { avatarPath = AvatarHelper.DefaultAvatarPath; } user.AvatarUrl = avatarPath; }
public CommentItem Add(CommentDetail item) { var c = new Comments(); try { var post = _ctx.Posts.Where(p => p.Id == item.PostId).FirstOrDefault(); c.CommentDate = DateTime.Now; c.ParentId = item.ParentId; c.IsApproved = true; c.Content = item.Content; if (string.IsNullOrEmpty(item.Author.Id)) { var guid = Guid.NewGuid().ToString().Replace("-", ""); var user = new ApplicationUser { UserName = "******" + guid, Email = item.Author.Email, DisplayName = "匿名_" + item.Author.DisplayName }; user.Avatar = AvatarHelper.GetRandomAvatar(); var result = _userManager.CreateAsync(user).Result; if (!result.Succeeded) { return(null); } item.Author = user; } c.Author = item.Author; c.Ip = AspNetCoreHelper.GetRequestIP(); c.Posts = post; _ctx.Comments.Add(c); _ctx.SaveChanges(); //var profile = AuthorProfile.GetProfile(c.Author); //if (profile != null && !string.IsNullOrEmpty(profile.DisplayName)) //{ // c.Author = profile.DisplayName; //} //c.Email = Membership.Provider.GetUser(Security.CurrentUser.Identity.Name, true).Email; //c.IP = WebUtils.GetClientIP(); //c.DateCreated = DateTime.Now; //c.Parent = post; var newComm = post.Comments.Where(cm => cm.Content == c.Content).FirstOrDefault(); return(_jsonService.GetComment(newComm, post.Comments.ToList())); } catch (Exception ex) { return(null); } }
public void StartGame() { MapMenu.SetActive(false); current = eventScrip.list[Random.Range(0, eventScrip.list.Count)]; Debug.Log(charScrip.avaList[Random.Range(0, charScrip.avaList.Count)]); currentChar = charScrip.avaList[Random.Range(0, charScrip.avaList.Count - 1)]; CardMenu.SetActive(true); string con = current.eventMsg.Replace("%name%", names.nounList[Random.Range(0, names.nounList.Count)]).Replace("%item%", items.nounList[Random.Range(0, items.nounList.Count)]).Replace("%place%", places.nounList[Random.Range(0, places.nounList.Count)]); con = con.Replace("%test%", names.nounList[Random.Range(0, names.nounList.Count)]); lore.text = con; avatar.sprite = currentChar.avatarImg; characterName.text = currentChar.charName; avaBackground.color = LandColor; }
public async void SaveProfile() { var fullName = EntryName.Text.Trim(); var phone = EntryPhone.Text.Trim(); var address = EntryAddress.Text.Trim(); var email = EntryEmail.Text.Trim(); var data = new Dictionary <string, object>(); data["FullName"] = fullName; data["Phone"] = phone; data["Address"] = address; if (EntryEmail.IsEnabled) { data["Email"] = email; } if (viewModel.SexOption != null) { bool sex = viewModel.SexOption.Id == 1 ? true : false; data["Sex"] = sex; } if (viewModel.Birthday != null) { data["Birthday"] = viewModel.Birthday; } ApiResponse response = await ApiHelper.Post("api/user/updateprofile", data, true); if (response.IsSuccess) { XFToast.ShortMessage("Cập nhật thành công"); EntryEmail.IsEnabled = false; UserLogged.FullName = fullName; UserLogged.Phone = phone; UserLogged.Address = address; lblDefaultAvatar.Text = AvatarHelper.NameToAvatarText(UserLogged.FullName); // update lai full name //var account = PageHelper.GetAccountTabPage(); //account_grouplv account_Grouplv = account.Content as account_grouplv; //account_Grouplv.RefreshName(); } else { await DisplayAlert("", "Không thể cập nhật thông tin cá nhân. " + response.Message, "Đóng"); } gridLoading.IsVisible = false; }
private void AvatarWorker_DoWork(object sender, DoWorkEventArgs e) { ZolaService.DataFile avatar = null; string username = e.Argument.ToString(); e.Result = username; if (AvatarHelper.GetAvatarExtension(username) != null) { return; } if (App.Proxy.IsUserHasAvatar(username)) { avatar = App.Proxy.GetAvatarFile(username); AvatarHelper.SaveAvatar(username, avatar); } }
public async void InitUpdate() { this.Title = "Lịch xem bất động sản"; LabelSave.Text = "Cập nhật lịch"; viewModel.Appointment = await viewModel.LoadAppointmentAsync(_id); if (viewModel.Appointment == null) { loadingPopup.IsVisible = false; await DisplayAlert("", "Không tìm thấy cuộc hẹn", Language.dong); return; } PostTitle.Text = viewModel.Appointment.Post.Title; PostAddress.Text = viewModel.Appointment.Post.Address; UserAvatar.Source = AvatarHelper.GetUserAvatar(viewModel.Appointment.Owner.AvatarUrl); PostUserFullName.Text = viewModel.Appointment.Owner.FullName; PostUserEmail.Text = viewModel.Appointment.Owner.Email; PostUserPhone.Text = viewModel.Appointment.Owner.Phone; EntryEmail.Text = viewModel.Appointment.BuyerEmail; EntryPhone.Text = viewModel.Appointment.BuyerPhone; EntryFullName.Text = viewModel.Appointment.BuyerFullName; EdtDescription.Text = viewModel.Appointment.Description; calendar.SelectedDate = viewModel.Appointment.Date; if (viewModel.Appointment.BuyerId == Guid.Parse(UserLogged.Id)) // buyier = nguoi tao lich. { } else { EntryFullName.IsVisible = EntryEmail.IsVisible = EntryPhone.IsVisible = BorderDescription.IsVisible = false; LblFullName.IsVisible = LblEmail.IsVisible = LblPhone.IsVisible = LblDescription.IsVisible = true; LblFullName.Text = viewModel.Appointment.BuyerEmail; LblEmail.Text = viewModel.Appointment.BuyerPhone; LblPhone.Text = viewModel.Appointment.BuyerFullName; LblDescription.Text = viewModel.Appointment.Description; } loadingPopup.IsVisible = false; }
public bool ReceiveMessage(DataMessage message) { DisplayMessage displayMessage = new DisplayMessage() { AvatarUrl = AvatarHelper.GetAvatarPath(message.Sender.Username), MessageContent = message.Message }; if (displayMessage.AvatarUrl == null) { displayMessage.AvatarUrl = AvatarHelper.DefaultAvatarPath; } ListViewItem item = new ListViewItem { Content = displayMessage, ContentTemplate = (DataTemplate)this.FindResource("FriendMessageTemplate") }; _displayMessages[message.Sender.Username].Add(item); lvChatMessages.ScrollIntoView(item); txtblIsWritting.Text = ""; DisplayUser user = _displayFriends.ToList().Find(x => (x.Content as DisplayUser).Username == message.Sender.Username).Content as DisplayUser; //MessageBox.Show("Here"); if (pnChat.Visibility == Visibility.Visible && txtblUsernameCurFriend.Text == message.Sender.Username) { user.UnreadMessage = null; //MessageBox.Show("null"); } else { if (user.UnreadMessage == null) { user.UnreadMessage = 1; } else { user.UnreadMessage++; } NotificationHelper.NotifyGotAMessage(message.Sender.Name, message.Message); //MessageBox.Show("unread message = " + user.UnreadMessage); } return(true); }
public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Email,Avatar,Address1,Address2,City,State,ZipCode,Phone,Birthday,Category")] Address address, IFormFile avatar) { if (ModelState.IsValid) { address.DateAdded = DateTime.Now; if (avatar != null) { address.FileName = avatar.FileName; address.Avatar = AvatarHelper.PutImage(avatar); } _context.Add(address); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(address)); }
public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null) { bool isAjaxRequest = Request.IsAjaxRequest(); ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var user = new AppUser { UserName = model.Email, Email = model.Email, DisplayName = model.DisplayName }; user.Avatar = AvatarHelper.GetRandomAvatar(); var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713 // Send an email with this link //var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); //var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme); //await _emailSender.SendEmailAsync(model.Email, "Confirm your account", // "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>"); await _signInManager.SignInAsync(user, isPersistent : false); _logger.LogInformation(3, "User created a new account with password."); if (isAjaxRequest) { return(Json(new { errno = 0, errmsg = "", returnUrl = returnUrl })); } else { return(RedirectToLocal(returnUrl)); } } AddErrors(result); } if (isAjaxRequest) { var modelErrors = ModelState.AllErrors(); return(Json(new { errno = 1, errmsg = "", errorList = modelErrors })); } return(View(model)); }
public async Task <IActionResult> Edit(int id, [Bind("id,FirstName,LastName,Email,ImagePath,ImageData,Address1,Address2,City,State,ZipCode,PhoneNumber,Created,Note")] AddressRecord addressRecord, IFormFile imageData) { if (id != addressRecord.id) { return(NotFound()); } if (ModelState.IsValid) { try { if (imageData != null) { addressRecord.ImagePath = imageData.FileName; addressRecord.ImageData = AvatarHelper.EncodeImage(imageData); } var truncPhone = addressRecord.PhoneNumber .Replace(" ", "") .Replace("(", "") .Replace(")", "") .Replace("-", ""); var formatedPhone = $"({truncPhone.Substring(0, 3)}) {truncPhone.Substring(3, 3)}-{truncPhone.Substring(6, 4)}"; addressRecord.PhoneNumber = formatedPhone; addressRecord.Updated = DateTime.Now; _context.Update(addressRecord); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressRecordExists(addressRecord.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(addressRecord)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Email,Avatar,Address1,Address2,City,State,ZipCode,Phone,DateAdded")] Address address, IFormFile avatar) { if (id != address.Id) { return(NotFound()); } if (ModelState.IsValid) { try { if (avatar != null) { address.Avatar = AvatarHelper.PutImage(avatar); address.FileName = avatar.FileName; } _context.Update(address); if (avatar == null) { _context.Entry(address).Property(p => p.Avatar).IsModified = false; } await _context.SaveChangesAsync(); _context.Update(address); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressExists(address.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(address)); }
public async Task <IActionResult> Create([Bind("FirstName,LastName,Email,Address1,Address2,City,State,ZipCode,PhoneNumber")] AddressBook addressBook, IFormFile image) { if (ModelState.IsValid) { addressBook.DateAdded = DateTime.Now; if (image != null) { addressBook.ImageData = AvatarHelper.PutImage(image); addressBook.ImagePath = image.FileName; } _context.Add(addressBook); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(addressBook)); }
public static void ForShowAvatar(this DepartmentNode node, AvatarSize size) { if (node.Type == DepartmentNodeType.Member) { node.Avatar = new TethysAvatar { Id = node.Addition.Uid, Name = node.Addition.Name, DisplayName = node.Addition.DisplayName, Background = AvatarHelper.GetColorBrush(node.Addition.DisplayName), Source = AvatarHelper.GetAvatarBitmap(node.Addition.Avatar, size, FromType.User) }; } else if (node.Type == DepartmentNodeType.Department) { foreach (var item in node.Children) { ForShowAvatar(item, size); } } }