HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
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
using Shared.Common;
using Shared.Phone.UserCenter;
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.Category
{
    /// <summary>
    /// 选择本地场景图片的界面
    /// </summary>
    public class SelectLocalSceneImageForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 结束选择的事件(图片名字)
        /// </summary>
        public Action<string> FinishSelectEvent = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //初始化中部信息
            this.InitMiddleFrame();
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.LocalPicture));
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            //列表控件
            var listView = new VerticalListControl();
            listView.Height = bodyFrameLayout.Height;
            bodyFrameLayout.AddChidren(listView);
 
            int picHeight = this.GetPictrueRealSize(220);
            int picWidth = this.GetPictrueRealSize(463);
            int leftRightSpace = this.GetPictrueRealSize(40);
            int space = listView.Width - leftRightSpace * 2 - picWidth * 2;
 
            //一共14张图片
            FrameLayout frameRow = null;
            for (int i = 0; i < 14; i++)
            {
                //图片
                var btnIcon = new ImageView();
                btnIcon.Y = Application.GetRealHeight(58);
                btnIcon.Width = picWidth;
                btnIcon.Height = picHeight;
                btnIcon.ImagePath = $"SceneIcon/{i}.png";
                btnIcon.Radius = (uint)Application.GetRealHeight(17);
 
                if (i % 2 == 0)
                {
                    btnIcon.X = leftRightSpace;
 
                    //行控件
                    frameRow = new FrameLayout();
                    frameRow.Height = picHeight + Application.GetRealHeight(58);
                    listView.AddChidren(frameRow);
                }
                else
                {
                    btnIcon.X = leftRightSpace + picWidth + space;
                }
                frameRow.AddChidren(btnIcon);
 
                //图片遮罩
                var btnZhezhao = new FrameLayout();
                btnZhezhao.Width = btnIcon.Width;
                btnZhezhao.Height = btnIcon.Height;
                btnZhezhao.Y = btnIcon.Y;
                btnZhezhao.X = btnIcon.X;
                btnZhezhao.Radius = (uint)Application.GetRealHeight(17);
                btnZhezhao.BackgroundColor = UserCenterColor.Current.PictrueZhezhaoColor;
                frameRow.AddChidren(btnZhezhao);
                btnZhezhao.SetViewShadow(true);
                btnZhezhao.MouseUpEventHandler += (sender, e) =>
                {
                    //结束选择的事件
                    this.FinishSelectEvent?.Invoke(btnIcon.ImagePath);
                    this.CloseForm();
                };
            }
 
            //底部间距
            var frameTemp = new FrameLayout();
            frameTemp.Height = Application.GetRealHeight(58);
            listView.AddChidren(frameTemp);
        }
 
        #endregion
 
        #region ■ 界面关闭___________________________
 
        /// <summary>
        /// 界面关闭
        /// </summary>
        public override void CloseFormBefore()
        {
            this.FinishSelectEvent = null;
 
            base.CloseFormBefore();
        }
 
        #endregion
    }
}