protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
 {
     TreeNodeCollection nodes = new TreeNodeCollection();
     TreeNode item = this.CreateTreeNode("-1", "-1", queryStrings, "");
     nodes.Add(item);
     return nodes;
 }
        public TreeNodeCollection GetNodes(string node)
        {
            TreeNodeCollection nodes = new TreeNodeCollection(false);

            if (!string.IsNullOrEmpty(node))
            {
                for (int i = 1; i < 6; i++)
                {
                    AsyncTreeNode asyncNode = new AsyncTreeNode();
                    asyncNode.Text = node + i;
                    asyncNode.NodeID = node + i;
                    nodes.Add(asyncNode);
                }

                for (int i = 6; i < 11; i++)
                {
                    TreeNode treeNode = new TreeNode();
                    treeNode.Text = node + i;
                    treeNode.NodeID = node + i;
                    treeNode.Leaf = true;
                    nodes.Add(treeNode);
                }
            }

            return nodes;
        }
 protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
 {
     var nodes = new TreeNodeCollection();
     var item = this.CreateTreeNode("dashboard", id, queryStrings, "Applicaion Forms", "icon-truck", true);
     nodes.Add(item);
     return nodes;
 }
Exemple #4
0
    private void BindTree(TreeNodeCollection Nds, int IDStr)
    {
        SqlConnection Conn = new SqlConnection(ConfigurationManager.AppSettings["SQLConnectionString"].ToString());
        Conn.Open();
        SqlCommand MyCmd = new SqlCommand("select * from ERPBuMen where DirID=" + IDStr.ToString() + " order by ID asc", Conn);
        SqlDataReader MyReader = MyCmd.ExecuteReader();
        while (MyReader.Read())
        {
            TreeNode OrganizationNode = new TreeNode();
            OrganizationNode.Text = MyReader["BuMenName"].ToString();
            OrganizationNode.Value = MyReader["ID"].ToString();
            int strId = int.Parse(MyReader["ID"].ToString());
            OrganizationNode.ImageUrl = "~/images/user_group.gif";
            OrganizationNode.SelectAction =  TreeNodeSelectAction.Expand ;

            string ChildID = ZWL.DBUtility.DbHelperSQL.GetSHSLInt("select top 1 ID from ERPBuMen where DirID=" + MyReader["ID"].ToString() + " order by ID asc");
            if (ChildID.Trim() != "0")
            {
                //需要父项目一起选中,如果父项目不需要的话,请不要注释掉下面的行
                //HaveChild = HaveChild + "|" + MyReader["BuMenName"].ToString() + "|";
            }
            OrganizationNode.ToolTip = MyReader["BuMenName"].ToString();
            OrganizationNode.Expand();
            Nds.Add(OrganizationNode);
            //递归循环
            BindTree(Nds[Nds.Count - 1].ChildNodes, strId);
        }
        MyReader.Close();
        Conn.Close();
    }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var collection = new TreeNodeCollection();
            switch (id)
            {
                case "settings":
                    collection.Add(CreateTreeNode("shipping", "settings", queryStrings, "Shipping", "icon-truck", false, "merchello/merchello/Shipping/manage"));
                    collection.Add(CreateTreeNode("taxation", "settings", queryStrings, "Taxation", "icon-piggy-bank", false, "merchello/merchello/Taxation/manage"));
                    collection.Add(CreateTreeNode("payment", "settings", queryStrings, "Payment", "icon-bill-dollar", false, "merchello/merchello/Payment/manage"));
                    collection.Add(CreateTreeNode("notifications", "settings", queryStrings, "Notifications", "icon-chat", false, "merchello/merchello/Notifications/manage"));
                    collection.Add(CreateTreeNode("gateways", "settings", queryStrings, "Gateway Providers", "icon-trafic", false, "merchello/merchello/GatewayProviders/manage"));
                    break;
                case "reports":
                    collection.Add(CreateTreeNode("salesOverTime", "reports", queryStrings, "Sales Over Time", "icon-loading", false, "merchello/merchello/SalesOverTime/manage"));
                    collection.Add(CreateTreeNode("salesByItem", "reports", queryStrings, "Sales By Item", "icon-barcode", false, "merchello/merchello/SalesByItem/manage"));
                    collection.Add(CreateTreeNode("taxesByDestination", "reports", queryStrings, "Taxes By Destination", "icon-piggy-bank", false, "merchello/merchello/TaxesByDestination/manage"));
                    break;
                default:
                    collection.Add(CreateTreeNode("catalog", "", queryStrings, "Catalog", "icon-barcode", false, "merchello/merchello/ProductList/manage"));
                    collection.Add(CreateTreeNode("orders", "", queryStrings, "Orders", "icon-receipt-dollar", false, "merchello/merchello/OrderList/manage"));
                    collection.Add(CreateTreeNode("settings", "", queryStrings, "Settings", "icon-settings", true, "merchello/merchello/Settings/manage"));
                    break;
            }

            return collection;
        }
Exemple #6
0
    private void RestoreTreeViewState(TreeNodeCollection nodes, List<string> list)
    {
        foreach (TreeNode node in nodes)
        {
            //
            // Restore the state of one node.
            //
            if (list.Contains(node.Text))
            {
                if (node.ChildNodes != null && node.ChildNodes.Count != 0 && node.Expanded.HasValue && node.Expanded == false)
                    node.Expand();
            }
            else
            {
                if (node.ChildNodes != null && node.ChildNodes.Count != 0 && node.Expanded.HasValue && node.Expanded == true)
                    node.Collapse();
            }

            //
            // If the node has child nodes, restore their state, too.
            //
            if (node.ChildNodes != null && node.ChildNodes.Count != 0)
                RestoreTreeViewState(node.ChildNodes, list);
        }
    }
Exemple #7
0
   public override TreeNode AddNode(IMaxNode wrapper, TreeNodeCollection parentCol)
   {
      TreeNode tn = base.AddNode(wrapper, parentCol);

      MaterialWrapper mtlWrapper = wrapper as MaterialWrapper;
      if (mtlWrapper != null)
      {
         AddObjects(mtlWrapper, tn.Nodes);
         AddTextureMaps(mtlWrapper, tn.Nodes);

         foreach (IMtl mtl in mtlWrapper.ChildMaterials)
         {
            this.AddNode(mtl, tn.Nodes);
         }
      } 
      else if (!(wrapper is INodeWrapper))
      {
         foreach (IMaxNode node in wrapper.ChildNodes)
         {
            this.AddNode(node, tn.Nodes);
         }
      }

      return tn;
   }
Exemple #8
0
        public static TreeNodeCollection BuildFirstLevel()
        {
            string path = HttpContext.Current.Server.MapPath("~/Examples/");
            DirectoryInfo root = new DirectoryInfo(path);
            DirectoryInfo[] folders = root.GetDirectories();
            folders = SortFolders(root, folders);

            TreeNodeCollection nodes = new TreeNodeCollection(false);

            foreach (DirectoryInfo folder in folders)
            {
                if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden ||
                    excludeList.Contains(folder.Name) || folder.Name.StartsWith("_"))
                {
                    continue;
                }

                ExampleConfig cfg = new ExampleConfig(folder.FullName + "\\config.xml", false);

                string iconCls = string.IsNullOrEmpty(cfg.IconCls) ? "" : cfg.IconCls;
                AsyncTreeNode node = new AsyncTreeNode();

                node.Text = MarkNew(folder.FullName, folder.Name.Replace("_", " "));
                node.IconCls = iconCls;
                string url = PhysicalToVirtual(folder.FullName + "/");
                node.NodeID = "e" + Math.Abs(url.ToLower().GetHashCode());

                nodes.Add(node);
            }

            return nodes;
        }
        /// <summary>
        /// Returns all section tree nodes
        /// </summary>
        /// <param name="id">Node's id.</param>
        /// <param name="queryStrings">Query strings</param>
        /// <returns>Collection of tree nodes</returns>
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();
            var ctrl = new WebsiteApiController();            

            if (id == Constants.System.Root.ToInvariantString())
            {
                var item = CreateTreeNode("0", "-1", queryStrings, "Websites", "icon-folder", true);
                nodes.Add(item);
                
                return nodes;
            }
            else if (id == "0")
            {
                foreach (var website in ctrl.GetAll())
                {
                    var node = CreateTreeNode(
                        website.Id.ToString(),
                        "0",
                        queryStrings,
                        website.ToString(),
                        "icon-document",
                        false);
                    
                    nodes.Add(node);
                }

                return nodes;
            }
            throw new NotSupportedException();
        }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            // check if we're rendering the root node's children
            var items = id == RealUmbraco.Core.Constants.System.Root.ToInvariantString()
                ? DefinedContent.Cache.GetRootDefinedContentItems()
                : DefinedContent.Cache.GetDefinedContentItem(id).Children;
            
            // empty tree
            //var tree = new TreeNodeCollection()
            //{
            //    CreateTreeNode("Bobs Something", id, new FormDataCollection("somequerystring=2"), "Bob's News Root", "icon-anchor")
            //};

            var tree = new TreeNodeCollection();
            foreach (var item in items)
            {
                tree.Add(CreateTreeNode(item.Key, item.Key, null, item.Key, "icon-anchor", item.Children.Any()));
            }

            // but if we wanted to add nodes - 
            /*  var tree = new TreeNodeCollection
            {
                CreateTreeNode("1", id, queryStrings, "My Node 1"), 
                CreateTreeNode("2", id, queryStrings, "My Node 2"), 
                CreateTreeNode("3", id, queryStrings, "My Node 3")
            };*/
            return tree;
        }
