internal Row(User user, Role role) { User = user; Role = role; LabelUserName.Content = User.UserName; LabelUserName.HorizontalContentAlignment = HorizontalAlignment.Left; LabelContextHeader.Content = User.UserName; ImageAvatar.Height = 28; ImageAvatar.Width = 28; SetDock(LabelUserName, Dock.Left); SetDock(ImageAvatar, Dock.Left); Children.Add(ImageAvatar); Children.Add(LabelUserName); // UserContextMenu.Items.Add(LabelContextHeader); UserContextMenu.Items.Add(MenuItemChangeRole); UserContextMenu.Items.Add(MenuItemKick); EventTrigger.RoutedEvent = Button.ClickEvent; LabelUserName.ContextMenu = UserContextMenu; LabelUserName.Triggers.Add(EventTrigger); LabelUserName.MouseEnter += (o, e) => { LabelUserName.Background = Brushes.DarkGray; }; LabelUserName.MouseLeave += (o, e) => { LabelUserName.Background = Brushes.Transparent; }; MenuItemKick.Click += (o, e) => { KickUser?.Invoke(this, new KickUserEventArgs(User)); }; MenuItemChangeRole.Click += (o, e) => { ChangeUserRole?.Invoke(this, new ChangeUserRoleEventArgs(User, Role)); }; LabelUserName.MouseUp += (o, e) => { LabelUserName.ContextMenu.IsOpen = true; }; Application.Current.Dispatcher.Invoke(async() => { await ImageResolver.DownloadUserImageAsync(user.ImageName, bitmap => { ImageAvatar.Source = bitmap; }); }); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { TextBoxUserName.Text = Inventory.CurrentUser.UserName; TextBoxEmail.Text = Inventory.CurrentUser.Email; if (Inventory.CurrentUser.ImageName != null) { await ImageResolver.DownloadUserImageAsync(Inventory.CurrentUser.ImageName, bitmap => { UserImage.Source = bitmap; }); } }
internal async Task MakeImageAsync() { Image.Height = 28; Image.Width = 28; if (Message.User.ImageName == null) { return; } await ImageResolver.DownloadUserImageAsync(Message.User.ImageName, bitmap => { Image.Source = bitmap; }); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { if (Inventory.CurrentUser == null) { return; } LabelUserName.Content = Inventory.CurrentUser.UserName; LabelEmail.Content = Inventory.CurrentUser.Email; if (Inventory.CurrentUser.ImageName != null) { await ImageResolver.DownloadUserImageAsync(Inventory.CurrentUser.ImageName, bitmap => { UserImage.Source = bitmap; }); } }