-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCustomCellView.cs
More file actions
89 lines (79 loc) · 3.54 KB
/
Copy pathCustomCellView.cs
File metadata and controls
89 lines (79 loc) · 3.54 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
using Android.Content;
using Android.Graphics;
using Android.Util;
using Android.Views;
using Android.Widget;
using DevExpress.XamarinAndroid.Scheduler.Visual.Data;
namespace CustomMonthViewProviders.Droid {
public class CustomCellView : ViewGroup {
View childView;
LinearLayout headerLayout;
TextView dateTextView;
ImageView moreButtonImgView;
MonthCellViewInfo viewInfo;
Paint borderPaint;
Color backColor;
bool showMoreButton;
public CustomCellView(Context context)
: base(context) {
SetWillNotDraw(false);
this.childView = LayoutInflater.From(context).Inflate(Resource.Layout.CustomCellLayout, null);
AddView(this.childView);
this.headerLayout = this.childView.FindViewById<LinearLayout>(Resource.Id.headerLayout);
this.dateTextView = this.childView.FindViewById<TextView>(Resource.Id.tvDate);
this.moreButtonImgView = this.childView.FindViewById<ImageView>(Resource.Id.imgMoreButton);
}
public MonthCellViewInfo ViewInfo {
get { return this.viewInfo; }
set {
if (this.viewInfo == value)
return;
this.viewInfo = value;
Update();
}
}
public bool ShowMoreButton {
get { return showMoreButton; }
set {
if (this.showMoreButton == value)
return;
this.showMoreButton = value;
this.moreButtonImgView.Visibility = this.showMoreButton ? ViewStates.Visible : ViewStates.Invisible;
}
}
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) {
this.childView.Measure(widthMeasureSpec, heightMeasureSpec);
SetMeasuredDimension(this.childView.MeasuredWidth, this.childView.MeasuredHeight);
}
protected override void OnLayout(bool changed, int l, int t, int r, int b) {
int left = ViewInfo.BorderThickness[0];
int top = ViewInfo.BorderThickness[1];
int right = r - l - ViewInfo.BorderThickness[2];
int bottom = b - t - ViewInfo.BorderThickness[3];
this.childView.Layout(left, top, right, bottom);
}
protected override void OnDraw(Canvas canvas) {
canvas.DrawColor(this.backColor);
DrawLeftBorder(canvas);
DrawBottomBorder(canvas);
}
void DrawLeftBorder(Canvas canvas) {
int leftBorder = ViewInfo.BorderThickness[0];
canvas.DrawRect(0, 0, leftBorder, Height, this.borderPaint);
}
void DrawBottomBorder(Canvas canvas) {
int borderHeight = ViewInfo.BorderThickness[3];
int top = Height - borderHeight;
canvas.DrawRect(0, top, Width, top + borderHeight, this.borderPaint);
}
void Update() {
this.backColor = new Color(ViewInfo.BackColor);
this.borderPaint = new Paint(PaintFlags.AntiAlias) { Color = new Color(ViewInfo.BottomBorderColor) };
this.headerLayout.SetBackgroundColor(new Color(ViewInfo.AlternateBackgroundColor));
this.dateTextView.Typeface = ViewInfo.DayNumberTextElement.Typeface;
this.dateTextView.SetTextSize(ComplexUnitType.Px, ViewInfo.DayNumberTextElement.TextSize);
this.dateTextView.SetTextColor(new Color(ViewInfo.DayNumberTextElement.TextColor));
this.dateTextView.Text = ViewInfo.DayNumberTextElement.Text;
}
}
}