Exemplo n.º 1
0
        //绑定事件选择数据
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            int index = oldIncident.SelectedIndex;

            oldIncident.ItemsSource   = ComparisonService.GetComboBoxResource();
            oldIncident.SelectedIndex = index == -1 ? 0 : index;
            index = newIncident.SelectedIndex;
            newIncident.ItemsSource   = ComparisonService.GetComboBoxResource();
            newIncident.SelectedIndex = index == -1 ? 0 : index;
            //添加标签标注缓存
            TagSupport.CheckTagSort();
        }
Exemplo n.º 2
0
        //添加或修改标签的地址
        public void EditedItem_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (isInIt)
            {
                return;
            }
            //取消注册事件
            MouseLeftButtonDown          -= EditedItem_MouseDown;
            pathList.MouseLeftButtonDown -= EditedItem_MouseDown;
            tagName.MouseLeftButtonDown  -= EditedItem_MouseDown;
            pathGrid.MouseLeftButtonDown -= EditedItem_MouseDown;
            //获取相关信息
            string editedGridUid = editedGrid.Uid;
            string editedPath    = null;

            foreach (UIElement element in editedGrid.Children)
            {
                if (element is TextBox)
                {
                    editedPath = (element as TextBox).Text;
                }
            }
            if (editedPath != string.Empty)
            {
                //添加
                if (editedGridUid == "newPath")
                {
                    DirTagMapper.AddOne(new DirTagBean()
                    {
                        TagId = selectedTagId,
                        Path  = editedPath,
                    });
                }
                //修改
                else
                {
                    DirTagMapper.EditOneById(uint.Parse(editedGridUid), editedPath);
                }
            }
            TagSupport.SetTagSort();
            int index = pathList.SelectedIndex;

            pathList.ItemsSource   = TagService.GetPathItemSource(selectedTagId);
            pathList.SelectedIndex = index;
            isInIt = true; //设置为true,关闭该方法的相应
        }
Exemplo n.º 3
0
        /// <summary>
        /// 建立该节点的子节点
        /// </summary>
        /// <param name="node">文件夹节点</param>
        public static void BuildChildrenNodes(DirNode node)
        {
            //获取对应节点下的文件夹列表
            RecordBean[] oldBeans;
            if (node.OldIncidentId == 0)
            {
                oldBeans = new RecordBean[0];
            }
            else
            {
                oldBeans = RecordMapper.GetBeansByPid(node.OldId, node.OldIncidentId);
            }
            RecordBean[] newBeans;
            if (node.NewIncidentId == 0)
            {
                newBeans = new RecordBean[0];
            }
            else
            {
                newBeans = RecordMapper.GetBeansByPid(node.NewId, node.NewIncidentId);
            }
            List <DirNode> dirNodes = new List <DirNode>();

            //遍历两个文件夹列表
            foreach (RecordBean oldBean in oldBeans)
            {
                RecordBean newBean = null;
                //去除重复项
                for (int i = 0; i < newBeans.Length; i++)
                {
                    if (newBeans[i] == null)
                    {
                        continue;
                    }
                    if (oldBean.Path == newBeans[i].Path)
                    {
                        newBean     = newBeans[i];
                        newBeans[i] = null;
                    }
                }
                //建立node
                DirNode dirNode = new DirNode()
                {
                    Name = oldBean.Name,
                    Path = oldBean.Path,
                    // 放入一个空数组,告知页面该节点可以展开
                    Children = oldBean.DirCount > 0 ? new DirNode[1] : null,
                };
                SetOldId(ref dirNode, oldBean, node.OldIncidentId);
                //设置类型
                if (newBean != null)
                {
                    SetNewId(ref dirNode, newBean, node.NewIncidentId);
                    if (oldBean.Equals(newBean))
                    {
                        dirNode.Type = DirNodeType.Unchanged;
                    }
                    else
                    {
                        dirNode.Type = DirNodeType.Changed;
                    }
                }
                else
                {
                    dirNode.Type = DirNodeType.Deleted;
                }
                dirNodes.Add(dirNode);
            }
            //新纪录中新增的部分
            foreach (RecordBean newBean in newBeans)
            {
                if (newBean == null)
                {
                    continue;
                }
                DirNode dirNode = new DirNode()
                {
                    Name     = newBean.Name,
                    Path     = newBean.Path,
                    Children = newBean.DirCount > 0 ? new DirNode[1] : null,
                    //新增的节点
                    Type = DirNodeType.Added,
                };
                SetNewId(ref dirNode, newBean, node.NewIncidentId);
                dirNodes.Add(dirNode);
            }
            //添加标签
            TagBean nullTag = new TagBean()
            {
                Color = "#FFFFFF"
            };

            foreach (DirNode dirNode in dirNodes)
            {
                TagBean tagBean = TagSupport.GetTagByPath(dirNode.Path, out bool isThis);
                if (tagBean == null)
                {
                    dirNode.Tag = nullTag;
                    continue;
                }
                dirNode.IsRootTag = isThis;
                dirNode.Tag       = tagBean;
            }
            node.Children = dirNodes.ToArray();
        }