wxr
2022-12-12 e1c35ade69cb253e8780dbedb4d244530fc88725
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.IO;
using Shared.Net;
using System.Text;
using System.Collections.Generic;
// <summary>
// 程序主入口
// </summary>
//using SystemConfiguration;
using System.Net;
using System.IO;
using Shared.SimpleControl.Phone;
namespace Shared.SimpleControl
{
    /// <summary>
    /// 主页面
    /// </summary>
    public static class MainPage
    {
        /// <summary>
        /// 主页面,根界面
        /// </summary>
        public static FrameLayout MainFrameLayout { get; internal set; }
        public static bool Showed;
 
        static Loading loading;
        /// <summary>
        /// 显示加载界面
        /// </summary>
        public static Loading Loading {
            get {
                if (loading == null) {
                    loading = new Loading ();
                }
                return loading;
            }
        } 
 
        /// <summary>
        /// 显示当前界面
        /// </summary>
        public static void Show ()
        {
            try {
                Showed = true;
                if (Shared.Application.IsPad) {
                    Application.DesignWidth = 2048;
                    Application.DesignHeight = 1536;
                } else {
                    Application.DesignWidth = 640;
                    Application.DesignHeight = 1136;
                }
                Shared.BusSocket.Start (6000);
                CommonPage.InitReceiveEvent ();
 
                MainFrameLayout = Application.MainPage;
                MainFrameLayout.AddChidren (Loading);
                if (Shared.Application.IsPad) {
                } else {
 
                    var addGatewayDialog = new SystemHomePage ();
                    MainFrameLayout.BackgroundColor = 0xFFF2F3F4;
                    MainFrameLayout.AddChidren (addGatewayDialog);
                    addGatewayDialog.Init ();
 
 
                    Loading.TextColor = 0xFFA9A9A9;
                    Loading.LodingBackgroundColor = SkinStyle.Current.MainColor;
                }
            } catch (Exception ex) {
                Console.WriteLine ("Hdl Error :"+ex.Message);
            }
        }
 
 
        /// <summary>
        /// 增加rjfi
        /// </summary>
        /// <param name="tip">Tip.</param>
        /// <param name="time">Time.</param>
        public static void AddTip (string tip, int time = 2000)
        {
            if (MainFrameLayout == null) {
                return;
            }
            Application.RunOnMainThread (() => {
                var button = new TextView {
                    Gravity = Gravity.Center,
                    Width = Application.GetRealWidth (560),
                    Height = Application.GetRealHeight (126),
                    BackgroundColor = SkinStyle.Current.AddTipButtonColor,
                    Radius = 10,
                    IsMoreLines = true,
                    Text = tip,
                    TextSize = 16,
                };
                MainFrameLayout.AddChidren (button);
                button.MouseUpEventHandler += (sender, e) => {
                    button.RemoveFromParent ();
                };
                System.Threading.Tasks.Task.Run (() => {
                    System.Threading.Thread.Sleep (time);
                    Application.RunOnMainThread (() => {
                        button.RemoveFromParent ();
                    });
                });
            });
        }
 
        static DateTime requesTime = DateTime.MinValue;
        static bool isShowLoading = true;
      
 
        public static void LoadingStart (string showString = "")
        {
            Application.RunOnMainThread (() => {
                MainPage.Loading.Start (showString);
            });
        }
 
        public static void LoadingHide ()
        {
            Application.RunOnMainThread (() => {
                MainPage.Loading.Hide ();
            });
        }
    }
}