public CustTreeItems(CustTreeItems Parent, bool hasParent, string name, bool? hasAccess) :this(hasParent, name, hasAccess)
 {
     this.Parent = Parent;
 }
 public Permission(CustTreeItems parent, string name, bool? value)
 {
     Name = name; _Value = value; ParentItem = parent;
 }
 public Permission(CustTreeItems parent, string name, string description, bool? value)
 {
     Name = name; _Value = value; ParentItem = parent; Description = description;
 }
        private void LoadButtons(CustTreeItems Permissions)
        {
            
            spButtons.Children.Clear();
            //string type = "Word";
            //MessageBox.Show("cleared");
            string p_name = Permissions.Name;
            HashSet<string> allowedButtons = new HashSet<string>();
            HashSet<string> denyButtons = new HashSet<string>();

            if (WindowUser.OwnedPermissions.AllowPermissions.ContainsKey(Permissions.Name)) 
            allowedButtons.AddRange(WindowUser.OwnedPermissions.AllowPermissions[Permissions.Name]);

            foreach(UserGroup ug in (_windowUser as User).UserGroupPermissions)
            {
                if (ug.OwnedPermissions.AllowPermissions.ContainsKey(Permissions.Name))
                {
                    allowedButtons.AddRange(ug.OwnedPermissions.AllowPermissions[Permissions.Name]);
                }
                if (ug.OwnedPermissions.DenyPermissions.ContainsKey(Permissions.Name))
                {
                    denyButtons.AddRange(ug.OwnedPermissions.DenyPermissions[Permissions.Name]);
                }
            }

            allowedButtons.RemoveWhere(x => denyButtons.Contains(x));
            

            foreach (var s in Permissions.Options.Where(x=> allowedButtons.Contains(x.Name)))
            {
                object[] parameters = new object[] { s.Description };
                MethodInfo methodinfo = methods[s.Name];
                Button button = new Button();
                button.Content = s.Name;
                button.Click += new RoutedEventHandler((x, e) => methodinfo.Invoke(this, parameters));
                spButtons.Children.Add(button);
                    
            }
        }