using System; using System.Collections.Generic; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON { public static class MainPage { public static FrameLayout BaseView { get; internal set; } public static PageLayout BasePageView { get; set; } public static bool DisplayCompleted = false; public static UserInfo LoginUser; public static List LocationFiles; public static string VersionString = "1.0103"; /// /// 公司代码 /// 预留第三方定制标记 /// 0:HDL /// public static int Company = 0; public static void Show() { try { Application.DesignWidth = 375; Application.DesignHeight = 667; //BusSocket.Start(6000); //CommonPage.InitHttpListener(); BaseView = Application.MainPage; Application.MainPage.BackgroundColor = CSS_Color.MainBackgroundColor; LoginUser = Newtonsoft.Json.JsonConvert.DeserializeObject(System.Text.Encoding.UTF8.GetString(MyIO.FileUtils.ReadFile("Register_File"))); //判断需不需要登录,有没有登录,或者登录是否过期, if (LoginUser == null || !LoginUser.IsLogin) { GoLoginPage(); } else { GoUserPage(); } } catch (Exception ex) { MainPage.Log("root erorr : " + ex.Message); } } /// /// 进入登录界面 /// public static void GoLoginPage(string account ="") { BaseView.RemoveAll(); var fisrtView = new UI.UI1Login.LoginPage(); fisrtView.BackgroundColor = CSS_Color.MainBackgroundColor; BaseView.AddChidren(fisrtView); fisrtView.LoadView(account); } /// /// 进入主页 /// public static void GoUserPage() { BaseView.RemoveAll(); BasePageView = new PageLayout(); BaseView.AddChidren(BasePageView); //跳转页面---- var userPage = new UI.UserPage(); BasePageView.AddChidren(userPage); userPage.LoadPage(); BasePageView.PageChange += (sender, e) => { while (e < BasePageView.ChildrenCount - 1) { BasePageView.GetChildren(BasePageView.ChildrenCount - 1).RemoveFromParent(); } }; } /// /// 自定义日志输出 /// public static void Log(string msg) { #if DEBUG Console.WriteLine(msg); #endif } } }