public string GetNodes(string node)
        {
            NodeCollection nodes = new NodeCollection(false);

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

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

            return nodes.ToJson();
        }
        public ActionResult GetNodes(string node)
        {
            if (!string.IsNullOrEmpty(node))
            {
                NodeCollection nodes = new NodeCollection();
                SiteMapNode siteMapNode = SiteMap.Provider.FindSiteMapNodeFromKey(node);

                if (siteMapNode == null)
                {
                    return this.Store(nodes);
                }

                SiteMapNodeCollection children = siteMapNode.ChildNodes;

                if (children != null && children.Count > 0)
                {
                    foreach (SiteMapNode mapNode in siteMapNode.ChildNodes)
                    {
                        nodes.Add(NodeHelper.CreateNodeWithOutChildren(mapNode));
                    }
                }

                return this.Store(nodes);
            }

            return new HttpStatusCodeResult(500);
        }
Example #3
0
        public static NodeCollection BuildFirstLevel()
        {
            string path = HttpContext.Current.Server.MapPath("~/Examples/");
            DirectoryInfo root = new DirectoryInfo(path);
            DirectoryInfo[] folders = root.GetDirectories();
            folders = UIHelpers.SortFolders(root, folders);

            NodeCollection nodes = new NodeCollection(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;
                Node node = new Node();

                node.Text = UIHelpers.MarkNew(folder.FullName, folder.Name.Replace("_", " "));
                node.IconCls = iconCls;

                string url = UIHelpers.PhysicalToVirtual(folder.FullName + "/");
                node.NodeID = "e" + Math.Abs(url.ToLower().GetHashCode());

                nodes.Add(node);
            }

            return nodes;
        }
Example #4
0
File: Node.cs Project: xxy1991/cozy
 /// <summary>
 /// Get all the children recursive and flattens it into the given list.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="listToFill">The list to fill.</param>
 private void FlattenChildren(Node parent, ref NodeCollection listToFill)
 {
     listToFill.Add(parent);
     foreach (var child in parent.Children)
     {
         this.FlattenChildren(child, ref listToFill);
     }
 }
        //Arrange the Nodes for Hexagon shape.
        private void CreateNode()
        {
            NodeCollection nodecollection    = diagram.Nodes as NodeCollection;
            double         commonfortop      = 0;
            double         alternate         = 0;
            double         levelfortop       = 50;
            double         levelforremaining = 0;

            for (int j = 1; j < 101; j++)
            {
                for (int i = 0; i < 100; ++i)
                {
                    NodeViewModel node = new NodeViewModel();
                    if (i == 0)
                    {
                        node.OffsetX = 100 + (levelfortop);
                        commonfortop = node.OffsetX;
                    }
                    else
                    {
                        alternate += 1;
                        if (alternate <= 2)
                        {
                            node.OffsetX = 40 + levelforremaining;
                        }
                        else
                        {
                            node.OffsetX = commonfortop;
                        }

                        if (alternate == 4)
                        {
                            alternate = 0;
                        }
                    }
                    node.UnitHeight = 30;
                    node.UnitWidth  = 50;
                    node.Shape      = new RectangleGeometry()
                    {
                        Rect = new Rect(10, 10, 10, 10)
                    };
                    node.ShapeStyle = App.Current.Resources["nodestyle"] as Style;
                    node.OffsetY    = 20 + (80 * i);
                    nodecollection.Add(node);
                }
                levelfortop       += 220;
                levelforremaining += 220;
                alternate          = 0;
            }
        }
        protected override RebelTreeResult GetTreeData(HiveId parentId, FormCollection queryStrings)
        {
            using (var uow = Hive.CreateReadonly())
            {
                var repo = uow.Repositories;
                IEnumerable <File> files;

                //First node - get the root entities
                if (parentId == RootNodeId)
                {
                    files = repo.GetAll <File>();
                }
                else
                {
                    //get entities from the current depth
                    var fileRelations = repo.GetLazyChildRelations(parentId, FixedRelationTypes.DefaultRelationType);
                    files = fileRelations.Select(x => x.Destination).OfType <File>();
                }

                var treeNodes = files.Select(f => new
                {
                    treeNode = CreateTreeNode(
                        f.Id,
                        queryStrings,
                        f.GetFileNameForDisplay(),
                        f.IsContainer
                            ? GetDashboardUrl()
                            : GetEditorUrl(f.Id, queryStrings)
                        ),
                    entity = f
                }
                                             );
                foreach (var file in treeNodes)
                {
                    if (file.entity.IsContainer)
                    {
                        //If container then see if it has children
                        file.treeNode.HasChildren = repo.GetChildRelations(file.entity.Id, FixedRelationTypes.DefaultRelationType).Any();
                        CustomizeFolderNode(file.treeNode, queryStrings);
                    }
                    else
                    {
                        CustomizeFileNode(file.treeNode, queryStrings);
                    }
                    NodeCollection.Add(file.treeNode);
                }
            }

            return(RebelTree());
        }
