public CalendarPage() { Title = "La Chronique"; InitializeComponent(); calendarSorties.ShowInlineEvents = true; CalendarInlineEvent events = new CalendarInlineEvent(); events.StartTime = new DateTime(2017, 11, 3, 5, 0, 0); events.EndTime = new DateTime(2017, 11, 3, 7, 0, 0); events.Subject = "Sortie Novembre: 105z"; events.Color = Color.Fuchsia; CalendarInlineEvent events2 = new CalendarInlineEvent(); events2.StartTime = new DateTime(2017, 11, 3, 11, 0, 0); events2.EndTime = new DateTime(2017, 11, 3, 15, 0, 0); events2.Subject = "Sortie Novembre: 106z"; events2.Color = Color.DeepSkyBlue; CalendarEventCollection collection = new CalendarEventCollection(); collection.Add(events); collection.Add(events2); calendarSorties.DataSource = collection; }
public Pag_Calendario() { InitializeComponent(); SfCalendar calendar = new SfCalendar(); calendar.ShowInlineEvents = true; CalendarInlineEvent events = new CalendarInlineEvent(); CalendarInlineEvent reunion = new CalendarInlineEvent(); reunion.StartTime = new DateTime(2018, 10, 1, 17, 30, 00); reunion.EndTime = new DateTime(2018, 10, 1, 19, 0, 0); reunion.Subject = "Junta Liber Salus"; reunion.Color = Color.Aqua; events.StartTime = new DateTime(2018, 10, 11, 12, 0, 0); events.EndTime = new DateTime(2018, 10, 11, 14, 0, 0); events.Subject = "Junta Diana"; events.Color = Color.Magenta; CalendarEventCollection collection = new CalendarEventCollection(); collection.Add(events); collection.Add(reunion); calendar.DataSource = collection; //calendar.DataSource = collection; this.Content = calendar; }
public InlineEvents() { InitializeComponent(); this.Padding = new Thickness(-10); MonthViewSettings monthSettings = new MonthViewSettings(); monthSettings.DayHeight = 50; monthSettings.WeekEndTextColor = Color.FromHex("#009688"); monthSettings.HeaderBackgroundColor = Color.White; monthSettings.InlineBackgroundColor = Color.FromHex("#EEEEEE"); monthSettings.DateSelectionColor = Color.FromHex("#EEEEEE"); monthSettings.TodayTextColor = Color.FromHex("#2196F3"); monthSettings.SelectedDayTextColor = Color.Black; calendar.MonthViewSettings = monthSettings; if (Device.OS == TargetPlatform.Android) { calendar.HeaderHeight = 50; } else if (Device.OS == TargetPlatform.Windows) { calendar.HeaderHeight = 50; } if (Device.OS == TargetPlatform.iOS) { calendar.HeaderHeight = 40; } viewModePicker.Items.Add("Inline"); viewModePicker.Items.Add("Agenda"); viewModePicker.SelectedIndex = 0; viewModePicker.SelectedIndexChanged += ViewModePicker_SelectedIndexChanged;; calendarEventCollection = new CalendarEventCollection(); setColors(); setSubjects(); setStartTime(); setEndTime(); for (int i = 0; i < 5; i++) { CalendarInlineEvent appointment = new CalendarInlineEvent(); appointment.Color = Color.FromHex(colorCollection[i]); appointment.Subject = subjectCollection[i]; appointment.StartTime = startTimeCollection[i]; appointment.EndTime = endTimeCollection[i]; calendarEventCollection.Add(appointment); } for (int i = 0; i < 5; i++) { CalendarInlineEvent appointment2 = new CalendarInlineEvent(); appointment2.Color = Color.FromHex(colorCollection2[i]); appointment2.Subject = subjectCollection2[i]; appointment2.StartTime = startTimeCollection2[i]; appointment2.EndTime = endTimeCollection2[i]; calendarEventCollection.Add(appointment2); } calendar.BindingContext = calendarEventCollection; }
/// <summary> /// イベントを更新します。 /// </summary> /// <remarks> /// 今月のイベントを表示するために、対象月+前後一週間のイベントをコレクションに設定します。 /// 1ヶ月のカレンダーの前後に 前月・次月 の日付が表示されるため、前後1週間のイベントを設定します。 /// </remarks> /// <param name="calendarDate"></param> private void UpdateEvents(DateTime calendarDate) { // バインド対象のthis.CalendarEventCollectionを直接、繰り返しAdd()するとパフォーマンスが著しく落ちるのでテンポラリにデータコレクションを用意して差し替える CalendarEventCollection newCalendarEventCollection = new CalendarEventCollection(); DateTime dt = new DateTime(calendarDate.Year, calendarDate.Month, 1); int thisMonthLastDay = dt.AddMonths(1).AddDays(-1).Day; for (int i = -7; i < thisMonthLastDay + 7; i++) { // イベントはサンプルなので適当に2日に1回散歩と仕事、毎日のランチを設定 DateTime eventDt = dt.AddDays(i); if (eventDt.Day % 2 == 1) { //this.calendarEventCollection.Add( newCalendarEventCollection.Add( new CalendarInlineEvent() { Subject = $"{eventDt.Day}日 散歩", StartTime = eventDt.AddHours(10), EndTime = eventDt.AddHours(11), Color = Color.Green }); } //this.calendarEventCollection.Add( newCalendarEventCollection.Add( new CalendarInlineEvent() { Subject = $"{eventDt.Day}日 ランチ", StartTime = eventDt.AddHours(12), EndTime = eventDt.AddHours(13), Color = Color.Orange }); if (eventDt.Day % 2 == 0) { //this.calendarEventCollection.Add( newCalendarEventCollection.Add( new CalendarInlineEvent() { Subject = $"{eventDt.Day}日 仕事", StartTime = eventDt.AddHours(10), EndTime = eventDt.AddHours(19), Color = Color.Blue }); } } this.CalendarEventCollection.Clear(); this.CalendarEventCollection = newCalendarEventCollection; }
public Calendar() { InitializeComponent(); calendar.FirstDayofWeek = 1; DateTime blackOutDate = new DateTime(2017, 7, 23); List <DateTime> blackOutList = new List <DateTime>(); blackOutList.Add(blackOutDate); calendar.BlackoutDates = blackOutList; CalendarInlineEvent events = new CalendarInlineEvent(); events.StartTime = new DateTime(2017, 8, 1); events.EndTime = new DateTime(2017, 8, 2); events.Subject = "First tuesday"; events.Color = Color.Aqua; CalendarEventCollection collection = new CalendarEventCollection(); collection.Add(events); calendar.DataSource = collection; calendar.Locale = new System.Globalization.CultureInfo("fr-FR"); }
async Task RefreshCarendarAsync(DateTime dt) { IsRequesting(true); CalendarEventCollection newCalendarEventCollection = new CalendarEventCollection(); var calendarDates = await cDateManager.GetCalendarDatesAsync(dt); foreach (var cd in calendarDates) { newCalendarEventCollection.Add( new CalendarInlineEvent() { StartTime = cd.StampAt, EndTime = cd.StampAt, Color = ColorByTypeColor(cd.Type), }); } // 形だけでも待たないと落ちる await Task.Delay(10); calendarEventCollection = newCalendarEventCollection; calendar.DataSource = newCalendarEventCollection; IsRequesting(false); }
public MainPage() { InitializeComponent(); calendar.Locale = new System.Globalization.CultureInfo("pt-BR"); calendar.ShowInlineEvents = true; CalendarInlineEvent events = new CalendarInlineEvent { StartTime = new DateTime(2018, 9, 3, 5, 0, 0), EndTime = new DateTime(2018, 9, 3, 5, 0, 0), Subject = "Go to Meeting", Color = Color.Fuchsia }; CalendarEventCollection collection = new CalendarEventCollection(); collection.Add(events); calendar.DataSource = collection; List <DateTime> black_dates = new List <DateTime>(); black_dates.Add(new DateTime(2018, 9, 10)); calendar.BlackoutDates = black_dates; // this.Content = calendar; }
public async Task SetCalendarEvents() { var response = await Helper.ApiCall <CalendarEventsResponseModel>(RequestType.Post, ControllerType.Home, "getcalendarevents", JsonConvert.SerializeObject(new { AccessToken = Utility.User.accessToken, HomeID = Utility.User.CurrentHome }), IsSecure : true); CalendarInlineEvents = new CalendarEventCollection(); if (response.responseVal == 0) { foreach (var each in response.requestedEvents) { DateTime eachDate = Convert.ToDateTime(each.ExpectedDate); DateTime shouldEnd = new DateTime(eachDate.Year, eachDate.Month, eachDate.Day, 23, 59, 59); CalendarInlineEventModel item = new CalendarInlineEventModel() { StartTime = eachDate, EndTime = shouldEnd, Subject = each.EventExplanation, PayerName = each.PayerName, PaymentAmount = each.PaymentAmount, Color = Color.FromRgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)), Paid = each.Paid }; CalendarInlineEvents.Add(item); } } else { await PopupNavigation.Instance.PushAsync(new ErrorPopup(response.responseText)); } }
protected override void OnAttachedTo(ContentPage bindable) { var page = bindable as Page; calendar = page.FindByName <SfCalendar>("calendar"); comboBox = page.FindByName <SfComboBox>("comboBox"); comboBox.Watermark = "Search Events"; // To Display Inline appointment layout. calendar.ShowInlineEvents = true; //Inline ViewMode calendar.InlineViewMode = InlineViewMode.Agenda; var currentDay = DateTime.Now.Date; for (int i = 0; i < 40; i++) { calendarInlineEvents.Add(new CalendarInlineEvent() { StartTime = currentDay.AddDays(i), EndTime = currentDay.AddDays(i), Subject = "Meeting on " + currentDay.AddDays(i).ToString("dd/MM/yy"), Color = Color.Fuchsia }); calendarInlineEvents.Add(new CalendarInlineEvent() { StartTime = currentDay.AddDays(i), EndTime = currentDay.AddDays(i), Subject = "Conference on " + currentDay.AddDays(i).ToString("dd/MM/yy"), Color = Color.DodgerBlue }); } // Setting Datasource for calendar. calendar.DataSource = calendarInlineEvents; // Setting Data Source for combo box comboBox.DataSource = calendarInlineEvents; // Displaying Data in combo box based on subject comboBox.DisplayMemberPath = "Subject"; comboBox.SelectionChanged += ComboBox_SelectionChanged; base.OnAttachedTo(bindable); }
private void PopulateCalendar() { Color mainYellowColor = (Color)Application.Current.Resources["MainYellowColor"]; var eventList = new CalendarEventCollection(); // var source = ((CalendarEventsViewModel) BindingContext).CalendarEvents; var source = Global.GetCalendarWeek(); foreach (var item in source) { var inlineEvent = new CalendarInlineEvent(); inlineEvent.Subject = item.Subject; inlineEvent.StartTime = item.StartEventDateTime; inlineEvent.EndTime = item.EndEventDateTime; inlineEvent.Color = mainYellowColor; eventList.Add(inlineEvent); } var sourceM = Global.GetCalendarMonth(); foreach (var item in sourceM) { var inlineEvent = new CalendarInlineEvent(); inlineEvent.Subject = item.Subject; inlineEvent.StartTime = item.StartEventDateTime; inlineEvent.EndTime = item.EndEventDateTime; inlineEvent.Color = mainYellowColor; eventList.Add(inlineEvent); } var sourceY = Global.GetCalendarYear(); foreach (var item in sourceY) { var inlineEvent = new CalendarInlineEvent(); inlineEvent.Subject = item.Subject; inlineEvent.StartTime = item.StartEventDateTime; inlineEvent.EndTime = item.EndEventDateTime; inlineEvent.Color = mainYellowColor; eventList.Add(inlineEvent); } Calendar.DataSource = eventList; }
/// <summary> /// Gets the appointments based on subject. /// </summary> /// <returns>The appointments.</returns> /// <param name="subject">Subject.</param> private CalendarEventCollection GetAppointments(string subject) { var data = new CalendarEventCollection(); foreach (var item in calendarInlineEvents) { if (item.Subject == subject) { data.Add(item); } } return(data); }
private void PopulateEvents() { var events = _eventService.GetAllEvents(); TodayEvents = new ObservableCollection <Event>(events.Where(evnt => evnt.StartTime.Date == DateTime.Today)); AllEvents = new CalendarEventCollection(); events.ForEach(evnt => AllEvents.Add(new CalendarInlineEvent { StartTime = evnt.StartTime, EndTime = evnt.EndTime, Subject = evnt.Description })); }
public InlineEvents() { InitializeComponent(); this.Padding = new Thickness(-10); if (Device.OS == TargetPlatform.Android) { calendar.HeaderHeight = 50 * (float)(App.Density / 2); } if (Device.OS == TargetPlatform.iOS) { calendar.HeaderHeight = 40; sampleLayout.Padding = new Thickness(0, 0, 0, 90); } calendarEventCollection = new CalendarEventCollection(); setColors(); setSubjects(); setStartTime(); setEndTime(); for (int i = 0; i < 5; i++) { CalendarInlineEvent appointment = new CalendarInlineEvent(); appointment.Color = Color.FromHex(colorCollection[i]); appointment.Subject = subjectCollection[i]; appointment.StartTime = startTimeCollection[i]; appointment.EndTime = endTimeCollection[i]; calendarEventCollection.Add(appointment); } for (int i = 0; i < 5; i++) { CalendarInlineEvent appointment2 = new CalendarInlineEvent(); appointment2.Color = Color.FromHex(colorCollection2[i]); appointment2.Subject = subjectCollection2[i]; appointment2.StartTime = startTimeCollection2[i]; appointment2.EndTime = endTimeCollection2[i]; calendarEventCollection.Add(appointment2); } calendar.BindingContext = calendarEventCollection; }
public static CalendarEventCollection ToCalendarInlineEvent(IEnumerable <WorkShift> workShifts) { var collection = new CalendarEventCollection(); if (workShifts != null && workShifts.Any()) { foreach (var workshift in workShifts) { collection.Add(ToCalendarInlineEvent(workshift)); } } return(collection); }
/// <summary> /// Gets the selected date appointments. /// </summary> /// <returns>The selected date appointments.</returns> /// <param name="date">Date.</param> public CalendarEventCollection GetSelectedDateAppointments(DateTime?date) { CalendarEventCollection selectedDateAppointments = new CalendarEventCollection(); for (int i = 0; i < calendarInlineEvents.Count; i++) { DateTime startDate = calendarInlineEvents[i].StartTime; if (date.Value.Day == startDate.Day && date.Value.Month == startDate.Month && date.Value.Year == startDate.Year) { selectedDateAppointments.Add(calendarInlineEvents[i]); } } return(selectedDateAppointments); }
/*********************************************************** **Creating appointments for ScheduleAppointmentCollection** ***********************************************************/ private void GetAppointments() { appointmentCollection = new CalendarEventCollection(); SetColors(); SetSubjects(); SetStartTime(); SetEndTime(); for (int i = 0; i < 15; i++) { CalendarInlineEvent appointment = new CalendarInlineEvent(); appointment.Color = Color.ParseColor(colorCollection[i]); appointment.Subject = subjectCollection[i]; appointment.StartTime = startTimeCollection[i]; appointment.EndTime = endTimeCollection[i]; appointmentCollection.Add(appointment); } }
public void InitSchoolSchedule() { var appointments = new CalendarEventCollection(); var schoolSchedule = App.SchoolSchedule; var datas = new List <JsonData>(); foreach (var key in schoolSchedule.Keys) { foreach (var value in schoolSchedule[key].Data.Keys) { var date = DateTime.ParseExact(key + value.PadLeft(2, '0'), "yyyyMMdd", null).ToString(); var random = new Random(); foreach (var item in schoolSchedule[key].Data[value]) { datas.Add(new JsonData { Subject = item, StartTime = date, EndTime = date, IsAllDay = "True", Background = string.Format("#{0:X6}", random.Next(0x1000000)) }); } } } foreach (var data in datas) { appointments.Add(new CalendarInlineEvent() { Subject = data.Subject, StartTime = Convert.ToDateTime(data.StartTime), EndTime = Convert.ToDateTime(data.EndTime), Color = Color.FromHex(data.Background), IsAllDay = Convert.ToBoolean(data.IsAllDay) }); } SchoolScheduleCalendar.DataSource = appointments; }
public void InitLunchMenu() { var appointments = new CalendarEventCollection(); var lunchMenu = App.LunchMenu; var datas = new List <JsonData>(); foreach (var key in lunchMenu.Data.Keys) { var date = DateTime.ParseExact(key, "yyyyMMdd", null).ToString(); foreach (var item in lunchMenu.Data[key]) { var random = new Random(); datas.Add(new JsonData { Subject = item, StartTime = date, EndTime = date, IsAllDay = "True", Background = string.Format("#{0:X6}", random.Next(0x1000000)) }); } } foreach (var data in datas) { appointments.Add(new CalendarInlineEvent() { Subject = data.Subject, StartTime = Convert.ToDateTime(data.StartTime), EndTime = Convert.ToDateTime(data.EndTime), Color = Color.FromHex(data.Background), IsAllDay = Convert.ToBoolean(data.IsAllDay) }); } LunchMenuCalendar.DataSource = appointments; }
public GettingStarted() { //InitializeComponent (); SfCalendar calendar = new SfCalendar(); //calendar.SelectionMode = SelectionMode.MultiSelection; //เลือกวันMuti calendar.ShowInlineEvents = true; CalendarInlineEvent events = new CalendarInlineEvent(); WebClient wb = new WebClient(); string userID = LoginPage.myUser_id; string myQuery = userID.ToString(); string re = wb.UploadString("http://10.80.119.250:8082/notification/get_appoinement_data", myQuery); //string re = "2018-07-24 11:00:00|ฉีดยาไข้หวัดนก"; string[] detail = re.Split('|'); DateTime time; DateTime.TryParse(detail[0], out time); events.StartTime = time; events.EndTime = time.AddHours(5); events.Subject = detail[1]; events.Color = Color.Fuchsia; CalendarEventCollection collection = new CalendarEventCollection(); collection.Add(events); calendar.DataSource = collection; this.Content = calendar; }
void UpdateEvents(DateTime calendarDate) { DateTime dt = new DateTime(calendarDate.Year, calendarDate.Month, calendarDate.Day); var ev = calendarEventCollection.Where(e => e.StartTime == dt && e.EndTime == dt); // UpdateEventsは承認リクエスト以降に呼び出されないという実装に依存しているので、 // 既に何らかの承認ステータスであることを想定しない if (ev.Count() == 0) { calendarEventCollection.Add( new CalendarInlineEvent() { StartTime = dt, EndTime = dt, Color = Color.Yellow }); calendar.DataSource = calendarEventCollection; } else { throw new Exception($"{calendarDate} is invalid"); } }
private void DisplayBookmarkedTender(List <tenderBookmark> tenderBookmarks) { //SfCalendar calendar = new SfCalendar(); calendar.ShowInlineEvents = true; CalendarEventCollection collection = new CalendarEventCollection(); //string closingdate = "2018-04-30 00:00:00"; //working date format //string closingdate = "30-05-2018 at 3:00 PM"; //not working *ORIGINAL TEXT FROM SESCO TENDER WEBSITE //string closingdate = "30-05-2018 3:00 PM"; //working //string closingdate = "30-05-2018 3:00 PM"; //CultureInfo MyCultureInfo = CultureInfo.CurrentCulture; //not working //CultureInfo MyCultureInfo = new CultureInfo("fr-FR"); foreach (var bookmark in tenderBookmarks) { CalendarInlineEvent events = new CalendarInlineEvent(); /* * // If only closingDate exist * if (String.IsNullOrEmpty(bookmark.startDate)) * { * events.StartTime = DateTime.Parse(bookmark.closingDate); * events.EndTime = events.StartTime; * events.Subject = bookmark.tenderTitle; * } * // If only startDate exist * else if (String.IsNullOrEmpty(bookmark.closingDate)) * { * events.StartTime = DateTime.Parse(bookmark.startDate); * events.EndTime = events.StartTime; * events.Subject = bookmark.tenderTitle; * } * // If both startDate and closingDate exist * else * { * events.StartTime = DateTime.Parse(bookmark.startDate); * events.EndTime = DateTime.Parse(bookmark.closingDate); * events.Subject = bookmark.tenderTitle; * }*/ events.StartTime = DateTime.Parse(bookmark.closingDate); events.EndTime = DateTime.Parse(bookmark.closingDate); events.Subject = bookmark.tenderTitle; events.Color = Color.Navy; /* * // random event color * Color randomColor = Color.FromRgb(rnd.Next(256), rnd.Next(256), rnd.Next(256)); * events.Color = randomColor; */ collection.Add(events); } /* * CalendarInlineEvent events = new CalendarInlineEvent(); * events.StartTime = DateTime.Parse(closingdate, MyCultureInfo); * events.EndTime = events.StartTime; * //events.EndTime = DateTime.Parse(closingdate, MyCultureInfo); * events.Subject = "Medamit to Limbang Town 132kV Transmission Line Pr..."; * * CalendarEventCollection collection = new CalendarEventCollection(); * collection.Add(events); */ calendar.DataSource = collection; //this.Content = calendar; //Console.WriteLine("CLOSING DATE!!!! CLOSING DATE!!!! CLOSING DATE!!!!:" + DateTime.Parse(closingdate,MyCultureInfo)); }
public CalendarPage() { InitializeComponent(); MonthViewSettings monthViewSettings = new MonthViewSettings(); calendar.HeightRequest = 300; monthViewSettings.DateSelectionColor = Color.LightGray; monthViewSettings.SelectedDayTextColor = Color.Pink; monthViewSettings.BlackoutColor = Color.Gray; calendar.MonthViewSettings = monthViewSettings; calresult = Controller.InstanceCreation().GetCalenderData(DateTime.Now.Month, DateTime.Now.Year); temp_result = calresult; CalendarEventCollection appointments = new CalendarEventCollection(); List<string> show_meeting_days1 = new List<string>(); DateTime dateTime = new DateTime(); foreach (all_events cal in calresult) { //for (int i = 0; i < cal.meeting_days.Count; i++) //{ // string md = cal.meeting_days[i]; // // DateTime dateTime = DateTime.ParseExact(md, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); // string mdfin = Convert.ToDateTime(md).ToLocalTime().ToString(); // try // { // dateTime = DateTime.ParseExact(mdfin, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture); // } // catch // { // try // { // dateTime = DateTime.ParseExact(mdfin, "M/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture); // } // catch // { // try // { // dateTime = DateTime.ParseExact(mdfin, "MM/dd/yyyy h:mm:ss tt", CultureInfo.InvariantCulture); // } // catch // { // try // { // dateTime = DateTime.ParseExact(mdfin, "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture); // } // catch // { // dateTime = DateTime.ParseExact(mdfin, "M/dd/yyyy h:mm:ss tt", CultureInfo.InvariantCulture); // } // } // } // } // string convertstartdate = dateTime.ToString("yyyy-MM-dd"); // show_meeting_days1.Add(mdfin); //} if (cal.start == "") { continue; } try { if (cal.allday) { string startTime = cal.start; string stopTime = cal.stop; foreach (string dt in cal.meeting_days) { appointments.Add(new CalendarInlineEvent() { StartTime = Convert.ToDateTime(dt).ToLocalTime(), EndTime = Convert.ToDateTime(dt).ToLocalTime(), Subject = cal.meeting_subject.ToString(), Color = Color.Blue, }); } } else { appointments.Add(new CalendarInlineEvent() { StartTime = Convert.ToDateTime(cal.start.ToString()).ToLocalTime(), EndTime = Convert.ToDateTime(cal.start.ToString()).ToLocalTime(), Subject = cal.meeting_subject.ToString(), Color = Color.Pink, }); string StartTime2 = Convert.ToDateTime(cal.start.ToString()).ToLocalTime().ToString(); } } catch (Exception exc) { System.Diagnostics.Debug.WriteLine("" + exc.Message); } } List<all_events> selectedCalDate = calresult.Where((cal) => { // return cal.start.Contains(DateTime.Today.ToString("yyyy-MM-dd")); return cal.StartAt.Contains(DateTime.Today.ToString("yyyy-MM-dd")); } ).ToList<all_events>(); CalendarListView.ItemsSource = selectedCalDate; calendar.DataSource = appointments; CalendarListView.ItemsSource = calresult; }
private async Task calendar_MonthChangedAsync(object sender, MonthChangedEventArgs args) { var currentpage = new LoadingAlert(); await PopupNavigation.PushAsync(currentpage); DateTime dt = args.args.CurrentValue; calresult = new List<all_events>(); calresult = Controller.InstanceCreation().GetCalenderData(dt.Month, dt.Year); CalendarEventCollection appointments = new CalendarEventCollection(); foreach (all_events cal in calresult) { if (cal.start == "") { continue; } try { if (cal.allday) { string startTime = cal.start; string stopTime = cal.stop; foreach (string data in cal.meeting_days) { appointments.Add(new CalendarInlineEvent() { StartTime = Convert.ToDateTime(data).ToLocalTime(), EndTime = Convert.ToDateTime(data).ToLocalTime(), Subject = cal.meeting_subject.ToString(), Color = Color.Blue, }); } } else { appointments.Add(new CalendarInlineEvent() { StartTime = Convert.ToDateTime(cal.start.ToString()).ToLocalTime(), EndTime = Convert.ToDateTime(cal.start.ToString()).ToLocalTime(), Subject = cal.meeting_subject.ToString(), Color = Color.Pink, }); } } catch (Exception exc) { System.Diagnostics.Debug.WriteLine("" + exc.Message); } } List<all_events> selectedCalDate = calresult.Where((cal) => { return cal.start.Contains(DateTime.Today.ToString("yyyy-MM-dd")); } ).ToList<all_events>(); CalendarListView.ItemsSource = selectedCalDate; calendar.DataSource = appointments; CalendarListView.ItemsSource = calresult; Loadingalertcall(); }
/// <summary> /// /////////////////////// /// </summary> protected override void OnAttachedTo(SfCalendar bindable) { calendar = bindable; int SemanaPublicada = 1; calendar.MoveToDate = new DateTime(2020, 03, 8); calendar.MaximumEventIndicatorCount = 10; // create CalendarInlineEvents collection CalendarEventCollection calendarInlineEvents = new CalendarEventCollection(); //// Create events for (int i = 1; i <= TareasColleccion.Count * 7; i = i + 7) { foreach (Tarea itemTarea in TareasColleccion) { if (itemTarea.SemanaTerminacionPlaneada == SemanaPublicada && itemTarea.PlanIndividualId == 3) { calendarInlineEvents.Add( new CalendarInlineEvent() { Subject = itemTarea.Nombre, StartTime = calendar.MoveToDate.AddDays(i).AddHours(7), EndTime = calendar.MoveToDate.AddDays(i).AddHours(19), Color = ObtenerColorRamdon() }); } } SemanaPublicada = SemanaPublicada + 1; /** * calendarInlineEvents.Add( * new CalendarInlineEvent() * { * Subject = "Goto Meeting", * StartTime = calendar.MoveToDate.AddDays(i).AddHours(7), * EndTime = calendar.MoveToDate.AddDays(i).AddHours(19), * Color = Color.Green * }); * * calendarInlineEvents.Add( * new CalendarInlineEvent() * { * Subject = "Goto Conference", * StartTime = calendar.MoveToDate.AddDays(i).AddHours(11), * EndTime = calendar.MoveToDate.AddDays(i).AddHours(12), * Color = Color.Blue * }); * * calendarInlineEvents.Add( * new CalendarInlineEvent() * { * Subject = "Goto Lunch", * StartTime = calendar.MoveToDate.AddDays(i).AddHours(13), * EndTime = calendar.MoveToDate.AddDays(i).AddHours(14), * Color = Color.Fuchsia * }); * * calendarInlineEvents.Add( * new CalendarInlineEvent() * { * Subject = "Goto Meeting", * StartTime = calendar.MoveToDate.AddDays(i).AddHours(15), * EndTime = calendar.MoveToDate.AddDays(i).AddHours(16), * Color = Color.Red * }); * * calendarInlineEvents.Add( * new CalendarInlineEvent() * { * Subject = "Goto Conference", * StartTime = calendar.MoveToDate.AddDays(i).AddHours(16), * EndTime = calendar.MoveToDate.AddDays(i).AddHours(17), * Color = Color.FromRgb(53, 122, 160) * }); **/ } // Customize the DayHeader using MonthView Settings MonthViewSettings monthViewSettings = new MonthViewSettings(); monthViewSettings.DayHeaderBackgroundColor = Color.FromRgb(53, 122, 160); monthViewSettings.DayHeaderTextColor = Color.White; calendar.MonthViewSettings = monthViewSettings; // Set CalendarInlineEvents collection as SfCalendar DataSource calendar.DataSource = calendarInlineEvents; base.OnAttachedTo(bindable); }
public CalendarPage() { InitializeComponent(); calendar.MonthViewSettings = monthViewSettings; calendar.HeightRequest = 300; monthViewSettings.DateSelectionColor = Color.Gray; monthViewSettings.SelectedDayTextColor = Color.FromHex("#363E4B"); monthViewSettings.BlackoutColor = Color.Gray; monthViewSettings.CurrentMonthTextColor = Color.FromHex("#ffffff"); monthViewSettings.PreviousMonthTextColor = Color.Black; // monthViewSettings.CurrentMonthTextColor = Color.FromHex("#128197"); monthViewSettings.CurrentMonthBackgroundColor = Color.FromHex("#128197"); // monthViewSettings.PreviousMonthBackgroundColor = Color.White; monthViewSettings.PreviousMonthBackgroundColor = Color.FromHex("#363E4B"); monthViewSettings.SelectedDayTextColor = Color.GreenYellow; monthViewSettings.DayLabelTextAlignment = DayLabelTextAlignment.Center; calendar.MonthViewSettings = monthViewSettings; calresult = Controller.InstanceCreation().GetCalenderData(DateTime.Now.Month, DateTime.Now.Year); temp_result = calresult; CalendarEventCollection appointments = new CalendarEventCollection(); List<string> show_meeting_days1 = new List<string>(); DateTime dateTime = new DateTime(); foreach (all_events cal in calresult) { if (cal.start == "") { continue; } try { if (cal.allday) { string startTime = cal.start; string stopTime = cal.stop; foreach (string dt in cal.meeting_days) { appointments.Add(new CalendarInlineEvent() { StartTime = Convert.ToDateTime(dt).ToLocalTime(), EndTime = Convert.ToDateTime(dt).ToLocalTime(), Subject = cal.meeting_subject.ToString(), // Color = Color.Blue, Color = Color.FromHex("#FDA701"), }); } } else { appointments.Add(new CalendarInlineEvent() { StartTime = Convert.ToDateTime(cal.start.ToString()).ToLocalTime(), EndTime = Convert.ToDateTime(cal.start.ToString()).ToLocalTime(), Subject = cal.meeting_subject.ToString(), Color = Color.White, }); string StartTime2 = Convert.ToDateTime(cal.start.ToString()).ToLocalTime().ToString(); } } catch (Exception exc) { System.Diagnostics.Debug.WriteLine("" + exc.Message); } } List<all_events> selectedCalDate = calresult.Where((cal) => { // return cal.start.Contains(DateTime.Today.ToString("yyyy-MM-dd")); return cal.StartAt.Contains(DateTime.Today.ToString("yyyy-MM-dd")); } ).ToList<all_events>(); CalendarListView.ItemsSource = selectedCalDate; calendar.DataSource = appointments; CalendarListView.ItemsSource = calresult; }