using System; using System.Collections.Generic; using System.Linq; using System.Text; using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; using Android.Widget; using Android.Util; namespace Shared { /// /// ʱ¼äÊÓͼ /// public class TimeView : View { /// /// µ±Ç°ÊÓͼ /// /// The android text. internal AndroidTimePicker currentAndroidTimePicker { get { return this.AndroidView as AndroidTimePicker; } set { this.AndroidView = value; } } /// /// ʱ /// public int Hour { get { return currentAndroidTimePicker.CurrentHour.IntValue(); } set { currentAndroidTimePicker.CurrentHour = new Java.Lang.Integer(value); } } /// /// ·Ö /// public int Minute { get { return currentAndroidTimePicker.CurrentMinute.IntValue(); } set { currentAndroidTimePicker.CurrentMinute =new Java.Lang.Integer(value); } } /// /// ÊÓͼ /// public TimeView() { currentAndroidTimePicker = new AndroidTimePicker(Application.Activity); } internal class AndroidTimePicker : Android.Widget.TimePicker { #region public AndroidTimePicker(Context context) : base(context) { //SetTextColor(Android.Graphics.Color.White); //SetPadding(0, 0, 0, 0); //TextAlignment = Android.Views.TextAlignment.Center; } public AndroidTimePicker(Context context, IAttributeSet attrs) : base(context, attrs) { } protected AndroidTimePicker(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { } public AndroidTimePicker(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { } #endregion /// /// µã»÷µ¯Æðʼþ /// public Action MouseUPEventHandler; /// /// µã»÷°´ÏÂʼþ /// public Action MouseDownEventHandler; /// /// µã»÷ʼþ /// /// The touch event. /// E. public override bool OnTouchEvent(Android.Views.MotionEvent e) { if (e.Action == Android.Views.MotionEventActions.Down && MouseDownEventHandler != null) { MouseDownEventHandler(this, new MouseEventArgs { X = e.GetX(), Y = e.GetY() }); } else if (e.Action == Android.Views.MotionEventActions.Up && MouseUPEventHandler != null) { MouseUPEventHandler(this, new MouseEventArgs { X = e.GetX(), Y = e.GetY() }); } return base.OnTouchEvent(e); } /// /// ´óС±ä»¯Ê¼þ /// public Action SizeChangeEventHandler; /// /// λÖò¼¾Ö /// public override Android.Views.ViewGroup.LayoutParams LayoutParameters { get { return base.LayoutParameters; } set { var layoutParams = base.LayoutParameters; base.LayoutParameters = value; if (layoutParams == null || layoutParams.Width != value.Width || layoutParams.Height != value.Height) { SizeChangeEventHandler?.Invoke(this, new Size(LayoutParameters.Width, LayoutParameters.Height)); } } } } } }