Example #7
0
        private Node FindOrCreateNamespaceNode(string ns, NodeCollection collection)
        {
            var node = FindFirstNodeNamed(ns, collection);

            if (node == null)
            {
                node = new Node {
                    Text = ns, Name = ns
                };
                collection.Add(node);
            }

            return(node);
        }
        /// <summary>
        /// 生成文件名称树形结构
        /// </summary>
        /// <param name="info_MedicalRecords">Info_MedicalRecords的集合</param>
        /// <param name="nodes">TreeView的根结点集合</param>
        public static void ShowFilesView(ArrayList info_MedicalRecords, NodeCollection nodes)
        {
            nodes.Clear();
            foreach (Info_MedicalRecords imr in info_MedicalRecords)
            {
                bool isHave = false;
                Node node   = new Node();

                for (int i = 0; i < nodes.Count; i++)
                {
                    try
                    {
                        string[] tag = nodes[i].Tag.ToString().Split('-');
                        if (imr.PatientID.Equals(tag[0]) && imr.VisitID == int.Parse(tag[1]))
                        {
                            isHave = true;

                            //病人姓名
                            imr.PatientName = node.Text;
                            node            = nodes[i];
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        continue;
                    }
                }
                if (!isHave)
                {
                    //数据库查询病人姓名
                    string sql = "select t.patient_name from t_in_patient t where t.his_id = '"
                                 + imr.PatientID
                                 + "-"
                                 + imr.VisitID + "'";
                    DataSet ds = App.GetDataSet(sql);
                    if (ds.Tables.Count > 0)
                    {
                        imr.PatientName = ds.Tables[0].Rows[0]["patient_name"].ToString();
                    }

                    node.Text = imr.PatientName + " " + imr.PatientID + "(" + imr.VisitID + ")";

                    node.Tag             = imr.PatientID + "-" + imr.VisitID.ToString();
                    node.CheckBoxVisible = true;
                    nodes.Add(node);
                }
                Tools_FileOperation.GetFilesTree(imr, node.Nodes);
            }
        }
Example #9
0
        public void Add(IStat stat)
        {
            if (!stat.IsRegisteredExplicitly)
            {
                return;
            }
            var node = NodeRepository.GetNode(stat);

            _registeredNodes[stat] = node;
            var wrappedNode = new WrappingNode(node);

            _registeredWrappedNodes[stat] = wrappedNode;
            _nodeCollection.Add(wrappedNode, stat);
        }
        void CreateGeneralEmrTree_EMRTemplate()
        {
            TreeTYBL.Nodes.Clear();
            NodeCollection nodes  = TreeTYBL.Nodes;
            XmlNodeList    xnlist = KnowledgeManage.GeneralEmr_xd.DocumentElement.SelectNodes("EMRTemplate/deptClass");

            if (xnlist != null)
            {
                foreach (XmlNode xn in xnlist)
                {
                    string id   = xn.Attributes["id"].Value;
                    string name = xn.Attributes["name"].Value;
                    Node   node = new Node();
                    node.Text          = name;
                    node.Image         = Resources.FolderClosed;
                    node.ImageExpanded = Resources.FolderOpen;
                    nodes.Add(node);
                    XmlNodeList txnlist = xn.SelectNodes("templateNode");
                    if (txnlist != null)
                    {
                        foreach (XmlNode txn in txnlist)
                        {
                            string tid   = txn.Attributes["id"].Value;
                            string tname = txn.Attributes["name"].Value;
                            Node   tnode = new Node();
                            tnode.Image         = Resources.FolderClosed;
                            tnode.ImageExpanded = Resources.FolderOpen;
                            tnode.Text          = tname;
                            node.Nodes.Add(tnode);

                            XmlNodeList fxnlist = txn.SelectNodes("templateFull");
                            if (fxnlist != null)
                            {
                                foreach (XmlNode fxn in fxnlist)
                                {
                                    string fname    = fxn.Attributes["name"].Value;
                                    string filepath = fxn.Attributes["filepath"].Value;
                                    Node   fnode    = new Node();
                                    fnode.Image         = Resources.Document;
                                    fnode.ImageExpanded = Resources.Document;
                                    fnode.Text          = fname;
                                    fnode.Tag           = filepath;
                                    tnode.Nodes.Add(fnode);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #11
0
        private void GetCheckedNodes(TreeNodeCollection nodes, NodeCollection checkedNodes)
        {
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    checkedNodes.Add(node);
                }

                if (node.Nodes.Count > 0)
                {
                    GetCheckedNodes(node.Nodes, checkedNodes);
                }
            }
        }
Example #12
0
        /// <summary>
        /// Checks if the node Id is the root node and if so creates the root node and appends it to the
        /// NodeCollection based on the standard tree parameters
        /// </summary>
        /// <param name="id"></param>
        /// <param name="queryStrings"></param>
        /// <returns></returns>
        /// <remarks>
        /// This method ensure that all of the correct meta data is set for the root node so that the Umbraco application works
        /// as expected. Meta data such as 'treeId' and 'searchable'
        /// </remarks>
        protected bool AddRootNodeToCollection(string id, FormDataCollection queryStrings)
        {
            //if its the root model
            if (id == RootNodeId)
            {
                //get the root model
                var rootNode = CreateRootNode(queryStrings);

                NodeCollection.Add(rootNode);

                return(true);
            }

            return(false);
        }
Example #13
0
        private void FindExpandedNodes(TreeNodeCollection nodes, NodeCollection list)
        {
            for (int i = 0; i < nodes.Count; i++)
            {
                if (nodes[i].IsExpanded)
                {
                    list.Add(nodes[i]);
                }

                if (nodes[i].Nodes.Count > 0)
                {
                    FindExpandedNodes(nodes[i].Nodes, list);
                }
            }
        }
    /// <summary>
    /// 下载专区
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void GetExNodes8(object sender, NodeLoadEventArgs e)
    {
        NodeCollection nodes = new NodeCollection();

        Node node1 = new Node();

        node1.NodeID = "NodeDd";
        node1.Text   = "谷歌浏览器下载";
        node1.Href   = "WebPage\\Download\\GoolgleDownload.aspx";
        node1.Icon   = Icon.DiskDownload;
        node1.Leaf   = true;
        nodes.Add(node1);

        e.Nodes = nodes;
    }
Example #15
0
        public void Add(IStat stat)
        {
            if (stat.ExplicitRegistrationType is null)
            {
                return;
            }
            var node = NodeRepository.GetNode(stat);

            _registeredNodeSet.Add(node);
            _registeredNodes[stat] = node;
            var wrappedNode = new WrappingNode(node);

            _registeredWrappedNodes[stat] = wrappedNode;
            _nodeCollection.Add(wrappedNode, stat);
        }
Example #16
0
 public void AddNode(Node node)
 {
     node.Scene = this;
     if (node is RenderableNode)
     {
         _renderableNodes.Add(node);
         if (node is Sprite)
         {
             _flatNodes.Add(node);
         }
     }
     else
     {
         _environmentalNodes.Add(node);
     }
 }
Example #17
0
 /// <summary>
 /// Generate a node at this vertex, if it does not already posess one.
 /// This override can be used to generate nodes independent of a full model/element system.
 /// </summary>
 /// <param name="options"></param>
 public void GenerateNode(NodeGenerationParameters options, NodeCollection nodes, NodeDDTree nodeTree)
 {
     if (Node == null)
     {
         Node = nodeTree.NearestTo(Position, options.ConnectionTolerance);
         if (Node == null)
         {
             Node = new Node(Position);
         }
     }
     if (!nodes.Contains(Node.GUID))
     {
         nodes.Add(Node);
         nodeTree.Add(Node);
     }
 }
Example #18
0
        private Node AddChildNode(NodeCollection parent, string strNode, string strCell)
        {
            Node node = new Node();

            node.Text = strNode;

            if (!string.IsNullOrEmpty(strCell))
            {
                Cell cell = new Cell(strCell);
                node.Cells.Add(cell);
            }

            parent.Add(node);

            return(node);
        }
Example #19
0
 /// <summary>
 /// 将菜单列表转为菜单树,并将菜单对象赋值给成员Tag
 /// </summary>
 /// <param name="sourceList">菜单列表</param>
 /// <param name="targetNodeCollection">菜单Node</param>
 public void ConvertFunctionMenuListToNode(List <FunctionMenu> sourceList, NodeCollection targetNodeCollection)
 {
     for (int i = 0; i < sourceList.Count; i++)
     {
         if (sourceList[i].ParentMenuName == null)
         {
             Node parentNode = new Node
             {
                 Text = sourceList[i].MenuDesc,
                 Tag  = sourceList[i]
             };
             targetNodeCollection.Add(parentNode);
             AddChildNode(sourceList, sourceList[i].MenuName, parentNode);
         }
     }
 }
Example #20
0
        /// <summary>
        /// Get all nodes in the specified model which have a mapping entry in this table
        /// </summary>
        /// <param name="inModel"></param>
        /// <returns></returns>
        public NodeCollection AllMappedNodes(Model.Model inModel)
        {
            var result = new NodeCollection();

            if (ContainsKey(NodeCategory))
            {
                foreach (Guid guid in this[NodeCategory].Keys)
                {
                    if (inModel.Nodes.Contains(guid))
                    {
                        result.Add(inModel.Nodes[guid]);
                    }
                }
            }
            return(result);
        }
        public StoreResult GetNodes(string node)
        {
            NodeCollection nodes = new NodeCollection(false);

            string prefix = DateTime.Now.Second + "_";
            for (int i = 0; i < 10; i++)
            {
                Node newNode = new Node();
                newNode.NodeID = i.ToString();
                newNode.Text = prefix + i;
                newNode.Leaf = true;
                nodes.Add(newNode);
            }

            return this.Store(nodes);
        }
Example #22
0
    /// <summary>
    /// Create a new method to get NodeCollection of current node.
    /// </summary>
    /// <returns></returns>
    private NodeCollection GetSubNodes()
    {
        NodeCollection nodes = new NodeCollection();

        foreach (IGraphEdge edge in this.EdgesLeaving)
        {
            Node toNode = edge.ToNode as Node;

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

        return(nodes);
    }
        protected override UmbracoTreeResult GetTreeData(HiveId parentId, FormCollection queryStrings)
        {
            //if its the first level
            if (parentId == RootNodeId)
            {
                var hive = BackOfficeRequestContext.Application.Hive.GetReader <ISecurityStore>(
                    //BUG: this check is only a work around because the way that Hive currently works cannot return the 'real' id of the entity. SD.
                    parentId == RootNodeId
                        ? new Uri("security://user-groups/")
                        : parentId.ToUri());

                Mandate.That(hive != null, x => new NotSupportedException("Could not find a hive provider for route: " + parentId.ToString(HiveIdFormatStyle.AsUri)));

                using (var uow = hive.CreateReadonly())
                {
                    //TODO: not sure how this is supposed to be casted to UserGroup
                    var items = uow.Repositories.GetEntityByRelationType <UserGroup>(FixedRelationTypes.DefaultRelationType, FixedHiveIds.UserGroupVirtualRoot)
                                .OrderBy(x => x.Name)
                                .ToArray();

                    foreach (var treeNode in items.Select(user =>
                                                          (TreeNode)CreateTreeNode(
                                                              user.Id,
                                                              queryStrings,
                                                              user.Name,
                                                              Url.GetEditorUrl(user.Id, EditorControllerId, BackOfficeRequestContext.RegisteredComponents, BackOfficeRequestContext.Application.Settings))))
                    {
                        treeNode.Icon        = "tree-user-type";
                        treeNode.HasChildren = false;

                        //add the menu items
                        if (treeNode.Title != "Administrator")
                        {
                            treeNode.AddEditorMenuItem <Delete>(this, "deleteUrl", "Delete");
                        }

                        NodeCollection.Add(treeNode);
                    }
                }
            }
            else
            {
                throw new NotSupportedException("The User Group tree does not support more than 1 level");
            }

            return(UmbracoTree());
        }
Example #24
0
        //Arrange the Nodes for Hexagon shape.
        private void CreateNode()
        {
            NodeCollection nodecollection    = diagram.Nodes as NodeCollection;
            double         commonfortop      = 0;
            double         alternate         = 0;
            double         levelfortop       = 50;
            double         levelforremaining = 0;

            for (int j = 1; j < 101; j++)
            {
                for (int i = 0; i < 100; ++i)
                {
                    NodeViewModel node = new NodeViewModel();
                    node.UnitWidth  = 50;
                    node.UnitHeight = 30;

                    if (i == 0)
                    {
                        node.OffsetX = 100 + (levelfortop);
                        commonfortop = node.OffsetX;
                    }
                    else
                    {
                        alternate += 1;
                        if (alternate <= 2)
                        {
                            node.OffsetX = 40 + levelforremaining;
                        }
                        else
                        {
                            node.OffsetX = commonfortop;
                        }

                        if (alternate == 4)
                        {
                            alternate = 0;
                        }
                    }

                    node.OffsetY = 20 + (80 * i);
                    nodecollection.Add(node);
                }
                levelfortop       += 220;
                levelforremaining += 220;
                alternate          = 0;
            }
        }
        public string GetNodes(string node)
        {
            NodeCollection nodes = new NodeCollection(false);

            string prefix = DateTime.Now.Second + "_";

            for (int i = 0; i < 10; i++)
            {
                Node newNode = new Node();
                newNode.NodeID = i.ToString();
                newNode.Text   = prefix + i;
                newNode.Leaf   = true;
                nodes.Add(newNode);
            }

            return(nodes.ToJson());
        }
Example #26
0
 public void ConvertFunctionMenuListToNode(List <Function> sourceList, NodeCollection targetNodeCollection)
 {
     for (int i = 0; i < sourceList.Count; i++)
     {
         if (sourceList[i].ParentName == null || sourceList[i].ParentName == string.Empty || sourceList[i].FunctionType == "M")
         {
             Node parentNode = new Node
             {
                 Name = sourceList[i].FunctionName,
                 Text = sourceList[i].FunctionDesc,
                 Tag  = sourceList[i]
             };
             targetNodeCollection.Add(parentNode);
             AddChildNode(sourceList, sourceList[i].FunctionName, parentNode);
         }
     }
 }
Example #27
0
        private void LoadBlock(HUDOptionsBlock b, NodeCollection parentCollection)
        {
            var n = new Node()
            {
                Text = HUDOptionsLangRes.ResourceManager.GetString("HUDPos_" + b.Name),
                Tag  = b
            };

            Invoke(new Action(() => parentCollection.Add(n)));
            if (b.Childs is object)
            {
                foreach (HUDOptionsBlock bb in b.Childs)
                {
                    LoadBlock(bb, n.Nodes);
                }
            }
        }
Example #28
0
        private void AddFunSonNode(List <FunctionRepository> _list, NodeCollection _nodes, string parentid)
        {
            var _nodestyleBlue = new DevComponents.DotNetBar.ElementStyle();

            _nodestyleBlue.TextColor = System.Drawing.Color.Blue;
            _nodestyleBlue.Font      = new System.Drawing.Font("宋体", 14);
            _nodestyleBlue.BackColor = System.Drawing.Color.FromArgb(207, 221, 238);

            var _nodestyleRed = new DevComponents.DotNetBar.ElementStyle();

            _nodestyleRed.TextColor = System.Drawing.Color.Red;
            _nodestyleRed.Font      = new System.Drawing.Font("宋体", 14);
            _nodestyleRed.BackColor = System.Drawing.Color.FromArgb(207, 221, 238);



            var _mlist = _list.FindAll(t => t.Fun_ParantId == parentid);

            for (int i = 0; i < _mlist.Count; i++)
            {
                Node _node = new Node();
                _node.Text = _mlist[i].Func_Descpt;

                _node.Name = _mlist[i].Fun_Id;
                _node.Tag  = _mlist[i];

                _nodes.Add(_node);
                //_node.EnsureVisible();

                if (string.IsNullOrEmpty(_mlist[i].Fun_Name.Trim()) && (string.IsNullOrEmpty(_mlist[i].Fun_CLSF.Trim())))
                {
                    _node.Image         = global::MyPorgamManage.Properties.Resources.feature_16x16;
                    _node.Style         = _nodestyleRed;
                    _node.StyleSelected = _nodestyleRed;
                }
                else
                {
                    _node.Image         = global::MyPorgamManage.Properties.Resources.csharp_16x16;
                    _node.Style         = _nodestyleBlue;
                    _node.StyleSelected = _nodestyleBlue;
                }

                this.AddFunSonNode(_list, _node.Nodes, _mlist[i].Fun_Id);
            }
        }
Example #29
0
        private static void AddNode(TabInfo objTab, NodeCollection objNodes, Hashtable objBreadCrumbs, PortalSettings objPortalSettings, ToolTipSource eToolTips)
        {
            Node objNode = new Node();

            if (objTab.Title == "~")
            {
                objNodes.AddBreak();
            }
            else
            {
                if (objBreadCrumbs.Contains(objTab.TabID))
                {
                    objNode.BreadCrumb = true;
                    if (objTab.TabID == objPortalSettings.ActiveTab.TabID)
                    {
                        objNode.Selected = true;
                    }
                }
                if (objTab.DisableLink)
                {
                    objNode.Enabled = false;
                }
                objNode.ID          = objTab.TabID.ToString();
                objNode.Key         = objNode.ID;
                objNode.Text        = objTab.LocalizedTabName;
                objNode.NavigateURL = objTab.FullUrl;
                objNode.ClickAction = eClickAction.Navigate;
                objNode.Image       = objTab.IconFile;
                switch (eToolTips)
                {
                case ToolTipSource.TabName:
                    objNode.ToolTip = objTab.LocalizedTabName;
                    break;

                case ToolTipSource.Title:
                    objNode.ToolTip = objTab.Title;
                    break;

                case ToolTipSource.Description:
                    objNode.ToolTip = objTab.Description;
                    break;
                }
                objNodes.Add(objNode);
            }
        }
Example #30
0
        private void AddSonNodeByUserid(List <ProgList> _list, List <Prog_WRT> _pgwrtlist, NodeCollection _nodes, string parentid)
        {
            var _nodestyleBlue = new DevComponents.DotNetBar.ElementStyle();

            _nodestyleBlue.TextColor = System.Drawing.Color.Blue;
            _nodestyleBlue.Font      = new System.Drawing.Font("宋体", 14);
            _nodestyleBlue.BackColor = System.Drawing.Color.FromArgb(207, 221, 238);

            var _nodestyleRed = new DevComponents.DotNetBar.ElementStyle();

            _nodestyleRed.TextColor = System.Drawing.Color.Red;
            _nodestyleRed.Font      = new System.Drawing.Font("宋体", 14);
            _nodestyleRed.BackColor = System.Drawing.Color.FromArgb(207, 221, 238);


            var _mlist = _list.FindAll(t => t.Prog_ParantId == parentid);

            for (int i = 0; i < _mlist.Count; i++)
            {
                Node _node = new Node();
                _node.Text = _mlist[i].Prog_Descp;
                _node.Name = _mlist[i].Prog_Id;

                //_node.Tag = _mlist[i];

                var _wrtlist = _pgwrtlist.FindAll(t => t.Prog_Id == _mlist[i].Prog_Id);
                if (_wrtlist.Count <= 0)//不存在
                {
                    _node.Style         = _nodestyleRed;
                    _node.StyleSelected = _nodestyleRed;
                    _node.Tag           = null;
                }
                else
                {
                    _node.Style         = _nodestyleBlue;
                    _node.StyleSelected = _nodestyleBlue;
                    _node.Tag           = _wrtlist[0];
                }

                _nodes.Add(_node);
                _node.EnsureVisible();

                this.AddSonNodeByUserid(_list, _pgwrtlist, _node.Nodes, _mlist[i].Prog_Id);
            }
        }
Example #31
0
        public string GenerarNodo(string strNodoID)
        {
            //1. Obtener las cuentas contables del siguiente nivel
            List <CuentaContable> lCuentasContables = CuentaContableBusiness.ObtenerCuentaContablePorRama(strNodoID);
            NodeCollection        ncNivel           = new NodeCollection();

            //2. Armar el arbol de hijos
            foreach (CuentaContable sd in lCuentasContables)
            {
                Node nNivel = new Node();
                nNivel.Text   = sd.Descripcion;
                nNivel.NodeID = sd.Cuenta;
                ncNivel.Add(nNivel);
            }

            //3. Regresar los nodos
            return(ncNivel.ToJson());
        }
        private void CopyCatalogs(NodeCollection <Catalog> catalogs)
        {
            var cloner = new CatalogCloner();
            var defaultNodeCatalogs = GetDefaultNodeCatalogs();
            var currentCatalogNodes = GetCurrentExtratableCatalogs();

            if (currentCatalogNodes.Count == 1)
            {
                catalogs.Add(cloner.Clone(defaultNodeCatalogs[0], mappingResolver, currentCatalogNodes[0]));
            }
            else
            {
                defaultNodeCatalogs
                .Select(
                    catalog => cloner.Clone(catalog, mappingResolver, buildingNodeConfiguration.DatabaseMapping.Apply(catalog.Name)))
                .ForEach(catalogs.Add);
            }
        }
Example #33
0
        /// <summary>
        /// Checks if the node Id is the root node and if so creates the root node and appends it to the
        /// NodeCollection based on the standard tree parameters
        /// </summary>
        /// <param name="id"></param>
        /// <param name="queryStrings"></param>
        /// <returns></returns>
        /// <remarks>
        /// This method ensure that all of the correct meta data is set for the root node so that the Rebel application works
        /// as expected. Meta data such as 'treeId' and 'searchable'
        /// </remarks>
        protected bool AddRootNodeToCollection(HiveId id, FormCollection queryStrings)
        {
            Mandate.ParameterNotEmpty(id, "id");
            Mandate.ParameterCondition(!id.IsNullValueOrEmpty(), "id");

            //if its the root model
            if (id.Equals(TreeId))
            {
                //get the root model
                var rootNode = CreateRootNode(queryStrings);

                NodeCollection.Add(rootNode);

                return(true);
            }

            return(false);
        }
Example #34
0
        private void EnumNodes(XmlItem rootItem, NodeCollection rootNode)
        {
            // skip root xml item
            if (rootItem.Parent != null)
            {
                string text = Converter.FromXml(rootItem.GetProp("Text"));
                Node   node = new Node();
                node.Text = text;
                node.Tag  = rootItem;
                rootNode.Add(node);
                rootNode = node.Nodes;
            }

            for (int i = 0; i < rootItem.Count; i++)
            {
                EnumNodes(rootItem[i], rootNode);
            }
        }
Example #35
0
        public string GenerarNodo(string strNodoID)
        {
            //1. Obtener las colonias del siguiente nivel
            List <Colonia> lColonias = ColoniaBusiness.ObtenerColoniasPorMunicipio(strNodoID);
            NodeCollection ncNivel   = new NodeCollection();

            //2. Armar el arbol de hijos
            foreach (Colonia col in lColonias)
            {
                Node nCol = new Node();
                nCol.Text       = col.Descripcion;
                nCol.NodeID     = col.ID;
                nCol.Expanded   = false;
                nCol.Expandable = false;
                ncNivel.Add(nCol);
            }
            //3. Regresar los nodos
            return(ncNivel.ToJson());
        }
        public ActionResult LoadPages(string node)
        {
            NodeCollection result = null;
            if (node == "_root")
            {
                result = SiteMapModel.CreateNode(SiteMap.RootNode).Children;
            }
            else
            {
                SiteMapNode siteMapNode = SiteMap.Provider.FindSiteMapNodeFromKey(node);
                SiteMapNodeCollection children = siteMapNode.ChildNodes;
                result = new NodeCollection();

                if (children != null && children.Count > 0)
                {
                    foreach (SiteMapNode mapNode in siteMapNode.ChildNodes)
                    {
                        result.Add(SiteMapModel.CreateNodeWithOutChildren(mapNode));
                    }
                }
            }

            return this.Store(result);
        }
Example #37
0
		private NodeCollection<ParamDeclNode> ParseParamList(TokenID openToken, TokenID closeToken)
		{
			AssertAndAdvance(openToken);
			if (curtok.ID == closeToken)
			{
				Advance();
				return null;
			}
			NodeCollection<ParamDeclNode> result = new NodeCollection<ParamDeclNode>();
			bool isParams;
			bool hasComma;
			do
			{
				ParamDeclNode node = new ParamDeclNode(curtok);
				result.Add(node);
				isParams = false;

				ParsePossibleAttributes(false);

                if (isAnonynous > 0
                    && curAttributes.Count > 0)
                {
                    ReportError("Attributes are not allowed for anonymous delegate's parameters.");
                }

				if (curtok.ID == TokenID.Ref)
				{
					node.Modifiers |= Modifier.Ref;
					Advance();
				}
				else if (curtok.ID == TokenID.Out)
				{
					node.Modifiers |= Modifier.Out;
					Advance();
				}
				else if (curtok.ID == TokenID.Params)
				{
                    if (isAnonynous > 0)
                    {
                        ReportError("Params parameter are not allowed for anonymous delegate.");
                    }

					isParams = true;
					node.Modifiers |= Modifier.Params;
					Advance();
				}

				node.Type = ParseType();

				if (isParams)
				{
					// ensure is array type
				}

				if (curtok.ID == TokenID.Ident)
				{
                    node.Name = ((IdentifierExpression)ParseIdentifierOrKeyword(false, false, false, false)).Identifier;//strings[curtok.Data];
				}

				hasComma = false;
				if (curtok.ID == TokenID.Comma)
				{
					Advance();
					hasComma = true;
				}
			}
			while (!isParams && hasComma);

			AssertAndAdvance(closeToken);

			return result;
		}
Example #38
0
        private DictionaryCreationExpression ParseDictionaryCreation()
        {
            DictionaryCreationExpression dicNode = new DictionaryCreationExpression(_curtok);
            AssertAndAdvance(TokenId.LCurly);

            NodeCollection<NameExpressionNode> nodes = new NodeCollection<NameExpressionNode>();

            dicNode.Expressions = nodes;

            while (_curtok.TokenId != TokenId.RCurly && _curtok != _eof)
            {
                NameExpressionNode node = new NameExpressionNode(_curtok);

                Advance();

                AssertAndAdvance(TokenId.Colon);
                node.Expression = ParseExpression();
                nodes.Add(node);

                if (_curtok.TokenId == TokenId.Comma)
                    Advance();
            }

            return dicNode;
        }
Example #39
0
        private void ListToNode(IEnumerable<Category> lists, NodeCollection nodes)
        {
            foreach (Category tasksList in lists)
            {
                Node node = new Node();
                node.NodeID = tasksList.ID.ToString();
                node.Text = tasksList.Name;
                node.Leaf = !tasksList.IsFolder;
                node.IconCls = tasksList.IsFolder ? "icon-folder" : "icon-category";
                node.CustomAttributes.Add(new ConfigItem("isFolder", JSON.Serialize(tasksList.IsFolder), ParameterMode.Raw));
                if (!tasksList.IsFolder)
                {
                    node.AllowDrop = false;
                }
                node.Expanded = tasksList.IsFolder;

                if (tasksList.Categories.Count > 0)
                {
                    this.ListToNode(tasksList.Categories, node.Children);
                }
                else if(!node.Leaf)
                {
                    node.EmptyChildren = true;
                }

                nodes.Add(node);
            }
        }
        private static NodeCollection BuildAreasLevel()
        {
            string path = HttpContext.Current.Server.MapPath(ExamplesModel.ExamplesRoot);
            DirectoryInfo root = new DirectoryInfo(path);
            DirectoryInfo[] folders = root.GetDirectories();
            folders = ExamplesModel.SortFolders(root, folders);

            NodeCollection nodes = new NodeCollection(false);

            var staticIcons = new StaticNodeIcon(path);

            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");

                string iconCls = string.IsNullOrEmpty(cfg.IconCls) ? "" : cfg.IconCls;
                Node node = null;
                var index = folder.Name.IndexOf('_');

                if (cfg.MainGroup || index < 0)
                {
                    node = new Node();
                    node.NodeID = BaseControl.GenerateID();
                    node.Text = folder.Name.Replace("_", " ");

                    nodes.Add(node);

                    if (String.IsNullOrWhiteSpace(iconCls)) {
                        staticIcons.TryGetIconCLS(out iconCls, folder.Name);
                    }

                    node.IconCls = iconCls;
                    if (ExamplesModel.IsNew(folder.FullName))
                    {
                        node.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
                    }
                }
                else
                {
                    string otherIconCls;
                    var mainGroupName = folder.Name.Substring(0, index);
                    node = nodes.FirstOrDefault(n => n.Text == mainGroupName);

                    if (node == null)
                    {
                        node = new Node();
                        node.NodeID = BaseControl.GenerateID();
                        node.Text = mainGroupName;
                        nodes.Add(node);
                    }

                    if (staticIcons.TryGetIconCLS(out otherIconCls, mainGroupName))
                    {
                        node.IconCls = otherIconCls;
                    }

                    if (ExamplesModel.IsNew(folder.FullName) && !node.CustomAttributes.Contains("isNew"))
                    {
                        node.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
                    }

                    var groupNode = new Node();
                    var subGroupNodeName = folder.Name.Substring(index + 1);

                    groupNode.NodeID = BaseControl.GenerateID();
                    groupNode.Text = subGroupNodeName.Replace("_", " ");

                    if (iconCls.IsNotEmpty())
                    {
                        groupNode.IconCls = iconCls;
                    }
                    else if (staticIcons.TryGetIconCLS(out otherIconCls, mainGroupName, subGroupNodeName))
                    {
                        groupNode.IconCls = otherIconCls;
                    }

                    if (ExamplesModel.IsNew(folder.FullName) && !groupNode.CustomAttributes.Contains("isNew"))
                    {
                        groupNode.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
                    }

                    node.Children.Add(groupNode);
                    node = groupNode;
                }

                ExamplesModel.BuildViewsLevel(folder, node);
            }

            return nodes;
        }
Example #41
0
        private void BuilderType(InterfaceNode type,NamespaceNode nspace)
        {
            DDW.ClassNode cls = new ClassNode(new Token(TokenID.Public));
            cls.Modifiers = Modifier.Public;
            cls.BaseClasses.Add(new TypeNode(new IdentifierExpression("Peanut.Mappings.DataObject", new Token(TokenID.Typeof))));
            foreach (AttributeNode attr in type.Attributes)
            {
                cls.Attributes.Add(attr);
            }
            mTableName = GetTableName(type);
            mClassName = type.Name.Identifier.Substring(1, type.Name.Identifier.Length - 1);
            cls.Name = new IdentifierExpression(mClassName, new Token(TokenID.String|TokenID.Public));
            cls.IsPartial = true;
            nspace.Classes.Add(cls);

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("///<summary>");
            sb.AppendLine("///Peanut Generator Copyright @ FanJianHan 2010-2013");
            sb.AppendLine("///website:http://www.ikende.com");
            if (!string.IsNullOrEmpty(type.Comment))
            {
                sb.AppendLine(type.Comment);
            }
            StringReader sr = new StringReader(type.DocComment);
            string value = sr.ReadLine();
            while (value != null)
            {
                if (value.IndexOf("summary>") == -1)
                {
                    sb.AppendLine(value);
                }
                value = sr.ReadLine();
            }
            sb.AppendLine("///</summary>");
            cls.DocComment = sb.ToString();

            foreach (InterfacePropertyNode property in type.Properties)
            {
                string propertyname = property.Names[0].GenericIdentifier;
                string fieldname= GetFieldName(property);
                FieldNode field = new FieldNode(new Token(TokenID.False));
                field.Modifiers = Modifier.Private;
                QualifiedIdentifierExpression name = new QualifiedIdentifierExpression(new Token(TokenID.String));
                name.Expressions.Add(new IdentifierExpression("m" + property.Names[0].GenericIdentifier, new Token(TokenID.String)));
                field.Names.Add(name);
                field.Type = property.Type;
                cls.Fields.Add(field);

                IType fieldtype=new TypeNode(new IdentifierExpression("Peanut.FieldInfo<"+((TypeNode)property.Type).GenericIdentifier+">", new Token(TokenID.Typeof)));
                field = new FieldNode(new Token(TokenID.False));
                field.Modifiers = Modifier.Public| Modifier.Static;
               
                NodeCollection<ArgumentNode> args = new NodeCollection<ArgumentNode>();
                args.Add(new ArgumentNode(new Token(TokenID.String)));
                args.Add(new ArgumentNode(new Token(TokenID.String)));
                args[0].Expression = new StringPrimitive(mTableName, new Token(TokenID.String));
                args[1].Expression = new StringPrimitive(fieldname, new Token(TokenID.String));

                name = new QualifiedIdentifierExpression(new Token(TokenID.String));
                name.Expressions.Add(new AssignmentExpression(TokenID.Equal,
                    new IdentifierExpression(propertyname.Substring(0, 1).ToLower() + propertyname.Substring(1, propertyname.Length - 1)
                    , new Token(TokenID.String)), new ObjectCreationExpression(fieldtype, args, new Token(TokenID.New))));
                field.Names.Add(name);
                field.Type = fieldtype;
               
                cls.Fields.Add(field);


                PropertyNode pn = new PropertyNode(new Token(TokenID.Newline));
                foreach (AttributeNode attr in property.Attributes)
                {
                    pn.Attributes.Add(attr);
                }
                pn.Names = property.Names;
                pn.Modifiers = Modifier.Public | Modifier.Virtual;
                pn.Type = property.Type;
                pn.Setter = new AccessorNode(true, new Token(TokenID.Newline));
                pn.Setter.Kind = "set";
                ExpressionStatement setvalue = new ExpressionStatement(
                    new AssignmentExpression(TokenID.Equal,
                    new IdentifierExpression("m" + property.Names[0].GenericIdentifier, new Token(TokenID.String))
                    , new IdentifierExpression("value", new Token(TokenID.String)))
                    );
                pn.Setter.StatementBlock.Statements.Add(setvalue);

                args = new NodeCollection<ArgumentNode>();
                args.Add(new ArgumentNode(new Token(TokenID.String)));
                args[0].Expression = new StringPrimitive(propertyname, new Token(TokenID.String));
                QualifiedIdentifierExpression invoke = new QualifiedIdentifierExpression(new Token(TokenID.String));
                invoke.Expressions.Add(new IdentifierExpression("EntityState", new Token(TokenID.String)));
                invoke.Expressions.Add(new InvocationExpression(new IdentifierExpression("FieldChange", new Token(TokenID.Default)), args));
                setvalue = new ExpressionStatement(invoke);
                pn.Setter.StatementBlock.Statements.Add(setvalue);

                pn.Getter = new AccessorNode(true, new Token(TokenID.Newline));
                pn.Getter.Kind = "get";
                ReturnStatement rs = new ReturnStatement(new Token(TokenID.Return));
                rs.ReturnValue = new IdentifierExpression("m" + property.Names[0].GenericIdentifier, new Token(TokenID.String));
                pn.Getter.StatementBlock.Statements.Add(rs);

                sb = new StringBuilder();
                sb.AppendLine("///<summary>");
                sb.AppendLine("///Type:" + ((TypeNode)property.Type).GenericIdentifier);
                if (!string.IsNullOrEmpty(property.Comment))
                {
                    sb.AppendLine(type.Comment);
                }
                sr = new StringReader(property.DocComment);
                value = sr.ReadLine();
                while (value != null)
                {
                    if (value.IndexOf("summary>") == -1)
                    {
                        sb.AppendLine(value);
                    }
                    value = sr.ReadLine();
                }
                sb.AppendLine("///</summary>");
                pn.DocComment = sb.ToString();
                

                cls.Properties.Add(pn);
                
            }
            //CodeTypeDeclaration entity = new CodeTypeDeclaration(mClassName);
            //CodeCommentStatement comm;
            //cns.Types.Add(entity);

           
            //comm = new CodeCommentStatement("<summary>");
            //comm.Comment.DocComment = true;
            //entity.Comments.Add(comm);
            //comm = new CodeCommentStatement("Peanut Generator Copyright © FanJianHan 2010-2013");
            //comm.Comment.DocComment = true;
            //entity.Comments.Add(comm);
            //comm = new CodeCommentStatement("website:http://www.ikende.com");
            //comm.Comment.DocComment = true;
            //entity.Comments.Add(comm);
            //if (!string.IsNullOrEmpty(type.Comment))
            //{
            //    comm = new CodeCommentStatement(type.Comment);
            //    comm.Comment.DocComment = true;
            //    entity.Comments.Add(comm);
            //}

            //StringReader sr = new StringReader(type.DocComment);
            //string value = sr.ReadLine();
            //while (value != null)
            //{
            //    if (value.IndexOf("summary>") == -1)
            //    {
            //        comm = new CodeCommentStatement(value.Replace("///", ""));
            //        comm.Comment.DocComment = true;
            //        entity.Comments.Add(comm);
            //    }
            //    value = sr.ReadLine();
            //}
            //comm = new CodeCommentStatement("</summary>");
            //comm.Comment.DocComment = true;
            //entity.Comments.Add(comm);
            //// }
            //entity.BaseTypes.Add(new CodeTypeReference("Peanut.Mappings.DataObject"));
            //entity.BaseTypes.Add(new CodeTypeReference(type.Name.Identifier));
            //entity.Attributes = MemberAttributes.Public;
            //entity.IsPartial = true;
            //entity.CustomAttributes.Add(new CodeAttributeDeclaration("Serializable"));
            //entity.IsClass = true;
            //foreach (AttributeNode aitem in type.Attributes)
            //{
            //    CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(aitem.Name.GenericIdentifier);
            //    entity.CustomAttributes.Add(attribute);
            //    if (attribute.Name.ToLower() == "table")
            //    {
            //        if (aitem.Arguments.Count > 0)
            //        {

            //            DDW.StringPrimitive pe = (DDW.StringPrimitive)aitem.Arguments[0].Expression;
            //            if (pe != null)
            //            {
            //                mTableName = pe.Value.ToString();
            //            }
            //            else
            //            {
            //                mTableName = mClassName;

            //            }
            //            attribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(mTableName)));
            //        }
            //        else
            //        {
            //            mTableName = mClassName;
            //        }
            //    }

            //}
            //foreach (InterfacePropertyNode mitem in type.Properties)
            //{


            //    BuilderProperty(entity, mitem);

            //}



        }
Example #42
0
 NodeCollection FloatUpToNeighbours(IEnumerable<BasicBlock> basicBlocks)
 {
     NodeCollection neighbours = new NodeCollection();
     if (this.Parent != null) {
         foreach(BasicBlock basicBlock in basicBlocks) {
             Node targetNode = FloatUpToNeighbours(basicBlock);
             // The target is outside the scope of the parent node
             if (targetNode == null) continue;
             // This child is a loop
             if (targetNode == this) continue;
             // We found a target in our scope
             neighbours.Add(targetNode);
         }
     }
     return neighbours;
 }
Example #43
0
        private NodeCollection<ArgumentNode> ParseArgumentList()
        {
            NodeCollection<ArgumentNode> list = new NodeCollection<ArgumentNode>();
            if (curtok.ID == TokenID.RParen) return list;

            while (true)
            {
                ArgumentNode arg = new ArgumentNode(curtok);
                switch (curtok.ID)
                {
                    case TokenID.Out:
                        Advance();
                        arg.IsOut = true;
                        break;

                    case TokenID.Ref:
                        Advance();
                        arg.IsRef = true;
                        break;
                }
                arg.Expression = ParseExpression();
                list.Add(arg);
                if (curtok.ID != TokenID.Comma) break;
                Advance();
            }
            return list;
        }
Example #44
0
        private static NodeCollection BuildTreeLevel(DirectoryInfo root, int level, int maxLevel, XmlElement siteMap)
        {
            DirectoryInfo[] folders = root.GetDirectories();

            folders = SortFolders(root, folders);

            NodeCollection nodes = new NodeCollection(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;
                Node node = new Node();
                XmlElement siteNode = null;

                string folderName = folder.Name.Replace("_", " ");

                if (level < maxLevel)
                {
                    node.Text = UIHelpers.MarkNew(folder.FullName, folderName);
                    node.IconCls = iconCls;
                    //node.NodeID = "e" + Math.Abs(url.ToLower().GetHashCode());
                    //node.SingleClickExpand = true;

                    if (siteMap != null)
                    {
                        siteNode = siteMap.OwnerDocument.CreateElement("siteMapNode");
                        siteNode.SetAttribute("title", folderName);
                        siteMap.AppendChild(siteNode);
                    }

                    node.Children.AddRange(UIHelpers.BuildTreeLevel(folder, level + 1, maxLevel, siteNode));
                }
                else
                {
                    node.Text = UIHelpers.MarkNew(folder.FullName, folderName);
                    node.IconCls = iconCls;
                    string url = PhysicalToVirtual(folder.FullName + "/");
                    node.NodeID = "e" + Math.Abs(url.ToLower().GetHashCode());
                    node.Href = Regex.Replace(url, "^/Examples","");

                    node.Leaf = true;

                    if (siteMap != null)
                    {
                        siteNode = siteMap.OwnerDocument.CreateElement("siteMapNode");
                        siteNode.SetAttribute("title", folderName);
                        siteNode.SetAttribute("description", string.IsNullOrEmpty(cfg.Description) ? "No description" : cfg.Description);
                        siteNode.SetAttribute("url", "~" + UIHelpers.PhysicalToVirtual(folder.FullName + "/"));
                        siteMap.AppendChild(siteNode);
                    }
                }

                nodes.Add(node);
            }

            return nodes;
        }
		private void InsertToken(NodeCollection nodeCollection, AuthorityTokenTableEntry token, int depth)
		{
			// check if a node for this path segment already exists in the tree
			PathSegment segment = token.Path.Segments[depth];
			Node node = CollectionUtils.SelectFirst<Node>(nodeCollection,
			                            delegate(Node n)
			                            {
			                            	return n.Text == segment.LocalizedText;
			                            });
			// if not, create the node
			if(node == null)
			{
				node = new Node(segment.LocalizedText);
				node.CheckStateChanged += new EventHandler(node_CheckStateChanged);
				nodeCollection.Add(node);
			}

			// if this is a leaf node, set the properties of the tree node accordingly
			if (segment == token.Path.LastSegment)
			{
				node.Tag = token;
				node.Tooltip = token.Description;
				node.CheckState = token.Selected ? CheckState.Checked : CheckState.Unchecked;

				// addition of this leaf may need to alter the check state of the parent
				if (node.Parent != null)
				{
					PropagateCheckStateUp(node.Parent);
				}
			}
			else
			{
				// otherwise, recur until we hit the leaf
				InsertToken(node.Nodes, token, depth + 1);
			}
		}
Example #46
0
        private BaseNode ParseEnum()
        {
            EnumNode node = new EnumNode(curtok);
            // todo: this needs to have any nested class info, or go in potential container class

            ApplyAttributes(node);
            ApplyDocComment(node);


            uint enumMask = ~(uint)Modifier.EnumMods;
            if (((uint)curmods & enumMask) != (uint)Modifier.Empty)
                ReportError("Enum contains illegal modifiers");

            node.Modifiers = curmods;
            curmods = Modifier.Empty;

            Advance(); // advance over Enum token
            node.Name = (IdentifierExpression)ParseIdentifierOrKeyword(false, false, false, true, false);

            if (curtok.ID == TokenID.Colon) // for base type
            {
                Advance();
                node.BaseClass = ParseType(false);
            }

            CheckTypeUnicityAndAdd(node);

            nameTable.AddIdentifier(new EnumName(node.Name.Identifier,
                ToVisibilityRestriction(node.Modifiers),
                currentContext));

            currentContext.Enter(node.Name.Identifier, false);

            ClassNode cl = typeStack.Count == 0 ? null : typeStack.Peek();

            if (cl == null)
            {
                namespaceStack.Peek().Enums.Add(node);
            }
            else
            {
                cl.Enums.Add(node);
            }

            AssertAndAdvance(TokenID.LCurly);

            NodeCollection<EnumNode> list = new NodeCollection<EnumNode>();
            node.Value = list;

            while (curtok.ID != TokenID.RCurly) // guard for empty
            {
                list.Add(ParseEnumMember());
                if (curtok.ID != TokenID.Comma) break;
                Advance();
            }

            AssertAndAdvance(TokenID.RCurly);

            if (curtok.ID == TokenID.Semi)
            {
                Advance();
            }

            currentContext.Leave();

            return node;
        }
Example #47
0
        /// <summary>
        /// Finds the Best path between 2 points
        /// </summary>
        /// <param name="topologyName">[in] Name of existing topology.</param>
        /// <returns> 
        /// Returns true if successful.
        /// </returns>
        private bool FindBestPath(string topologyName)
        {
            // Get the Topology object for the specified Topology
            TopologyModel mapTopology = null;
            MapApplication mapApp = HostMapApplicationServices.Application;
            Topologies topos = mapApp.ActiveProject.Topologies;
            if (topos.Exists(topologyName))
            {
                mapTopology = topos[topologyName];
            }
            else
            {
                Utility.AcadEditor.WriteMessage(string.Format("\nERROR: The Topology {0} doesn't exit!", topologyName));
                return false;
            }

            // Required for the TraceBestPath Function
            ElementCollection objectsOnPath = null;
            TraceParameters objTraceParams = new  TraceParameters(
                0,		 // MinResistance,
                100000,	 // MaxResistance,
                null,	 // NodeResistanceExpression,
                null,	 // LinkDirectionExpression,
                null,	 // LinkResistanceExpression,
                null,	 // LinkReverseResistanceExpression,
                false,	 // UseReverseDirection,
                "Result",// Name
                "Test"); // Description

            // Open the topology for read
            try
            {
                mapTopology.Open(Autodesk.Gis.Map.Topology.OpenMode.ForRead);
            }
            catch (MapException e)
            {
                Utility.AcadEditor.WriteMessage(string.Format("\nERROR: Unable to open Topology {0} for read with error code: {1}.", topologyName, e.ErrorCode));
                return false;
            }

            try
            {
                // Select the starting node
                string promptString = "\nSelect the Start Node:";
                Node startNode = null;
                if (!SelectNode(ref startNode, promptString, mapTopology))
                {
                    Utility.AcadEditor.WriteMessage("\nERROR: A valid Start Node was not selected.");
                    return false;
                }

                // Select the end node
                Node endNode = null;
                promptString = "\nSelect the End Node:";
                if (!SelectNode(ref endNode, promptString, mapTopology))
                {
                    Utility.AcadEditor.WriteMessage("\nERROR: A valid End Node was not selected.");
                    return false;
                }

                // Select the intermediate nodes
                NodeCollection	intermediates = new NodeCollection();
                Node intermediateNode = null;

                promptString = "\nSelect an Intermediate Node:";
                while (SelectNode(ref intermediateNode, promptString, mapTopology))
                {
                    intermediates.Add(intermediateNode);
                    intermediateNode = null;
                }

                // Find the best path and output it as a new topology called result
                objectsOnPath = mapTopology.TraceBestPath(startNode, endNode, intermediates, objTraceParams);

                Utility.AcadEditor.WriteMessage("\nThe best path function has created a Topology named Result.");
                Utility.SendCommand("_regen\n");
                return true;
            }
            catch (MapException e)
            {
                if (2001 == e.ErrorCode)
                {
                    Utility.AcadEditor.WriteMessage("\nERROR: Topology Result already exists.");
                }
                else
                {
                    Utility.AcadEditor.WriteMessage(string.Format("\nERROR: Unable to find the best path with error code: {0}.",  e.ErrorCode));
                }
                return false;
            }
            finally
            {
                mapTopology.Close();
            }
        }
Example #48
0
 NodeCollection GetReachableNodes()
 {
     NodeCollection reachableNodes = new NodeCollection();
     reachableNodes.Add(this);
     for(int i = 0; i < reachableNodes.Count; i++) {
         foreach(Node alsoReachable in reachableNodes[i].Successors) {
             // Do not go though the head child
             if (alsoReachable != this.Parent.HeadChild) {
                 reachableNodes.Add(alsoReachable);
             }
         }
     }
     return reachableNodes;
 }
Example #49
0
		private NodeCollection<ArgumentNode> ParseArgs()					
		{
			AssertAndAdvance(TokenID.LParen);
			if (curtok.ID == TokenID.RParen)
			{
				Advance();
				return null;
			}
			bool hasComma;
			NodeCollection<ArgumentNode> result = new NodeCollection<ArgumentNode>();
			do
			{
				ArgumentNode node = new ArgumentNode(curtok);
				result.Add(node);

				if (curtok.ID == TokenID.Ref)		
				{
					node.IsRef = true;
					Advance();
				}
				else if (curtok.ID == TokenID.Out)
				{
					node.IsOut = true;
					Advance();
				}
				node.Expression = ParseExpression();

				hasComma = false;
				if (curtok.ID == TokenID.Comma)
				{
					Advance();
					hasComma = true;
				}
			}
			while (hasComma);

			AssertAndAdvance(TokenID.RParen);

			return result;
		}
Example #50
0
        private NodeCollection<ArgumentNode> ParseArgumentList()
        {
            NodeCollection<ArgumentNode> list = new NodeCollection<ArgumentNode>();
            if (_curtok.TokenId == TokenId.RParen) return list;

            while (true)
            {
                ArgumentNode arg = new ArgumentNode(_curtok);
                arg.Expression = ParseExpression();
                list.Add(arg);
                if (_curtok.TokenId != TokenId.Comma) break;
                Advance();
            }

            return list;
        }
Example #51
0
		// statements		
		private void ParseStatement(NodeCollection<StatementNode> node)		
		{
			// label		ident	: colon
			// localDecl	type	: ident
			// block		LCurly
			// empty		Semi
			// expression	
			//	-invoke		pexpr	: LParen
			//	-objCre		new		: type
			//	-assign		uexpr	: assignOp
			//	-postInc	pexpr	: ++
			//	-postDec	pexpr	: --
			//	-preInc		++		: uexpr
			//	-preDec		--		: uexpr
			//
			// selection	if		: LParen
			//				switch	: LParen
			//
			// iteration	while	: LParen
			//				do		: LParen
			//				for		: LParen
			//				foreach	: LParen
			//
			// jump			break	: Semi
			//				continue: Semi
			//				goto	: ident | case | default
			//				return	: expr
			//				throw	: expr
			//
			// try			try		: block
			// checked		checked	: block
			// unchecked	unchecked : block
			// lock			lock	: LParen
			// using		using	: LParen
			switch (curtok.ID)
			{
				case TokenID.LCurly:	// block
                    BlockStatement newBlock = new BlockStatement(isUnsafe > 0, curtok);
                    newBlock.IsUnsafe = isUnsafe > 0;
					node.Add(newBlock);
					ParseBlock(newBlock);
					break;
				case TokenID.Semi:		// empty statement
					node.Add(new StatementNode(curtok));
                    Advance();
					break;
				case TokenID.If:		// If statement
					node.Add(ParseIf());
					break;
				case TokenID.Switch:	// Switch statement
					node.Add(ParseSwitch());
					break;
				case TokenID.While:		// While statement
					node.Add(ParseWhile());
					break;
				case TokenID.Do:		// Do statement
					node.Add(ParseDo());
					break;
				case TokenID.For:		// For statement
					node.Add(ParseFor());
					break;
				case TokenID.Foreach:	// Foreach statement
					node.Add(ParseForEach());
					break;
				case TokenID.Break:		// Break statement
					node.Add(ParseBreak());
					break;
				case TokenID.Continue:	// Continue statement
					node.Add(ParseContinue());
					break;
				case TokenID.Goto:		// Goto statement
					node.Add(ParseGoto());
					break;
				case TokenID.Return:	// Return statement
					node.Add(ParseReturn());
					break;
				case TokenID.Throw:		// Throw statement
					node.Add(ParseThrow());
					break;
				case TokenID.Try:		// Try statement
					node.Add(ParseTry());
					break;
				case TokenID.Checked:	// Checked statement
					node.Add(ParseChecked());
					break;
				case TokenID.Unchecked:	// Unchecked statement
					node.Add(ParseUnchecked());
					break;
				case TokenID.Lock:		// Lock statement
					node.Add(ParseLock());
					break;
				case TokenID.Using:		// Using statement
					node.Add(ParseUsing());
					break;

				case TokenID.Const:
					isLocalConst = true;
					Advance();
					break;

                case TokenID.Yield:
                    node.Add(ParseYieldStatement());
                    break;

                case TokenID.Void:
				case TokenID.Bool:
				case TokenID.Byte:
				case TokenID.Char:
				case TokenID.Decimal:
				case TokenID.Double:
				case TokenID.Float:
				case TokenID.Int:
				case TokenID.Long:
				case TokenID.Object:
				case TokenID.SByte:
				case TokenID.Short:
				case TokenID.String:
				case TokenID.UInt:
				case TokenID.ULong:
				case TokenID.UShort:

				case TokenID.StringLiteral:
				case TokenID.HexLiteral:
				case TokenID.IntLiteral:
				case TokenID.UIntLiteral:
				case TokenID.LongLiteral:
				case TokenID.ULongLiteral:
				case TokenID.TrueLiteral:
				case TokenID.FalseLiteral:
				case TokenID.NullLiteral:
				case TokenID.LParen:
				case TokenID.DecimalLiteral:
				case TokenID.RealLiteral:
				case TokenID.CharLiteral:
				case TokenID.PlusPlus:	// PreInc statement
				case TokenID.MinusMinus:// PreDec statement
				case TokenID.This:
				case TokenID.Base:
				case TokenID.New:		// creation statement

                    ExpressionNode rexpr = ParseExpression();

                    if (rexpr is LocalDeclarationStatement )
                    {
                        PopLocalDeclaration(rexpr);
                    }
                    else
                    {
                        ExpressionStatement enode = new ExpressionStatement(rexpr );
                        node.Add(enode);
                    }

					if (curtok.ID == TokenID.Semi)
					{
						Advance();
					}
					break;

				case TokenID.Ident:
                    if (curTokNode != null && curTokNode.Next != null && curTokNode.Value.ID == TokenID.Colon)
					{
						LabeledStatement lsnode = new LabeledStatement(curtok);
                        lsnode.Name = (IdentifierExpression)ParseIdentifierOrKeyword(false, true, false, false);
						AssertAndAdvance(TokenID.Colon);
						ParseStatement(lsnode.Statements);
						node.Add(lsnode);
					}
					else
					{
                        rexpr = ParseExpression();

                        if (rexpr is LocalDeclarationStatement)
                        {
                            PopLocalDeclaration(rexpr);
                        }
                        else
                        {
                            ExpressionStatement enode = new ExpressionStatement(rexpr );
                            node.Add(enode);
                        }
                    }
					if (curtok.ID == TokenID.Semi)
					{
						Advance();
					}
					break;

				case TokenID.Unsafe:
					// preprocessor directives
                    node.Add(ParseUnsafeCode());
					break;

                case TokenID.Fixed:
                    // preprocessor directives
                    node.Add(ParseFixedStatement());
                    break;


                case TokenID.Star:
                    // dereference variable 
                    // introduced because of the mono file test-406.cs
                    //private static uint DoOp2 (uint *u) {
                    //    *(u) += 100;
                    //    return *u;
                    //}
                    node.Add(new ExpressionStatement(ParseExpression()));
                    break;

				default:
                    if (Lexer.IsKeyWord(curtok.ID))
                    {
                        // in this case a key word is used like a variable name.
                        goto case TokenID.Ident;
                    }
                    else
                    {
                        Console.WriteLine("Unhandled case in statement parsing: \"" + curtok.ID + "\" in line: " + lineCount);
                        // this is almost always an expression
                        ExpressionStatement dnode = new ExpressionStatement(ParseExpression());
                        node.Add(dnode);
                        if (curtok.ID == TokenID.Semi)
                        {
                            Advance();
                        }
                    }
					break;
			}
		}
Example #52
0
		private void ParsePossibleAttributes(bool isGlobal)					
		{
			while (curtok.ID == TokenID.LBracket)
			{
                // is it neccessary to save current typeparameter
                // because an attribute can be declared for a type parameter
                // so if we do not do that, the typeparameter will be considered
                // as the type parameter of his attribute declaration ...
                // i.e. : 
                // class cons <[GenPar] A, [GenPar] B>{}
                //
                // without backup, A is considered as the type parameter of GenPar, 
                // and the parser will generate the wrong outpu :  class cons <[GenPar<A>]...

                List<TypeParameterNode> backupTypeParameters = curTypeParameters;
                curTypeParameters = new List<TypeParameterNode>();
                Dictionary<string, Constraint> backupConstraints = curTypeParameterConstraints;
                curTypeParameterConstraints = new Dictionary<string, Constraint>();

				Advance(); // advance over LBracket token
				curmods = ParseAttributeModifiers();

				if (isGlobal && curmods == Modifier.GlobalAttributeMods)
				{
					// nothing to check, globally positioned attributes can still apply to namespaces etc
				}
				else
				{
					uint attribMask = ~(uint)Modifier.AttributeMods;
					if (((uint)curmods & attribMask) != (uint)Modifier.Empty)
						ReportError("Attribute contains illegal modifiers.");
				}

                AttributeNode node = new AttributeNode(curtok);

				Modifier curAttribMods = curmods;
				curmods = Modifier.Empty;

				if (curAttribMods != Modifier.Empty)
				{
					AssertAndAdvance(TokenID.Colon);
				}

                curAttributes.Add(node);
				node.Modifiers = curAttribMods;

				while (curtok.ID != TokenID.RBracket && curtok.ID != TokenID.Eof)
				{
                    node.Name = ParseQualifiedIdentifier(true, false, false);

					if (curtok.ID == TokenID.LParen)
					{
                        // named argument
                        //gtest-286, line 16
                        // [Test(typeof(C<string>))]
                        // public static void Foo()
                        // {
                        // }
                        //
                        // the attribute is applied to the type parameter, so we back up it.
                        NodeCollection<AttributeNode> backupAttributes = curAttributes;
                        curAttributes = new NodeCollection<AttributeNode>();

						// has attribute arguments
						Advance(); // over lparen

						// named args are ident = expr
						// positional args are just expr
						while (curtok.ID != TokenID.RParen && curtok.ID != TokenID.Eof)
						{
							AttributeArgumentNode aNode = new AttributeArgumentNode(curtok);

							if ( curTokNode != null 
                                    && curTokNode.Next != null && curTokNode.Next.Next != null &&
								curtok.ID == TokenID.Ident &&
								curTokNode.Value.ID == TokenID.Equal)
							{   
                                aNode.ArgumentName = (IdentifierExpression)ParseIdentifierOrKeyword(false, false, false, false);
								Advance(); // over '='
							}
							aNode.Expression = ParseExpression();
							node.Arguments.Add(aNode);

							if (curtok.ID == TokenID.Comma)
							{
								Advance(); // over comma
							}
						}
						AssertAndAdvance(TokenID.RParen);  // over rparen

                        // restore the backup
                        curAttributes = backupAttributes;

						if ( curTokNode != null && curTokNode.Next != null && curTokNode.Next.Next != null &&
							curtok.ID == TokenID.Comma &&
							curTokNode.Value.ID != TokenID.RBracket)
						{
							Advance(); // over comma
							node = new AttributeNode(curtok);
							curAttributes.Add(node);
							node.Modifiers = curAttribMods;
						}
					}
					if (curtok.ID == TokenID.Comma)
					{
						// comma can hang a t end like enums
						Advance();
					}
				}
				AssertAndAdvance(TokenID.RBracket); // over rbracket

                curTypeParameters = backupTypeParameters;
                curTypeParameterConstraints = backupConstraints;
			}
		}
Example #53
0
        public Task<NodeCollection> DiscoverNodes()
        {
            return _getNodes = Task.Run(async () =>
            {
                var response = await Channel.Send(Function.DiscoveryNodes);
                var values = response.Skip(3).Take(29).ToArray();

                var nodes = new NodeCollection();
                var bits = new BitArray(values);
                for (byte i = 0; i < bits.Length; i++)
                {
                    if (bits[i])
                    {
                        var node = new Node((byte)(i + 1), this);
                        nodes.Add(node);
                    }
                }
                return nodes;
            });
        }