using System; using Com.Hdl.Widget; namespace Shared { /// /// HDLWaveSeekBar 波浪滑动控件 /// public class WaveSeekBar : BaseSeekBar { /// /// 当前视图 /// /// The HDLWaveSeekBar. HDLWaveSeekBar mHDLWaveSeekBar { get { return AndroidView as HDLWaveSeekBar; } set { AndroidView = value; } } /// /// 构造函数 /// public WaveSeekBar() { mHDLWaveSeekBar = new HDLWaveSeekBar(Application.Activity); mOnProgressChangeListener = new OnProgressChangeListener(this); mHDLWaveSeekBar.SetOnProgressChangeListener(mOnProgressChangeListener); } /// /// 进度值显示单位 /// /// 单位字符 public String ProgressBarUnitSring { set { mHDLWaveSeekBar.SetProgressBarUnitSring(value); } } /// /// 进度值最大值 /// /// 最大值 public int MaxValue { set { mHDLWaveSeekBar.SetMaxValue(value); } } /// /// 进度值最小值 /// /// 最小值 public int MinValue { set { mHDLWaveSeekBar.SetMinValue(value); } } /// /// 当前进度值 /// /// 进度值 public int Progress { set { mHDLWaveSeekBar.Progress = value; } get { return mHDLWaveSeekBar.Progress; } } /// /// 当前进度值显示的文字颜色 /// /// 文字颜色 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); mHDLWaveSeekBar.SetProgressTextColor(Android.Graphics.Color.Argb(a, r, g, b)); } } /// /// 当前进度值显示的文字大小 /// /// 文字大小 public int ProgressTextSize { set => mHDLWaveSeekBar.SetProgressTextSize(value); } /// /// 是否可以滑动 /// /// 是否可以滑动 public bool IsClickable { set { mHDLWaveSeekBar.SetIsClickable(value); } } /// /// 是否可以滑动 /// /// 是否可以滑动 public bool IsProgressTextShow { set { mHDLWaveSeekBar.SetProgressTextShow(value); } } /// /// 背景边框宽度 /// /// 半径 public int WaveBorderWidth { set { mHDLWaveSeekBar.SetBorderWidth(value); } } /// /// 圆角 /// /// 圆角 public int CornerRadius { set { mHDLWaveSeekBar.SetCornerRadius(value); } } ///// ///// 波浪进度颜色 ///// ///// 波浪进度颜色 //public uint WaveColor //{ // 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); // mHDLWaveSeekBar.SetWaveColor(Android.Graphics.Color.Argb(a, r, g, b)); // mHDLWaveSeekBar.PostInvalidate(); // } //} /// /// 设置进度条 渐变颜色的开始颜色和结束颜色 /// /// 开始颜色、结束颜色 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 }; mHDLWaveSeekBar.SetProgressBarColors(mArcColors); mHDLWaveSeekBar.PostInvalidate(); } /// /// 背景边框颜色 /// /// 背景边框颜色 public uint WaveBorderColor { 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); mHDLWaveSeekBar.SetWaveBorderColor(Android.Graphics.Color.Argb(a, r, g, b)); mHDLWaveSeekBar.PostInvalidate(); } } /// /// 进度条与边框边距 /// /// 半径 public int WavePadding { set { mHDLWaveSeekBar.SetWavePadding(value); } } /// /// 当前进度值 Y坐标 /// /// Y坐标 public int NowProgressY { get { return (int)mHDLWaveSeekBar.ProgressY; } } ////默认 300毫秒 //private int DelayTime = 300; ////上一次Change时间 //DateTime delayDateTime = DateTime.MinValue; //public int ProgressChangeDelayTime //{ // get // { // return DelayTime; // } // set // { // DelayTime = value; // } //} ///// ///// 判断是否屏蔽 ///// //public bool IsProgressChangeDelay() //{ // if ((DateTime.Now - delayDateTime).TotalMilliseconds < DelayTime) // { // return true; // } // delayDateTime = DateTime.Now; // return false; //} //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); // mHDLWaveSeekBar.SetThumbColor(Android.Graphics.Color.Argb(a, r, g, b)); // } //} /// /// EventHandler /// public EventHandler OnProgressChangedEvent; public EventHandler OnStartTrackingTouchEvent; public EventHandler OnStopTrackingTouchEvent; /// /// OnProgressChangeListener 继承响应事件 /// OnProgressChangeListener mOnProgressChangeListener; public class OnProgressChangeListener : Java.Lang.Object, HDLWaveSeekBar.IOnProgressChangeListener { WaveSeekBar _WaveSeekBar; public OnProgressChangeListener(WaveSeekBar view) { _WaveSeekBar = view; } public void OnProgressChanged(HDLWaveSeekBar p0, int p1, bool p2) { //if (_WaveSeekBar.IsProgressChangeDelay()) return; _WaveSeekBar.OnProgressChangedEvent?.Invoke(this, p0.Progress); } public void OnStartTrackingTouch(HDLWaveSeekBar p0) { _WaveSeekBar.OnStartTrackingTouchEvent?.Invoke(this, true); } public void OnStopTrackingTouch(HDLWaveSeekBar p0) { _WaveSeekBar.OnProgressChangedEvent?.Invoke(this, p0.Progress); _WaveSeekBar.OnStopTrackingTouchEvent?.Invoke(this, p0.Progress); } } } }