mac
2023-10-19 baca65d449433d73516660d849c112ed8f5d3dd3
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
171
172
173
174
using System;
using Shared;
namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView
{
    public class BaseFramLayout : FrameLayout
    {
        public BaseFramLayout()
        {
        }
        /// <summary>
        /// 是否可以点击
        /// </summary>
        private bool mIsClick = true;
 
        /// <summary>
        /// 设置控制点击事件
        /// </summary>
        /// <param name="isClick">false点击无效</param>
        public void SetClick(bool isClick)
        {
            this.mIsClick = isClick;
        }
        /// <summary>
        /// 设置控制点击事件
        /// </summary>
        /// <param name="isClick">false点击无效</param>
        public bool GetClick()
        {
            return this.mIsClick;
        }
 
        /// <summary>
        /// 延时时间ms
        /// </summary>
        public const int millisecondsTimeout = 100;
 
        /// <summary>
        /// 选中颜色
        /// </summary>
        public const uint seleBackgroundColor = 0xFFF2F3F7;
        /// <summary>
        /// 不支持按键文本颜色
        /// </summary>
        public const uint unBackgroundColor = 0xFFA3AAB7;
        /// <summary>
        /// 不支持整个颜色
        /// </summary>
        public const uint unParentBackgroundColor = 0xFFF2F3F7;
 
        /// <summary>
        /// 调整真实高度
        /// </summary>
        /// <param name="bottomSpace">底部高度(非真实值)</param>
        public void AdjustRealHeight(int bottomSpace = 0)
        {
            int bottomHeight = -1;
 
            for (int i = 0; i < this.ChildrenCount; i++)
            {
                var child = this.GetChildren(i);
                if (child.Bottom > bottomHeight)
                {
                    bottomHeight = child.Bottom;
                }
            }
            if (bottomHeight != -1)
            {
                this.Height = bottomHeight + Application.GetRealHeight(bottomSpace);
            }
        }
 
        /// <summary>
        /// 获取坐标底部最下面的那个控件的底部坐标
        /// </summary>
        /// <returns></returns>
        public int GetLocationMostLastViewBottom()
        {
            int bottomHeight = -1;
 
            for (int i = 0; i < this.ChildrenCount; i++)
            {
                var child = this.GetChildren(i);
                if (child.Bottom > bottomHeight)
                {
                    bottomHeight = child.Bottom;
                }
            }
            return bottomHeight;
        }
        /// <summary>
        /// 设置高亮颜色(grb)
        /// </summary>
        /// <param name="seleColor">选中颜色值</param>
        /// <param name="unColor">未选中颜色值</param>
        /// <param name="view">组件</param>
        public void SetHighlightColor(View view, uint seleColor =seleBackgroundColor, uint unColor = 0x00000000) 
        {
            if (view == null)
            {
                return;
            }
            //按下去改变背景颜色
            view.BackgroundColor = seleColor;
            new System.Threading.Thread(() =>
            {
                System.Threading.Thread.Sleep(millisecondsTimeout);
                Application.RunOnMainThread(() =>
                {
                    //弹起来还原背景颜色
                    view.BackgroundColor = unColor;
                });
            })
            { IsBackground = true }.Start();
 
        }
 
        /// <summary>
        /// 设置Button专用
        /// </summary>
        /// <param name="button">组件</param>
        public void SetButtonIsSelected(Button button)
        {
            if (button == null)
            {
                return;
            }
            //按下去改变背景颜色
            button.IsSelected = true;
            new System.Threading.Thread(() =>
            {
                System.Threading.Thread.Sleep(millisecondsTimeout);
                Application.RunOnMainThread(() =>
                {
                    //弹起来还原背景颜色
                    button.IsSelected = false;
                });
            })
            { IsBackground = true }.Start();
 
        }
 
        /// <summary>
        /// 设置高亮背景图标
        /// </summary>
        /// <param name="sele">选中图片路径</param>
        /// <param name="unColor">未选中图片路径<</param>
        /// <param name="view">组件</param>
        public void SetHighlightImagePath(FrameLayout frame, string seleImagePath, string unImagePath)
        {
            if (frame == null)
            {
                return;
            }
            //按下去改变背景颜色
            frame.BackgroundImagePath = seleImagePath;
            new System.Threading.Thread(() =>
            {
                System.Threading.Thread.Sleep(millisecondsTimeout);
                Application.RunOnMainThread(() =>
                {
                    //弹起来还原背景颜色
                    frame.BackgroundImagePath = unImagePath;
                });
            })
            { IsBackground = true }.Start();
 
        }
 
 
 
    }
 
 
}