添加项目文件。
This commit is contained in:
135
OrpaonEMS.App/ViewModels/DataLogViewModel.cs
Normal file
135
OrpaonEMS.App/ViewModels/DataLogViewModel.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
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<string>();
|
||||
Director(@"C:\EsDataLog\", data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private ObservableCollection<DataLogFile> _DataLogFileInfo;
|
||||
/// <summary>
|
||||
/// 集合信息
|
||||
/// </summary>
|
||||
public ObservableCollection<DataLogFile> DataLogFileInfo
|
||||
{
|
||||
get { return _DataLogFileInfo; }
|
||||
set
|
||||
{
|
||||
_DataLogFileInfo = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void Director(string dir, List<string> 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;
|
||||
/// <summary>
|
||||
/// 保存命令
|
||||
/// </summary>
|
||||
public DelegateCommand SaveCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
saveCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (saveCmd == null)
|
||||
{
|
||||
saveCmd = new DelegateCommand(() => SaveCmdMethod());
|
||||
}
|
||||
return saveCmd;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存命令方法
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void SaveCmdMethod()
|
||||
{
|
||||
|
||||
|
||||
DialogParameters pars = new DialogParameters
|
||||
{
|
||||
{ "Model", "" }
|
||||
};
|
||||
|
||||
RaiseRequestClose(new DialogResult(ButtonResult.OK, pars));
|
||||
}
|
||||
|
||||
private DelegateCommand cancelCmd;
|
||||
/// <summary>
|
||||
/// 保存命令
|
||||
/// </summary>
|
||||
public DelegateCommand CancelCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
cancelCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (cancelCmd == null)
|
||||
{
|
||||
cancelCmd = new DelegateCommand(() => CancelCmdMethod());
|
||||
}
|
||||
return cancelCmd;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消命令方法
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void CancelCmdMethod()
|
||||
{
|
||||
RaiseRequestClose(new DialogResult(ButtonResult.Cancel));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口打开时的传递的参数
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
public override void OnDialogOpened(IDialogParameters parameters)
|
||||
{
|
||||
//ConfigModel = parameters.GetValue<BmsRwCell>("Model");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user