Example #1
0
 public void RebuildUI()
 {
     INodes.Clear();
     IPath.Clear();
     SetView.Nodes[0].Nodes.Clear();
     foreach (var s in InImages)
     {
         SetView.Nodes[0].Nodes.Add(s.Name + "[" + s.Imgs.Count + "]");
         foreach (var i in s.Imgs)
         {
             var nn = SetView.Nodes[0].Nodes[SetView.Nodes[0].Nodes.Count - 1].Nodes.Add("F:" + i.Name);
             INodes.Add(nn);
             IPath.Add(nn, i);
         }
     }
     SetView.Nodes[1].Nodes.Clear();
     foreach (var s in OutImages)
     {
         SetView.Nodes[1].Nodes.Add(s.Name + "[" + s.Imgs.Count + "]");
         foreach (var i in s.Imgs)
         {
             var nn = SetView.Nodes[1].Nodes[SetView.Nodes[1].Nodes.Count - 1].Nodes.Add("F:" + i.Name);
             ONodes.Add(nn);
             OPath.Add(nn, i);
         }
     }
 }
Example #2
0
        public static int Add(NodeInfo nodeInfo)
        {
            int maxRootId = GetMaxRootId();

            nodeInfo.NodeId     = GetMaxNodeId() + 1;
            nodeInfo.ArrChildId = nodeInfo.NodeId.ToString();
            nodeInfo.Child      = 0;
            if (ExistsNodeName(nodeInfo.ParentId, nodeInfo.NodeName))
            {
                return(2);
            }
            if (ExistsNodeIdentifier(nodeInfo.ParentId, nodeInfo.NodeIdentifier))
            {
                return(3);
            }
            if (nodeInfo.NodeType < NodeType.Special)
            {
                nodeInfo.ParentDir = "/" + nodeInfo.ParentDir;
                if (ExistsNodeDir(nodeInfo.ParentId, nodeInfo.NodeDir))
                {
                    return(4);
                }
            }
            if (nodeInfo.ParentId > 0)
            {
                NodeInfo cacheNodeById = GetCacheNodeById(nodeInfo.ParentId);
                if (cacheNodeById.IsNull)
                {
                    return(6);
                }
                nodeInfo.ParentPath = cacheNodeById.ParentPath + "," + cacheNodeById.NodeId.ToString();
                nodeInfo.RootId     = cacheNodeById.RootId;
                nodeInfo.Depth      = cacheNodeById.Depth + 1;
                nodeInfo.ParentDir  = cacheNodeById.ParentDir + cacheNodeById.NodeDir + "/";
                if ((cacheNodeById.NodeType == NodeType.Single) || (cacheNodeById.NodeType == NodeType.Link))
                {
                    return(5);
                }
                UpdateChild(nodeInfo.ParentId);
                foreach (KeyValuePair <int, string> pair in GetParentPathArrChildId(nodeInfo.ParentPath))
                {
                    int    key        = pair.Key;
                    string arrChildId = pair.Value + "," + nodeInfo.NodeId.ToString();
                    UpdateArrChildId(key, arrChildId);
                }
                if (cacheNodeById.Child > 0)
                {
                    nodeInfo.OrderId = GetPrevOrderId(cacheNodeById.ArrChildId);
                    nodeInfo.PrevId  = GetPrevId(nodeInfo.ParentId);
                }
                else
                {
                    nodeInfo.OrderId = cacheNodeById.OrderId;
                    nodeInfo.PrevId  = 0;
                }
            }
            else
            {
                nodeInfo.ParentDir = "/";
                if (maxRootId > 0)
                {
                    nodeInfo.PrevId = dal.GetRootPrevId(maxRootId);
                }
                else
                {
                    nodeInfo.PrevId = 0;
                }
                nodeInfo.RootId     = maxRootId + 1;
                nodeInfo.ParentPath = "0";
                nodeInfo.OrderId    = 0;
                nodeInfo.Depth      = 0;
            }
            UpdateNextId(nodeInfo.PrevId, nodeInfo.NodeId);
            bool flag = dal.Add(nodeInfo);

            UpdateOrderId(nodeInfo.RootId, nodeInfo.OrderId, 1);
            if (nodeInfo.ParentId > 0)
            {
                UpdateOrderId(nodeInfo.NodeId, nodeInfo.OrderId + 1);
            }
            RemoveCacheAllNodeInfo();
            if (!flag)
            {
                return(0);
            }
            return(1);
        }