Exemple #11
0
    public void BindBuMenTree(TreeNodeCollection Nds, int IDStr)
    {
        DataSet MYDT=ZWL.DBUtility.DbHelperSQL.GetDataSet("select * from ERPBuMen where DirID=" + IDStr.ToString() + " order by ID asc");
        for(int i=0;i<MYDT.Tables[0].Rows.Count;i++)
        {
            TreeNode OrganizationNode = new TreeNode();
            string CharManStr = "";
            if (MYDT.Tables[0].Rows[i]["ChargeMan"].ToString().Trim().Length <= 0)
            {
                CharManStr = "<font color=\"Red\">[未设置负责人]</font>";
            }
            else
            {
                CharManStr = MYDT.Tables[0].Rows[i]["ChargeMan"].ToString().Trim();
            }

            OrganizationNode.Text = MYDT.Tables[0].Rows[i]["BuMenName"].ToString() + "&nbsp;部门主管:" + CharManStr;
            OrganizationNode.ToolTip = "部门主管:" + MYDT.Tables[0].Rows[i]["ChargeMan"].ToString() + "\n电话:" + MYDT.Tables[0].Rows[i]["TelStr"].ToString() + "\n传真:" + MYDT.Tables[0].Rows[i]["ChuanZhen"].ToString() + "\n备注:" + MYDT.Tables[0].Rows[i]["BackInfo"].ToString();

            OrganizationNode.Value = MYDT.Tables[0].Rows[i]["ID"].ToString();
            int strId = int.Parse(MYDT.Tables[0].Rows[i]["ID"].ToString());
            OrganizationNode.ImageUrl = "~/images/user_group.gif";
            OrganizationNode.SelectAction = TreeNodeSelectAction.Expand;

            OrganizationNode.Expand();
            Nds.Add(OrganizationNode);
            //递归循环
            BindBuMenTree(Nds[Nds.Count - 1].ChildNodes, strId);
        }
    }
 /// <summary>
 /// Gets the tree nodes for the given id
 /// </summary>
 /// <param name="id"></param>
 /// <param name="queryStrings"></param>
 /// <returns></returns>
 /// <remarks>
 /// If the content item is a container node then we will not return anything
 /// </remarks>
 protected override TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings)
 {
     var nodes = new TreeNodeCollection();
     var entities = GetChildEntities(id);
     nodes.AddRange(entities.Select(entity => GetSingleTreeNode(entity, id, queryStrings)).Where(node => node != null));            
     return nodes;
 }
        private void ReadNodes( string path, TreeNodeCollection nodes, string selectedPath )
        {
            foreach( TreeNode node in nodes )
            {
                string childPath = path + "/" + GetNodeText( node ).Replace( '/', '_' );
                bool expand = ControlPreferences.GetValue( Name, childPath ) == "Expanded";
                bool collapse = ControlPreferences.GetValue( Name, childPath ) == "Collapsed";
                bool select = (childPath == selectedPath);

                if( expand )
                {
                    _treeControl.ExpandNode( node );

                    ReadNodes( childPath, node.ChildNodes, selectedPath );
                }
                else if( collapse )
                {
                    _treeControl.CollapseNode( node );
                }
                if( select )
                {
                    _treeControl.SelectedNode = node;
                }
            }
        }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            if (id == "-1")
            {
                var nodes = new TreeNodeCollection();

                var allContacts = this.CreateTreeNode("dashboard", id, queryStrings, "All Contact Message", "icon-list", false);
                var repliedContacts = this.CreateTreeNode("replied", id, queryStrings, "Replied Contact Message", "icon-check", false);
                var unRepliedContacts = this.CreateTreeNode("unreplied", id, queryStrings, "Un-Replied Contact Message", "icon-time", false);
                var spamContacts = this.CreateTreeNode("spam", id, queryStrings, "Spam", "icon-squiggly-line", false);
                var trashedContacts = this.CreateTreeNode("deleted", id, queryStrings, "Deleted", "icon-trash", false);
                var settingsContacts = this.CreateTreeNode("settings", id, queryStrings, "Settings", "icon-wrench", false);

                repliedContacts.RoutePath = "/uContactor/uContactorSection/replied/0";
                unRepliedContacts.RoutePath = "/uContactor/uContactorSection/unreplied/0";
                spamContacts.RoutePath = "/uContactor/uContactorSection/spam/0";
                trashedContacts.RoutePath = "/uContactor/uContactorSection/deleted/0";
                settingsContacts.RoutePath = "/uContactor/uContactorSection/settings/0";

                nodes.Add(allContacts);
                nodes.Add(repliedContacts);
                nodes.Add(unRepliedContacts);
                nodes.Add(spamContacts);
                nodes.Add(trashedContacts);
                nodes.Add(settingsContacts);

                return nodes;
            }

            throw new NotImplementedException();
        }
 protected VerticalPositioning( TreeNodeCollection nodes, IRenderer renderer, ITreeInfo treeInfo, ITreeEvents treeEvents )
 {
     _nodes = nodes;
     _renderer = renderer;
     _treeInfo = treeInfo;
     _treeEvents = treeEvents;
 }
Exemple #16
0
        private TreeNodeCollection BuildTree(List<TypedTreeNodeItem<SystemDepartmentWrapper>> items)
        {
            TreeNodeCollection nodes = new TreeNodeCollection();

            TreeNode root = new TreeNode();
            root.Text = "All Department";
            root.Icon = Icon.Group;

            nodes.Add(root);

            if (items == null || items.Count == 0)
                return nodes;

            foreach (TypedTreeNodeItem<SystemDepartmentWrapper> menu in items)
            {
                TreeNode mainNode = new TreeNode();
                mainNode.Text = menu.Name;
                mainNode.NodeID = menu.Id;

                mainNode.Icon = Icon.Group;

                mainNode.CustomAttributes.Add(new ConfigItem("ID", menu.Id, ParameterMode.Value));
                GenerateSubTreeNode(mainNode, menu);
                root.Nodes.Add(mainNode);
            }

            return nodes;
        }
Exemple #17
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            string nodeId = context.Request["node"];

            if (!string.IsNullOrEmpty(nodeId))
            {
                TreeNodeCollection nodes = new TreeNodeCollection(false);

                for (int i = 1; i < 6; i++)
                {
                    AsyncTreeNode asyncNode = new AsyncTreeNode();
                    asyncNode.Text = nodeId + i;
                    asyncNode.NodeID = nodeId + i;
                    nodes.Add(asyncNode);
                }

                for (int i = 6; i < 11; i++)
                {
                    TreeNode node = new TreeNode();
                    node.Text = nodeId + i;
                    node.NodeID = nodeId + i;
                    node.Leaf = true;
                    nodes.Add(node);
                }

                context.Response.Write(nodes.ToJson());
                context.Response.End();
            }
        }
    protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
    {
        if (id == Constants.System.Root.ToInvariantString())
        {
            var ctrl = new ClientApiController();
            var nodes = new TreeNodeCollection();

            foreach (var client in ctrl.GetAll())
            {
                var node = CreateTreeNode(
                    client.Id.ToString(),
                    "-1",
                    queryStrings,
                    client.ToString(),
                    "icon-user",
                    false);

                nodes.Add(node);
            }

            return nodes;
        }

        throw new NotSupportedException();
    }
        /// <summary>
        /// Called by the ASP.NET MVC framework after the action method executes.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            if (filterContext.Result is RebelTreeResult)
            {
                var treeResult = (RebelTreeResult)filterContext.Result;

                var nodeCollection = new TreeNodeCollection();
                nodeCollection.AddRange(treeResult.NodeCollection);

                foreach (var node in nodeCollection)
                {
                    var menuActions = node.MenuActions.ToList();
                    foreach (var menuAction in menuActions)
                    {
                        var attributes = menuAction.Metadata.ComponentType.GetCustomAttributes(typeof(RebelAuthorizeAttribute), true);
                        if (attributes.Length > 0)
                        {
                            var authorized = attributes.Aggregate(false, (current, attribute) => current || ((RebelAuthorizeAttribute)attribute).IsAuthorized(filterContext.HttpContext, node.HiveId));
                            if (!authorized)
                                node.MenuActions.Remove(menuAction);
                        }
                    }
                }

                filterContext.Result = new RebelTreeResult(nodeCollection, filterContext.Controller.ControllerContext);
            }
        }
        protected override Umbraco.Web.Models.Trees.TreeNodeCollection GetTreeNodes(string id, System.Net.Http.Formatting.FormDataCollection queryStrings)
        {
            //check if we're rendering the root node's children
            if (id == Constants.System.Root.ToInvariantString())
            {
                var ctrl = new PersonApiController();
                var nodes = new TreeNodeCollection();

                foreach (var person in ctrl.GetAll())
                {
                    var node = CreateTreeNode(
                        person.Id.ToString(),
                        "-1",
                        queryStrings,
                        person.ToString(),
                        "icon-user",
                        false);

                    nodes.Add(node);

                }
                return nodes;
            }

            //this tree doesn't suport rendering more than 1 level
            throw new NotSupportedException();
        }
        private TreeNodeCollection AddFiles(string folder, FormDataCollection queryStrings)
        {
            var pickerApiController = new FileSystemPickerApiController();
            //var str = queryStrings.Get("startfolder");

            if (string.IsNullOrWhiteSpace(folder))
                return null;

            var filter = queryStrings.Get("filter").Split(',').Select(a => a.Trim().EnsureStartsWith(".")).ToArray();

            var path = IOHelper.MapPath(folder);
            var rootPath = IOHelper.MapPath(queryStrings.Get("startfolder"));
            var treeNodeCollection = new TreeNodeCollection();

            foreach (FileInfo file in pickerApiController.GetFiles(folder, filter))
            {
                string nodeTitle = file.Name;
                string filePath = file.FullName.Replace(rootPath, "").Replace("\\", "/");

                //if (file.Extension.ToLower() == ".gif" || file.Extension.ToLower() == ".jpg" || file.Extension.ToLower() == ".png")
                //{
                //    nodeTitle += "<div><img src=\"/umbraco/backoffice/FileSystemPicker/FileSystemThumbnailApi/GetThumbnail?width=150&imagePath="+ HttpUtility.UrlPathEncode(filePath) +"\" /></div>";
                //}

                TreeNode treeNode = CreateTreeNode(filePath, path, queryStrings, nodeTitle, "icon-document", false);
                treeNodeCollection.Add(treeNode);
            }

            return treeNodeCollection;
        }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            // check if we're rendering the root node's children
            if (id == Constants.System.Root.ToInvariantString())
            {
                var tree = new TreeNodeCollection();
                var ctrl = new EasyADApiController();

                foreach (var g in ctrl.GetAll())
                {
                    var node = CreateTreeNode(
                                    g.Id.ToInvariantString(),
                                    Constants.System.Root.ToInvariantString(),
                                    queryStrings,
                                    g.Name,
                                    "icon-users-alt");
                    tree.Add(node);
                }

                return tree;
            }

            // this tree doesn't support rendering more than 1 level
            throw new NotSupportedException();
        }
Exemple #23
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";

            // "node" will be a comma-separated list of nodes that are going to be deleted.
            string node = context.Request["node"];

            if (!string.IsNullOrEmpty(node))
            {
                string[] nodeIDsTemp = node.Split(',');
                var nodeIDs = nodeIDsTemp.Select(s => Convert.ToInt32(s));

                TreeNodeCollection treeNodes = new TreeNodeCollection();

                foreach (int nodeID in nodeIDs)
                {
                    ContentItem selectedItem = Context.Persister.Get(nodeID);

                    SiteTree tree = SiteTree.From(selectedItem, int.MaxValue);

                    TreeNodeBase treeNode = tree.Filter(items => items.Authorized(context.User, Context.SecurityManager, Operations.Read))
                        .ToTreeNode(false);

                    treeNodes.Add(treeNode);
                }

                string json = treeNodes.ToJson();
                context.Response.Write(json);
                context.Response.End();
            }
        }
Exemple #24
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="tnc"></param>
 protected void ChoiceTreeNode(TreeNodeCollection tnc,List<RoleMoudleInfo> info)
 {
     foreach (TreeNode node in tnc)
     {
         RoleMoudleInfo Info = info.Find(delegate(RoleMoudleInfo info1)
         {
             return info1.MoudleId == int.Parse(node.Value);
         });
         if (node.ChildNodes.Count != 0)
         {
             if (Info!=null)
             {
                 node.Checked = true;
             }
             ChoiceTreeNode(node.ChildNodes, info);
         }
         else
         {
             if (Info != null)
             {
                 node.Checked = true;
             }
         }
     }
 }
    private bool SetSelect(string strSelected, TreeNodeCollection nodes)
    {
        if (nodes != null
            && nodes.Count > 0
            )
        {
            foreach (TreeNode node in nodes)
            {
                if (node != null
                    )
                {
                    if (
                        !PubClass.IsNull(node.Value)
                        && node.Value == strSelected
                        )
                    {
                        node.Select();
                        return true;
                    }
                    else if (node.ChildNodes != null
                        && node.ChildNodes.Count > 0
                        )
                    {
                        bool success = SetSelect(strSelected, node.ChildNodes);

                        // 如果成功了,就不往下继续查找了;
                        if (success)
                            return true;
                    }
                }
            }
        }
        return false;
    }
