JLChen
2021-01-06 f60ce72c3c29c7d31a046795c88ec39a69e73d45
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
using System;
using Shared.SimpleControl;
using Shared.SimpleControl.Phone;
 
namespace Shared
{
    public class Utlis
    {
 
        ///// <summary>
        ///// 将int数值转换为占四个字节的byte数组
        ///// </summary>
        ///// <param name="value"></param>
        ///// <returns></returns>
        //public static byte [] IntToByteArray (int i)
        //{
        //    byte [] result = new byte [4];
        //    // 由高位到低位  
        //    result [0] = (byte)((i >> 24) & 0xFF);
        //    result [1] = (byte)((i >> 16) & 0xFF);
        //    result [2] = (byte)((i >> 8) & 0xFF);
        //    result [3] = (byte)(i & 0xFF);
        //    return result;
        //}
 
        ///// <summary>
        ///// byte[]转int 
        ///// </summary>
        ///// <param name="bytes"></param>
        ///// <returns></returns>
        //public static int ByteArrayToInt (byte [] bytes)
        //{
        //    int value = 0;
        //    // 由高位到低位  
        //    for (int i = 0; i < 4; i++) {
        //        int shift = (4 - 1 - i) * 8;
        //        value += (bytes [i] & 0x000000FF) << shift;// 往高位游  
        //    }
        //    return value;
        //}
 
        /// <summary>
        /// 全局打印
        /// </summary>
        public static void WriteLine (object mes)
        {
#if DEBUG
            System.Console.WriteLine (mes);
#endif
        }
 
        public static int StringToInt (string mStr) {
            try {
                return int.Parse (mStr);
            } catch {
                return 0;
            }
        }
 
        public static void ShowAppLinkStatus (AppLinkStatus mStatus) {
 
            switch (mStatus) {
            case AppLinkStatus.CloudLink:
                MainPage.WiFiStatus = "CrabtreeAdd/CloudLink.png";
                break;
            case AppLinkStatus.CloudUnlink:
                MainPage.WiFiStatus = "CrabtreeAdd/CloudUnlink.png";
                break;
            case AppLinkStatus.CloudOffline:
                MainPage.WiFiStatus = "CrabtreeAdd/CloudOffline.png";
                break;
            case AppLinkStatus.WiFi:
                MainPage.WiFiStatus = "CrabtreeAdd/WiFi.png";
                break;
            case AppLinkStatus.WiFiUnlink:
                MainPage.WiFiStatus = "CrabtreeAdd/WiFiUnlink.png";
                break;
            case AppLinkStatus.WiFiOffline:
                MainPage.WiFiStatus = "CrabtreeAdd/WiFiOffline.png";
                break;
            default:
 
 
                break;
            }
            
            Shared.Application.RunOnMainThread (() => {
                UserMiddle.btnLinkStatus.UnSelectedImagePath = MainPage.WiFiStatus;
            });
            
        }
 
        /// <summary>
        /// 获取请求提交的语言参数
        /// </summary>
        public static string GetPostLanguageType ()
        {
            //L1APP默认英语
            return LanguageTypeEnum.ENGLISH.ToString (); 
            //return Language.CurrentLanguage == "Chinese" ? LanguageTypeEnum.CHINESE.ToString () : LanguageTypeEnum.ENGLISH.ToString ();
        }
 
        /// <summary>
        /// 弹窗提示
        /// </summary>
        /// <param name="mes"></param>
        public static void ShowAlertOnMainThread (string mes)
        {
            Application.RunOnMainThread (() => {
                new Alert ("", mes, Language.StringByID (SimpleControl.R.MyInternationalizationString.Close)).Show ();
            });
        }
 
        /// <summary>
        /// ShowTip
        /// </summary>
        /// <param name="mes"></param>
        /// <param name="closeTime">关闭时间</param>
        public static void ShowTip (string mes, int closeTime = 2)
        {
            var tip = new Tip () {
                Text = mes,
                CloseTime = closeTime,
                Direction = AMPopTipDirection.None
            };
            tip.Show (MainPage.MainFrameLayout);
        }
    }
}