-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCustomCellView.cs
More file actions
93 lines (82 loc) · 3.46 KB
/
Copy pathCustomCellView.cs
File metadata and controls
93 lines (82 loc) · 3.46 KB
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
using System;
using CoreGraphics;
using DevExpress.Xamarin.iOS.Scheduler;
using UIKit;
namespace CustomMonthViewProviders.iOS {
public class CustomCellView : UIView {
UILabel dateLabel;
UIImageView moreButtonImgView;
DXMonthCellItemViewInfo viewInfo;
bool showMoreButton;
double imgWidth = 10;
double imgHeight = 8;
public CustomCellView() {
this.dateLabel = new UILabel();
AddSubview(this.dateLabel);
this.moreButtonImgView = new UIImageView(UIImage.GetSystemImage("arrowtriangle.down"));
AddSubview(this.moreButtonImgView);
}
public DXMonthCellItemViewInfo ViewInfo {
get { return this.viewInfo; }
set {
if (this.viewInfo == value)
return;
this.viewInfo = value;
Update();
}
}
public bool ShowMoreButton {
get { return this.showMoreButton; }
set {
if (this.showMoreButton == value)
return;
this.showMoreButton = value;
this.moreButtonImgView.Hidden = !this.showMoreButton;
}
}
public double CellHeaderHeight { get; set; }
public override CGSize SizeThatFits(CGSize size) {
CGSize dateLabelSize = this.dateLabel.SizeThatFits(size);
CGSize moreButtonSize = CGSize.Empty;
if (ShowMoreButton)
moreButtonSize = this.moreButtonImgView.SizeThatFits(size);
return new CGSize(Math.Max(dateLabelSize.Width, moreButtonSize.Width), dateLabelSize.Height + moreButtonSize.Height);
}
public override void LayoutSubviews() {
this.dateLabel.Frame = new CGRect(ViewInfo.LeftBorderThickness, 0, Bounds.Width - ViewInfo.LeftBorderThickness, CellHeaderHeight);
this.moreButtonImgView.Frame = new CGRect(Bounds.Width - this.imgWidth - 1, (CellHeaderHeight - this.imgHeight) / 2, this.imgWidth, this.imgHeight);
}
public override void Draw(CGRect rect) {
CGContext ctx = UIGraphics.GetCurrentContext();
DrawLeftBorder(ctx, rect);
DrawBottomBorder(ctx, rect);
}
void Update() {
this.BackgroundColor = ViewInfo.BackgroundColor;
this.dateLabel.BackgroundColor = ViewInfo.TextBackColor;
this.dateLabel.Font = ViewInfo.Font;
this.dateLabel.TextColor = ViewInfo.TextColor;
this.dateLabel.Text = ViewInfo.Text;
}
void DrawLeftBorder(CGContext ctx, CGRect rect) {
if (ViewInfo.LeftBorderThickness <= 0)
return;
ctx.SetStrokeColor(ViewInfo.LeftBorderColor.CGColor);
ctx.SetLineWidth((nfloat)ViewInfo.LeftBorderThickness);
ctx.BeginPath();
ctx.MoveTo(rect.GetMinX(), rect.GetMinY());
ctx.AddLineToPoint(rect.GetMinX(), rect.GetMaxY());
ctx.StrokePath();
}
void DrawBottomBorder(CGContext ctx, CGRect rect) {
if (ViewInfo.BottomBorderThickness <= 0)
return;
ctx.SetStrokeColor(ViewInfo.BottomBorderColor.CGColor);
ctx.SetLineWidth((nfloat)ViewInfo.BottomBorderThickness);
ctx.BeginPath();
ctx.MoveTo(rect.GetMinX(), rect.GetMaxY());
ctx.AddLineToPoint(rect.GetMaxX(), rect.GetMaxY());
ctx.StrokePath();
}
}
}