Ejemplo n.º 1
0
 /// <summary>
 ///     把文档路径转为ListBoxItem
 /// </summary>
 /// <param name="folderDocument">需要转化的DocumentPathDTO</param>
 /// <returns></returns>
 public static ListBoxDocumentItem TransformToRootListBoxItem(DocumentPathDTO folderDocument)
 {
     if (folderDocument == null)
         throw new Exception("文件夹文档不能为空");
     var currentListBox = new ListBoxDocumentItem
         {
             DocumentPathId = folderDocument.DocumentPathId,
             Extension = folderDocument.Extension,
             Name = folderDocument.Name,
             IsLeaf = folderDocument.IsLeaf,
             ParentId = folderDocument.ParentId,
             DocumentGuid = folderDocument.DocumentGuid,
             FullPath = folderDocument.Name,
             Path = folderDocument.Path,
             SmallIconPath =
                 ImagePathHelper.GetSmallImageSource(folderDocument.Extension),
             BigIconPath =
                 ImagePathHelper.GetBigImageSource(folderDocument.Extension),
         };
     currentListBox.SubDocumentPaths.Clear();
     currentListBox.SubFolders.Clear();
     //子项路劲遍历
     folderDocument.SubDocumentPaths.ToList().ForEach(p =>
         {
             var newListBoxItem = new ListBoxDocumentItem
                 {
                     DocumentPathId = p.SubDocumentPathId,
                     Extension = p.Extension,
                     Name = p.Name,
                     IsLeaf = p.IsLeaf,
                     ParentId = p.ParentId,
                     DocumentGuid = p.DocumentGuid,
                     Path = p.Path,
                     SmallIconPath =
                         ImagePathHelper.GetSmallImageSource(p.Extension),
                     BigIconPath =
                         ImagePathHelper.GetBigImageSource(p.Extension),
                     FullPath = currentListBox.FullPath + @"\" + p.Name
                 };
             if (!p.IsLeaf)
             {
                 currentListBox.SubFolders.Add(newListBoxItem);
             }
             currentListBox.SubDocumentPaths.Add(newListBoxItem);
         });
     return currentListBox;
 }
Ejemplo n.º 2
0
 /// <summary>
 ///     加载子项文件与文件夹
 /// </summary>
 private void LoadSubFolderDocuemnt(ListBoxDocumentItem currentDocumentPath)
 {
     if (_pathFilterDes.Value != null && currentDocumentPath != null &&
         int.Parse(_pathFilterDes.Value.ToString()) == currentDocumentPath.DocumentPathId)
     {
         GetListBoxDocumentItem(); //加载子项
         return;
     }
     if (currentDocumentPath != null)
     {
         _openResult = false;
         //根据选中的父亲节点,查询子项文件
         if (currentDocumentPath.ParentId != null)
         {
             IsBusy = true;
             _pathFilterDes.Value = currentDocumentPath.DocumentPathId;
             return;
         }
         //选中的项为根目录,其父亲节点为空
         _pathFilterDes.Value = null;
     }
 }
Ejemplo n.º 3
0
        public static ListBoxDocumentItem TransformToSubListBoxItem(ListBoxDocumentItem currentListBox,
            IEnumerable<DocumentPathDTO> subDocumentPaths)
        {
            currentListBox.SubDocumentPaths.Clear();
            currentListBox.SubFolders.Clear();
            //子项路劲遍历
            subDocumentPaths.ToList().ForEach(p =>
                {
                    var newListBoxItem = new ListBoxDocumentItem
                        {
                            DocumentPathId = p.DocumentPathId,
                            Extension = p.Extension,
                            Name = p.Name,
                            IsLeaf = p.IsLeaf,
                            ParentId = p.ParentId,
                            Path = p.Path,
                            DocumentGuid = p.DocumentGuid,
                            SmallIconPath =
                                ImagePathHelper.GetSmallImageSource(p.Extension),
                            BigIconPath =
                                ImagePathHelper.GetBigImageSource(p.Extension),
                            FullPath = currentListBox.FullPath + @"\" + p.Name,
                        };

                    if (!p.IsLeaf)
                    {
                        currentListBox.SubFolders.Add(newListBoxItem);
                    }
                    currentListBox.SubDocumentPaths.Add(newListBoxItem);
                });
            return currentListBox;
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     获取ListBoxItem
 /// </summary>
 private void GetListBoxDocumentItem()
 {
     IsBusy = false;
     if (DocumentPathsView.Any(p => p.ParentId == null))
     {
         //获取顶层文件夹文档
         RootPath =
             ListBoxItemHelper.TransformToRootListBoxItem(
                 DocumentPathsView.FirstOrDefault(p => p.ParentId == null));
         //为Treeview集合
         _listBoxDocumentItems.Clear();
         _listBoxDocumentItems.Add(RootPath);
         CurrentPathItem = RootPath;
     }
     else //双击打开文件夹
         if (_loadType.Equals("DoubleClick", StringComparison.OrdinalIgnoreCase))
         {
             if (SelectDocumentPath != null && !SelectDocumentPath.IsLeaf)
             {
                 //子项文档集合
                 var childDocuments =
                     DocumentPathsView.Where(p => p.ParentId == SelectDocumentPath.DocumentPathId);
                 //设置当前选中项
                 _currentPathItem = CurrentPathItem.SubDocumentPaths.FirstOrDefault(
                     p => p.DocumentPathId == SelectDocumentPath.DocumentPathId);
                 //子项文档转化为ListBoxItem
                 ListBoxItemHelper.TransformToSubListBoxItem(_currentPathItem, childDocuments);
                 RaisePropertyChanged(() => CurrentPathItem);
             }
         }
         else //通过搜索框打开文件夹
         {
             if (CurrentPathItem != null)
             {
                 //子项文档集合
                 var childDocuments = DocumentPathsView
                     .Where(p => p.ParentId == _currentPathItem.DocumentPathId);
                 //子项文档转化为ListBoxItem
                 ListBoxItemHelper.TransformToSubListBoxItem(_currentPathItem, childDocuments);
                 RaisePropertyChanged(() => CurrentPathItem);
             }
         }
     RaisePropertyChanged(() => ListBoxDocumentItems);
 }