-
Notifications
You must be signed in to change notification settings - Fork 201
/
Copy pathScheduleViewOptionLayout.cs
150 lines (125 loc) · 4.81 KB
/
ScheduleViewOptionLayout.cs
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
#region Copyright Syncfusion® Inc. 2001-2025.
// Copyright Syncfusion® Inc. 2001-2025. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// [email protected]. Any infringement will be prosecuted under
// applicable laws.
#endregion
using System;
using Android.Widget;
using Android.Views;
using Android.Content;
using Android.Graphics;
using Android.App;
using Android.OS;
using System.Collections.ObjectModel;
using System.Reflection.Emit;
using Android.Media;
using Com.Syncfusion.Schedule;
using Com.Syncfusion.Schedule.Enums;
using Android.Util;
namespace SampleBrowser
{
public class ScheduleViewOptionLayout : IDisposable
{
private Context con;
private LinearLayout mainLayout, borderLayout;
private SfSchedule sfSchedule;
public FrameLayout OptionLayout
{
get;
set;
}
public ScheduleViewOptionLayout(Context context, SfSchedule schedule)
{
con = context;
sfSchedule = schedule;
Density = con.Resources.DisplayMetrics;
OptionLayout = new FrameLayout(context);
OptionLayout.SetBackgroundColor(Color.White);
OptionLayout.LayoutParameters = new ViewGroup.LayoutParams(Density.WidthPixels / 3, Density.HeightPixels / 3);
borderLayout = new LinearLayout(context);
borderLayout.SetBackgroundColor(Color.LightGray);
borderLayout.SetPadding(1, 1, 1, 1);
borderLayout.LayoutParameters = new ViewGroup.LayoutParams(Density.WidthPixels / 3, Density.HeightPixels / 3);
AddHeaderViews();
}
internal DisplayMetrics Density { get; set; }
internal TextView Day { get; set; }
internal TextView Week { get; set; }
internal TextView Workweek { get; set; }
internal TextView Month { get; set; }
private void AddHeaderViews()
{
mainLayout = new LinearLayout(con);
mainLayout.SetBackgroundColor(Color.White);
mainLayout.LayoutParameters = new ViewGroup.LayoutParams(Density.WidthPixels / 3, Density.HeightPixels / 3);
mainLayout.Orientation = Android.Widget.Orientation.Vertical;
Day = new TextView(con);
Day.Text = "Day";
Day.TextSize = 20;
Day.LayoutParameters = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MatchParent, (Density.HeightPixels / 3) / 4);
//Where 20 as a textsize
Day.SetPadding(10, (Day.LayoutParameters.Height / 2) - 20, 0, 0);
Week = new TextView(con);
Week.Text = "Week";
Week.LayoutParameters = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MatchParent, (Density.HeightPixels / 3) / 4);
Week.TextSize = 20;
//Where 20 as a textsize
Week.SetPadding(10, (Week.LayoutParameters.Height / 2) - 20, 0, 0);
Workweek = new TextView(con);
Workweek.Text = "Workweek";
Workweek.LayoutParameters = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MatchParent, (Density.HeightPixels / 3) / 4);
Workweek.TextSize = 20;
//Where 20 as a textsize
Workweek.SetPadding(10, (Workweek.LayoutParameters.Height / 2) - 20, 0, 0);
Month = new TextView(con);
Month.Text = "Month";
Month.LayoutParameters = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MatchParent, (Density.HeightPixels / 3) / 4);
Month.TextSize = 20;
//Where 20 as a textsize
Month.SetPadding(10, (Month.LayoutParameters.Height / 2) - 20, 0, 0);
View divider1 = new View(con);
divider1.SetBackgroundColor(Color.LightGray);
divider1.LayoutParameters = new ViewGroup.LayoutParams(Density.WidthPixels / 3, 2);
View divider2 = new View(con);
divider2.SetBackgroundColor(Color.LightGray);
divider2.LayoutParameters = new ViewGroup.LayoutParams(Density.WidthPixels / 3, 2);
View divider3 = new View(con);
divider3.SetBackgroundColor(Color.LightGray);
divider3.LayoutParameters = new ViewGroup.LayoutParams(Density.WidthPixels / 3, 2);
mainLayout.AddView(Day);
mainLayout.AddView(divider1);
mainLayout.AddView(Week);
mainLayout.AddView(divider2);
mainLayout.AddView(Workweek);
mainLayout.AddView(divider3);
mainLayout.AddView(Month);
borderLayout.AddView(mainLayout);
OptionLayout.AddView(borderLayout);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
private void Day_Click(object sender, EventArgs e)
{
sfSchedule.ScheduleView = ScheduleView.DayView;
}
public void Dispose()
{
if (sfSchedule!= null)
{
sfSchedule.Dispose();
sfSchedule = null;
}
if (mainLayout != null)
{
mainLayout.Dispose();
mainLayout = null;
}
if (borderLayout != null)
{
borderLayout.Dispose();
borderLayout = null;
}
}
}
}