Exemple #26
0
    private void BindTree(TreeNodeCollection Nds, int IDStr)
    {
        //SqlConnection Conn = new SqlConnection(DecryptDBStr(ConfigurationManager.AppSettings["SQLConnectionString"].ToString(),"zhangweilong"));
        SqlConnection Conn = new SqlConnection(ConfigurationManager.AppSettings["SQLConnectionString"].ToString());
        Conn.Open();

        string DepartmentID = "";
        string SuperiorID = ZWL.Common.PublicMethod.GetSessionValue("DepartmentID"); ;
        while(SuperiorID != "0") {
            DepartmentID = SuperiorID;
            SuperiorID = GetSuperiorDepartmentID(SuperiorID);
        }

        SqlCommand MyCmd;
        if (ZWL.Common.PublicMethod.GetSessionValue("UserName") == "admin")
            MyCmd = new SqlCommand("select * from hx_vERPBuMen where DirID=" + IDStr.ToString() + " and CHARINDEX('" + DepartmentID + "',p_depart_ids)>0 order by ID asc", Conn);
        else
            MyCmd = new SqlCommand("select * from hx_vERPBuMen where DirID=" + IDStr.ToString() + " and CHARINDEX('," + ZWL.Common.PublicMethod.GetSessionValue("DepartmentID") + ",',p_depart_ids)>0 order by ID asc", Conn);
        SqlDataReader MyReader = MyCmd.ExecuteReader();
        while (MyReader.Read())
        {
            TreeNode OrganizationNode = new TreeNode();
            OrganizationNode.Text = MyReader["BuMenName"].ToString();
            OrganizationNode.Value = MyReader["ID"].ToString();
            int strId = int.Parse(MyReader["ID"].ToString());
            OrganizationNode.ImageUrl = "~/images/user_group.gif";
            OrganizationNode.SelectAction = TreeNodeSelectAction.Expand;
            OrganizationNode.Expanded = true;

            /////////////////////////////////////////////////////////////////////////////////////////////////////
            //在当前节点下加入用户
            SqlConnection Conn1 = new SqlConnection(ConfigurationManager.AppSettings["SQLConnectionString"].ToString());
            Conn1.Open();
            //SqlCommand MyCmd1 = new SqlCommand("select * from ERPUser where Department like '%" + MyReader["BuMenName"].ToString() + "%' order by ID asc", Conn1);
            SqlCommand MyCmd1 = new SqlCommand("select * from ERPUser where Department = '" + MyReader["BuMenName"].ToString() + "' order by ID asc", Conn1);
            SqlDataReader MyReader1 = MyCmd1.ExecuteReader();
            while (MyReader1.Read())
            {
                TreeNode UserNode = new TreeNode();
                //UserNode.Text = MyReader1["UserName"].ToString();
                UserNode.Text = MyReader1["TrueName"].ToString();
                UserNode.Value = MyReader1["ID"].ToString();
                UserNode.ToolTip = MyReader1["UserName"].ToString();
                UserNode.ImageUrl = OnLinePic(MyReader1["ID"].ToString());
                UserNode.NavigateUrl = "../LanEmail/LanEmailAdd.aspx?UserName="******"UserName"].ToString();
                OrganizationNode.ChildNodes.Add(UserNode);
            }
            MyReader1.Close();
            Conn1.Close();
            /////////////////////////////////////////////////////////////////////////////////////////////////////

            Nds.Add(OrganizationNode);

            //递归循环
            BindTree(Nds[Nds.Count - 1].ChildNodes, strId);
        }
        MyReader.Close();
        Conn.Close();
    }
 public void CheckNode(TreeNodeCollection node, bool selected)
 {
     foreach (TreeNode item in node)
     {
         item.Checked = selected;
         CheckNode(item.ChildNodes, selected);
     }
 }
        /// <summary>
        /// Constructs the tree result with the pre compiled TreeNodeCollection, also checks for any JavaScript files that 
        /// need to be added via ClientDependency that have been specified on menu items.
        /// </summary>
        /// <param name="nodeCollection"></param>
        /// <param name="controller">The current ControllerContext</param>
        public UmbracoTreeResult(TreeNodeCollection nodeCollection, ControllerContext controller)
        {
            Content = nodeCollection.Serialize();
            ContentType = "application/json";
            ContentEncoding = Encoding.UTF8;

            NodeCollection = nodeCollection;
        }
 public static SectionRootNode CreateSingleTreeSectionRoot(string nodeId, string getChildNodesUrl, string menuUrl, string title, TreeNodeCollection children)
 {
     return new SectionRootNode(nodeId, getChildNodesUrl, menuUrl)
     {
         Children = children,
         Name = title
     };
 }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            nodes.AddRange(_getNodes(id, queryStrings));

            return nodes;
        }
 public void SetEnabledSeries(TreeNodeCollection groups)
 {
     //pass
 }
Exemple #32
0
 /// <summary>
 /// Adds the objects node.
 /// </summary>
 /// <param name="dictionaries">The dictionaries.</param>
 /// <param name="nodesSource">The nodes source.</param>
 /// <param name="nodesDestionation">The nodes destionation.</param>
 private void AddDictionariesNodes(IEnumerable <KeyValuePair <string, DictionaryResult> > dictionaries, TreeNodeCollection nodesSource, TreeNodeCollection nodesDestionation)
 {
     foreach (KeyValuePair <string, DictionaryResult> keyValuePair in dictionaries)
     {
         AddDictionaryNode(keyValuePair, nodesSource, nodesDestionation);
     }
 }
