黄学彪
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
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 控件的逻辑
    /// </summary>
    public class HdlControlLogic
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 控件的逻辑
        /// </summary>
        private static HdlControlLogic m_Current = null;
        /// <summary>
        /// 控件的逻辑
        /// </summary>
        public static HdlControlLogic Current
        {
            get
            {
                if (m_Current == null)
                {
                    m_Current = new HdlControlLogic();
                }
                return m_Current;
            }
        }
 
        #endregion
 
        #region ■ 子控件的Y轴坐标____________________
 
        /// <summary>
        /// 指定位置类型获取Rowlayout的子控件的Y轴坐标(请确保子控件不大于父容器)
        /// </summary>
        /// <param name="fatherCtrHeight">父控件的真实高度</param>
        /// <param name="ctrHeight">子控件的真实高度</param>
        /// <param name="alignment">位置对齐方式</param>
        /// <param name="Space">上下间的空白间距,省略时,取行控件共通变量的值。设置为-1时,不计算空白间距</param>
        /// <returns></returns>
        public int GetControlChidrenYaxis(int fatherCtrHeight, int ctrHeight, UViewAlignment alignment, int Space = 0)
        {
            if (Space < 0)
            {
                //不计算间距值
                Space = 0;
            }
 
            if (alignment == UViewAlignment.Center)
            {
                return fatherCtrHeight / 2 - ctrHeight / 2;
            }
            else if (alignment == UViewAlignment.Top)
            {
                return (fatherCtrHeight / 2 - Space / 2) / 2 - ctrHeight / 2;
            }
            else
            {
                int top = fatherCtrHeight / 2 + Space / 2;
                return top + (fatherCtrHeight - top) / 2 - ctrHeight / 2;
            }
        }
 
        #endregion
 
        #region ■ 计算图片真实大小___________________
 
        /// <summary>
        /// 计算图片的真实高宽度
        /// </summary>
        /// <param name="i_size"></param>
        /// <returns></returns>
        public int GetPictrueRealSize(int i_size)
        {
            return Application.GetRealWidth(i_size);
        }
 
        #endregion
    }
}