/// <summary> /// //加载子文件 /// </summary> /// <param name="xmlNode"></param> /// <param name="listView"></param> /// <param name="FlterType"></param> private void InitListViewSubFile(XmlNodeList xmlNode, ListViewEx listView, string FlterType) { foreach (XmlNode node in xmlNode) { if (node is FileSimpleExXmlElement) { FileSimpleExXmlElement fileEle = (FileSimpleExXmlElement)node; string exfile = Path.GetExtension(fileEle.AbsoluteFilePath).ToLower(); if (!FlterType.Contains(exfile)) { continue; } MyListFileItem myFileItem = new MyListFileItem(fileEle); if (fileEle.IsDeleted) { continue; } myFileItem.Element = fileEle; myFileItem.Text = fileEle.Title; listView.Items.Add(myFileItem); } } }
private void InitListViewSubFile(XmlNodeList xmlNode, ListViewEx listView, string FlterType) { //加载子文件 foreach (XmlNode node in xmlNode) { if (node is FileSimpleExXmlElement) { FileSimpleExXmlElement fileEle = (FileSimpleExXmlElement)node; string exfile = Path.GetExtension(fileEle.AbsoluteFilePath).ToLower(); if (FlterType != _strAll && !FlterType.Contains(exfile)) { continue; } MyListFileItem myFileItem = new MyListFileItem(fileEle); if (fileEle.IsDeleted) { continue; } myFileItem.ItemMediaType = GetListItemType(exfile); myFileItem.Element = fileEle; myFileItem.Text = fileEle.Title; listView.Items.Add(myFileItem); } else if (node is PageSimpleExXmlElement) { PageSimpleExXmlElement fileEle = (PageSimpleExXmlElement)node; if (FlterType != _strAll && fileEle.PageType.ToString() != FlterType) { continue; } MyListFileItem myFileItem = new MyListFileItem(fileEle); if (fileEle.IsDeleted) { continue; } myFileItem.Element = fileEle; myFileItem.Text = fileEle.Title; listView.Items.Add(myFileItem); } } }
/// <summary> /// 保存/替换文件 /// </summary> /// <param name="isReplace">true 替换文件 , false 只保存</param> /// <returns>保存/替换成功 返回TRUE 失败 FALSE</returns> private bool SaveOrReplaceFile(bool isReplace, string fileName) { SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument; if (isReplace) { DialogResult result = MessageService.Show("${res:Tree.msg.coverFile}", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { return(false); } //旧文件删除 foreach (MyListItem item in listViewFodel.Items) { if (item is MyListFileItem) { MyListFileItem fileItem = item as MyListFileItem; if (fileName.Equals(fileItem.Element.FileName, StringComparison.CurrentCultureIgnoreCase)) { MyListItem deleItem = fileItem as MyListItem; doc.DeleteItem(deleItem.Element); listViewFodel.Items.Remove(deleItem); } } } } //保存新文件 if (myResourceCurrentItem != null) { string strSrcFile = Path.Combine(myResourceCurrentItem.Element.AbsoluteFilePath, fileName); _image.Save(strSrcFile, _imgFormat); FileSimpleExXmlElement fileEle = doc.CreateFileElement(myResourceCurrentItem.Element as FolderXmlElement, strSrcFile); InitListView(myResourceCurrentItem, listViewFodel, _resourceCurrentType); this.DialogResult = DialogResult.OK; } return(true); }