using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UIKit;
using Foundation;
using Shared.IO;
using CoreGraphics;
namespace Shared
{
///
/// Button 按键
///
public class DateView : View
{
MyUIDatePicker myUIDatePicker
{
get
{
return uiView as MyUIDatePicker;
}
set
{
uiView = value;
}
}
///
/// 年
///
public int Year
{
get
{
return (int)myUIDatePicker.current.Year;
}
}
///
/// 月
///
public int Month
{
get { return (int)myUIDatePicker.current.Month; }
}
///
/// 天
///
public int Day
{
get { return (int)myUIDatePicker.current.Day; }
}
///
/// Initializes a new instance of the class.
///
public DateView()
{
myUIDatePicker = new MyUIDatePicker(this) { };
}
class MyUIDatePicker : UIDatePicker
{
[Weak] DateView dateView;
public MyUIDatePicker(DateView dateView)
{
this.dateView = dateView;
Mode = UIDatePickerMode.Date;
}
///
/// 点击开始
///
/// Touches.
/// Evt.
public override void TouchesBegan(NSSet touches, UIEvent evt)
{
dateView?.TouchEvent(EventActions.Down, (touches.AnyObject as UITouch).LocationInView(this));
}
///
/// 移动
///
/// Touches.
/// Evt.
public override void TouchesMoved(NSSet touches, UIEvent evt)
{
dateView?.TouchEvent(EventActions.Move, (touches.AnyObject as UITouch).LocationInView(this));
}
///
/// 点击弹起
///
/// Touches.
/// Evt.
public override void TouchesEnded(NSSet touches, UIEvent evt)
{
dateView?.TouchEvent(EventActions.Up, (touches.AnyObject as UITouch).LocationInView(this));
}
public override void TouchesCancelled(NSSet touches, UIEvent evt)
{
dateView?.TouchEvent(EventActions.Cancel, (touches.AnyObject as UITouch).LocationInView(this));
}
///
/// 当前时间对象
///
/// The current.
public NSDateComponents current
{
get
{
NSCalendar cal = NSCalendar.CurrentCalendar;
return cal.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, Date);// [cal components: unitFlags fromDate: now]
}
}
}
}
}