xm
2019-07-16 b910cb79c9b5bcc204022a3cf9e6950f0a64dfbd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using Foundation;
using Shared.IO;
using UIKit;
 
namespace Shared
{
    /// <summary>
    /// ImageView 
    /// </summary>
    public class ImageView : View
    {
        MyImageView myImageView
        {
            get
            {
                return uiView as MyImageView;
            }
            set
            {
                uiView = value;
            }
        }
 
        /// <summary>
        /// Initializes a new instance of the <see cref="Shared.Button"/> class.
        /// </summary>
        public ImageView()
        {
            myImageView = new MyImageView(this);
        }
 
        internal string imagePath, tempImagePath;
        /// <summary>
        /// 非选中状态的背景图路径
        /// </summary>
        /// <value>The un selected image path.</value>
        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;
        }
 
        /// <summary>
        /// 点击开始
        /// </summary>
        /// <param name="touches">Touches.</param>
        /// <param name="evt">Evt.</param>
        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));
        }
        /// <summary>
        ///  移动
        /// </summary>
        /// <param name="touches">Touches.</param>
        /// <param name="evt">Evt.</param>
        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));
        }
 
        /// <summary>
        /// 点击弹起
        /// </summary>
        /// <param name="touches">Touches.</param>
        /// <param name="evt">Evt.</param>
        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));
        }
    }
}