using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 界面类型的进度条控件 /// public class ProgressFormBar { #region ■ 变量声明___________________________ /// /// 界面类型的进度条控件 /// private static ProgressFormBar m_Current = null; /// /// 界面类型的进度条控件 /// public static ProgressFormBar Current { get { if (m_Current == null) { m_Current = new ProgressFormBar(); } return m_Current; } } /// /// 消息控件单击的事件 /// public Action MsgClickEvent = null; /// /// 界面关闭的事件 /// public Action CloseEvent = null; /// /// 容器控件 /// private FrameLayout bodyFrameLayout = null; /// /// 信息控件 /// private NormalViewControl btnText = null; /// /// 进度条控件 /// private ProgressRowBar btnProgressBar = null; /// /// 原来的滑动标识 /// private bool oldScrollEnabled = false; /// /// 原来的那个圆形进度条是否可见 /// private bool oldPrigressVisible = false; #endregion #region ■ 初始化_____________________________ /// /// 初始化进度条 /// private void InitProgressFormBar() { //安卓可以点击系统的返回键 this.oldScrollEnabled = UserView.HomePage.Instance.ScrollEnabled; UserView.HomePage.Instance.ScrollEnabled = false; Shared.Common.CommonPage.BackKeyCanClick = false; this.oldPrigressVisible = Common.CommonPage.Loading.Visible; if (oldPrigressVisible == true) { //圆形进度条临时关闭 Common.CommonPage.Loading.Hide(); } //容器 bodyFrameLayout = new FrameLayout(); bodyFrameLayout.BackgroundColor = UserCenterColor.Current.DialogBackColor; Common.CommonPage.Instance.AddChidren(bodyFrameLayout); var frameBack = new FrameLayout(); frameBack.Width = Application.GetRealWidth(674); frameBack.Height = Application.GetRealHeight(386); frameBack.BackgroundColor = UserCenterColor.Current.White; frameBack.Gravity = Gravity.CenterHorizontal; frameBack.Y = Application.GetRealHeight(683); frameBack.Radius = (uint)Application.GetRealHeight(17); bodyFrameLayout.AddChidren(frameBack); //进度显示文本 this.btnText = new NormalViewControl(frameBack.Width, Application.GetRealHeight(58), false); btnText.Y = Application.GetRealHeight(248); btnText.TextColor = UserCenterColor.Current.TextGrayColor1; btnText.TextAlignment = TextAlignment.Center; frameBack.AddChidren(btnText); btnText.ButtonClickEvent += (sender, e) => { this.MsgClickEvent?.Invoke(); }; //进度条 this.btnProgressBar = new ProgressRowBar(559, 29); btnProgressBar.Gravity = Gravity.CenterHorizontal; btnProgressBar.Y = Application.GetRealHeight(161); frameBack.AddChidren(btnProgressBar); btnProgressBar.StartMode1(true); } #endregion #region ■ 设置信息___________________________ /// /// 设置显示信息 /// /// public void SetMsg(string msg) { HdlThreadLogic.Current.RunMain(() => { btnText.Text = msg; }); } #endregion #region ■ 设置进度值_________________________ /// /// 设置进度值 /// /// 此值为百分比值(也就是小于或者等于1的) public void SetValue(decimal value) { this.btnProgressBar.SetValue(value); } /// /// 设置进度值 /// /// 进度值,内部会除以maxValue /// 最大值 public void SetValue(decimal value, decimal maxValue) { this.btnProgressBar.SetValue(value, maxValue); } #endregion #region ■ 开启进度条_________________________ /// /// 开启进度条 /// public void Start() { if (this.bodyFrameLayout == null) { HdlThreadLogic.Current.RunMain(() => { //初始化进度条 this.InitProgressFormBar(); }); } } #endregion #region ■ 关闭进度条_________________________ /// /// 关闭进度条 /// public void Close() { HdlThreadLogic.Current.RunMain(() => { if (this.oldScrollEnabled == true) { //如果它原来就是不可以滑动的话,不处理 UserView.HomePage.Instance.ScrollEnabled = true; } Shared.Common.CommonPage.BackKeyCanClick = true; if (this.oldPrigressVisible == true) { //如果原来的进度条是可见的话,还原回去 Common.CommonPage.Loading.Start(Common.CommonPage.Loading.Text); } bodyFrameLayout?.RemoveFromParent(); bodyFrameLayout = null; btnText = null; btnProgressBar = null; this.MsgClickEvent = null; //关闭事件 this.CloseEvent?.Invoke(); this.CloseEvent = null; }); } #endregion } }