using Shared; using System; using System.Collections.Generic; using System.Text; namespace HDL_ON.Stan { /// /// 进度条(圆形) /// public class ProgressBar { /// /// 最大值 /// private static decimal Max = 100; /// /// 当前值 /// private static decimal m_value = 0; /// /// 附加文本 /// private static string appendText = string.Empty; /// /// 转圈的控件 /// private static Loading waitPage = null; /// /// 显示进度条 /// /// 初始文本 public static void Show(string text = "") { m_value = 0; HdlThreadLogic.Current.RunMain(() => { if (waitPage == null) { //取当前最顶层的界面 var frame = MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1) as FrameLayout; if (frame != null) { //加载Loading效果 waitPage = new Loading(); frame.AddChidren(waitPage); waitPage.Start(text); } } }, ShowErrorMode.NO); } /// /// 隐藏进度条 /// public static void Close() { m_value = 0; Max = 0; HdlThreadLogic.Current.RunMain(() => { if (waitPage != null) { waitPage.RemoveFromParent(); waitPage = null; } }, ShowErrorMode.NO); } /// /// 进度值设定(数字) /// /// Value. public static void SetValue(decimal value) { m_value += value; int value2 = (int)((m_value / Max) * 100); if (value2 > 100) { value2 = 100; } SetValue(value2.ToString() + "%"); } /// /// 进度值设定 /// /// Value. /// 附加值 public static void SetValue(decimal value, string text) { m_value += value; int value2 = (int)((m_value / Max) * 100); if (value2 > 100) { value2 = 100; } SetValue(value2.ToString() + "% " + text); } /// /// 进度值设定(文本) /// /// Text. public static void SetValue(string text) { HdlThreadLogic.Current.RunMain(() => { waitPage.Text = text + appendText; }, ShowErrorMode.NO); } /// /// 设定进度值最大的值(分母) /// /// 设定进度值最大的值(分母) public static void SetMaxValue(decimal maxValue) { Max = maxValue; } /// /// 在进度条里面附加自定义文本 /// /// public static void SetAppendText(string i_text) { appendText = i_text; if (appendText != string.Empty) { //多加一个空格 appendText = " " + appendText; } } } }