Exemple #33
0
        /// <summary>
        /// Adds the dictionary node.
        /// </summary>
        /// <param name="keyValuePair">The key value pair.</param>
        /// <param name="nodesSource">The nodes source.</param>
        /// <param name="nodesDestionation">The nodes destionation.</param>
        private void AddDictionaryNode(KeyValuePair <string, DictionaryResult> keyValuePair, TreeNodeCollection nodesSource, TreeNodeCollection nodesDestionation)
        {
            DictionaryResult dictionaryResult = keyValuePair.Value;

            TreeNode destionationNode = AddDictionaryNode(keyValuePair.Key, dictionaryResult.IsEquals, nodesDestionation);
            TreeNode sourceNode       = AddDictionaryNode(keyValuePair.Key, dictionaryResult.IsEquals, nodesSource);



            foreach (string key in dictionaryResult.Keys)
            {
                DictionaryEntryResult dictionaryEntryResult = dictionaryResult[key];

                AddObjectResult(dictionaryEntryResult.ResultType, dictionaryEntryResult.ObjectResult, sourceNode.Nodes, destionationNode.Nodes);
            }
        }
        protected override Umbraco.Web.Models.Trees.TreeNodeCollection GetTreeNodes(string id, System.Net.Http.Formatting.FormDataCollection queryStrings)
        {
            var types = Helper.GetTypesWithUIOMaticAttribute();

            //check if we're rendering the root node's children
            if (id == "-1")
            {
                var nodes = new TreeNodeCollection();
                foreach (var type in types)
                {
                    var attri = (UIOMaticAttribute)Attribute.GetCustomAttribute(type, typeof(UIOMaticAttribute));

                    if (attri.RenderType == Enums.UIOMaticRenderType.Tree)
                    {
                        var node = CreateTreeNode(
                            type.AssemblyQualifiedName,
                            "-1",
                            queryStrings,
                            attri.Name,
                            attri.FolderIcon,
                            true);

                        nodes.Add(node);
                    }
                    else
                    {
                        var node = CreateTreeNode(
                            type.AssemblyQualifiedName,
                            "-1",
                            queryStrings,
                            attri.Name,
                            attri.FolderIcon,
                            false,
                            "uiomatic/uioMaticTree/list/" + type.AssemblyQualifiedName);

                        nodes.Add(node);
                    }
                }
                return(nodes);
            }



            if (types.Any(x => x.AssemblyQualifiedName == id))
            {
                var ctrl  = new PetaPocoObjectController();
                var nodes = new TreeNodeCollection();

                var currentType = types.SingleOrDefault(x => x.AssemblyQualifiedName == id);
                var attri       = (UIOMaticAttribute)Attribute.GetCustomAttribute(currentType, typeof(UIOMaticAttribute));

                var itemIdPropName = "Id";
                foreach (var property in currentType.GetProperties())
                {
                    var keyAttri = property.GetCustomAttributes().Where(x => x.GetType() == typeof(PrimaryKeyColumnAttribute));
                    if (keyAttri.Any())
                    {
                        var columnAttri =
                            property.GetCustomAttributes().Where(x => x.GetType() == typeof(ColumnAttribute));
                        itemIdPropName = property.Name;
                    }
                }

                foreach (dynamic item in ctrl.GetAll(id, attri.SortColumn, attri.SortOrder))
                {
                    var node = CreateTreeNode(
                        item.GetType().GetProperty(itemIdPropName).GetValue(item, null).ToString() + "?type=" + id,
                        id,
                        queryStrings,
                        item.ToString(),
                        attri.ItemIcon,
                        false);

                    nodes.Add(node);
                }
                return(nodes);
            }

            //this tree doesn't suport rendering more than 2 levels
            throw new NotSupportedException();
        }
        /// <summary>
        /// Returns the tree nodes for an application
        /// </summary>
        /// <param name="application">The application to load tree for</param>
        /// <param name="tree">An optional single tree alias, if specified will only load the single tree for the request app</param>
        /// <param name="queryStrings"></param>
        /// <param name="use">Tree use.</param>
        /// <returns></returns>
        public async Task <TreeRootNode> GetApplicationTrees(string application, string tree, [System.Web.Http.ModelBinding.ModelBinder(typeof(HttpQueryStringModelBinder))] FormDataCollection queryStrings, TreeUse use = TreeUse.Main)
        {
            application = application.CleanForXss();

            if (string.IsNullOrEmpty(application))
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var section = _sectionService.GetByAlias(application);

            if (section == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            //find all tree definitions that have the current application alias
            var groupedTrees = _treeService.GetBySectionGrouped(application, use);
            var allTrees     = groupedTrees.Values.SelectMany(x => x).ToList();

            if (allTrees.Count == 0)
            {
                //if there are no trees defined for this section but the section is defined then we can have a simple
                //full screen section without trees
                var name = Services.TextService.Localize("sections", application);
                return(TreeRootNode.CreateSingleTreeRoot(Constants.System.RootString, null, null, name, TreeNodeCollection.Empty, true));
            }

            // handle request for a specific tree / or when there is only one tree
            if (!tree.IsNullOrWhiteSpace() || allTrees.Count == 1)
            {
                var t = tree.IsNullOrWhiteSpace()
                    ? allTrees[0]
                    : allTrees.FirstOrDefault(x => x.TreeAlias == tree);

                if (t == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }

                var treeRootNode = await GetTreeRootNode(t, Constants.System.Root, queryStrings);

                if (treeRootNode != null)
                {
                    return(treeRootNode);
                }

                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            // handle requests for all trees
            // for only 1 group
            if (groupedTrees.Count == 1)
            {
                var nodes = new TreeNodeCollection();
                foreach (var t in allTrees)
                {
                    var node = await TryGetRootNode(t, queryStrings);

                    if (node != null)
                    {
                        nodes.Add(node);
                    }
                }

                var name = Services.TextService.Localize("sections", application);

                if (nodes.Count > 0)
                {
                    var treeRootNode = TreeRootNode.CreateMultiTreeRoot(nodes);
                    treeRootNode.Name = name;
                    return(treeRootNode);
                }

                // otherwise it's a section with all empty trees, aka a fullscreen section
                // todo is this true? what if we just failed to TryGetRootNode on all of them? SD: Yes it's true but we should check the result of TryGetRootNode and throw?
                return(TreeRootNode.CreateSingleTreeRoot(Constants.System.RootString, null, null, name, TreeNodeCollection.Empty, true));
            }

            // for many groups
            var treeRootNodes = new List <TreeRootNode>();

            foreach (var(groupName, trees) in groupedTrees)
            {
                var nodes = new TreeNodeCollection();
                foreach (var t in trees)
                {
                    var node = await TryGetRootNode(t, queryStrings);

                    if (node != null)
                    {
                        nodes.Add(node);
                    }
                }

                if (nodes.Count == 0)
                {
                    continue;
                }

                // no name => third party
                // use localization key treeHeaders/thirdPartyGroup
                // todo this is an odd convention
                var name = groupName.IsNullOrWhiteSpace() ? "thirdPartyGroup" : groupName;

                var groupRootNode = TreeRootNode.CreateGroupNode(nodes, application);
                groupRootNode.Name = Services.TextService.Localize("treeHeaders", name);
                treeRootNodes.Add(groupRootNode);
            }

            return(TreeRootNode.CreateGroupedMultiTreeRoot(new TreeNodeCollection(treeRootNodes.OrderBy(x => x.Name))));
        }
        /// <summary>
        /// 初始化树
        /// </summary>
        /// <param name="xmlFilename"></param>
        public static void SetTree(string xmlFileName, string fileName, TreeView treeView, TreeNodeCollection treeNodes)//读取XML文件,建树
        {
            XmlDocument filesXml = new XmlDocument();

            filesXml.Load(fileName);//下载xml文件
            XmlNodeList rootList = filesXml.ChildNodes;
            int         i        = 0;
            int         flag     = 0;

            foreach (XmlNode xmlNode in rootList)
            {
                if (flag == 1)
                {
                    TreeNode newchild = new TreeNode();     //创建根节点
                    newchild.Text = xmlNode.Name;           //给根节点赋值
                    treeNodes.Add(newchild);                //加入根节点
                    CreatTreeNode(xmlNode, newchild.Nodes); //继续创建根节点以下结点
                    i++;
                }
                flag = 1;
            }
        }
Exemple #37
0
 private void CommentWayPoint()
 {
     TreeNodeCollection tncWayPointRoot = tvWayPoint.Nodes;
 }
Exemple #38
0
        AddObjectsToTree(Element elem, TreeNodeCollection curNodes)
        {
            Options geomOp;

            TreeNode tmpNode;

            // add geometry with the View set to null.
            var rootNode1 = new TreeNode("View = null");

            curNodes.Add(rootNode1);
            foreach (ViewDetailLevel viewDetailLevel in Enum.GetValues(typeof(ViewDetailLevel)))
            {
                tmpNode = new TreeNode($"Detail Level = {viewDetailLevel}");
                // IMPORTANT!!! Need to create options each time when you are
                // getting geometry. In other case, all the geometry you got at the
                // previous step will be owerriten according with the latest DetailLevel
                geomOp = MApp.Create.NewGeometryOptions();
                geomOp.ComputeReferences = true;
                geomOp.DetailLevel       = viewDetailLevel;
                tmpNode.Tag = elem.get_Geometry(geomOp);
                rootNode1.Nodes.Add(tmpNode);
            }


            // add model geometry including geometry objects not set as Visible.
            var rootNode = new TreeNode("View = null - Including geometry objects not set as Visible");

            curNodes.Add(rootNode);
            foreach (ViewDetailLevel viewDetailLevel in Enum.GetValues(typeof(ViewDetailLevel)))
            {
                tmpNode = new TreeNode($"Detail Level = {viewDetailLevel}");
                // IMPORTANT!!! Need to create options each time when you are
                // getting geometry. In other case, all the geometry you got at the
                // previous step will be owerriten according with the latest DetailLevel
                geomOp = MApp.Create.NewGeometryOptions();
                geomOp.ComputeReferences        = true;
                geomOp.IncludeNonVisibleObjects = true;
                geomOp.DetailLevel = viewDetailLevel;
                tmpNode.Tag        = elem.get_Geometry(geomOp);
                rootNode.Nodes.Add(tmpNode);
            }

            // now add geometry with the View set to the current view
            if (elem.Document.ActiveView != null)
            {
                var geomOp2 = MApp.Create.NewGeometryOptions();
                geomOp2.ComputeReferences = true;
                geomOp2.View = elem.Document.ActiveView;

                var rootNode2 = new TreeNode("View = Document.ActiveView")
                {
                    Tag = elem.get_Geometry(geomOp2)
                };
                curNodes.Add(rootNode2);

                // SOFiSTiK FS
                // add model geometry including geometry objects not set as Visible.
                {
                    var opts = MApp.Create.NewGeometryOptions();
                    opts.ComputeReferences        = true;
                    opts.IncludeNonVisibleObjects = true;
                    opts.View = elem.Document.ActiveView;

                    rootNode = new TreeNode("View = Document.ActiveView - Including geometry objects not set as Visible");
                    curNodes.Add(rootNode);

                    rootNode.Tag = elem.get_Geometry(opts);
                }
            }
        }
Exemple #39
0
        AddObjectsToTree(FamilyInstance elem, TreeNodeCollection curNodes)
        {
            var geomOp = MApp.Create.NewGeometryOptions();

            geomOp.ComputeReferences = false; // Not allowed for GetOriginalGeometry()!
            TreeNode tmpNode;

            // add geometry with the View set to null.
            var rootNode1 = new TreeNode("View = null");

            curNodes.Add(rootNode1);

            tmpNode            = new TreeNode("Detail Level = Undefined");
            geomOp.DetailLevel = ViewDetailLevel.Undefined;
            tmpNode.Tag        = elem.GetOriginalGeometry(geomOp);
            rootNode1.Nodes.Add(tmpNode);

            tmpNode            = new TreeNode("Detail Level = Coarse");
            geomOp.DetailLevel = ViewDetailLevel.Coarse;
            tmpNode.Tag        = elem.GetOriginalGeometry(geomOp);
            rootNode1.Nodes.Add(tmpNode);

            tmpNode            = new TreeNode("Detail Level = Medium");
            geomOp.DetailLevel = ViewDetailLevel.Medium;
            tmpNode.Tag        = elem.GetOriginalGeometry(geomOp);
            rootNode1.Nodes.Add(tmpNode);

            tmpNode            = new TreeNode("Detail Level = Fine");
            geomOp.DetailLevel = ViewDetailLevel.Fine;
            tmpNode.Tag        = elem.GetOriginalGeometry(geomOp);
            rootNode1.Nodes.Add(tmpNode);

            // SOFiSTiK FS
            // add model geometry including geometry objects not set as Visible.
            {
                var opts = MApp.Create.NewGeometryOptions();
                opts.ComputeReferences        = false; // Not allowed for GetOriginalGeometry()!;
                opts.IncludeNonVisibleObjects = true;

                var rootNode = new TreeNode("View = null - Including geometry objects not set as Visible");
                curNodes.Add(rootNode);

                tmpNode          = new TreeNode("Detail Level = Undefined");
                opts.DetailLevel = ViewDetailLevel.Undefined;
                tmpNode.Tag      = elem.GetOriginalGeometry(opts);
                rootNode.Nodes.Add(tmpNode);

                tmpNode          = new TreeNode("Detail Level = Coarse");
                opts.DetailLevel = ViewDetailLevel.Coarse;
                tmpNode.Tag      = elem.GetOriginalGeometry(opts);
                rootNode.Nodes.Add(tmpNode);

                tmpNode          = new TreeNode("Detail Level = Medium");
                opts.DetailLevel = ViewDetailLevel.Medium;
                tmpNode.Tag      = elem.GetOriginalGeometry(opts);
                rootNode.Nodes.Add(tmpNode);

                tmpNode          = new TreeNode("Detail Level = Fine");
                opts.DetailLevel = ViewDetailLevel.Fine;
                tmpNode.Tag      = elem.GetOriginalGeometry(opts);
                rootNode.Nodes.Add(tmpNode);
            }

            // now add geometry with the View set to the current view
            if (elem.Document.ActiveView != null)
            {
                var geomOp2 = MApp.Create.NewGeometryOptions();
                geomOp2.ComputeReferences = false; // Not allowed for GetOriginalGeometry()!;
                geomOp2.View = elem.Document.ActiveView;

                var rootNode2 = new TreeNode("View = Document.ActiveView")
                {
                    Tag = elem.GetOriginalGeometry(geomOp2)
                };
                curNodes.Add(rootNode2);

                // SOFiSTiK FS
                // add model geometry including geometry objects not set as Visible.
                {
                    var opts = MApp.Create.NewGeometryOptions();
                    opts.ComputeReferences        = false; // Not allowed for GetOriginalGeometry()!;
                    opts.IncludeNonVisibleObjects = true;
                    opts.View = elem.Document.ActiveView;

                    var rootNode = new TreeNode("View = Document.ActiveView - Including geometry objects not set as Visible");
                    curNodes.Add(rootNode);

                    rootNode.Tag = elem.GetOriginalGeometry(opts);
                }
            }
        }
Exemple #40
0
 void clearTree(TreeNodeCollection coll)
 {
     coll.Clear();
 }
Exemple #41
0
        /// <summary>
        /// Populates the tree with the elements within the specified area.
        /// </summary>
        private void BrowseArea(TreeNodeCollection nodes, Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType browseType, Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseElement area)
        {
            IOpcBrowsePosition position = null;

            try
            {
                // fetch first batch of elements.
                Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseElement[] elements = mServer_.Browse(
                    area?.QualifiedName,
                    browseType,
                    mBrowseFilter_,
                    mMaxElements_,
                    out position);


                do
                {
                    // add elements to tree.
                    for (int ii = 0; ii < elements.Length; ii++)
                    {
                        // create node.
                        TreeNode node = new TreeNode(elements[ii].Name)
                        {
                            ImageIndex         = (browseType == Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType.Area) ? Resources.IMAGE_CLOSED_BLUE_FOLDER : Resources.IMAGE_GREEN_SCROLL,
                            SelectedImageIndex = (browseType == Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType.Area) ? Resources.IMAGE_OPEN_BLUE_FOLDER : Resources.IMAGE_GREEN_SCROLL,
                            Tag = elements[ii]
                        };

                        // add dummy child to ensure '+' sign is visible.
                        node.Nodes.Add(new TreeNode());

                        // add to tree.
                        nodes.Add(node);
                    }

                    // check if browse is complete.
                    if (position == null)
                    {
                        break;
                    }

                    // prompt to continue browse.
                    DialogResult result = MessageBox.Show(
                        "More elements meeting search criteria exist. Continue browse?",
                        "Browse " + browseType + "s",
                        MessageBoxButtons.YesNo);

                    if (result == DialogResult.No)
                    {
                        break;
                    }

                    // continue browse.
                    elements = mServer_.BrowseNext(mMaxElements_, ref position);
                }while (true);
            }
            finally
            {
                // dipose position object on exit.
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
        }
        private void BrowseToFolder(string strPath)
        {
            try
            {
                DirectoryInfo di    = new DirectoryInfo(strPath);
                string[]      vPath = di.FullName.Split(new char[] { Path.DirectorySeparatorChar });
                if ((vPath == null) || (vPath.Length == 0))
                {
                    Debug.Assert(false); return;
                }

                TreeNode tn  = null;
                string   str = string.Empty;
                for (int i = 0; i < vPath.Length; ++i)
                {
                    if (i > 0)
                    {
                        str = UrlUtil.EnsureTerminatingSeparator(str, false);
                    }
                    str += vPath[i];
                    if (i == 0)
                    {
                        str = UrlUtil.EnsureTerminatingSeparator(str, false);
                    }

                    TreeNodeCollection tnc = ((tn != null) ? tn.Nodes : m_tvFolders.Nodes);
                    tn = null;

                    foreach (TreeNode tnSub in tnc)
                    {
                        string strSub = (tnSub.Tag as string);
                        if (string.IsNullOrEmpty(strSub))
                        {
                            Debug.Assert(false); continue;
                        }

                        if (strSub.Equals(str, StrUtil.CaseIgnoreCmp))
                        {
                            tn = tnSub;
                            break;
                        }
                    }

                    if (tn == null)
                    {
                        Debug.Assert(false); break;
                    }

                    if ((i != (vPath.Length - 1)) && !tn.IsExpanded)
                    {
                        tn.Expand();
                    }
                }

                if (tn != null)
                {
                    m_tvFolders.SelectedNode = tn;
                    tn.EnsureVisible();
                }
                else
                {
                    Debug.Assert(false);
                }
            }
            catch (Exception) { Debug.Assert(false); }
        }
Exemple #43
0
        private void syncTreeNodes(string destPath, TreeNodeCollection nodes)
        {
            foreach (TreeNode node in nodes)
            {
                if ((bool)node.Tag)
                {
                    if (node.Nodes.Count > 0)
                    {
                        var childPath = destPath;
                        if (node.Checked)
                        {
                            if (destPath.Equals(ROOT_FOLDER))
                            {
                                childPath = ROOT_FOLDER + node.Text;
                            }
                            else
                            {
                                childPath = destPath + PATH_SEPERATOR + node.Text;
                            }
                        }
                        syncTreeNodes(childPath, node.Nodes);
                    }
                    else
                    {
                        if (!existingPaths.Contains(destPath))
                        {
                            EnsureDestDir(destPath);
                            existingPaths.Add(destPath);
                        }
                        var itemPath = ROOT_FOLDER + node.FullPath.Replace("\\", PATH_SEPERATOR);
                        var itemType = sourceRS.GetItemType(itemPath);
                        if (itemType == ItemTypeEnum.Resource)
                        {
                            //Download the resource
                            string resourceType;
                            var    contents = sourceRS.GetResourceContents(itemPath, out resourceType);
                            uploadResource(destPath, node.Text, resourceType, contents);
                            processedNodeCount++;
                            continue;
                        }
                        var reportDef = sourceRS.GetReportDefinition(itemPath);
                        uploadReport(destPath, node.Text, reportDef);

                        //Sync subscriptions
                        ExtensionSettings extSettings;
                        string            desc;
                        ActiveState       active;
                        string            status;
                        string            eventType;
                        string            matchData;
                        ParameterValue[]  values        = null;
                        Subscription[]    subscriptions = null;
                        ParameterValueOrFieldReference[] extensionParams = null;

                        var destReportPath = destPath;
                        if (destReportPath.EndsWith("/"))
                        {
                            destReportPath += node.Text;
                        }
                        else
                        {
                            destReportPath += "/" + node.Text;
                        }

                        subscriptions = sourceRS.ListSubscriptions(itemPath, txtSourceUser.Text);
                        foreach (var subscription in subscriptions)
                        {
                            sourceRS.GetSubscriptionProperties(subscription.SubscriptionID, out extSettings, out desc, out active, out status, out eventType, out matchData, out values);
                            if (extSettings.Extension == "Report Server FileShare")
                            {
                                ParameterValue para = new ParameterValue();
                                para.Name  = "PASSWORD";
                                para.Value = txtDestPassword.Text;
                                ParameterValueOrFieldReference[] exParams = new ParameterValueOrFieldReference[extSettings.ParameterValues.Length + 1];
                                Array.Copy(extSettings.ParameterValues, exParams, extSettings.ParameterValues.Length);
                                exParams[extSettings.ParameterValues.Length] = para;
                                extSettings.ParameterValues = exParams;
                            }
                            destRS.CreateSubscription(destReportPath, extSettings, desc, eventType, matchData, values);
                        }

                        processedNodeCount++;
                        bwSync.ReportProgress(processedNodeCount * 100 / selectedNodeCount);
                    }
                }
            }
        }
        protected override TreeNodeCollection GetTreeNodes(string id,
                                                           FormDataCollection queryStrings)
        {
            var entityId          = GuidHelper.GetGuid(id);
            var nodes             = new TreeNodeCollection();
            var rootId            = CoreConstants.System.Root.ToInvariantString();
            var rootFormsId       = GuidHelper.GetGuid(FormConstants.Id);
            var rootLayoutsId     = GuidHelper.GetGuid(LayoutConstants.Id);
            var rootValidationsId = GuidHelper.GetGuid(
                ValidationConstants.Id);
            var rootDataValueId = GuidHelper.GetGuid(DataValueConstants.Id);

            if (id.InvariantEquals(rootId))
            {
                // Get root nodes.
                var formatUrl    = "/formulate/formulate/{0}/{1}";
                var hasRootForms = Persistence
                                   .RetrieveChildren(rootFormsId).Any();
                var formsNode = this.CreateTreeNode(FormConstants.Id, id,
                                                    queryStrings, LocalizationHelper.GetTreeName(FormConstants.Title),
                                                    FormConstants.TreeIcon, hasRootForms,
                                                    string.Format(formatUrl, "forms", FormConstants.Id));
                nodes.Add(formsNode);
                var hasRootLayouts = Persistence
                                     .RetrieveChildren(rootLayoutsId).Any();
                var layoutsNode = this.CreateTreeNode(LayoutConstants.Id,
                                                      id, queryStrings, LocalizationHelper.GetTreeName(LayoutConstants.Title),
                                                      LayoutConstants.TreeIcon, hasRootLayouts,
                                                      string.Format(formatUrl, "layouts", LayoutConstants.Id));
                nodes.Add(layoutsNode);
                var dataSourcesNode = this.CreateTreeNode(
                    DataSourceConstants.Id, id, queryStrings,
                    LocalizationHelper.GetTreeName(DataSourceConstants.Title),
                    DataSourceConstants.TreeIcon, false,
                    string.Format(formatUrl, "dataSources", DataSourceConstants.Id));
                nodes.Add(dataSourcesNode);
                var hasRootDataValues = Persistence
                                        .RetrieveChildren(rootDataValueId).Any();
                var dataValuesNode = this.CreateTreeNode(
                    DataValueConstants.Id, id, queryStrings,
                    LocalizationHelper.GetTreeName(DataValueConstants.Title),
                    DataValueConstants.TreeIcon, hasRootDataValues,
                    string.Format(formatUrl, "dataValues", DataValueConstants.Id));
                nodes.Add(dataValuesNode);
                var hasRootValidations = Persistence
                                         .RetrieveChildren(rootValidationsId).Any();
                var validationsNode = this.CreateTreeNode(
                    ValidationConstants.Id, id, queryStrings,
                    LocalizationHelper.GetTreeName(ValidationConstants.Title),
                    ValidationConstants.TreeIcon, hasRootValidations,
                    string.Format(formatUrl, "validationLibrary", ValidationConstants.Id));
                nodes.Add(validationsNode);
            }
            else if (id.InvariantEquals(LayoutConstants.Id))
            {
                // Get root nodes under layouts.
                var entities = Persistence
                               .RetrieveChildren(rootLayoutsId);
                LayoutHelper.AddLayoutChildrenToTree(nodes, queryStrings,
                                                     entities.OrderBy(x => x.Name));
            }
            else if (id.InvariantEquals(ValidationConstants.Id))
            {
                // Get root nodes under validations.
                var entities = Persistence
                               .RetrieveChildren(rootValidationsId);
                ValidationHelper.AddValidationChildrenToTree(
                    nodes, queryStrings, entities.OrderBy(x => x.Name));
            }
            else if (id.InvariantEquals(FormConstants.Id))
            {
                // Get root nodes under forms.
                var entities = Persistence
                               .RetrieveChildren(rootFormsId);
                FormHelper.AddFormChildrenToTree(nodes, queryStrings,
                                                 entities.OrderBy(x => x.Name));
            }
            else if (id.InvariantEquals(DataValueConstants.Id))
            {
                // Get root nodes under data values.
                var entities = Persistence
                               .RetrieveChildren(rootDataValueId);
                DataValueHelper.AddChildrenToTree(nodes, queryStrings,
                                                  entities.OrderBy(x => x.Name));
            }
            else
            {
                // Variables.
                var entity     = Persistence.Retrieve(entityId);
                var ancestorId = entity.Path.First();
                var children   = Persistence
                                 .RetrieveChildren(entityId);


                // Add children of folder.
                if (entity is Folder)
                {
                    // Which subtree?
                    if (ancestorId == rootFormsId)
                    {
                        FormHelper.AddFormChildrenToTree(nodes, queryStrings,
                                                         children.OrderBy(x => x.Name));
                    }
                    else if (ancestorId == rootLayoutsId)
                    {
                        LayoutHelper.AddLayoutChildrenToTree(nodes,
                                                             queryStrings, children.OrderBy(x => x.Name));
                    }
                    else if (ancestorId == rootValidationsId)
                    {
                        ValidationHelper.AddValidationChildrenToTree(
                            nodes, queryStrings, children.OrderBy(x => x.Name));
                    }
                    else if (ancestorId == rootDataValueId)
                    {
                        DataValueHelper.AddChildrenToTree(nodes,
                                                          queryStrings, children.OrderBy(x => x.Name));
                    }
                }
                else if (entity is Form)
                {
                    ConfiguredFormHelper.AddConfiguredFormChildrenToTree(nodes,
                                                                         queryStrings, children.OrderBy(x => x.Name));
                }
            }
            return(nodes);
        }
Exemple #45
0
 public static IEnumerable <TreeNode> FlattenTree(this TreeNodeCollection coll)
 {
     return(coll.Cast <TreeNode>()
            .Concat(coll.Cast <TreeNode>()
                    .SelectMany(x => FlattenTree(x.Nodes))));
 }
Exemple #46
0
        private static void Recurse(TreeNodeCollection nodes, string path)
        {
            try
            {
                string[] macros = Directory.GetFiles(path, "*.macro");
                for (int i = 0; i < macros.Length; i++)
                {
                    Macro m = null;
                    for (int j = 0; j < m_MacroList.Count; j++)
                    {
                        Macro check = m_MacroList[j];

                        if (check.Filename == macros[i])
                        {
                            m = check;
                            break;
                        }
                    }

                    if (m == null)
                    {
                        Add(m = new Macro(macros[i]));
                    }

                    if (nodes != null)
                    {
                        TreeNode node = new TreeNode(Path.GetFileNameWithoutExtension(m.Filename));
                        node.Tag = m;
                        nodes.Add(node);
                    }
                }
            }
            catch
            {
            }

            try
            {
                string[] dirs = Directory.GetDirectories(path);
                for (int i = 0; i < dirs.Length; i++)
                {
                    if (dirs[i] != "" && dirs[i] != "." && dirs[i] != "..")
                    {
                        if (nodes != null)
                        {
                            TreeNode node = new TreeNode($"[{Path.GetFileName(dirs[i])}]");
                            node.Tag = dirs[i];
                            nodes.Add(node);
                            Recurse(node.Nodes, dirs[i]);
                        }
                        else
                        {
                            Recurse(null, dirs[i]);
                        }
                    }
                }
            }
            catch
            {
            }
        }
Exemple #47
0
        private void ReadWayPointList(List <clsWayPoint> wayPoints)
        {
            TreeNodeCollection tncWayPointRoot = tvWayPoint.Nodes;

            tncWayPointRoot.Clear();

            clsWayPoint wpLast = null;

            foreach (clsWayPoint wp in wayPoints)
            {
                //从星系开始记录
                if (wpLast == null)
                {
                    if (!wp.PointName.StartsWith("J"))
                    {
                        wpLast = wp;
                    }
                    continue;
                }
                //虫洞
                if (wp.PointName.StartsWith("J"))
                {
                    if (!wpLast.PointName.StartsWith("J"))
                    {
                        //洞外→洞内
                        TreeNode tnRoot = SearchTreeNode(tncWayPointRoot, wpLast.PointName);
                        TreeNode tnNow  = SearchTreeNode(tncWayPointRoot, wp.PointName);

                        if (tnRoot == null)
                        {
                            //排除回洞
                            tnRoot = new TreeNode(wpLast.PointName);
                            tnRoot.Nodes.Add(wp.PointName);
                            tncWayPointRoot.Add(tnRoot);
                        }
                        else
                        {
                            //排除重复进洞
                        }
                    }
                    else
                    {
                        //洞内→洞内
                        TreeNode tnLast = SearchTreeNode(tncWayPointRoot, wpLast.PointName);
                        TreeNode tnNow  = SearchTreeNode(tncWayPointRoot, wp.PointName);
                        if (tnNow == null)
                        {
                            tnLast.Nodes.Add(wp.PointName);
                        }
                    }
                }
                else
                {
                    if (!wpLast.PointName.StartsWith("J"))
                    {
                        //洞外→洞外
                    }
                    else
                    {
                        //洞内→洞外
                        TreeNode tnLast = SearchTreeNode(tncWayPointRoot, wpLast.PointName);
                        TreeNode tnNow  = SearchTreeNode(tncWayPointRoot, wp.PointName);
                        if (tnNow == null)
                        {
                            tnLast.Nodes.Add(wp.PointName);
                        }
                        else if (tnNow != null && SearchTreeNode(tnLast.Nodes, wp.PointName) != null)
                        {
                            //排除重复探头记录
                        }
                        else if (tnLast != null && SearchTreeNode(tnNow.Nodes, wpLast.PointName) != null)
                        {
                            //排除原地出洞
                        }
                    }
                }
                wpLast = wp;
            }

            tvWayPoint.ExpandAll();
        }
Exemple #48
0
        private void runCheckButton_Click(object sender, EventArgs e)
        {
            var checkDups  = checkDuplicates.Checked;
            var checkLen   = checkLength.Checked;
            var lenToCheck = Convert.ToInt32(lengthToCheckInput.Value);
            var checkComp  = checkComplexity.Checked;
            var comp       = (PasswordScore)complexitySlider.Value;

            if (!checkDups && !checkLen && !checkComp)
            {
                MessageBox.Show("You must select at least one criteria to check.", "Error");
                return;
            }

            runCheckButton.Enabled     = false;
            checkDuplicates.Enabled    = false;
            checkLength.Enabled        = false;
            lengthToCheckInput.Enabled = false;
            checkComplexity.Enabled    = false;
            complexitySlider.Enabled   = false;

            try
            {
                this.statusLabel.Text = "Starting Check...";
                PwDatabase pwdb = m_host.Database;

                if (!pwdb.IsOpen)
                {
                    statusLabel.Text = "Please open database first...";
                    return;
                }

                PwObjectList <PwEntry> entries = pwdb.RootGroup.GetEntries(true);

                if (entries != null)
                {
                    statusLabel.Text = "Database opened, " + entries.UCount + " entries to check...";
                }
                else
                {
                    statusLabel.Text = "No entries in Database.";
                    return;
                }

                //Used to check for Duplicate Passwords
                Dictionary <string, List <string> > results = new Dictionary <string, List <string> >(entries.Count <PwEntry>());
                //Used to check password length
                List <string> shortPasses = new List <string>();
                //Used to check password complexity
                List <string> simplePasses = new List <string>();

                foreach (var entry in entries)
                {
                    string pass = entry.Strings.Get(PwDefs.PasswordField).ReadString();
                    if (pass.Equals(""))
                    {
                        continue;
                    }
                    if (checkDups)
                    {
                        if (results.ContainsKey(pass))
                        {
                            results[pass].Add(entry.Strings.Get(PwDefs.TitleField).ReadString());
                        }
                        else
                        {
                            List <string> list = new List <string>();
                            var           xx   = entry.Strings.Get(PwDefs.TitleField);
                            if (xx != null)
                            {
                                list.Add(xx.ReadString());
                            }
                            else
                            {
                                var urlxx = entry.Strings.Get(PwDefs.UrlField);
                                if (urlxx != null)
                                {
                                    list.Add(urlxx.ReadString());
                                }
                                else
                                {
                                    list.Add(entry.ToString());
                                }
                            }
                            results.Add(pass, list);
                        }
                    }
                    if (checkLen)
                    {
                        if (pass.Length < lenToCheck)
                        {
                            shortPasses.Add(entry.Strings.Get(PwDefs.TitleField).ReadString() + " (" + pass.Length + ")");
                        }
                    }

                    if (checkComp)
                    {
                        var tcomp = PasswordAdvisor.CheckStrength(pass);
                        if (tcomp < comp)
                        {
                            simplePasses.Add(entry.Strings.Get(PwDefs.TitleField).ReadString() + " (" + Enum.GetName(typeof(PasswordScore), tcomp) + ")");
                        }
                    }
                }

                checkResultsView.BeginUpdate();

                TreeNodeCollection nodes = checkResultsView.Nodes;

                checkResultsView.Nodes.Clear();

                if (checkDups)
                {
                    int dupPass = 1;
                    foreach (KeyValuePair <string, List <string> > result in results)
                    {
                        if (result.Value.Count > 1)
                        {
                            List <TreeNode> children = new List <TreeNode>();
                            foreach (var title in result.Value)
                            {
                                children.Add(new TreeNode(title));
                            }
                            TreeNode node = new TreeNode(string.Format("Duplicated Password [{0}] ({1})", result.Key, children.Count), children.ToArray());
                            nodes.Add(node);
                            dupPass++;
                        }
                    }
                }

                if (checkLen)
                {
                    if (shortPasses.Count > 0)
                    {
                        List <TreeNode> children = new List <TreeNode>();
                        foreach (var title in shortPasses)
                        {
                            children.Add(new TreeNode(title));
                        }
                        TreeNode node = new TreeNode("Short Passwords", children.ToArray());
                        nodes.Add(node);
                    }
                }

                if (checkComp)
                {
                    if (simplePasses.Count > 0)
                    {
                        List <TreeNode> children = new List <TreeNode>();
                        foreach (var title in simplePasses)
                        {
                            children.Add(new TreeNode(title));
                        }
                        TreeNode node = new TreeNode("Simple Passwords", children.ToArray());
                        nodes.Add(node);
                    }
                }

                checkResultsView.EndUpdate();

                statusLabel.Text = "Check complete.";
            }
            catch (NullReferenceException nre)
            {
                MessageBox.Show(string.Format("I tried to read a null value.\n{0}", nre.StackTrace));
                throw;
            }
            runCheckButton.Enabled     = true;
            checkDuplicates.Enabled    = true;
            checkLength.Enabled        = true;
            lengthToCheckInput.Enabled = true;
            checkComplexity.Enabled    = true;
            complexitySlider.Enabled   = true;
        }
Exemple #49
0
        public string SaveGroup(TreeView myTreeView, string myGroupId, bool isUpdate, XDocument xv, XDocument xb, TreeView treeViewSource, DataGridView dataGridViewGroupVanilla)
        {
            errorMessage = "";
            TreeNodeCollection newTreeNodeCollection    = myTreeView.Nodes;
            TreeNodeCollection treeViewSourceCollection = treeViewSource.Nodes;

            if (isUpdate)
            {
                string nodeToDelete = "";
                bool   swFound      = false;

                foreach (TreeNode node in newTreeNodeCollection)
                {
                    try
                    {
                        nodeToDelete = Shared.GetElementValue(node.Text);
                        if (nodeToDelete.Trim() == myGroupId)
                        {
                            // Start "EditControls" ver: 1.0.8 date: 03-03-16
                            int nodeIndex = node.Index;
                            // End "EditControls" ver: 1.0.8 date: 03-03-16
                            // Remove old Group Id
                            newTreeNodeCollection.Remove(node);
                            swFound = true;
                            // Add the updated Group Id
                            XElement group           = FillNewXelement(myGroupId, groupPairs);
                            TreeNode groupParentNode = FillNewTreeNode(myGroupId, groupPairs);
                            // Compares current group with base and source
                            string nodeTag = "";
                            if (xv != null)
                            {
                                // Compares with source
                                bool isDiffFromSource = CompareGroups(myGroupId, group, xb);
                                // Compares with base
                                bool isDiffFromBase = CompareGroups(myGroupId, group, xv);
                                if (isDiffFromSource && isDiffFromBase)
                                {
                                    nodeTag = "DiffFromSourceAndBase";
                                }
                                else
                                {
                                    if (isDiffFromSource)
                                    {
                                        nodeTag = "DiffFromSource";
                                    }
                                    else
                                    {
                                        if (isDiffFromBase)
                                        {
                                            nodeTag = "DiffFromBase";
                                        }
                                    }
                                }
                            }
                            else
                            {
                                // Compares with source
                                if (CompareGroups(myGroupId, group, xb))
                                {
                                    nodeTag = "DiffFromSource";
                                }
                                else
                                {
                                    nodeTag = "NoDiff";
                                }
                            }
                            groupParentNode.Tag = nodeTag;
                            // Start "EditControls" ver: 1.0.8 date: 03-03-16
                            //newTreeNodeCollection.Add(groupParentNode);
                            newTreeNodeCollection.Insert(nodeIndex, groupParentNode);
                            // End "EditControls" ver: 1.0.8 date: 03-03-16
                            // Compare dataGridViewVanilla with current group to highlight the differences
                            //Shared.CompareVanillaGroupToCurrentGroupHighlightDifferences(groupParentNode, dataGridViewGroupVanilla);
                            break;
                        }
                    }
                    catch (Exception err)
                    {
                        errorMessage = "There was a problem when trying to update " + myGroupId + "." + err.Message;
                    }
                }
                if (!swFound)
                {
                    errorMessage = myGroupId + " was not updated because it was not found.";
                }
            }
            else
            {
                try
                {
                    bool doUpdate = true;
                    // Check if the group already exist on the target treeview
                    foreach (TreeNode node in newTreeNodeCollection)
                    {
                        if (Shared.GetElementValue(node.Text) == myGroupId)
                        {
                            errorMessage = "The group " + myGroupId + " already exist.";
                            doUpdate     = false;
                            break;
                        }
                    }
                    // Check if the group already exist on the source treeview
                    foreach (TreeNode node in treeViewSourceCollection)
                    {
                        if (Shared.GetElementValue(node.Text) == myGroupId)
                        {
                            errorMessage = "The group " + myGroupId + " already exist on the source signature.";
                            doUpdate     = false;
                            break;
                        }
                    }
                    if (doUpdate)
                    {
                        // Add the new Group Id
                        TreeNode groupParentNode = FillNewTreeNode(myGroupId, groupPairs);
                        if (xv != null)
                        {
                            XElement group = FillNewXelement(myGroupId, groupPairs);
                            // Compares with base
                            bool isDiffFromBase = CompareGroups(myGroupId, group, xv);
                            //
                            if (isDiffFromBase)
                            {
                                groupParentNode.Tag = "DiffFromSourceAndBase";
                            }
                            else
                            {
                                groupParentNode.Tag = "DiffFromSource";
                            }
                        }
                        else
                        {
                            groupParentNode.Tag = "DiffFromSource";
                        }
                        //
                        newTreeNodeCollection.Add(groupParentNode);
                    }
                }
                catch (Exception err)
                {
                    errorMessage = "The new group " + myGroupId + " was not added." + err.Message;
                }
            }
            return(errorMessage);
        }
Exemple #50
0
 public WrappedNodeList(TreeNodeCollection nodes)
 {
     this.nodes = nodes;
 }
Exemple #51
0
    private void BindTree(TreeNodeCollection Nds, int IDStr)
    {
        //Andy  20130925
        ArrayList listName = null;

        if (Request.QueryString["Condition"] != null && Request.QueryString["Condition"].ToString() != "")
        {
            listName = new ArrayList(Request.QueryString["Condition"].ToString().Split(','));
        }


        SqlConnection Conn = new SqlConnection(ConfigurationManager.AppSettings["SQLConnectionString"].ToString());


        //SqlConnection Conn = new SqlConnection(ConfigurationManager.AppSettings["SQLConnectionString"].ToString());
        Conn.Open();
        SqlCommand    MyCmd    = new SqlCommand("select * from ERPBuMen where DirID=" + IDStr.ToString() + " order by ID asc", Conn);
        SqlDataReader MyReader = MyCmd.ExecuteReader();

        while (MyReader.Read())
        {
            TreeNode OrganizationNode = new TreeNode();
            OrganizationNode.Text  = MyReader["BuMenName"].ToString();
            OrganizationNode.Value = MyReader["ID"].ToString();
            int strId = int.Parse(MyReader["ID"].ToString());
            OrganizationNode.ImageUrl     = "~/images/user_group.gif";
            OrganizationNode.SelectAction = TreeNodeSelectAction.Expand;
            //OrganizationNode.Expanded = true;
            //string ChildID = ZWL.DBUtility.DbHelperSQL.GetSHSLInt("select top 1 ID from ERPBuMen where DirID=" + MyReader["ID"].ToString() + " order by ID asc");
            //if (ChildID.Trim() != "0")
            //{
            HaveChild = HaveChild + "|" + MyReader["BuMenName"].ToString() + "|";
            //}
            OrganizationNode.ToolTip = MyReader["BuMenName"].ToString();
            //OrganizationNode.Collapse();

            /////////////////////////////////////////////////////////////////////////////////////////////////////
            //在当前节点下加入用户
            //SqlConnection Conn1 = new SqlConnection(ConfigurationManager.AppSettings["SQLConnectionString"].ToString());
            SqlConnection Conn1 = new SqlConnection(ConfigurationManager.AppSettings["SQLConnectionString"].ToString());
            Conn1.Open();
            SqlCommand    MyCmd1    = new SqlCommand("select * from ERPUser where Department like '%" + MyReader["BuMenName"].ToString() + "%' order by ID asc", Conn1);
            SqlDataReader MyReader1 = MyCmd1.ExecuteReader();
            while (MyReader1.Read())
            {
                TreeNode UserNode = new TreeNode();

                //Andy 20130925 选中文本框中传过来的用户
                if (listName != null)
                {
                    if (listName.Contains(MyReader1["UserName"].ToString()))
                    {
                        UserNode.Checked = true;
                    }
                }

                UserNode.Text         = MyReader1["UserName"].ToString();
                UserNode.Value        = MyReader1["ID"].ToString();
                UserNode.ImageUrl     = OnLinePic(MyReader1["ID"].ToString());
                UserNode.ToolTip      = MyReader1["UserName"].ToString();
                UserNode.SelectAction = TreeNodeSelectAction.Expand;
                OrganizationNode.ChildNodes.Add(UserNode);
            }

            MyReader1.Close();
            Conn1.Close();


            /////////////////////////////////////////////////////////////////////////////////////////////////////



            Nds.Add(OrganizationNode);
            //递归循环
            BindTree(Nds[Nds.Count - 1].ChildNodes, strId);
        }
        readTreeNode(this.ListTreeView.Nodes);
        MyReader.Close();
        Conn.Close();
    }
Exemple #52
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request["menuid"]))
        {
            if (Request["menuid"] == "Add")
            {
                _mode = eMenuMode.Create;
            }
            else
            {
                Int32.TryParse(Request["menuid"], out _menuItemId);
                if (_menuItemId != -1)
                {
                    _mode = eMenuMode.Edit;
                }
            }
            if (_menuItemId == -1)
            {
                _mode = eMenuMode.Err;
            }
        }
        else
        {
            _mode = eMenuMode.Err;
        }

        if (!string.IsNullOrEmpty(Request["type"]))
        {
            Enum.TryParse(Request["type"], true, out _type);
        }

        Page.Title = string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_m_Category_AddCategory);

        if (Request["mode"] != null)
        {
            if (Request["mode"] == "edit")
            {
                _mode = eMenuMode.Edit;
            }
            else if (Request["mode"] == "create")
            {
                _mode = eMenuMode.Create;
            }
            else
            {
                _mode = eMenuMode.Err;
            }
        }
        else
        {
            _mode = eMenuMode.Err;
        }

        if (!IsPostBack)
        {
            lblBigHead.Text = _type == MenuService.EMenuType.Top
                ? Resource.Admin_MenuManager_TopMenu
                : Resource.Admin_MenuManager_BottomMenu;

            if (_mode == eMenuMode.Edit)
            {
                btnAdd.Text     = Resource.Admin_m_Category_Save;
                lblSubHead.Text = Resource.Admin_MenuManager_EditMenuItem;

                if (!LoadMenuItem(_menuItemId))
                {
                    return;
                }
            }
            else if (_mode == eMenuMode.Create)
            {
                txtName.Text = string.Empty;
                txtName.Focus();

                txtSortOrder.Text = @"0";

                btnAdd.Text     = Resource.Admin_m_Category_Add;
                lblSubHead.Text = Resource.Admin_MenuManager_CreateMenuItem;
            }

            if (_mode == eMenuMode.Create && _menuItemId == 0)
            {
                lParent.Text    = Resource.Admin_MenuManager_RootItem;
                pnlIcon.Visible = false;
            }
            else if (_mode == eMenuMode.Create)
            {
                var mItem = MenuService.GetMenuItemById(_menuItemId, _type);
                lParent.Text  = mItem != null ? mItem.MenuItemName : Resource.Admin_m_Category_No;
                hParent.Value = mItem != null?Convert.ToString(mItem.MenuItemID) : string.Empty;

                pnlIcon.Visible = false;
            }

            if (_menuItemId == 0 && _mode == eMenuMode.Edit)
            {
                lParent.Text           = Resource.Admin_m_Category_No;
                lbParentChange.Visible = false;
            }
            else if (_mode == eMenuMode.Edit)
            {
                var mItem = MenuService.GetMenuItemById(_menuItemId, _type);

                if (mItem.MenuItemParentID != 0)
                {
                    var pItem = MenuService.GetMenuItemById(mItem.MenuItemParentID, _type);
                    lParent.Text = pItem != null ? pItem.MenuItemName
                                                 : Resource.Admin_MenuManager_RootItem;
                }
                else
                {
                    lParent.Text = Resource.Admin_MenuManager_RootItem;
                }
                hParent.Value = Convert.ToString(mItem.MenuItemParentID);
            }

            var node = new TreeNode {
                Text = Resource.Admin_m_Category_Root, Value = @"0", Selected = true
            };
            tree.Nodes.Add(node);

            LoadChildItems(tree.Nodes[0]);

            TreeNodeCollection nodes = tree.Nodes[0].ChildNodes;
            //var isFirstNode = true;
            foreach (var parentItems in MenuService.GetParentMenuItems(String.IsNullOrEmpty(hParent.Value) ? 0 : Convert.ToInt32(hParent.Value), _type))
            {
                TreeNode tn = (nodes.Cast <TreeNode>().Where(n => n.Value == parentItems.ToString(CultureInfo.InvariantCulture))).SingleOrDefault();

                if (tn != null)
                {
                    //tn.Selected = isFirstNode;
                    //isFirstNode = false;
                    tn.Expand();
                    nodes = tn.ChildNodes;
                }
            }
        }
    }
        private void LoadBindableProperties()
        {
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.Control, BindablePropertiesFilter);
            string             name            = null;
            PropertyDescriptor defaultProperty = TypeDescriptor.GetDefaultProperty(this.Control);

            if (defaultProperty != null)
            {
                name = defaultProperty.Name;
            }
            TreeNodeCollection          nodes       = this._bindablePropsTree.Nodes;
            ExpressionBindingCollection expressions = ((IExpressionsAccessor)this.Control).Expressions;
            Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);

            foreach (ExpressionBinding binding in expressions)
            {
                hashtable[binding.PropertyName] = binding;
            }
            TreeNode node = null;

            foreach (PropertyDescriptor descriptor2 in properties)
            {
                if (string.Compare(descriptor2.Name, "ID", StringComparison.OrdinalIgnoreCase) != 0)
                {
                    ExpressionBinding binding2 = null;
                    if (hashtable.Contains(descriptor2.Name))
                    {
                        binding2 = (ExpressionBinding)hashtable[descriptor2.Name];
                        hashtable.Remove(descriptor2.Name);
                    }
                    TreeNode node2 = new BindablePropertyNode(descriptor2, binding2);
                    if (descriptor2.Name.Equals(name, StringComparison.OrdinalIgnoreCase))
                    {
                        node = node2;
                    }
                    nodes.Add(node2);
                }
            }
            this._complexBindings = hashtable;
            if ((node == null) && (nodes.Count != 0))
            {
                int count = nodes.Count;
                for (int i = 0; i < count; i++)
                {
                    BindablePropertyNode node3 = (BindablePropertyNode)nodes[i];
                    if (node3.IsBound)
                    {
                        node = node3;
                        break;
                    }
                }
                if (node == null)
                {
                    node = nodes[0];
                }
            }
            if (node != null)
            {
                this._bindablePropsTree.SelectedNode = node;
            }
        }
        protected PluginMenuPartStruct GetMenuItemIndex(PluginMenuItemPart theMenuItemPart, TreeNodeCollection nodes)
        {
            PluginMenuPartStruct theMenuItem = new PluginMenuPartStruct();
            int    index         = 0;
            string menuItemIndex = GetMenuItemIndex(theMenuItemPart.Locate);
            PluginMenuItemLocateType menuItemLocationType = (PluginMenuItemLocateType)(
                Enum.Parse(typeof(PluginMenuItemLocateType),
                           GetMenuItemLocator(theMenuItemPart.Locate),
                           true
                           )
                );

            theMenuItem.IsCreate = menuItemLocationType == PluginMenuItemLocateType.Create;

            if (int.TryParse(menuItemIndex, out index))
            {
                theMenuItem.Index = PluginMenuItemPartLocator.GetMenuLocatorIndex(menuItemLocationType, index, nodes.Count);
            }
            else if (menuItemIndex.Length == 0)
            {
                theMenuItem.Index = nodes.Count;
            }
            else
            {
                int realIndex = GetMenuItemIndexById(nodes, menuItemIndex);
                theMenuItem.Index = PluginMenuItemPartLocator.GetMenuLocatorIndex(
                    menuItemLocationType,
                    realIndex,
                    nodes.Count
                    );
                // Make only support ID
                if (menuItemLocationType == PluginMenuItemLocateType.Make)
                {
                    if (realIndex >= 0 && realIndex < nodes.Count)
                    {
                        theMenuItem.IsCreate = false;
                    }
                    else
                    {
                        theMenuItem.IsCreate = true;
                    }
                }
            }
            theMenuItem.Exist = theMenuItem.Index < nodes.Count &&
                                theMenuItem.Index >= 0;

            return(theMenuItem);
        }
