Example #1
0
        void _lstGroups_SelectedIndexChanged(object sender, EventArgs e)
        {
            GroupItem item = _lstGroups.SelectedItem as GroupItem;

            if (item != null)
            {
                for (int i = 0; i < _chkLstRoles.Items.Count; ++i)
                {
                    CheckRoleItem checkRoleItem = _chkLstRoles.Items[i] as CheckRoleItem;
                    if (checkRoleItem != null)
                    {
                        if (item.Roles.Contains(checkRoleItem.Role))
                        {
                            _chkLstRoles.SetItemChecked(i, true);
                        }
                        else
                        {
                            _chkLstRoles.SetItemChecked(i, false);
                        }
                    }
                }
            }


            UpdateUI();
        }
Example #2
0
        void _chkLstRoles_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            CheckRoleItem role = (CheckRoleItem)_chkLstRoles.Items[e.Index];

            if (role != null)
            {
                int index = _lstGroups.SelectedIndex;
                if (index >= 0)
                {
                    GroupItem item = _lstGroups.Items[index] as GroupItem;
                    if (item != null)
                    {
                        if (e.NewValue == CheckState.Checked)
                        {
                            if (!item.Roles.Contains(role.Role))
                            {
                                item.Roles.Add(role.Role);
                                if (role.Role == AnnRoles.ViewAll || role.Role == AnnRoles.Edit)
                                {
                                    _chkLstRoles.SetItemChecked(0, true);
                                }
                                else if (role.Role == AnnRoles.EditAll)
                                {
                                    _chkLstRoles.SetItemChecked(0, true);
                                    _chkLstRoles.SetItemChecked(1, true);
                                    _chkLstRoles.SetItemChecked(2, true);
                                    _chkLstRoles.SetItemChecked(4, false);
                                }
                                else if (role.Role == CustomRoles.RulersOnly)
                                {
                                    _chkLstRoles.SetItemChecked(0, false);
                                    _chkLstRoles.SetItemChecked(1, false);
                                    _chkLstRoles.SetItemChecked(2, false);
                                    _chkLstRoles.SetItemChecked(3, false);
                                }
                            }
                        }
                        else
                        {
                            if (item.Roles.Contains(role.Role))
                            {
                                item.Roles.Remove(role.Role);
                            }
                        }
                    }
                }
            }
        }