using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreGraphics;
using Foundation;
using UIKit;
namespace Shared
{
///
/// 时间视图
///
public class TimeView : View
{
///
/// 当前视图
///
/// The android text.
MyUITimePicker currentUITimePicker
{
get
{
return uiView as MyUITimePicker;
}
set
{
uiView = value;
}
}
///
/// 时
///
public int Hour
{
get { return (int)currentUITimePicker.current.Hour; }
}
///
/// 分
///
public int Minute
{
get { return (int)currentUITimePicker.current.Minute; }
}
///
/// 视图
///
public TimeView()
{
currentUITimePicker = new MyUITimePicker(this) { };
}
class MyUITimePicker : UIDatePicker
{
[Weak] TimeView timeView;
public MyUITimePicker(TimeView timeView)
{
this.timeView = timeView;
Mode = UIDatePickerMode.Time;
}
nfloat x;
///
/// 点击开始
///
/// Touches.
/// Evt.
public override void TouchesBegan(NSSet touches, UIEvent evt)
{
timeView?.TouchEvent(EventActions.Down, (touches.AnyObject as UITouch).LocationInView(this));
}
///
/// 移动
///
/// Touches.
/// Evt.
public override void TouchesMoved(NSSet touches, UIEvent evt)
{
timeView?.TouchEvent(EventActions.Move, (touches.AnyObject as UITouch).LocationInView(this));
}
///
/// 点击弹起
///
/// Touches.
/// Evt.
public override void TouchesEnded(NSSet touches, UIEvent evt)
{
timeView?.TouchEvent(EventActions.Up, (touches.AnyObject as UITouch).LocationInView(this));
}
public override void TouchesCancelled(NSSet touches, UIEvent evt)
{
timeView?.TouchEvent(EventActions.Cancel, (touches.AnyObject as UITouch).LocationInView(this));
}
public NSDateComponents current
{
get
{
NSCalendar cal = NSCalendar.CurrentCalendar;
return cal.Components(NSCalendarUnit.Hour | NSCalendarUnit.Minute | NSCalendarUnit.Second, Date);// [cal components: unitFlags fromDate: now
}
}
}
}
}