Exemple #55
0
        private void LifestyleQualitiesOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
        {
            if (notifyCollectionChangedEventArgs.Action == NotifyCollectionChangedAction.Reset)
            {
                ResetLifestyleQualitiesTree();
                return;
            }
            if (notifyCollectionChangedEventArgs.Action == NotifyCollectionChangedAction.Move)
            {
                return;
            }

            TreeNode nodPositiveQualityRoot = treLifestyleQualities.FindNode("Node_SelectAdvancedLifestyle_PositiveQualities", false);
            TreeNode nodNegativeQualityRoot = treLifestyleQualities.FindNode("Node_SelectAdvancedLifestyle_NegativeQualities", false);
            TreeNode nodEntertainmentsRoot  = treLifestyleQualities.FindNode("Node_SelectAdvancedLifestyle_Entertainments", false);

            switch (notifyCollectionChangedEventArgs.Action)
            {
            case NotifyCollectionChangedAction.Add:
            {
                foreach (LifestyleQuality objQuality in notifyCollectionChangedEventArgs.NewItems)
                {
                    AddToTree(objQuality);
                }
                break;
            }

            case NotifyCollectionChangedAction.Remove:
            {
                foreach (LifestyleQuality objQuality in notifyCollectionChangedEventArgs.OldItems)
                {
                    TreeNode objNode = treLifestyleQualities.FindNodeByTag(objQuality);
                    if (objNode != null)
                    {
                        TreeNode objParent = objNode.Parent;
                        objNode.Remove();
                        if (objParent.Level == 0 && objParent.Nodes.Count == 0)
                        {
                            objParent.Remove();
                        }
                    }
                }
                break;
            }

            case NotifyCollectionChangedAction.Replace:
            {
                List <TreeNode> lstOldParents = new List <TreeNode>();
                foreach (LifestyleQuality objQuality in notifyCollectionChangedEventArgs.OldItems)
                {
                    TreeNode objNode = treLifestyleQualities.FindNodeByTag(objQuality);
                    if (objNode != null)
                    {
                        if (objNode.Parent != null)
                        {
                            lstOldParents.Add(objNode.Parent);
                        }
                        objNode.Remove();
                    }
                }
                foreach (LifestyleQuality objQuality in notifyCollectionChangedEventArgs.NewItems)
                {
                    AddToTree(objQuality);
                }
                foreach (TreeNode objOldParent in lstOldParents)
                {
                    if (objOldParent.Level == 0 && objOldParent.Nodes.Count == 0)
                    {
                        objOldParent.Remove();
                    }
                }
                break;
            }
            }

            void AddToTree(LifestyleQuality objQuality)
            {
                TreeNode objNode = objQuality.CreateTreeNode();

                if (objNode == null)
                {
                    return;
                }
                TreeNode objParentNode;

                switch (objQuality.Type)
                {
                case QualityType.Positive:
                    if (nodPositiveQualityRoot == null)
                    {
                        nodPositiveQualityRoot = new TreeNode
                        {
                            Tag  = "Node_SelectAdvancedLifestyle_PositiveQualities",
                            Text = LanguageManager.GetString("Node_SelectAdvancedLifestyle_PositiveQualities")
                        };
                        treLifestyleQualities.Nodes.Insert(0, nodPositiveQualityRoot);
                        nodPositiveQualityRoot.Expand();
                    }
                    objParentNode = nodPositiveQualityRoot;
                    break;

                case QualityType.Negative:
                    if (nodNegativeQualityRoot == null)
                    {
                        nodNegativeQualityRoot = new TreeNode
                        {
                            Tag  = "Node_SelectAdvancedLifestyle_NegativeQualities",
                            Text = LanguageManager.GetString("Node_SelectAdvancedLifestyle_NegativeQualities")
                        };
                        treLifestyleQualities.Nodes.Insert(nodPositiveQualityRoot == null ? 0 : 1, nodNegativeQualityRoot);
                        nodNegativeQualityRoot.Expand();
                    }
                    objParentNode = nodNegativeQualityRoot;
                    break;

                default:
                    if (nodEntertainmentsRoot == null)
                    {
                        nodEntertainmentsRoot = new TreeNode
                        {
                            Tag  = "Node_SelectAdvancedLifestyle_Entertainments",
                            Text = LanguageManager.GetString("Node_SelectAdvancedLifestyle_Entertainments")
                        };
                        treLifestyleQualities.Nodes.Insert((nodPositiveQualityRoot == null ? 0 : 1) + (nodNegativeQualityRoot == null ? 0 : 1), nodEntertainmentsRoot);
                        nodEntertainmentsRoot.Expand();
                    }
                    objParentNode = nodEntertainmentsRoot;
                    break;
                }

                TreeNodeCollection lstParentNodeChildren = objParentNode.Nodes;
                int intNodesCount  = lstParentNodeChildren.Count;
                int intTargetIndex = 0;

                for (; intTargetIndex < intNodesCount; ++intTargetIndex)
                {
                    if (CompareTreeNodes.CompareText(lstParentNodeChildren[intTargetIndex], objNode) >= 0)
                    {
                        break;
                    }
                }

                lstParentNodeChildren.Insert(intTargetIndex, objNode);
                treLifestyleQualities.SelectedNode = objNode;
            }
        }
