public static void Show(Action callback, Action <GroupValidationArgs> validation, UserGroupBase group)
        {
            var control = new AddGroupView(group);
            var dialog  = new DialogView(control);

            control.Validation = validation;
            control.OkClicked += () =>
            {
                callback?.Invoke();
                dialog.Close();
            };
            dialog.Show();
        }
Example #2
0
        public GroupsListView()
        {
            InitializeComponent();

            Refresh();

            btAdd.Click += (o, e) => {
                var group = new UserGroup();
                AddGroupView.Show(
                    () => {
                    _repository.Add(group);
                    AddInternal(group);
                },
                    (args) => args.Success = !_repository.Groups.Any(x => x.Name.Equals(args.Name)),
                    group
                    );
            };

            btRemove.Click += (o, e) =>
            {
                MessageView.ShowYesNo("Вы уверены что хотите удалить выбранные группы?", "Удаление групп", Icons.Icon.GroupDelete,
                                      (result) => {
                    if (result)
                    {
                        var selectedGroups = SelectedGroupsIds.Select(x => _repository.Groups.First(z => z.Name.Equals(x)));
                        foreach (var group in selectedGroups)
                        {
                            Remove(group);
                        }
                    }
                });
            };

            itemsView.SelectionChanged += (o, e) =>
            {
                SelectionChanged?.Invoke(this);
                btRemove.IsEnabled = SelectedGroupsIds.Any();
            };
        }