Beispiel #1
0
 public GroupsListViewExtended()
 {
     InitializeComponent();
     btUsers.IsEnabled          = false;
     listView.SelectionChanged += (ctrl) => btUsers.IsEnabled = listView.SelectedGroupsIds.Any();
     btUsers.Click             += (o, e) => {
         var groupId = listView.SelectedGroupsIds.First();
         var group   = _repository.Groups.First(x => x.Name.Equals(groupId));
         UsersSelectView.Show(
             (users) => {
             group.UsersIds = users.Select(x => x.Id).ToList();
             _repository.Save(group);
         },
             group.UsersIds.ToArray(),
             true);
     };
 }
 public static void Show(Action <UserBase[]> callback, string[] selectedUsersIds, bool hideButtons = false)
 {
     if (!Repository.Users.Any())
     {
         MessageView.ShowMessage("Пользователи не созданы!", "Выбор пользователей", Icons.Icon.Warning);
     }
     else
     {
         var control    = new UsersSelectView(selectedUsersIds, hideButtons);
         var dialogView = new DialogView(control);
         dialogView.Caption    = "Выберите пользователей";
         control.ApplyClicked += () =>
         {
             callback?.Invoke(control.SelectedUsers);
             dialogView.Close();
         };
         dialogView.Show();
     }
 }