Exemple #56
0
        private void FreeGridsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
        {
            if (notifyCollectionChangedEventArgs.Action == NotifyCollectionChangedAction.Reset)
            {
                ResetLifestyleQualitiesTree();
                return;
            }
            if (notifyCollectionChangedEventArgs.Action == NotifyCollectionChangedAction.Move)
            {
                return;
            }

            TreeNode nodFreeGridsRoot = treLifestyleQualities.FindNode("Node_SelectAdvancedLifestyle_FreeMatrixGrids", false);

            switch (notifyCollectionChangedEventArgs.Action)
            {
            case NotifyCollectionChangedAction.Add:
            {
                foreach (LifestyleQuality objFreeGrid in notifyCollectionChangedEventArgs.NewItems)
                {
                    TreeNode objNode = objFreeGrid.CreateTreeNode();
                    if (objNode == null)
                    {
                        return;
                    }
                    if (nodFreeGridsRoot == null)
                    {
                        nodFreeGridsRoot = new TreeNode
                        {
                            Tag  = "Node_SelectAdvancedLifestyle_FreeMatrixGrids",
                            Text = LanguageManager.GetString("Node_SelectAdvancedLifestyle_FreeMatrixGrids")
                        };
                        treLifestyleQualities.Nodes.Add(nodFreeGridsRoot);
                        nodFreeGridsRoot.Expand();
                    }

                    TreeNodeCollection lstParentNodeChildren = nodFreeGridsRoot.Nodes;
                    int intNodesCount  = lstParentNodeChildren.Count;
                    int intTargetIndex = 0;
                    for (; intTargetIndex < intNodesCount; ++intTargetIndex)
                    {
                        if (CompareTreeNodes.CompareText(lstParentNodeChildren[intTargetIndex], objNode) >= 0)
                        {
                            break;
                        }
                    }

                    lstParentNodeChildren.Insert(intTargetIndex, objNode);
                    treLifestyleQualities.SelectedNode = objNode;
                }
                break;
            }

            case NotifyCollectionChangedAction.Remove:
            {
                foreach (LifestyleQuality objFreeGrid in notifyCollectionChangedEventArgs.OldItems)
                {
                    TreeNode objNode = treLifestyleQualities.FindNodeByTag(objFreeGrid);
                    if (objNode != null)
                    {
                        TreeNode objParent = objNode.Parent;
                        objNode.Remove();
                        if (objParent.Level == 0 && objParent.Nodes.Count == 0)
                        {
                            objParent.Remove();
                        }
                    }
                }
                break;
            }

            case NotifyCollectionChangedAction.Replace:
            {
                List <TreeNode> lstOldParents = new List <TreeNode>();
                foreach (LifestyleQuality objFreeGrid in notifyCollectionChangedEventArgs.OldItems)
                {
                    TreeNode objNode = treLifestyleQualities.FindNodeByTag(objFreeGrid);
                    if (objNode != null)
                    {
                        if (objNode.Parent != null)
                        {
                            lstOldParents.Add(objNode.Parent);
                        }
                        objNode.Remove();
                    }
                }
                foreach (LifestyleQuality objFreeGrid in notifyCollectionChangedEventArgs.NewItems)
                {
                    TreeNode objNode = objFreeGrid.CreateTreeNode();
                    if (objNode == null)
                    {
                        return;
                    }
                    if (nodFreeGridsRoot == null)
                    {
                        nodFreeGridsRoot = new TreeNode
                        {
                            Tag  = "Node_SelectAdvancedLifestyle_FreeMatrixGrids",
                            Text = LanguageManager.GetString("Node_SelectAdvancedLifestyle_FreeMatrixGrids")
                        };
                        treLifestyleQualities.Nodes.Add(nodFreeGridsRoot);
                        nodFreeGridsRoot.Expand();
                    }

                    TreeNodeCollection lstParentNodeChildren = nodFreeGridsRoot.Nodes;
                    int intNodesCount  = lstParentNodeChildren.Count;
                    int intTargetIndex = 0;
                    for (; intTargetIndex < intNodesCount; ++intTargetIndex)
                    {
                        if (CompareTreeNodes.CompareText(lstParentNodeChildren[intTargetIndex], objNode) >= 0)
                        {
                            break;
                        }
                    }

                    lstParentNodeChildren.Insert(intTargetIndex, objNode);
                    treLifestyleQualities.SelectedNode = objNode;
                }
                foreach (TreeNode objOldParent in lstOldParents)
                {
                    if (objOldParent.Level == 0 && objOldParent.Nodes.Count == 0)
                    {
                        objOldParent.Remove();
                    }
                }
                break;
            }
            }
        }
