wxr
2019-12-06 9aa32bd5ed75d54b2141b6c91f163d43216a3643
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
using System;
using System.Collections.Generic;
using CoreAnimation;
using CoreGraphics;
using UIKit;
 
//两个问题,第一个是RCU协议,第二个是WIFI过多  23个 
 namespace Shared{
 
    /// <summary>
    /// 根视图,所有视图的父视图
    /// </summary>
    class RootView : ViewGroup { }
    /// <summary>
    /// 所有类的基类,已经全面检查
    /// </summary>
    public abstract class View
    {
        ~View()
        {
#if DEBUG
            System.Console.WriteLine("=====" + GetType() + " " + Name);
#endif
            if (this is ViewGroup)
            {
                var viewGroup = this as ViewGroup;
                if (viewGroup.realViewGroup != RealView)
                {
                    foreach (var view in viewGroup.viewList)
                    {
                        view.RealView.Dispose();
                    }
                    viewGroup.realViewGroup?.Dispose();
                }
            }
 
            RealView?.Dispose();
        }
        
       
        /// <summary>
        /// 是否需要更新控件
        /// </summary>
        /// <value>The is need refresh.</value>
        protected bool IsCanRefresh
        {
            get
            {
                View tempView = Parent;
                while (tempView != null)
                {
                    //如果父视图是RootView,那说明视图已经加载完成,可以刷新视图
                    if (tempView.GetType() == typeof(RootView))
                    {
                        return true;
                    }
                    tempView = tempView.Parent;
                }
                return false;
            }
        }
 
 
        /// <summary>
        /// 当前对应的IOS控件
        /// </summary>
        protected UIView uiView;
 
        /// <summary>
        /// 内边距
        /// </summary>
        /// <value>The padding.</value>
        public virtual Padding Padding
        {
            get;
            set;
        }
 
        /// <summary>
        /// 是否使能
        /// </summary>
        /// <value><c>true</c> if enable; otherwise, <c>false</c>.</value>
        public virtual bool Enable
        {
            get;
            set;
        }
 
        int height=LayoutParams.MatchParent;
        /// <summary>
        /// 控件的高度
        /// </summary>
        /// <value>The height.</value>
        public virtual int Height
        {
            get
            {
                return IsCanRefresh ? (int)uiView.Frame.Height : height;
            }
            set
            {
 
                height = value;
 
                if (!IsCanRefresh)
                    return;
 
                var frame = uiView.Frame;
                var beforeValue = frame.Height;
                if (value == LayoutParams.MatchParent)
                {
                    frame.Height = Parent.Height;
                    uiView.Frame = frame;
                }
                else
                {
                    frame.Height = value;
                    uiView.Frame = frame;
                }
 
                if (frame.Height != beforeValue)
                {
                    SizeChangeEventHandler?.Invoke(this, new Size((int)frame.Width, (int)frame.Height));
                }
 
                //如果父视图是VerticalScrolViewLayout,那需要重新刷新排列
                if (Parent is VerticalScrolViewLayout)
                {
                    (Parent as VerticalScrolViewLayout).ReLocation();
                }
 
                if (Parent is VerticalRefreshLayout)
                {
                    (Parent as VerticalRefreshLayout).ReLocation();
                }
            }
        }
 
        int width = LayoutParams.MatchParent;
        /// <summary>
        /// 控件宽度
        /// </summary>
        /// <value>The width.</value>
        public virtual int Width
        {
            get
            {
                return IsCanRefresh ? (int)uiView.Frame.Width : width;
            }
            set
            {
                width = value;
 
                if (!IsCanRefresh)
                    return;
 
 
                var frame = uiView.Frame;
                var beforeValue = frame.Width;
                if (value == LayoutParams.MatchParent)
                {
                    frame.Width = Parent.Width;
                    uiView.Frame = frame;
                }
                else
                {
                    frame.Width = value;
                    uiView.Frame = frame;
                }
 
                if (frame.Width != beforeValue)
                {
                    SizeChangeEventHandler?.Invoke(this, new Size((int)frame.Width, (int)frame.Height));
                }
 
                //如果父视图是HorizontalScrolViewLayout,那需要重新刷新排列
                if (Parent is HorizontalScrolViewLayout)
                {
                    (Parent as HorizontalScrolViewLayout).ReLocation();
                }
 
            }
        }
 
        Gravity gravity = Gravity.Frame;
        /// <summary>
        /// 当前视图对齐方式
        /// </summary>
        /// <value>The gravity.</value>
        public Gravity Gravity
        {
            get
            {
                return gravity;
            }
            set
            {
                gravity = value;
                if (uiView.Superview == null)
                {
                    return;
                }
                switch (value)
                {
                    case Gravity.TopLeft:
                        X = 0;
                        Y = 0;
                        break;
                    case Gravity.TopCenter:
                        X = ((int)uiView.Superview.Frame.Width - Width) / 2;
                        Y = 0;
                        break;
                    case Gravity.TopRight:
                        X = (int)uiView.Superview.Frame.Width - Width;
                        Y = 0;
                        break;
                    case Gravity.CenterLeft:
                        X = 0;
                        Y = ((int)uiView.Superview.Frame.Height - Height) / 2;
                        break;
                    case Gravity.Center:
                        X = ((int)uiView.Superview.Frame.Width - Width) / 2;
                        Y = ((int)uiView.Superview.Frame.Height - Height) / 2;
                        break;
                    case Gravity.CenterRight:
                        X = (int)uiView.Superview.Frame.Width - Width;
                        Y = ((int)uiView.Superview.Frame.Height - Height) / 2;
                        break;
                    case Gravity.BottomLeft:
                        X = 0;
                        Y = (int)uiView.Superview.Frame.Height - Height;
                        break;
                    case Gravity.BottomCenter:
                        X = ((int)uiView.Superview.Frame.Width - Width) / 2;
                        Y = (int)uiView.Superview.Frame.Height - Height;
                        break;
                    case Gravity.BottomRight:
                        X = (int)uiView.Superview.Frame.Width - Width;
                        Y = (int)uiView.Superview.Frame.Height - Height;
                        break;
                    case Gravity.CenterVertical:
                        Y = ((int)uiView.Superview.Frame.Height - Height) / 2;
                        break;
                    case Gravity.CenterHorizontal:
                        X = ((int)uiView.Superview.Frame.Width - Width) / 2;
                        break;
                    default:
                        break;
                }
            }
        }
 
        /// <summary>
        /// 创新需要创新的信息
        /// </summary>
        public virtual void Refresh()
        {
            Width = width;
            Height = height;
            Gravity = gravity;
            Animate = animate;
            Radius = radius;
        }
 
        /// <summary>
        /// 左边线位置
        /// </summary>
        /// <value>The bottom.</value>
        public int Bottom
        {
            get
            {
                return Height + Y;
            }
        }
 
        /// <summary>
        ///  右边线位置
        /// </summary>
        /// <value>The right.</value>
        public int Right
        {
            get
            {
                return Width + X;
            }
        }
 
        /// <summary>
        /// 名称
        /// </summary>
        /// <value>The name.</value>
        public string Name { get; set; }
 
        int x;
        /// <summary>
        /// X轴坐标
        /// </summary>
        /// <value>The x.</value>
        public virtual int X
        {
            get
            {
                if (Parent != null && Parent is HorizontalScrolViewLayout)
                {
                    return (int)uiView.Frame.X;
                }
                else
                {
                    return x;
                }
            }
            set
            {
                x = value;
 
                //这个部局,不需要处理坐标
                if (Parent != null && Parent is HorizontalScrolViewLayout)
                {
                    return;
                }
                else
                {
                    var frame = uiView.Frame;
                    frame.X = value;
                    uiView.Frame = frame;
                }
            }
        }
 
        int y;
        /// <summary>
        /// Y轴坐标
        /// </summary>
        /// <value>The y.</value>
        public virtual int Y
        {
            get
            {
                if (Parent != null && (Parent is VerticalScrolViewLayout || Parent is VerticalRefreshLayout))
                {
                    return (int)uiView.Frame.Y;
                }
                else
                {
                    return y;
                }
            }
            set
            {
                y = value;
 
                //这个部局,不需要处理坐标
                if (Parent != null && (Parent is VerticalScrolViewLayout || Parent is VerticalRefreshLayout))
                {
                    return;
                }
                else {
                    var frame = uiView.Frame;
                    frame.Y = value;
                    uiView.Frame = frame;
                }
            }
        }
 
        /// <summary>
        /// 当前窗口大小及位置
        /// </summary>
        /// <value>The frame.</value>
        public virtual Size Size
        {
            get
            {
                return new Size(Width, Height);
            }
            set
            {
                Width = value.Width;
                Height = value.Height;
            }
        }
 
        /// <summary>
        /// 父容器
        /// </summary>
        /// <value>The parent.</value>
        public ViewGroup Parent;
        bool isUp;
        bool longClicked;
        System.Threading.Thread thread;
        /// <summary>
        /// 点击事件
        /// </summary>
        /// <returns>反馈当前事件是否已经处理</returns>
        /// <param name="e">事件</param>
        /// <param name="point">当前点击位置</param>
        internal virtual bool TouchEvent(EventActions eventAction, CGPoint point)
        {
            switch (eventAction)
            {
                case EventActions.Down:
                    isUp = false;
                    longClicked = false;
 
                    MouseDownEventHandler?.Invoke(this, new MouseEventArgs { X = (int)point.X, Y = (int)point.Y });
                    if (MouseLongEventHandler != null)
                    {
                        try
                        {
                            if (thread != null && thread.IsAlive)
                            {
                                thread.Abort();
                            }
                            thread = new System.Threading.Thread(() =>
                            {
                                System.Threading.Thread.Sleep(800);
                                if (!isUp)
                                {
                                    longClicked = true;
                                    Application.RunOnMainThread(() =>
                                    {
                                        MouseLongEventHandler(this, new MouseEventArgs { X = (int)point.X, Y = (int)point.Y });
                                    });
                                }
                            })
                            { IsBackground = true };
                            thread.Start();
                        }
                        catch { }
                    }
                    break;
                case EventActions.Move:
                    MouseMoveEventHandler?.Invoke(this, new MouseEventArgs { X = (int)point.X, Y = (int)point.Y });
                    break;
                case EventActions.Up:
                    isUp = true;
                    if (!longClicked)
                    {
                        MouseUpEventHandler?.Invoke(this, new MouseEventArgs { X = (int)point.X, Y = (int)point.Y });
                    }
                    break;
                case EventActions.Cancel:
                    isUp = true;
                    break;
            }
            
            return false;
        }
 
        /// <summary>
        /// 点击按下事件
        /// </summary>
        public  EventHandler<MouseEventArgs> MouseDownEventHandler;
        /// <summary>
        /// 控件上移动事件
        /// </summary>
        public  EventHandler<MouseEventArgs> MouseMoveEventHandler;
 
        /// <summary>
        /// 点击弹起事件
        /// </summary>
         public  EventHandler<MouseEventArgs> MouseUpEventHandler;
 
        public EventHandler<MouseEventArgs> MouseLongEventHandler;
 
        /// <summary>
        /// 大小变化事件
        /// </summary>
        public EventHandler<Size> SizeChangeEventHandler;
 
 
        uint backgroundColor;
        /// <summary>
        /// 背景颜色
        /// </summary>
        /// <value>The color of the background.</value>
        public virtual uint BackgroundColor
        {
            get
            {
                return backgroundColor;
            }
            set
            {
                backgroundColor = value;
                if (!IsCanRefresh)
                {
                    return;
                }
                byte r, g, b, a;
                r = (byte)(backgroundColor / 256 / 256 % 256);
                g = (byte)(backgroundColor / 256 % 256);
                b = (byte)(backgroundColor % 256);
                a = (byte)(backgroundColor / 256 / 256 / 256 % 256);
                uiView.BackgroundColor = UIKit.UIColor.FromRGBA(r, g, b, a);
            }
        }
 
        /// <summary>
        ///  获取真实的控件
        /// </summary>
        /// <value>The real view.</value>
        internal UIKit.UIView RealView
        {
            get { return uiView; }
        }
 
        /// <summary>
        /// 将控制移到最前
        /// </summary>
        public virtual void BringToFront()
        {
            if (!IsCanRefresh)
            {
                return;
            }
            uiView.Superview.BringSubviewToFront(uiView);
        }
 
        /// <summary>
        /// 将控件移到最后
        /// </summary>
        public virtual void SendToBack()
        {
            if (!IsCanRefresh)
            {
                return;
            }
            uiView.Superview.SendSubviewToBack(uiView);
        }
 
        System.Collections.Generic.Dictionary<string, object> tag;
 
        /// <summary>
        /// 键值对,方便开发用
        /// </summary>
        /// <param name="key">Key.</param>
        /// <param name="value">Value.</param>
        public void AddTag(string key, object value)
        {
            if (tag == null)
            {
                tag = new System.Collections.Generic.Dictionary<string, object>();
            }
            tag.Remove(key);
            tag.Add(key, value);
        }
 
        /// <summary>
        /// 删除指定键值对
        /// </summary>
        /// <param name="key">Key.</param>
        public void RemoveTag(string key)
        {
            if (tag == null)
            {
                return;
            }
            tag.Remove(key);
        }
 
        /// <summary>
        /// 根据键获取值
        /// </summary>
        /// <returns>The tag by key.</returns>
        /// <param name="key">Key.</param>
        public object GetTagByKey(string key)
        {
            if (tag == null)
            {
                return null;
            }
            object value;
            tag.TryGetValue(key, out value);
            return value;
        }
 
        /// <summary>
        /// 全部删除Tag
        /// </summary>
        /// <returns>The tag.</returns>
        public void ClearTag()
        {
            if (tag != null)
            {
                tag.Clear();
            }
        }
 
        /// <summary>
        /// 方便开发者开发用
        /// </summary>
        public object Tag;
 
        /// <summary>
        /// 是否显示
        /// </summary>
        /// <value><c>true</c> if visible; otherwise, <c>false</c>.</value>
        public bool Visible
        {
            get
            {
                return !uiView.Hidden;
            }
            set
            {
                uiView.Hidden = !value;
            }
        }
 
 
        /// <summary>
        /// 从父视图里面移除掉
        /// </summary>
        public virtual void RemoveFromParent()
        {
            if (Parent == null)
            {
                return;
            }
 
            Parent.Remove(this);
        }
 
       
 
        Animate animate = Animate.None;
        /// <summary>
        /// 动画方式
        /// </summary>
        /// <value>The animate.</value>
        public Animate Animate
        {
            get
            {
                return animate;
            }
            set
            {
                animate = value;
                if (!IsCanRefresh)
                {
                    return;
                }
 
                var frameBefore = RealView.Frame;
                var frame = frameBefore;
                switch (animate)
                {
                    case Animate.DownToUp:
                        frame.Y += RealView.Frame.Height;
                        RealView.Frame = frame;
                        UIView.AnimateNotify(0.6f, 0.001f, UIViewAnimationOptions.CurveLinear, () =>
                        {
                            RealView.Frame = frameBefore;
                        }, null);
                        break;
                    case Animate.UpToDown:
                        frame.Y -= RealView.Frame.Height;
                        RealView.Frame = frame;
                        UIView.AnimateNotify(0.6f, 0.001f, UIViewAnimationOptions.CurveLinear, () =>
                        {
                            RealView.Frame = frameBefore;
                        }, null);
                        break;
                    case Animate.LeftToRight:
                        System.Threading.Tasks.Task.Run(() =>
                        {
                            System.Threading.Thread.Sleep(1);
                            Application.RunOnMainThread(() =>
                            {
                                UIView.BeginAnimations("");
                                UIView.SetAnimationCurve(UIViewAnimationCurve.EaseInOut);
                                UIView.SetAnimationDuration(1.0);
                                UIView.SetAnimationTransition(UIViewAnimationTransition.FlipFromLeft, RealView, true);// cache:YES];
                                UIView.CommitAnimations();
                            });
                        });
                        break;
                    case Animate.RightToLeft:
                        System.Threading.Tasks.Task.Run(() =>
                        {
                            System.Threading.Thread.Sleep(1);
                            Application.RunOnMainThread(() =>
                            {
                                UIView.BeginAnimations("");
                                UIView.SetAnimationCurve(UIViewAnimationCurve.EaseInOut);
                                UIView.SetAnimationDuration(1.0);
                                UIView.SetAnimationTransition(UIViewAnimationTransition.FlipFromRight, RealView, true);// cache:YES];
                                UIView.CommitAnimations();
                            });
                        });
                        break;
                    case Animate.Rotation:
                        rotation();
                        break;
 
                }
 
            }
        }
        void rotation()
        {
            UIView.Animate(4, 0, UIViewAnimationOptions.CurveLinear, () =>
            {
                RealView.Transform = CGAffineTransform.Rotate(RealView.Transform, 3.1415926535898f / 2);
            }, () =>
            {
                if (IsCanRefresh)
                    rotation();
            });
        }
 
        /// <summary>
        ///  透明度设置
        /// </summary>
        /// <value>The alpha.</value>
        public nfloat Alpha
        {
            get
            {
                return uiView.Alpha;
            }
            set
            {
                uiView.Alpha = value;
            }
        }
 
 
 
 
 
        //4个圆角分别对应的值
        //float topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius;
        ///未实现,代完善
        //public void SetAloneRadius(float topLeft, float topRight, float bottomLeft, float bottomRight)
        //{
        //    IsSetAloneRadius = true;
        //    topLeftRadius = topLeft;
        //    topRightRadius = topRight;
        //    bottomLeftRadius = bottomLeft;
        //    bottomRightRadius = bottomRight;
        //    RefreshAloneCorner();
        //}
 
        //是否单独设置圆角
        private bool IsSetAloneRadius;
        float mAloneRadius;
        float mRadiusId;
        /// <summary>
        /// 指定位置 设置相同的圆角
        /// </summary>
        public void SetCornerWithSameRadius(float mRadius, int mSetID)
        {
            //bool btopLeft, btopRight, bbottomLeft, bbottomRight;
            IsSetAloneRadius = true;
            mAloneRadius = mRadius;
            mRadiusId = mSetID;
            RefreshAloneCorner();
        }
 
        /// <summary>
        /// 更新圆角
        /// </summary>
        /// <returns>The corner.</returns>
        private void RefreshAloneCorner()
        {
            BackgroundColor = backgroundColor;
            uiView.Layer.MasksToBounds = true;
            UIRectCorner corner = (UIRectCorner)(mRadiusId);
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                uiView.Layer.CornerRadius = mAloneRadius;
                uiView.Layer.MaskedCorners = (CACornerMask)corner;
            }
            else
            {
                UIBezierPath mUIBezierPath = UIBezierPath.FromRoundedRect(uiView.Bounds, corner, new CoreGraphics.CGSize(mAloneRadius, mAloneRadius));
                CAShapeLayer mCAShapeLayer = new CAShapeLayer();
                mCAShapeLayer.Frame = uiView.Bounds;
                mCAShapeLayer.Path = mUIBezierPath.CGPath;
                uiView.Layer.Mask = mCAShapeLayer;
            }
            uiView.Layer.BorderWidth = BorderWidth;
            byte r, g, b, a;
            r = (byte)(borderColor / 256 / 256 % 256);
            g = (byte)(borderColor / 256 % 256);
            b = (byte)(borderColor % 256);
            a = (byte)(borderColor / 256 / 256 / 256 % 256);
            uiView.Layer.BorderColor = new CGColor(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
 
        }
 
 
 
        uint radius;
        /// <summary>
        /// 圆角大小
        /// </summary>
        /// <value>The corner.</value>
        public uint Radius
        {
            get
            {
                return radius;
            }
            set
            {
                IsSetAloneRadius = false;
                radius = value;
                if (!IsCanRefresh)
                {
                    return;
                }
                refreshCorner();
            }
        }
 
 
        /// <summary>
        /// 更新圆角
        /// </summary>
        /// <returns>The corner.</returns>
        void refreshCorner()
        {
            BackgroundColor = backgroundColor;
 
            if (Radius == 0)
            {
                return;
            }
 
            uiView.Layer.MasksToBounds = true;
            uiView.Layer.CornerRadius = Radius;
            uiView.Layer.BorderWidth = BorderWidth;
 
            byte r, g, b, a;
            r = (byte)(borderColor / 256 / 256 % 256);
            g = (byte)(borderColor / 256 % 256);
            b = (byte)(borderColor % 256);
            a = (byte)(borderColor / 256 / 256 / 256 % 256);
            uiView.Layer.BorderColor = new CGColor(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
 
        }
 
 
        uint borderWidth;
        /// <summary>
        /// 边框线大小
        /// </summary>
        /// <value>The width of the border.</value>
        public uint BorderWidth
        {
            get
            {
                return borderWidth;
            }
            set
            {
                borderWidth = value;
                Radius = radius;
            }
        }
 
        uint borderColor = 0xFFCCCCCC;
        /// <summary>
        /// 边框线颜色
        /// </summary>
        public uint BorderColor
        {
            get
            {
                return borderColor;
            }
            set
            {
                borderColor = value;
                Radius = radius;
            }
        }
 
        /// <summary>
        /// 旋转View
        /// </summary>
        /// <value>旋转角度</value>
        public void SetRotation(float mRotation)
        {
            if (mRotation > 180) {
                mRotation = mRotation - 360f;
            }
            var mCGAffineTransform = CGAffineTransform.MakeRotation((nfloat)(mRotation * Math.PI / 180.0));
            uiView.Transform = mCGAffineTransform;
        }
 
        /// <summary>
        /// 设置阴影效果
        /// </summary>
        /// <value>是否显示阴影</value>
        public void SetViewShadow(bool bShow, float mOffsetY = 5.0f)
        {
            if (bShow)
            {   
                uiView.Layer.ShadowOffset = new CGSize(0, mOffsetY);
                uiView.Layer.ShadowOpacity = 0.5f;
                uiView.Layer.ShadowColor =  UIColor.Gray.CGColor;
                uiView.ClipsToBounds = false;
            }
            else
            {
                //uiView.Layer.ShadowOffset = new CGSize(0, 0);
                //uiView.Layer.ShadowOpacity = 0f;
                uiView.ClipsToBounds = true;
            }
 
        }
 
    }
 
    /// <summary>
    /// 视图大小
    /// </summary>
    public class Size
    {
        /// <summary>
        /// 视图大小
        /// </summary>
        /// <param name="width">Width.</param>
        /// <param name="height">Height.</param>
        public Size(int width,int height)
        {
            Width = width;
            Height = height;
        }
            
        
        /// <summary>
        /// 宽度
        /// </summary>
        public int Width {
            get;
            set;
        }
        /// <summary>
        /// 高度
        /// </summary>
        public int Height {
            get;
            set;
        }
 
    }
 
    /// <summary>
    /// 内边距
    /// </summary>
    public class Padding
    {
        /// <summary>
        /// 内边距
        /// </summary>
        /// <param name="top">Top.</param>
        /// <param name="left">Left.</param>
        /// <param name="bottom">Bottom.</param>
        /// <param name="right">Right.</param>
        public Padding(int top,int left,int bottom,int right)
        {
            Top = top;
            Left = left;
            Bottom = bottom;
            Right = right;
        }
        /// <summary>
        /// 顶部
        /// </summary>
        public int Top {
            get;
            set;
        }
        /// <summary>
        /// 左边
        /// </summary>
        public int Left {
            get;
            set;
        }
        /// <summary>
        /// 底部
        /// </summary>
        public int Bottom {
            get;
            set;
        }
        /// <summary>
        /// 右边
        /// </summary>
        public int Right {
            get;
            set;
        }
    }
 
    /// <summary>
    /// 点击时基本参数
    /// </summary>
    public class MouseEventArgs : EventArgs
    {
        /// <summary>
        /// X坐标
        /// </summary>
        public float X;
        /// <summary>
        /// Y坐标
        /// </summary>
        public float Y;
    }
 
    /// <summary>
    /// 点击事件
    /// </summary>
    enum EventActions
    {
        /// <summary>
        /// Down
        /// </summary>
        Down,
        /// <summary>
        /// Move
        /// </summary>
        Move,
        /// <summary>
        /// UP
        /// </summary>
        Up,
        /// <summary>
        /// Cancel
        /// </summary>
        Cancel,
    }
}