using System;
|
using Android.Runtime;
|
using Android.Views;
|
using Com.Hdl.Widget;
|
|
namespace Shared
|
{
|
|
/// <summary>
|
/// HDLArcSeekBar 圆弧滑动控件
|
/// </summary>
|
public class ArcSeekBar : View
|
{
|
/// <summary>
|
/// 当前视图
|
/// </summary>
|
/// <value>The HDLArcSeekBar.</value>
|
HDLArcSeekBar mHDLArcSeekBar
|
{
|
get
|
{
|
return AndroidView as HDLArcSeekBar;
|
}
|
set
|
{
|
AndroidView = value;
|
}
|
}
|
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
public ArcSeekBar()
|
{
|
mHDLArcSeekBar = new HDLArcSeekBar(Application.Activity);
|
mOnProgressChangeListener = new OnProgressChangeListener(this);
|
mHDLArcSeekBar.SetOnProgressChangeListener(mOnProgressChangeListener);
|
}
|
|
//internal static ProgressChangeListener:Com.Hdl.Widget.HDLArcSeekBar.IOnProgressChangeListener(){
|
|
|
//}
|
|
/// <summary>
|
/// 进度值显示单位
|
/// </summary>
|
/// <value>单位字符</value>
|
public String ProgressBarUnitSring
|
{
|
set
|
{
|
mHDLArcSeekBar.SetProgressBarUnitSring(value);
|
}
|
}
|
|
/// <summary>
|
/// 进度值最大值
|
/// </summary>
|
/// <value>最大值</value>
|
public int MaxValue
|
{
|
set
|
{
|
mHDLArcSeekBar.SetMaxValue(value);
|
}
|
}
|
|
/// <summary>
|
/// 进度值最小值
|
/// </summary>
|
/// <value>最小值</value>
|
public int MinValue
|
{
|
set
|
{
|
mHDLArcSeekBar.SetMinValue(value);
|
}
|
}
|
|
/// <summary>
|
/// 当前进度值
|
/// </summary>
|
/// <value>进度值</value>
|
public int Progress
|
{
|
set
|
{
|
mHDLArcSeekBar.Progress = value;
|
}
|
|
get
|
{
|
|
return mHDLArcSeekBar.Progress;
|
}
|
}
|
|
/// <summary>
|
/// 同时设置圆弧和拖动圆形的宽
|
/// </summary>
|
/// <value>宽</value>
|
public int ArcWidthWithDefaultStyle
|
{
|
set
|
{
|
mHDLArcSeekBar.SetArcWidthDefaultStyle(value);
|
}
|
}
|
|
/// <summary>
|
/// 圆弧默认背景颜色
|
/// </summary>
|
/// <value>背景颜色</value>
|
public uint ArcColor
|
{
|
set
|
{
|
byte r, g, b, a;
|
r = (byte)(value / 256 / 256 % 256);
|
g = (byte)(value / 256 % 256);
|
b = (byte)(value % 256);
|
a = (byte)(value / 256 / 256 / 256 % 256);
|
|
mHDLArcSeekBar.SetArcColor(Android.Graphics.Color.Argb(a, r, g, b));
|
}
|
}
|
|
/// <summary>
|
/// 进度条颜色 单一颜色不渐变
|
/// </summary>
|
/// <value>单一进度条颜色</value>
|
public uint ProgressBarColor
|
{
|
set
|
{
|
//mHDLArcSeekBar.SetProgressBarColor(value);
|
byte r, g, b, a;
|
r = (byte)(value / 256 / 256 % 256);
|
g = (byte)(value / 256 % 256);
|
b = (byte)(value % 256);
|
a = (byte)(value / 256 / 256 / 256 % 256);
|
|
mHDLArcSeekBar.SetProgressBarColor(Android.Graphics.Color.Argb(a, r, g, b));
|
}
|
|
}
|
|
|
uint thumbColor = 0xFFFFFFFF;
|
/// <summary>
|
/// 拖动按钮圆形颜色
|
/// </summary>
|
/// <value>拖动按钮颜色</value>
|
public uint ThumbColor
|
{
|
get
|
{
|
return thumbColor;
|
}
|
set
|
{
|
thumbColor = value;
|
|
byte r, g, b, a;
|
r = (byte)(thumbColor / 256 / 256 % 256);
|
g = (byte)(thumbColor / 256 % 256);
|
b = (byte)(thumbColor % 256);
|
a = (byte)(thumbColor / 256 / 256 / 256 % 256);
|
|
mHDLArcSeekBar.SetThumbColor(Android.Graphics.Color.Argb(a, r, g, b));
|
}
|
}
|
|
/// <summary>
|
/// 拖动按钮默认形状 填满实心或者空心
|
/// </summary>
|
/// <value>是否填满</value>
|
public bool ThumbModeFill
|
{
|
set
|
{
|
if (value)
|
{
|
mHDLArcSeekBar.SetThumbMode(Com.Hdl.Widget.HDLArcSeekBar.ThumbModeFill);
|
}
|
else
|
{
|
mHDLArcSeekBar.SetThumbMode(Com.Hdl.Widget.HDLArcSeekBar.ThumbModeStroke);
|
}
|
|
}
|
}
|
|
/// <summary>
|
/// 拖动按钮圆形半径
|
/// </summary>
|
/// <value>半径</value>
|
public int ThumbRadius
|
{
|
set
|
{
|
mHDLArcSeekBar.SetThumbRadius(value);
|
}
|
}
|
|
/// <summary>
|
/// 圆弧宽
|
/// </summary>
|
/// <value>宽</value>
|
public int ArcWidth
|
{
|
set
|
{
|
mHDLArcSeekBar.SetArcWidth(value);
|
}
|
}
|
|
/// <summary>
|
/// 当前进度值显示的文字颜色
|
/// </summary>
|
/// <value>文字颜色</value>
|
public uint ProgressTextColor
|
{
|
set
|
{
|
|
byte r, g, b, a;
|
r = (byte)(value / 256 / 256 % 256);
|
g = (byte)(value / 256 % 256);
|
b = (byte)(value % 256);
|
a = (byte)(value / 256 / 256 / 256 % 256);
|
|
mHDLArcSeekBar.SetProgressTextColor(Android.Graphics.Color.Argb(a, r, g, b));
|
|
}
|
}
|
|
/// <summary>
|
/// 当前进度值显示的文字大小
|
/// </summary>
|
/// <value>文字大小</value>
|
public int ProgressTextSize
|
{
|
set => mHDLArcSeekBar.SetProgressTextSize(value);
|
}
|
|
/// <summary>
|
/// 是否可以滑动
|
/// </summary>
|
/// <value>是否可以滑动</value>
|
public bool IsClickable
|
{
|
set
|
{
|
mHDLArcSeekBar.SetIsClickable(value);
|
}
|
}
|
|
/// <summary>
|
/// 设置进度条 渐变颜色的开始颜色和结束颜色
|
/// </summary>
|
/// <value>开始颜色、结束颜色</value>
|
public void SetProgressBarColors(uint startColor, uint endColor) {
|
byte r, g, b, a;
|
r = (byte)(startColor / 256 / 256 % 256);
|
g = (byte)(startColor / 256 % 256);
|
b = (byte)(startColor % 256);
|
a = (byte)(startColor / 256 / 256 / 256 % 256);
|
|
var start = Android.Graphics.Color.Argb(a, r, g, b);
|
|
|
byte r2, g2, b2, a2;
|
r2 = (byte)(endColor / 256 / 256 % 256);
|
g2 = (byte)(endColor / 256 % 256);
|
b2 = (byte)(endColor % 256);
|
a2 = (byte)(endColor / 256 / 256 / 256 % 256);
|
|
var end = Android.Graphics.Color.Argb(a2, r2, g2, b2);
|
|
int[] mArcColors = { start, end };
|
mHDLArcSeekBar.SetProgressBarColors(mArcColors);
|
|
}
|
|
//public void SetArcColors(uint startColor, uint endColor)
|
//{
|
// byte r, g, b, a;
|
// r = (byte)(startColor / 256 / 256 % 256);
|
// g = (byte)(startColor / 256 % 256);
|
// b = (byte)(startColor % 256);
|
// a = (byte)(startColor / 256 / 256 / 256 % 256);
|
|
// var start = Android.Graphics.Color.Argb(a, r, g, b);
|
|
|
// byte r2, g2, b2, a2;
|
// r2 = (byte)(endColor / 256 / 256 % 256);
|
// g2 = (byte)(endColor / 256 % 256);
|
// b2 = (byte)(endColor % 256);
|
// a2 = (byte)(endColor / 256 / 256 / 256 % 256);
|
|
// var end = Android.Graphics.Color.Argb(a2, r2, g2, b2);
|
|
// int[] mArcColors = { start, end, end };
|
// mHDLArcSeekBar.SetArcColors(mArcColors);
|
|
//}
|
|
|
|
/// <summary>
|
/// EventHandler
|
/// </summary>
|
public EventHandler<int> OnProgressChangedEvent;
|
public EventHandler<bool> OnStartTrackingTouchEvent;
|
public EventHandler<int> OnStopTrackingTouchEvent;
|
|
/// <summary>
|
/// OnProgressChangeListener 继承响应事件
|
/// </summary>
|
OnProgressChangeListener mOnProgressChangeListener;
|
|
public class OnProgressChangeListener : Java.Lang.Object, HDLArcSeekBar.IOnProgressChangeListener
|
{
|
|
ArcSeekBar _ArcSeekBar;
|
|
public OnProgressChangeListener(ArcSeekBar view)
|
{
|
_ArcSeekBar = view;
|
}
|
|
public void OnProgressChanged(HDLArcSeekBar p0, int p1, bool p2)
|
{
|
_ArcSeekBar.OnProgressChangedEvent?.Invoke(this, p0.Progress);
|
}
|
|
public void OnStartTrackingTouch(HDLArcSeekBar p0)
|
{
|
_ArcSeekBar.OnStartTrackingTouchEvent?.Invoke(this, true);
|
}
|
|
public void OnStopTrackingTouch(HDLArcSeekBar p0)
|
{
|
|
//if (_ArcSeekBar.OnStopTrackingTouchEvent != null)
|
//{
|
// _ArcSeekBar.OnStopTrackingTouchEvent(this, p0.Progress);
|
//}
|
_ArcSeekBar.OnStopTrackingTouchEvent?.Invoke(this, p0.Progress);
|
|
}
|
}
|
}
|
}
|