|
| 1 | +using Syncfusion.UI.Xaml.Schedule; |
| 2 | +using System; |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.Collections.ObjectModel; |
| 5 | +using System.Linq; |
| 6 | +using System.Text; |
| 7 | +using System.Threading.Tasks; |
| 8 | +using System.Windows; |
| 9 | +using System.Windows.Controls; |
| 10 | +using System.Windows.Data; |
| 11 | +using System.Windows.Documents; |
| 12 | +using System.Windows.Input; |
| 13 | +using System.Windows.Media; |
| 14 | +using System.Windows.Media.Imaging; |
| 15 | +using System.Windows.Navigation; |
| 16 | +using System.Windows.Shapes; |
| 17 | + |
| 18 | +namespace SfSchedule_CustomGrouping |
| 19 | +{ |
| 20 | + /// <summary> |
| 21 | + /// Interaction logic for MainWindow.xaml |
| 22 | + /// </summary> |
| 23 | + public partial class MainWindow : Window |
| 24 | + { |
| 25 | + private ObservableCollection<DateTime> datecoll = new ObservableCollection<DateTime>(); |
| 26 | + private ObservableCollection<DateTime> dateselected = new ObservableCollection<DateTime>(); |
| 27 | + public ScheduleAppointmentCollection FilterColl { get; set; } |
| 28 | + Random random; |
| 29 | + public MainWindow() |
| 30 | + { |
| 31 | + this.InitializeComponent(); |
| 32 | + |
| 33 | + television.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); |
| 34 | + random = new Random(); |
| 35 | + for (int i = -20; i < 20; i += 2) |
| 36 | + { |
| 37 | + for (int j = -7; j < 7; j++) |
| 38 | + { |
| 39 | + datecoll.Add(DateTime.Now.Date.AddDays(j).AddHours(i)); |
| 40 | + } |
| 41 | + } |
| 42 | + this.FilterColl = GetFilterCollection(); |
| 43 | + this.DataContext = this; |
| 44 | + } |
| 45 | + private ScheduleAppointmentCollection GetFilterCollection() |
| 46 | + { |
| 47 | + string[] football = new string[] { "USA vs IRN ", "RUS vs ARG", "POR vs SWI", "BEL vs ARG", "USA vs RUS", "IRN vs POR", "CRO vs MEX", "JPN vs ITA", "COL vs URU" }; |
| 48 | + string[] cricket = new string[] { "IND vs PAk", "AUS vs SA", "SRI vs WI", "SA vs IND", "ZIM vs PAK", "SRI vs AUS" }; |
| 49 | + string[] news = new string[] { "Cricket news", "Football news", "Hockey news", "Tennis news", "news of Athletics", "Golf news", "Kabaddi news", "VolleyBall news" }; |
| 50 | + string[] pgms = new string[] { "FootBall", "Cricket", "News" }; |
| 51 | + ScheduleAppointmentCollection app = new ScheduleAppointmentCollection(); |
| 52 | + for (int dc = 0; dc < datecoll.Count - 1; dc++) |
| 53 | + { |
| 54 | + DateTime date = datecoll[dc]; |
| 55 | + dateselected.Add(date); |
| 56 | + |
| 57 | + for (int sd = 0; sd < dateselected.Count - 1; sd++) |
| 58 | + { |
| 59 | + if (date == dateselected[sd]) |
| 60 | + { |
| 61 | + date = date.AddDays(1); |
| 62 | + } |
| 63 | + } |
| 64 | + ScheduleAppointment app1 = new ScheduleAppointment() { StartTime = date }; |
| 65 | + app1.ResourceCollection.Add(new Resource() { ResourceName = "TV" + random.Next(1, 4), TypeName = "TV" }); |
| 66 | + app1.ResourceCollection.Add(new Resource() { ResourceName = pgms[random.Next(0, 3)], TypeName = "programs" }); |
| 67 | + if ((app1.ResourceCollection[1] as Resource).ResourceName.Equals("FootBall")) |
| 68 | + { |
| 69 | + app1.Subject = football[random.Next(0, football.Length)]; |
| 70 | + app1.EndTime = date.AddHours(1); |
| 71 | + } |
| 72 | + else if ((app1.ResourceCollection[1] as Resource).ResourceName.Equals("Cricket")) |
| 73 | + { |
| 74 | + app1.Subject = cricket[random.Next(0, cricket.Length)]; |
| 75 | + app1.EndTime = date.AddHours(1); |
| 76 | + } |
| 77 | + else |
| 78 | + { |
| 79 | + app1.Subject = news[random.Next(0, news.Length)]; |
| 80 | + app1.EndTime = date.AddHours(1); |
| 81 | + } |
| 82 | + app1.AppointmentBackground = new SolidColorBrush(Colors.DimGray); |
| 83 | + |
| 84 | + app.Add(app1); |
| 85 | + } |
| 86 | + return app; |
| 87 | + } |
| 88 | + private void Button_Click_1(object sender, RoutedEventArgs e) |
| 89 | + { |
| 90 | + string str = (sender as Button).Content.ToString(); |
| 91 | + if (str.Equals("Television")) |
| 92 | + { |
| 93 | + programs.IsEnabled = true; |
| 94 | + this.schedule.Resource = "TV"; |
| 95 | + television.IsEnabled = false; |
| 96 | + } |
| 97 | + else |
| 98 | + { |
| 99 | + television.IsEnabled = true; |
| 100 | + this.schedule.Resource = "programs"; |
| 101 | + programs.IsEnabled = false; |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + } |
| 106 | +} |
0 commit comments