/// <summary> /// 生成文件夹 /// </summary> /// <param name="folderList">文件夹目录</param> /// <param name="row1Height">行1高</param> /// <param name="fileHeigth">文件高</param> /// <param name="fileWidth">文件宽</param> private void DataLoad_Directory(List <SP.Folder> folderList, double row1Height, double fileHeigth, double fileWidth) { try { //生成书本形式的文件夹 foreach (var folderItem in folderList) { UCBook ucBook = new UCBook(folderItem.Name, "/Image/TypeImage/folder.png") { Date = DateTime.Now.ToShortTimeString(), BookType = BookType.Folder, Width = fileWidth, Height = fileHeigth, Row1Height = row1Height }; this.Items_Add(ucBook); //创建一个面包线(目前在这里创建和根面包线【书架自带】) BreadLine breadLine = new BreadLine() { Folder = folderItem, Title = folderItem.Name }; //关联指定生成的面包线() ucBook.BreadLine = breadLine; //删除文件 ucBook.FileDeleteCallBack = ucBook_DeleteFile; //面包线点击事件 breadLine.LineClickEventCallBack = breadLine_LineClickEvent; } } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } finally { } }
/// <summary> /// 打开文件(包括文件夹) /// </summary> /// <param name="ucBook"></param> public void book_OpenFileEvent(UCBook ucBook) { try { switch (ucBook.BookType) { case BookType.File: //根据文件的类型使用相应的方式打开 this.fileOpenManage.FileOpenByExtension((ConferenceCommon.WPFControl.FileType)ucBook.FileType, ucBook.Uri); break; case BookType.Folder: //打开文件夹 this.FolderOpen(ucBook); break; default: break; } } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } }
/// <summary> /// 添加子项(先决条件:定位) /// </summary> public void ItemsAddByPosition(UCBook ucBook, int rowPosition, int columnPosition) { //【给元素定位行】 Grid.SetRow(ucBook, rowPosition); //【给元素定位列】 Grid.SetColumn(ucBook, columnPosition); //容器添加子项【添加】 this.GridBookParent.Children.Add(ucBook); }
/// <summary> /// 删除文件 /// </summary> /// <param name="uri"></param> public void ucBook_DeleteFile(UCBook ucbook) { try { switch (ucbook.BookType) { case BookType.File: if (this.currentBreadLine != null && this.currentBreadLine.Folder != null) { //等待提示 this.ShowTip(); //获取要删除的文件名称 var fileN = System.IO.Path.GetFileName(ucbook.Uri); //this.BorContent.Child = null; ThreadPool.QueueUserWorkItem((o) => { //删除文件 SpaceCodeEnterEntity.ClientContextManage.DeleFile(this.currentBreadLine.Folder, fileN); this.Dispatcher.BeginInvoke(new Action(() => { //填充数据(刷新) this.RefleshSpaceData(this.currentBreadLine); })); }); } break; case BookType.Folder: if (this.currentBreadLine != null && this.currentBreadLine.Folder != null) { //等待提示 this.ShowTip(); ThreadPool.QueueUserWorkItem((o) => { //删除文件夹 SpaceCodeEnterEntity.ClientContextManage.DeleteFolder(this.currentBreadLine.Folder, ucbook.Book_Title); this.Dispatcher.BeginInvoke(new Action(() => { //填充数据(刷新) this.RefleshSpaceData(this.currentBreadLine); })); }); } break; default: break; } } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } }
/// <summary> /// 生成文件 /// </summary> /// <param name="folderList">文件夹目录</param> /// <param name="row1Height">行1高</param> /// <param name="fileHeigth">文件高</param> /// <param name="fileWidth">文件宽</param> private void DataLoad_File(List <SP.File> fileList, double row1Height, double fileHeigth, double fileWidth) { try { //生成文件(根据文件类型去匹配) foreach (var item in fileList) { if (item.Name.Contains(".")) { //文件类型 var extention = System.IO.Path.GetExtension(item.ServerRelativeUrl); //文件名称 var fileName = System.IO.Path.GetFileNameWithoutExtension(item.ServerRelativeUrl); //去掉点 extention = extention.Replace(".", string.Empty); //文件类型 fileType fileType = default(fileType); //转换为枚举 Enum.TryParse(extention, true, out fileType); //图片 string imageUri = "/" + this.extetionImageFolderName + "/" + extention + ".png"; //文件具体地址 string uri = SpaceCodeEnterEntity.SPSiteAddressFront + item.ServerRelativeUrl; //生成书 UCBook ucBook = new UCBook(fileName, imageUri) { BookType = BookType.File, Uri = uri, FileType = fileType, Width = fileWidth, Height = fileHeigth, Row1Height = row1Height }; //添加书 this.Items_Add(ucBook); //删除文件 ucBook.FileDeleteCallBack = ucBook_DeleteFile; //下载文件 ucBook.FileDownLoadCallBack = ucBook_DownLoadFile; //推送文件 ucBook.FileSendCallBack = ucBook_SendFile; //实时共享 ucBook.FileShareCallBack = ucBook_RealShareFile; } } } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } finally { } }
/// <summary> /// 添加子项 /// </summary> /// <param name="book">书本的实例</param> public void Items_Add(UCBook ucBook) { try { //给书本集合添加书本 this.BookList.Add(ucBook); ucBook.PreviewMouseLeftButtonDown += ucBook_PreviewMouseLeftButtonDown; } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } finally { } }
/// <summary> /// 删除指定子项 /// </summary> /// <param name="ucBook">书本</param> public void Items_Remove(UCBook ucBook) { try { //删除子项 this.BookList.Remove(ucBook); //刷新 this.ReFlush_BookShell(); } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } finally { } }
/// <summary> /// 打开文件夹 /// </summary> public void FolderOpen(UCBook ucbook) { try { if (this.currentBreadLine != null && ucbook.BreadLine != null) { //设置当前面包线的子节点(子面包线) this.currentBreadLine.BreadLineChild = ucbook.BreadLine; //设置当前面包线 this.currentBreadLine = ucbook.BreadLine; //刷新当前页面 this.RefleshSpaceData(this.currentBreadLine); } } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } }