using OrpaonEMS.App.Models; using OrpaonEMS.Core; using OrpaonEMS.Model; using Prism.Commands; using Prism.Services.Dialogs; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace OrpaonEMS.App.ViewModels { public class DataLogViewModel : DialogViewModel { public DataLogViewModel() { this.Title = "数据记录查看"; var data = new List(); Director(@"C:\EsDataLog\", data); } private ObservableCollection _DataLogFileInfo; /// /// 集合信息 /// public ObservableCollection DataLogFileInfo { get { return _DataLogFileInfo; } set { _DataLogFileInfo = value; RaisePropertyChanged(); } } public void Director(string dir, List list) { DirectoryInfo d = new DirectoryInfo(dir); FileInfo[] files = d.GetFiles();//文件 DirectoryInfo[] directs = d.GetDirectories();//文件夹 foreach (FileInfo f in files) { list.Add(f.Name);//添加文件名到列表中 } //获取子文件夹内的文件列表,递归遍历 foreach (DirectoryInfo dd in directs) { Director(dd.FullName, list); } } private DelegateCommand saveCmd; /// /// 保存命令 /// public DelegateCommand SaveCmd { set { saveCmd = value; } get { if (saveCmd == null) { saveCmd = new DelegateCommand(() => SaveCmdMethod()); } return saveCmd; } } /// /// 保存命令方法 /// /// private void SaveCmdMethod() { DialogParameters pars = new DialogParameters { { "Model", "" } }; RaiseRequestClose(new DialogResult(ButtonResult.OK, pars)); } private DelegateCommand cancelCmd; /// /// 保存命令 /// public DelegateCommand CancelCmd { set { cancelCmd = value; } get { if (cancelCmd == null) { cancelCmd = new DelegateCommand(() => CancelCmdMethod()); } return cancelCmd; } } /// /// 取消命令方法 /// /// private void CancelCmdMethod() { RaiseRequestClose(new DialogResult(ButtonResult.Cancel)); } /// /// 窗口打开时的传递的参数 /// /// public override void OnDialogOpened(IDialogParameters parameters) { //ConfigModel = parameters.GetValue("Model"); } } }