黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
 
namespace Shared.Phone.UserCenter.HideOption
{
    /// <summary>
    /// 本地缓存文件夹列表的界面
    /// </summary>
    public class HideOptionDirectoryListForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //设置头部信息
            base.SetTitleText("文件夹列表");
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        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<System.Reflection.PropertyInfo>();
            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
    }
}