using Shared;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace HDL_ON.Stan
|
{
|
/// <summary>
|
/// 查看全部文件
|
/// </summary>
|
public class HideOptionSearchAllFile : EditorCommonForm
|
{
|
#region ■ 变量声明___________________________
|
|
private string nowDirectory = string.Empty;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
/// </summary>
|
public void ShowForm(string directory)
|
{
|
this.nowDirectory = directory;
|
//设置头部信息
|
base.SetTitleText("文件列表");
|
|
//初始化中部信息
|
this.InitMiddleFrame(nowDirectory);
|
|
this.BackButtonClickEvent = () =>
|
{
|
string rootPath = Shared.IO.FileUtils.RootPath.Trim('/');
|
if (this.nowDirectory.Trim('/') == rootPath)
|
{
|
this.CloseForm();
|
return;
|
}
|
string[] Arry = this.nowDirectory.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
|
string nextDir = string.Empty;
|
for (int i = 0; i < Arry.Length - 1; i++)
|
{
|
nextDir += Arry[i] + "/";
|
}
|
//初始化中部信息
|
this.InitMiddleFrame(nextDir);
|
};
|
}
|
|
/// <summary>
|
/// 初始化中部信息
|
/// </summary>
|
private void InitMiddleFrame(string directory)
|
{
|
this.nowDirectory = directory;
|
this.ClearBodyFrame();
|
|
var listDirectory = new List<string>();
|
var listAllFile = new List<string>();
|
|
//string rootPath = Shared.IO.FileUtils.RootPath.Trim('/');
|
//if (this.nowDirectory.Trim('/') == rootPath)
|
//{
|
// //根目录只要两个就可以了
|
// listDirectory.Add(Common.Config.Instance.Guid);
|
// listDirectory.Add(Application.Skin != null ? Application.Skin : "Phone");
|
//}
|
//else
|
{
|
var files = System.IO.Directory.GetDirectories(directory);
|
foreach (var file in files)
|
{
|
string[] arry = file.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
|
listDirectory.Add(arry[arry.Length - 1]);
|
}
|
listDirectory.Sort();
|
|
listAllFile = HdlFileLogic.Current.GetFileFromDirectory(directory.TrimEnd('/'));
|
listAllFile.Sort();
|
}
|
|
var listView = new VerticalListControl(8);
|
listView.BackgroundColor = 0xffffffff;
|
listView.Height = bodyFrameLayout.Height;
|
bodyFrameLayout.AddChidren(listView);
|
|
if (listDirectory.Count > 0)
|
{
|
var row1 = new RowLayoutControl(listView.rowSpace / 2);
|
listView.AddChidren(row1);
|
row1.frameTable.AddLeftCaption("【文件夹列表】", 278);
|
|
for (int i = 0; i < listDirectory.Count; i++)
|
{
|
this.AddDirectoryRowControl(listView, listDirectory[i], directory, i != listDirectory.Count - 1);
|
}
|
}
|
|
if (listAllFile.Count > 0)
|
{
|
var row1 = new RowLayoutControl(listView.rowSpace / 2);
|
listView.AddChidren(row1);
|
row1.frameTable.AddLeftCaption("【文件列表】", 278);
|
for (int i = 0; i < listAllFile.Count; i++)
|
{
|
this.AddFileRowControl(listView, listAllFile[i], directory, i != listAllFile.Count - 1);
|
}
|
}
|
listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(17));
|
|
var btnButon = new BottomClickButton();
|
btnButon.Text = "删除文件夹";
|
bodyFrameLayout.AddChidren(btnButon);
|
btnButon.ButtonClickEvent += (sender, e) =>
|
{
|
this.ShowMassage(ShowMsgType.Confirm, "是否清除该文件夹", () =>
|
{
|
try
|
{
|
System.IO.Directory.Delete(directory, true);
|
this.CloseForm();
|
}
|
catch (Exception ex)
|
{
|
this.ShowMassage(ShowMsgType.Error, "清除缓存文件夹异常");
|
}
|
});
|
};
|
}
|
|
private void AddDirectoryRowControl(VerticalListControl listView, string directoryName, string directory, bool addLine)
|
{
|
string dirNewName = directoryName;
|
|
var row1 = new RowLayoutControl(listView.rowSpace / 2);
|
listView.AddChidren(row1);
|
var btnName = row1.frameTable.AddLeftCaption(dirNewName, 278);
|
btnName.IsMoreLines = true;
|
if (addLine == true)
|
{
|
row1.frameTable.AddBottomLine();
|
}
|
row1.frameTable.AddRightArrow();
|
|
row1.frameTable.ButtonClickEvent += (sender, e) =>
|
{
|
//初始化中部信息
|
this.InitMiddleFrame(System.IO.Path.Combine(directory, directoryName));
|
};
|
}
|
|
private void AddFileRowControl(VerticalListControl listView, string fileName, string directory, bool addLine)
|
{
|
string fileNewName = fileName;
|
|
var row1 = new RowLayoutControl(listView.rowSpace / 2);
|
listView.AddChidren(row1);
|
var btnName = row1.frameTable.AddLeftCaption(fileNewName, 278);
|
btnName.IsMoreLines = true;
|
if (addLine == true)
|
{
|
row1.frameTable.AddBottomLine();
|
}
|
row1.frameTable.AddRightArrow();
|
|
row1.frameTable.ButtonClickEvent += (sender, e) =>
|
{
|
var form = new HideOptionFileContentForm();
|
form.AddForm(System.IO.Path.Combine(directory, fileName));
|
};
|
}
|
|
#endregion
|
|
#region ■ 一般方法___________________________
|
|
#endregion
|
}
|
}
|