黄学彪
2020-04-26 18a7f9f40e5fab3bee5d4ac3d8fd0273dea052d6
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
using Shared.Phone.UserCenter;
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.MainPage.Controls
{
    /// <summary>
    /// 选择本地设备图片的界面
    /// </summary>
    public class SelectLocalDeviceImageForm : 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 space = this.GetPictrueRealSize(46);
            int backWidth = (listView.Width - ControlCommonResourse.XXLeft * 2 - space * 3) / 4;
            //防止误差,分两步计算
            int iconWidth = backWidth - this.GetPictrueRealSize(43) - this.GetPictrueRealSize(43);
 
            //一共28张图片
            FrameLayout frameRow = null;
            for (int i = 0; i < 28; i++)
            {
                //4个一组
                if (i % 4 == 0)
                {
                    //行控件
                    frameRow = new FrameLayout();
                    frameRow.Height = backWidth + Application.GetRealHeight(58);
                    listView.AddChidren(frameRow);
                }
                //背景
                var frameBack = new FrameLayoutControl();
                frameBack.UseClickStatu = false;
                frameBack.Height = backWidth;
                frameBack.Width = backWidth;
                frameBack.Radius = (uint)backWidth / 2;
                frameBack.BackgroundColor = UserCenterColor.Current.White;
                frameBack.X = ControlCommonResourse.XXLeft + (i % 4) * (backWidth + space);
                frameBack.Y = Application.GetRealHeight(58);
                frameRow.AddChidren(frameBack);
 
                //图片
                var btnIcon = new PicViewControl(iconWidth, iconWidth, false);
                btnIcon.UnSelectedImagePath = $"FunctionIcon/{i + 1}Icon.png";
                btnIcon.SelectedImagePath = $"FunctionIcon/{i + 1}IconSelected.png";
                btnIcon.Gravity = Gravity.Center;
                frameBack.AddChidren(btnIcon, ChidrenBindMode.BindEventOnly);
 
                frameBack.ButtonClickEvent += (sender, e) =>
                {
                    //结束选择的事件
                    //this.FinishSelectEvent?.Invoke(btnIcon.ImagePath);
                    this.CloseForm();
                };
            }
 
            //保存
            var btnSave = new BottomClickButton();
            btnSave.TextID = R.MyInternationalizationString.uSave;
            btnSave.ButtonClickEvent += (sender, e) =>
            {
            };
 
            //调整桌布高度
            listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(23));
        }
 
        #endregion
 
        #region ■ 界面关闭___________________________
 
        /// <summary>
        /// 界面关闭
        /// </summary>
        public override void CloseFormBefore()
        {
            this.FinishSelectEvent = null;
 
            base.CloseFormBefore();
        }
 
        #endregion
    }
}