Exemple #57
0
 /// <summary>
 /// Create new not root level container
 /// </summary>
 private GroupsLevelUpdate(FavoriteIcons favoriteIcons, TreeNodeCollection nodes, GroupsChangedArgs changes,
                           GroupTreeNode parent, ToolTipBuilder toolTipBuilder)
     : base(favoriteIcons, nodes, changes, toolTipBuilder, parent)
 {
 }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            return(nodes);
        }
        void CheckAllObjects(TreeNodeCollection tncol)
        {
            foreach (TreeNode tn in tncol) // gets all nodes into the AddressSpaceTree
            {
                Application.DoEvents();

                BacnetObjectId object_id = (BacnetObjectId)tn.Tag;

                String Identifier = null;

                lock (yabeFrm.DevicesObjectsName) // translate to it's name if already known
                    yabeFrm.DevicesObjectsName.TryGetValue(new Tuple <String, BacnetObjectId>(adr.FullHashString(), object_id), out Identifier);

                try
                {
                    IList <BacnetValue> value;
                    // read RELIABILITY property on all objects (maybe a test could be done to avoid call without interest)
                    bool ret = client.ReadPropertyRequest(adr, object_id, BacnetPropertyIds.PROP_RELIABILITY, out value);

                    // another solution with ReadPropertyMultipleRequest, but not supported by simple devices
                    // ... can also read these two properties on all objects in one time (with segmentation on huge devices)

                    /*
                     * BacnetReadAccessSpecification[] bras = new BacnetReadAccessSpecification[1];
                     * bras[0].objectIdentifier = object_id;
                     * bras[0].propertyReferences = new BacnetPropertyReference[2];
                     * bras[0].propertyReferences[0] = new BacnetPropertyReference((uint)BacnetPropertyIds.PROP_RELIABILITY, ASN1.BACNET_ARRAY_ALL);
                     * bras[0].propertyReferences[1] = new BacnetPropertyReference((uint)BacnetPropertyIds.PROP_DESCRIPTION, ASN1.BACNET_ARRAY_ALL);
                     * IList<BacnetReadAccessResult> res;
                     * ret=client.ReadPropertyMultipleRequest(adr, bras, out res); // it's a read multiple properties on multiple objects
                     * value = res[0].values[0].value; // for PROP_RELIABILITY
                     * value = res[0].values[1].value; // for PROP_DESCRIPTION
                     */

                    if (ret)
                    {
                        if ((uint)value[0].Value != 0) // different than RELIABILITY_NO_FAULT_DETECTED
                        {
                            IsEmpty = false;

                            string name = object_id.ToString();
                            if (name.StartsWith("OBJECT_"))
                            {
                                name = name.Substring(7);
                            }

                            TreeNode N;
                            if (Identifier != null)
                            {
                                N = treeView1.Nodes.Add(Identifier + " (" + System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(name.ToLower()) + ")");
                            }
                            else
                            {
                                N = treeView1.Nodes.Add(name);
                            }

                            string reliability = ((BacnetReliability)value[0].Value).ToString();
                            reliability = reliability.Replace('_', ' ');
                            reliability = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(reliability.ToLower());

                            N.Nodes.Add(reliability);

                            // PROP_DESCRIPTION
                            //... if ReadPropertyMultipleRequest uses value = res[0].values[1].value

                            /*
                             * ret = client.ReadPropertyRequest(adr, object_id, BacnetPropertyIds.PROP_DESCRIPTION, out value); // with Description
                             * if (ret)
                             *  N.Nodes.Add(value[0].Value.ToString());
                             */
                        }
                    }
                }
                catch
                {
                }

                if (tn.Nodes != null)   // go deap into the tree
                {
                    CheckAllObjects(tn.Nodes);
                }
            }
        }
Exemple #60
0
 /// <summary>
 /// Create root level container. Parent is not defined. This is an entry point of the update.
 /// </summary>
 internal GroupsLevelUpdate(FavoriteIcons favoriteIcons, TreeNodeCollection nodes, GroupsChangedArgs changes,
                            ToolTipBuilder toolTipBuilder)
     : base(favoriteIcons, nodes, changes, toolTipBuilder)
 {
 }