-
Notifications
You must be signed in to change notification settings - Fork 203
/
CustomizationKanban.cs
292 lines (251 loc) · 8.04 KB
/
CustomizationKanban.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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#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.ObjectModel;
using Syncfusion.SfKanban.iOS;
using System.Collections.Generic;
#if __UNIFIED__
using Foundation;
using UIKit;
using CoreGraphics;
#else
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
using nint = System.Int32;
using nuint = System.Int32;
using CGRect = System.Drawing.RectangleF;
#endif
namespace SampleBrowser
{
public class CustomizationKanban : SampleView
{
SfKanban kanban;
public CustomizationKanban()
{
kanban = new SfKanban();
KanbanErrorBarSettings errorBar = new KanbanErrorBarSettings();
errorBar.Height = 2;
errorBar.Color = UIColor.FromRGB(179.0f / 255.0f, 71.0f / 255.0f, 36.0f / 255.0f);
errorBar.MaxValidationColor = UIColor.FromRGB(211.0f / 255.0f, 51.0f / 255.0f, 54.0f / 255.0f);
errorBar.MinValidationColor = UIColor.FromRGB(67.0f / 255.0f, 188.0f / 255.0f, 131.0f / 255.0f);
KanbanPlaceholderStyle style = new KanbanPlaceholderStyle();
style.SelectedBackgroundColor = UIColor.FromRGB(250.0f / 255.0f, 199.0f / 255.0f, 173.0f / 255.0f);
kanban.PlaceholderStyle = style;
KanbanColumn column1 = new KanbanColumn() { Categories = new List<object>() { "Menu" } };
column1.Title = "Menu";
column1.ErrorBarSettings = errorBar;
kanban.Columns.Add(column1);
KanbanColumn column2 = new KanbanColumn() { Categories = new List<object>() { "Dining", "Delivery" } };
column2.Title = "Order";
column2.ErrorBarSettings = errorBar;
kanban.Columns.Add(column2);
KanbanColumn column3 = new KanbanColumn() { Categories = new List<object>() { "Ready to Serve" } };
column3.Title = "Ready to Serve";
column3.AllowDrag = false;
column3.ErrorBarSettings = errorBar;
kanban.Columns.Add(column3);
KanbanColumn column4 = new KanbanColumn() { Categories = new List<object>() { "Door Delivery" } };
column4.Title = "Delivery";
column4.AllowDrag = false;
column4.ErrorBarSettings = errorBar;
kanban.Columns.Add(column4);
kanban.ItemsSource = this.ItemsSourceCards();
List<KanbanWorkflow> flows = new List<KanbanWorkflow>();
flows.Add(new KanbanWorkflow("Menu", new List<object>() { "Dining", "Delivery" }));
flows.Add(new KanbanWorkflow("Dining", new List<object>() { "Ready to Serve" }));
flows.Add(new KanbanWorkflow("Delivery", new List<object>() { "Door Delivery" }));
flows.Add(new KanbanWorkflow("Ready to Serve", new List<object>() { }));
flows.Add(new KanbanWorkflow("Door Delivery", new List<object>() { }));
kanban.Workflows = flows;
kanban.DragStart += (object sender, KanbanDragStartEventArgs e) =>
{
if ((e.Data as KanbanModel).Category.ToString() == "Menu")
e.KeepItem = true;
};
kanban.DragEnd += (object sender, KanbanDragEndEventArgs e) =>
{
if (e.TargetColumn != null && e.SourceColumn.Categories.Contains("Menu"))
{
e.Cancel = true;
e.TargetColumn.InsertItem(CloneModel((e.Data as KanbanModel),e.TargetCategory), e.TargetIndex);
}
else if (e.TargetColumn != null && e.TargetCategory != null)
{
(e.Data as KanbanModel).Category = e.TargetCategory;
}
};
this.AddSubview(kanban);
}
KanbanModel CloneModel(KanbanModel model, object category)
{
KanbanModel newModel = new KanbanModel();
newModel.ImageURL = model.ImageURL;
newModel.Category = category;
newModel.ColorKey = model.ColorKey;
newModel.Description = model.Description;
newModel.ID = model.ID;
newModel.Tags = model.Tags;
newModel.Title = model.Title;
return newModel;
}
public override void LayoutSubviews()
{
foreach (var view in this.Subviews)
{
if (view == kanban)
view.Frame = Bounds;
}
base.LayoutSubviews();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
kanban.Dispose();
}
#region ItemsSource
ObservableCollection<KanbanModel> ItemsSourceCards()
{
ObservableCollection<KanbanModel> cards = new ObservableCollection<KanbanModel>();
cards.Add(
new KanbanModel()
{
ID = 1,
Title = "Margherita",
ImageURL = "margherita.png",
Category = "Menu",
Description = "The classic. Fresh tomatoes, garlic, olive oil, and basil. For pizza purists and minimalists only.",
Tags = new string[] { "Cheese" }
}
);
cards.Add(
new KanbanModel()
{
ID = 2,
Title = "Double Cheese Margherita",
ImageURL = "doublecheesemargherita.png",
Category = "Menu",
Description = "The minimalist classic with a double helping of cheese",
Tags = new string[] { "Cheese" }
}
);
cards.Add(
new KanbanModel()
{
ID = 3,
Title = "Bucolic Pie",
ImageURL = "bucolicpie.png",
Category = "Menu",
Description = "The pizza you daydream about to escape city life. Onions, peppers, and tomatoes. (Note: The “Onions” tag beneath the description in the screenshot is misspelled.)",
Tags = new string[] { "Oninons", "Capsicum" }
}
);
cards.Add(
new KanbanModel()
{
ID = 4,
Title = "Bumper Crop",
ImageURL = "bumpercrop.png",
Category = "Menu",
Description = "Can’t get enough veggies? Eat this. Carrots, mushrooms, potatoes, and way more",
Tags = new string[] { "Tomato", "Mushroom" }
}
);
cards.Add(
new KanbanModel()
{
ID = 5,
Title = "Spice of Life",
ImageURL = "spiceoflife.png",
Category = "Menu",
Description = "Thrill-seeking, heat-seeking pizza people only. It’s hot. Trust us.",
Tags = new string[] { "Corn", "Gherkins" }
}
);
cards.Add(
new KanbanModel()
{
ID = 6,
Title = "Very Nicoise",
ImageURL = "verynicoise.png",
Category = "Menu",
Description = "Anchovies, Dijon vinaigrette, shallots, red peppers, and potatoes.",
Tags = new string[] { "Red pepper", "Capsicum" }
}
);
cards.Add(
new KanbanModel()
{
ID = 7,
Title = "Salad Daze",
ImageURL = "saladdaze.png",
Category = "Menu",
Description = "Pretty much salad on a pizza. Broccoli, olives, cherry tomatoes, red onion.",
Tags = new string[] { "Onions", "Jalapeno" }
}
);
cards.Add(
new KanbanModel()
{
ID = 4,
Title = "Bumper Crop",
ImageURL = "bumpercrop.png",
Category = "Ready to Serve",
Description = "Can’t get enough veggies? Eat this. Carrots, mushrooms, potatoes, and way more",
Tags = new string[] { "Tomato", "Mushroom" }
}
);
cards.Add(
new KanbanModel()
{
ID = 5,
Title = "Spice of Life",
ImageURL = "spiceoflife.png",
Category = "Ready to Serve",
Description = "Thrill-seeking, heat-seeking pizza people only. It’s hot. Trust us.",
Tags = new string[] { "Corn", "Gherkins" }
}
);
cards.Add(
new KanbanModel()
{
ID = 3,
Title = "Bucolic Pie",
ImageURL = "bucolicpie.png",
Category = "Door Delivery",
Description = "The pizza you daydream about to escape city life. Onions, peppers, and tomatoes. (Note: The “Onions” tag beneath the description in the screenshot is misspelled.)",
Tags = new string[] { "Oninons", "Capsicum" }
}
);
cards.Add(
new KanbanModel()
{
ID = 6,
Title = "Very Nicoise",
ImageURL = "verynicoise.png",
Category = "Dining",
Description = "Anchovies, Dijon vinaigrette, shallots, red peppers, and potatoes.",
Tags = new string[] { "Red pepper", "Capsicum" }
}
);
cards.Add(
new KanbanModel()
{
ID = 2,
Title = "Double Cheese Margherita",
ImageURL = "doublecheesemargherita.png",
Category = "Delivery",
Description = "The minimalist classic with a double helping of cheese",
Tags = new string[] { "Cheese" }
}
);
return cards;
}
#endregion
}
}