using System; using Foundation; using Shared.IO; using UIKit; namespace Shared { /// /// ImageView /// public class ImageView : View { MyImageView myImageView { get { return uiView as MyImageView; } set { uiView = value; } } /// /// Initializes a new instance of the class. /// public ImageView() { myImageView = new MyImageView(this); } internal string imagePath, tempImagePath; /// /// 非选中状态的背景图路径 /// /// The un selected image path. public string ImagePath { get { return imagePath; } set { tempImagePath = value; if (!IsCanRefresh || ImagePath == value) { return; } imagePath = value; myImageView.SetBackgroundImage(UIImage.FromFile(FileUtils.GetImageFilePath(imagePath)), UIControlState.Normal); } } public override void Refresh() { base.Refresh(); ImagePath = tempImagePath; } } class MyImageView : UIKit.UIButton { View _view; public MyImageView(View view) { _view = view; } /// /// 点击开始 /// /// Touches. /// Evt. public override void TouchesBegan(NSSet touches, UIEvent evt) { //base.TouchesBegan(touches, evt); UITouch touch = touches.AnyObject as UITouch; _view.TouchEvent(EventActions.Down, touch.LocationInView(this)); } /// /// 移动 /// /// Touches. /// Evt. public override void TouchesMoved(NSSet touches, UIEvent evt) { //base.TouchesMoved(touches, evt); UITouch touch = touches.AnyObject as UITouch; _view.TouchEvent(EventActions.Move, touch.LocationInView(this)); } /// /// 点击弹起 /// /// Touches. /// Evt. public override void TouchesEnded(NSSet touches, UIEvent evt) { //base.TouchesEnded(touches, evt); UITouch touch = touches.AnyObject as UITouch; _view.TouchEvent(EventActions.Up, touch.LocationInView(this)); } } }