using Shared;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace HDL_ON.Stan
|
{
|
/// <summary>
|
/// 进度条(圆形)
|
/// </summary>
|
public class ProgressBar
|
{
|
/// <summary>
|
/// 最大值
|
/// </summary>
|
private static decimal Max = 100;
|
/// <summary>
|
/// 当前值
|
/// </summary>
|
private static decimal m_value = 0;
|
/// <summary>
|
/// 附加文本
|
/// </summary>
|
private static string appendText = string.Empty;
|
/// <summary>
|
/// 转圈的控件
|
/// </summary>
|
private static Loading waitPage = null;
|
|
/// <summary>
|
/// 显示进度条
|
/// </summary>
|
/// <param name="text">初始文本</param>
|
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);
|
}
|
|
/// <summary>
|
/// 隐藏进度条
|
/// </summary>
|
public static void Close()
|
{
|
m_value = 0;
|
Max = 0;
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
if (waitPage != null)
|
{
|
waitPage.RemoveFromParent();
|
waitPage = null;
|
}
|
}, ShowErrorMode.NO);
|
}
|
|
/// <summary>
|
/// 进度值设定(数字)
|
/// </summary>
|
/// <param name="value">Value.</param>
|
public static void SetValue(decimal value)
|
{
|
m_value += value;
|
int value2 = (int)((m_value / Max) * 100);
|
if (value2 > 100)
|
{
|
value2 = 100;
|
}
|
|
SetValue(value2.ToString() + "%");
|
}
|
|
/// <summary>
|
/// 进度值设定
|
/// </summary>
|
/// <param name="value">Value.</param>
|
/// <param name="text">附加值</param>
|
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);
|
}
|
|
/// <summary>
|
/// 进度值设定(文本)
|
/// </summary>
|
/// <param name="text">Text.</param>
|
public static void SetValue(string text)
|
{
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
waitPage.Text = text + appendText;
|
}, ShowErrorMode.NO);
|
}
|
|
/// <summary>
|
/// 设定进度值最大的值(分母)
|
/// </summary>
|
/// <param name="maxValue">设定进度值最大的值(分母)</param>
|
public static void SetMaxValue(decimal maxValue)
|
{
|
Max = maxValue;
|
}
|
|
/// <summary>
|
/// 在进度条里面附加自定义文本
|
/// </summary>
|
/// <param name="i_text"></param>
|
public static void SetAppendText(string i_text)
|
{
|
appendText = i_text;
|
if (appendText != string.Empty)
|
{
|
//多加一个空格
|
appendText = " " + appendText;
|
}
|
}
|
}
|
}
|