forked from syncfusion/xamarin-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Linear.cs
265 lines (226 loc) · 10.1 KB
/
Linear.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
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
#region Copyright Syncfusion Inc. 2001-2022.
// Copyright Syncfusion Inc. 2001-2022. 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
namespace SampleBrowser
{
using System.Threading.Tasks;
using Android.Content;
using Android.Graphics;
using Android.Views;
using Android.Widget;
using Syncfusion.Android.ProgressBar;
public class Linear : SamplePage
{
private Context context;
private LinearLayout.LayoutParams layoutParams;
public override View GetSampleContent(Context ctx)
{
this.context = ctx;
this.layoutParams = new LinearLayout.LayoutParams(
this.context.Resources.DisplayMetrics.WidthPixels - 120,
this.context.Resources.DisplayMetrics.HeightPixels / 18);
LinearLayout linearLayout = new LinearLayout(this.context) { Orientation = Orientation.Vertical };
linearLayout.SetPadding(60, 20, 0, 0);
linearLayout.AddView(this.GetLinearDeterminate());
linearLayout.AddView(this.GetLinearIndeterminate());
linearLayout.AddView(this.GetLinearCornerRadius());
linearLayout.AddView(this.GetLinearPadding());
linearLayout.AddView(this.GetLinearRangeColors());
linearLayout.AddView(this.GetLinearRangeColorsWithGradient());
linearLayout.AddView(this.GetLinearBuffer());
linearLayout.AddView(this.GetLinearSegment());
linearLayout.AddView(this.GetLinearSegmentedCornerRadius());
ScrollView scrollView = new ScrollView(this.context);
scrollView.AddView(linearLayout);
return scrollView;
}
private View GetTextView(string content)
{
TextView textView = new TextView(this.context) { Text = content };
textView.TextSize = 15;
return textView;
}
private View GetLinearDeterminate()
{
LinearLayout linearLayout = new LinearLayout(this.context) { Orientation = Orientation.Vertical };
linearLayout.AddView(this.GetTextView("Determinate"));
linearLayout.AddView(new SfLinearProgressBar(this.context)
{
Progress = 75,
LayoutParameters = this.layoutParams
});
return linearLayout;
}
private View GetLinearSegment()
{
LinearLayout linearLayout = new LinearLayout(this.context) { Orientation = Orientation.Vertical };
linearLayout.AddView(this.GetTextView("Segment"));
linearLayout.AddView(new SfLinearProgressBar(this.context)
{
Progress = 75,
SegmentCount = 4,
LayoutParameters = this.layoutParams
});
return linearLayout;
}
private View GetLinearRangeColors()
{
LinearLayout linearLayout = new LinearLayout(this.context) { Orientation = Orientation.Vertical };
linearLayout.AddView(this.GetTextView("Range colors"));
RangeColorCollection rangeColorCollection = new RangeColorCollection
{
new RangeColor { Color = Color.ParseColor("#36BBE1"), Start = 0, End = 25 },
new RangeColor { Color = Color.ParseColor("#9AEDE1"), Start = 25, End = 50 },
new RangeColor { Color = Color.ParseColor("#FFDC28"), Start = 50, End = 75 },
new RangeColor { Color = Color.ParseColor("#E15E0D"), Start = 75, End = 100 }
};
SfLinearProgressBar progressBar = new SfLinearProgressBar(this.context)
{
AnimationDuration = 10000,
Progress = 100,
LayoutParameters = this.layoutParams,
RangeColors = rangeColorCollection
};
linearLayout.AddView(progressBar);
progressBar.ValueChanged += this.ProgressBar_ValueChanged;
return linearLayout;
}
private View GetLinearRangeColorsWithGradient()
{
LinearLayout linearLayout = new LinearLayout(this.context) { Orientation = Orientation.Vertical };
linearLayout.AddView(this.GetTextView("Gradient"));
RangeColorCollection rangeColorCollection = new RangeColorCollection
{
new RangeColor { IsGradient = true, Color = Color.ParseColor("#E9ECF7"), Start = 0, End = 20 },
new RangeColor { IsGradient = true, Color = Color.ParseColor("#A0D9EF"), Start = 20, End = 40 },
new RangeColor { IsGradient = true, Color = Color.ParseColor("#62C1E5"), Start = 40, End = 60 },
new RangeColor { IsGradient = true, Color = Color.ParseColor("#20A7DB"), Start = 60, End = 80 },
new RangeColor { IsGradient = true, Color = Color.ParseColor("#1C96C5"), Start = 80, End = 100 }
};
SfLinearProgressBar progressBar = new SfLinearProgressBar(this.context)
{
AnimationDuration = 10000,
Progress = 100,
LayoutParameters = this.layoutParams,
RangeColors = rangeColorCollection
};
progressBar.ValueChanged += this.ProgressBar_ValueChanged;
linearLayout.AddView(progressBar);
return linearLayout;
}
private View GetLinearCornerRadius()
{
LinearLayout linearLayout = new LinearLayout(this.context) { Orientation = Orientation.Vertical };
linearLayout.AddView(this.GetTextView("Corner radius"));
SfLinearProgressBar progressBar = new SfLinearProgressBar(this.context)
{
AnimationDuration = 10000,
Progress = 100,
CornerRadius = 10,
LayoutParameters = this.layoutParams
};
progressBar.ValueChanged += this.ProgressBar_ValueChanged;
linearLayout.AddView(progressBar);
return linearLayout;
}
private View GetLinearBuffer()
{
LinearLayout linearLayout = new LinearLayout(this.context) { Orientation = Orientation.Vertical };
linearLayout.AddView(this.GetTextView("Buffer"));
SfLinearProgressBar progressBar = new SfLinearProgressBar(this.context)
{
AnimationDuration = 20000,
SecondaryAnimationDuration = 10000,
Progress = 100,
SecondaryProgress = 100,
LayoutParameters = this.layoutParams
};
progressBar.ValueChanged += this.ProgressBar_ValueChanged1;
linearLayout.AddView(progressBar);
return linearLayout;
}
private View GetLinearPadding()
{
LinearLayout linearLayout = new LinearLayout(this.context) { Orientation = Orientation.Vertical };
linearLayout.AddView(this.GetTextView("Padding"));
SfLinearProgressBar progressBar = new SfLinearProgressBar(this.context)
{
AnimationDuration = 10000,
Progress = 100,
CornerRadius = 10,
IndicatorPadding = new Thickness(2),
LayoutParameters = this.layoutParams
};
progressBar.ValueChanged += this.ProgressBar_ValueChanged;
linearLayout.AddView(progressBar);
return linearLayout;
}
private View GetLinearSegmentedCornerRadius()
{
LinearLayout linearLayout = new LinearLayout(this.context) { Orientation = Orientation.Vertical };
linearLayout.AddView(this.GetTextView("Segment with corner radius"));
SfLinearProgressBar progressBar = new SfLinearProgressBar(this.context)
{
AnimationDuration = 10000,
SegmentCount = 4,
Progress = 100,
CornerRadius = 10,
GapWidth = 7,
LayoutParameters = this.layoutParams
};
progressBar.ValueChanged += this.ProgressBar_ValueChanged;
linearLayout.AddView(progressBar);
return linearLayout;
}
private View GetLinearIndeterminate()
{
LinearLayout linearLayout = new LinearLayout(this.context) { Orientation = Orientation.Vertical };
linearLayout.AddView(this.GetTextView("Indeterminate"));
linearLayout.AddView(new SfLinearProgressBar(this.context)
{
IsIndeterminate = true,
LayoutParameters = this.layoutParams
});
return linearLayout;
}
private async void ProgressBar_ValueChanged1(object sender, ProgressValueEventArgs e)
{
SfLinearProgressBar progressbar = sender as SfLinearProgressBar;
if (e.Progress.Equals(100))
{
progressbar.AnimationDuration = 0;
progressbar.Progress = 0;
progressbar.SecondaryAnimationDuration = 0;
progressbar.SecondaryProgress = 0;
}
if (e.Progress.Equals(0))
{
progressbar.AnimationDuration = 20000;
await Task.Delay(100);
progressbar.Progress = 100;
progressbar.SecondaryAnimationDuration = 10000;
await Task.Delay(100);
progressbar.SecondaryProgress = 100;
}
}
private async void ProgressBar_ValueChanged(object sender, ProgressValueEventArgs e)
{
SfLinearProgressBar progressbar = sender as SfLinearProgressBar;
if (e.Progress.Equals(100))
{
progressbar.AnimationDuration = 0;
progressbar.Progress = 0;
}
if (e.Progress.Equals(0))
{
progressbar.AnimationDuration = 10000;
await Task.Delay(100);
progressbar.Progress = 100;
}
}
}
}