| | |
| | | |
| | | namespace HDL_ON.Entity |
| | | { |
| | | public class CommonMethod |
| | | { |
| | | private Loading loading; |
| | | |
| | | private static CommonMethod commonMethod = null; |
| | | /// <summary> |
| | | /// 获取对象 |
| | | /// </summary> |
| | | public static CommonMethod Current |
| | | { |
| | | get |
| | | { |
| | | if (commonMethod == null) |
| | | { |
| | | commonMethod = new CommonMethod(); |
| | | } |
| | | |
| | | return commonMethod; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取Loading对象 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Loading Loading |
| | | { |
| | | get |
| | | { |
| | | this.MainThread(() => |
| | | { |
| | | if (loading == null)//|| MainPage.BasePageView.ChildrenCount < 1) |
| | | { |
| | | loading = new Loading(); |
| | | } |
| | | Application.MainPage.AddChidren(loading); |
| | | }); |
| | | return loading; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | #region ---------自定义线程(子线程,主线程)-------- |
| | | /// <summary> |
| | | /// 子线程 |
| | | /// </summary> |
| | | /// <paramref name="tipType"/>是否要提示错误信息(默认显示)<paramref> |
| | | /// <param name="action"></param> |
| | | public void SunThread(Action action, TipType tipType = TipType.confirmation) |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | action?.Invoke(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | this.ShowAlert(e, tipType); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 主线程(UI更新) |
| | | /// </summary> |
| | | /// <paramref name="tipType"/>是否要提示错误信息(默认显示)<paramref> |
| | | /// <param name="action"></param> |
| | | public void MainThread(Action action, TipType tipType = TipType.confirmation) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | action?.Invoke(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | this.ShowAlert(e, tipType); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | #endregion |
| | | #region --------- 提示框,确认框 -------- |
| | | /// <summary> |
| | | /// 对话框(只要程序报错的时候才用到) |
| | | /// </summary> |
| | | /// <paramref name="e"/>异常对象<paramref> |
| | | /// <paramref name="tipType"/>是否要提示错误信息(默认显示)<paramref> |
| | | private void ShowAlert(Exception e, TipType tipType) |
| | | { |
| | | |
| | | |
| | | } |
| | | |
| | | public void ShowTip(string msg,int time = 2) |
| | | { |
| | | new UI.PublicAssmebly().TipMsgAutoClose(msg, false, time); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 弹框类型 |