using System; using System.Collections.Generic; using System.IO; using System.Text; namespace Shared.Phone.UserCenter.HideOption { /// /// 本地缓存文件夹列表的界面 /// public class HideOptionDirectoryListForm : EditorCommonForm { #region ■ 变量声明___________________________ #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// public void ShowForm() { //设置头部信息 base.SetTitleText("文件夹列表"); //初始化中部信息 this.InitMiddleFrame(); } /// /// 初始化中部信息 /// private void InitMiddleFrame() { var listView = new VerticalListControl(23); listView.BackgroundColor = UserCenterColor.Current.White; listView.Height = bodyFrameLayout.Height; bodyFrameLayout.AddChidren(listView); Type type = typeof(HdlFileNameResourse); var PropertyList = type.GetProperties(); var listFile = new List(); foreach (var item in PropertyList) { if (item.Name.EndsWith("Directory") == true) { listFile.Add(item); } } for (int i = 0; i < listFile.Count; i++) { var item = listFile[i]; this.AddRowControl(listView, item.Name, item.GetValue(null).ToString(), true); } //本地文件 var row1 = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(row1); row1.AddLeftCaption("根目录文件", 800); row1.AddRightArrow(); row1.AddBottomLine(); row1.ButtonClickEvent += (sender, e) => { var form = new HideOptionSearchAllFile(); form.AddForm(Common.Config.Instance.FullPath); }; #if iOS //查看全部文件 var row0 = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(row0); row0.AddLeftCaption("IOS图片", 800); row0.AddRightArrow(); row0.AddBottomLine(); row0.ButtonClickEvent += (sender, e) => { string fileName = "Item/Add.png"; if (File.Exists(Path.Combine(Application.RootPath, fileName))) { var form = new HideOptionSearchAllFile(); form.AddForm(Application.RootPath); return; } string dirPath = string.Empty; if (Application.Skin != null) { dirPath = Application.Skin + "/" + fileName; if (File.Exists(Path.Combine(Application.RootPath, dirPath))) { var form = new HideOptionSearchAllFile(); form.AddForm(Path.Combine(Application.RootPath, Application.Skin + "/")); return; } string text2 = Foundation.NSBundle.MainBundle.PathForResource(dirPath, null); if (text2 != null) { var form = new HideOptionSearchAllFile(); form.AddForm(text2.Replace(dirPath, string.Empty)); return; } } else { dirPath = "Phone/" + fileName; if (File.Exists(Path.Combine(Application.RootPath, dirPath))) { var form = new HideOptionSearchAllFile(); form.AddForm(Path.Combine(Application.RootPath, "Phone/")); return; } string text2 = Foundation.NSBundle.MainBundle.PathForResource(dirPath, null); if (text2 != null) { var form = new HideOptionSearchAllFile(); form.AddForm(text2.Replace(dirPath, string.Empty)); return; } } }; #endif //查看全部文件 var row2 = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(row2); row2.AddLeftCaption("查看全部文件", 800); row2.AddRightArrow(); row2.ButtonClickEvent += (sender, e) => { var form = new HideOptionSearchAllFile(); form.AddForm(Shared.IO.FileUtils.RootPath); }; listView.AdjustRealHeight(Application.GetRealHeight(23)); } private void AddRowControl(VerticalListControl listView, string directory, string directoryValue, bool addLine) { if (System.IO.Directory.Exists(directoryValue) == false) { return; } var row1 = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(row1); row1.AddLeftCaption(directory, 800); row1.AddRightArrow(); if (addLine == true) { row1.AddBottomLine(); } row1.ButtonClickEvent += (sender, e) => { var form = new HideOptionSearchAllFile(); form.AddForm(directoryValue); }; } #endregion #region ■ 一般方法___________________________ #endregion } }