using System; using Android.Runtime; using Android.Views; using Com.Hdl.Widget; namespace Shared { /// /// HDLArcSeekBar 圆弧滑动控件 /// public class ArcSeekBar : View { /// /// 当前视图 /// /// The HDLArcSeekBar. HDLArcSeekBar mHDLArcSeekBar { get { return AndroidView as HDLArcSeekBar; } set { AndroidView = value; } } /// /// 构造函数 /// public ArcSeekBar() { mHDLArcSeekBar = new HDLArcSeekBar(Application.Activity); mOnProgressChangeListener = new OnProgressChangeListener(this); mHDLArcSeekBar.SetOnProgressChangeListener(mOnProgressChangeListener); } //internal static ProgressChangeListener:Com.Hdl.Widget.HDLArcSeekBar.IOnProgressChangeListener(){ //} /// /// 进度值显示单位 /// /// 单位字符 public String ProgressBarUnitSring { set { mHDLArcSeekBar.SetProgressBarUnitSring(value); } } /// /// 进度值最大值 /// /// 最大值 public int MaxValue { set { mHDLArcSeekBar.SetMaxValue(value); } } /// /// 进度值最小值 /// /// 最小值 public int MinValue { set { mHDLArcSeekBar.SetMinValue(value); } } /// /// 当前进度值 /// /// 进度值 public int Progress { set { mHDLArcSeekBar.Progress = value; } get { return mHDLArcSeekBar.Progress; } } /// /// 同时设置圆弧和拖动圆形的宽 /// /// public int ArcWidthWithDefaultStyle { set { mHDLArcSeekBar.SetArcWidthDefaultStyle(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)); } } /// /// 进度条颜色 单一颜色不渐变 /// /// 单一进度条颜色 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; /// /// 拖动按钮圆形颜色 /// /// 拖动按钮颜色 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)); } } /// /// 拖动按钮默认形状 填满实心或者空心 /// /// 是否填满 public bool ThumbModeFill { set { if (value) { mHDLArcSeekBar.SetThumbMode(Com.Hdl.Widget.HDLArcSeekBar.ThumbModeFill); } else { mHDLArcSeekBar.SetThumbMode(Com.Hdl.Widget.HDLArcSeekBar.ThumbModeStroke); } } } /// /// 拖动按钮圆形半径 /// /// 半径 public int ThumbRadius { set { mHDLArcSeekBar.SetThumbRadius(value); } } /// /// 圆弧宽 /// /// public int ArcWidth { set { mHDLArcSeekBar.SetArcWidth(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)); } } /// /// 当前进度值显示的文字大小 /// /// 文字大小 public int ProgressTextSize { set => mHDLArcSeekBar.SetProgressTextSize(value); } /// /// 是否可以滑动 /// /// 是否可以滑动 public bool IsClickable { set { mHDLArcSeekBar.SetIsClickable(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 int OpenAngle { set { mHDLArcSeekBar.SetOpenAngle(value); } } //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); //} /// /// EventHandler /// public EventHandler OnProgressChangedEvent; public EventHandler OnStartTrackingTouchEvent; public EventHandler OnStopTrackingTouchEvent; /// /// OnProgressChangeListener 继承响应事件 /// 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); } } } }