-
Notifications
You must be signed in to change notification settings - Fork 204
/
PickerGettingStarted.cs
128 lines (120 loc) · 4.63 KB
/
PickerGettingStarted.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
#region Copyright Syncfusion Inc. 2001-2024.
// Copyright Syncfusion Inc. 2001-2024. 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 System.Collections.Generic;
using CoreGraphics;
using Syncfusion.SfPicker.iOS;
using UIKit;
namespace SampleBrowser
{
public class PickerGettingStarted : SampleView
{
SfPicker pickerControl;
List<string> collectionStrings;
UITableView table = new UITableView();
string[] tableItems = new string[100];
UILabel eventLog;
int i = 0;
UIButton button_calendarView = new UIButton();
UIButton doneButton = new UIButton();
public UIView option = new UIView();
void PickerControl_ValueChanged(object sender, SelectionChangedEventArgs e)
{
switch(e.NewValue.ToString())
{
case "Blue":
pickerControl.BackgroundColor = UIColor.FromRGBA(0, 0, 255, 0.3f);
break;
case "Red":
pickerControl.BackgroundColor = UIColor.FromRGBA(255, 0, 0, 0.3f);
break;
case "Pink":
pickerControl.BackgroundColor = UIColor.FromRGBA(255, 0, 255, 0.3f);
break;
case "Orange":
pickerControl.BackgroundColor = UIColor.FromRGBA(255, 128, 0, 1);
break;
case "Yellow":
pickerControl.BackgroundColor = UIColor.FromRGBA(255, 255, 0, 0.3f);
break;
case "Brown":
pickerControl.BackgroundColor = UIColor.FromRGBA(102, 51, 0,1);
break;
case "Magenta":
pickerControl.BackgroundColor = UIColor.FromRGBA(102, 0, 102, 0.8f);
break;
case "LightGray":
pickerControl.BackgroundColor = UIColor.FromRGBA(192, 192, 192, 0.3f);
break;
case "Green":
pickerControl.BackgroundColor = UIColor.FromRGBA(0, 102, 0, 1);
break;
}
if (i > 99)
{
i = 0;
tableItems = new string[100];
}
tableItems[i] = e.NewValue.ToString() + "color has been selected";
table.ReloadData();
i++;
}
public PickerGettingStarted()
{
collectionStrings = new List<string>();
collectionStrings.Add("Blue");
collectionStrings.Add("Red");
collectionStrings.Add("Pink");
collectionStrings.Add("Orange");
collectionStrings.Add("Magenta");
collectionStrings.Add("Yellow");
collectionStrings.Add("Green");
collectionStrings.Add("LightGray");
collectionStrings.Add("Brown");
pickerControl = new SfPicker();
pickerControl.SelectedIndex = 2;
pickerControl.ShowColumnHeader = true;
pickerControl.HeaderText = "Select a Color";
pickerControl.ColumnHeaderText = "Colors";
pickerControl.ShowFooter = false;
pickerControl.ShowHeader = true;
pickerControl.SelectionChanged += PickerControl_ValueChanged;
pickerControl.ItemsSource = collectionStrings;
pickerControl.BackgroundColor = UIColor.FromRGBA(255, 0, 255, 0.3f);
this.Add(pickerControl);
eventLog = new UILabel();
eventLog.Lines = 0;
eventLog.Text = "Event Log :";
eventLog.BackgroundColor = UIColor.White;
eventLog.LineBreakMode = UILineBreakMode.WordWrap;
table = new UITableView(this.Bounds); // defaults to Plain style
tableItems = new string[100];
Add(eventLog);
table.Source = new TableSourceCollection(tableItems);
Add(table);
}
public override void LayoutSubviews()
{
foreach (var view in this.Subviews)
{
pickerControl.Frame = new CGRect(20, 30, this.Frame.Size.Width-40, 300);
if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
{
eventLog.Frame = new CGRect(20, 370, Frame.Width, 30);
table.Frame = new CGRect(20, 400, Frame.Width - 18, 200);
}
else
{
eventLog.Frame = new CGRect(16, Frame.Height - 150, Frame.Width, 30);
table.Frame = new CGRect(0, Frame.Height - 120, Frame.Width - 18, 200);
}
}
base.LayoutSubviews();
}
}
}