Exemplo n.º 1
0
 void quickrights_GetNodeStyle(object sender, GetNodeStyleEventArgs e)
 {
     /*
     if (e.Node.ImageIndex == ResTree.RESTYPE_DB)
         e.Style = this.treeView_objects.DbStyle;
     else
         e.Style = 0;
      */
     e.Style = this.treeView_objects.GetNodeStyle(e.Node);
 }
Exemplo n.º 2
0
 void quickrights_GetNodeStyle(object sender, GetNodeStyleEventArgs e)
 {
     e.Style = ResRightTree.GetNodeStyle(e.Node);
 }
Exemplo n.º 3
0
        // 按照预定模式修改一个节点以及以下的全部子节点的权限
        void ModiRights(int nFound,
                        List <TreeNode> selectedTreeNodes,
                        TreeNode curtreenode,
                        List <XmlNode> cfgnodes)
        {
            for (int i = 0; i < cfgnodes.Count; i++)
            {
                // 当前xml节点信息
                XmlNode node = cfgnodes[i];

                string strType   = DomUtil.GetAttr(node, "type");
                string strName   = DomUtil.GetAttr(node, "name");
                string strRights = DomUtil.GetAttrDiff(node, "rights");
                int    nStyle    = QuickRights.GetStyleInt(DomUtil.GetAttr(node, "style"));

                // 匹配对象名
                if (strName != "" && strName != "*")
                {
                    // @
                    if (strName != curtreenode.Text)
                    {
                        continue;
                    }
                }

                // 匹配对象类型
                bool bRet = QuickRights.MatchType(curtreenode.ImageIndex,
                                                  strType);
                if (bRet == false)
                {
                    continue;
                }

                // 匹配对象风格
                if (nStyle != 0)
                {
                    if (this.GetNodeStyle == null)
                    {
                        // 缺省行为

                        /*
                         * if (nStyle != ResRightTree.GetNodeStyle(curtreenode))
                         *  continue;
                         */
                    }
                    else
                    {
                        GetNodeStyleEventArgs e = new GetNodeStyleEventArgs();
                        e.Node  = curtreenode;
                        e.Style = 0;
                        this.GetNodeStyle(this, e);
                        if (nStyle != e.Style)
                        {
                            continue;
                        }
                    }
                }

                int nIndex = -1;
                if (nFound == 0)
                {
                    nIndex = selectedTreeNodes.IndexOf(curtreenode);
                }

                // 触发事件
                // 如果strRights == null,表示当前对象不需修改其rights值,但是递归仍然要进行
                if (strRights != null &&
                    (nIndex != -1 || nFound > 0))
                {
                    if (this.SetRights != null)
                    {
                        SetRightsEventArgs e = new SetRightsEventArgs();
                        e.Node = curtreenode;
                        if (strRights == "{clear}" || strRights == "{null}")
                        {
                            e.Rights = null;
                        }
                        else
                        {
                            e.Rights = strRights;
                        }
                        this.SetRights(this, e);
                    }
                }

                // DOCHILDREN:

                // 组织树子对象数组
                List <TreeNode> nodes = new List <TreeNode>();
                for (int j = 0; j < curtreenode.Nodes.Count; j++)
                {
                    nodes.Add(curtreenode.Nodes[j]);
                }

                // 递归
                if (nodes.Count != 0)
                {
                    List <XmlNode> chidrencfgnodes = new List <XmlNode>();
                    for (int j = 0; j < node.ChildNodes.Count; j++)
                    {
                        XmlNode cur = node.ChildNodes[j];

                        if (cur.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }

                        if (cur.Name != "object")
                        {
                            continue;
                        }

                        chidrencfgnodes.Add(cur);
                    }

                    if (nIndex != -1)
                    {
                        nFound++;
                    }
                    ModiRights(nFound,
                               selectedTreeNodes,
                               nodes,
                               chidrencfgnodes);
                    if (nIndex != -1)
                    {
                        nFound--;
                    }
                }
            }
        }
Exemplo n.º 4
0
        // 按照预定模式修改一个节点以及以下的全部子节点的权限
        void ModiRights(int nFound,
            List<TreeNode> selectedTreeNodes,
            TreeNode curtreenode,
            List<XmlNode> cfgnodes)
        {
            for (int i = 0; i < cfgnodes.Count; i++)
            {
                // 当前xml节点信息
                XmlNode node = cfgnodes[i];

                string strType = DomUtil.GetAttr(node, "type");
                string strName = DomUtil.GetAttr(node, "name");
                string strRights = DomUtil.GetAttrDiff(node, "rights");
                int nStyle = QuickRights.GetStyleInt(DomUtil.GetAttr(node, "style"));

                // 匹配对象名
                if (strName != "" && strName != "*")
                {
                    // @
                    if (strName != curtreenode.Text)
                        continue;
                }

                // 匹配对象类型
                bool bRet = QuickRights.MatchType(curtreenode.ImageIndex,
                    strType);
                if (bRet == false)
                    continue;

                // 匹配对象风格
                if (nStyle != 0)
                {
                    if (this.GetNodeStyle == null)
                    { 
                        // 缺省行为
                        /*
                        if (nStyle != ResRightTree.GetNodeStyle(curtreenode))
                            continue;
                         */
                    }
                    else
                    {
                        GetNodeStyleEventArgs e = new GetNodeStyleEventArgs();
                        e.Node = curtreenode;
                        e.Style = 0;
                        this.GetNodeStyle(this, e);
                        if (nStyle != e.Style)
                            continue;
                    }
                }

                int nIndex = -1;
                if (nFound == 0)
                    nIndex = selectedTreeNodes.IndexOf(curtreenode);

                // 触发事件
                // 如果strRights == null,表示当前对象不需修改其rights值,但是递归仍然要进行
                if (strRights != null 
                    && (nIndex != -1 || nFound > 0))
                {
                    if (this.SetRights != null)
                    {
                        SetRightsEventArgs e = new SetRightsEventArgs();
                        e.Node = curtreenode;
                        if (strRights == "{clear}" || strRights == "{null}")
                            e.Rights = null;
                        else
                            e.Rights = strRights;
                        this.SetRights(this, e);
                    }

                }

            // DOCHILDREN:

                // 组织树子对象数组
                List<TreeNode> nodes = new List<TreeNode>();
                for (int j = 0; j < curtreenode.Nodes.Count; j++)
                {
                    nodes.Add(curtreenode.Nodes[j]);
                }

                // 递归
                if (nodes.Count != 0)
                {
                    List<XmlNode> chidrencfgnodes = new List<XmlNode>();
                    for (int j = 0; j < node.ChildNodes.Count; j++)
                    {
                        XmlNode cur = node.ChildNodes[j];

                        if (cur.NodeType != XmlNodeType.Element)
                            continue;

                        if (cur.Name != "object")
                            continue;

                        chidrencfgnodes.Add(cur);
                    }

                    if (nIndex != -1)
                        nFound++;
                    ModiRights(nFound, 
                        selectedTreeNodes,
                        nodes,
                        chidrencfgnodes);
                    if (nIndex != -1)
                        nFound--;
                }

            }

        }
Exemplo n.º 5
0
 void quickrights_GetNodeStyle(object sender, GetNodeStyleEventArgs e)
 {
     e.Style = ResRightTree.GetNodeStyle(e.Node);
 }