コード例 #1
0
 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;
         });
     });
 }
コード例 #2
0
 private void ButtonOk_Click(object sender, RoutedEventArgs e)
 {
     ChangeUserRole?.Invoke(this, new ChangeUserRoleEventArgs(UserToChange, RadioButtonRoles[RadioButtonSelected]));
 }