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