namespace BNApp.CustomRenderers { public class BNScheduleAppointment : ScheduleAppointment { /// <summary> /// Gets or sets the <c>ShowLocation</c> property. /// </summary> public static readonly BindableProperty ShowLocationProperty = Create(p => p.ShowLocation, "", BindingMode.Default, null, ShowLocationPropertyChanged, null, null, (CreateDefaultValueDelegate<BNScheduleAppointment, string>)null); /// <summary> /// Property which state depends on whether the Appointment has been finished. /// </summary> /// <value> This property depends on <see cref="Aktie.Afgehandeld"/></value> public bool Finished; public List<Color> ColorCollection = new List<Color>(); public BNScheduleAppointment() { CreateColorCollection(); } /// <summary> /// The <c>Color</c> property is used to set the Color for the Appointment. This is a bindable property. /// The <c>Color</c> property is set to <value>Green</value> when the the value of <c>Finished</c> is set to true, otherwise it's color is set to red. /// <para> /// The properties can be changed by modifying the ColorCollection. [0] == true , [1] == false. /// </para> /// </summary> /// <value>This property takes the <see cref="P:Syncfusion.SfSchedule.XForms.ScheduleAppointment.Color" /> And <seealso cref="Finished"/> value.</value> public new Color Color { get { return (Color)this.GetValue(ScheduleAppointment.ColorProperty); } set { if (Finished) { this.SetValue(ScheduleAppointment.ColorProperty, ColorCollection[0]); } else if (!Finished) { this.SetValue(ScheduleAppointment.ColorProperty, ColorCollection[1]); } //else if (!Finished && Color != Color.Default) // this.SetValue(ScheduleAppointment.ColorProperty, (object)value); } } /// <summary> /// The <c>Location</c> property is used to set the location for the Appointment. This is a bindable property. /// </summary> /// <value>This property takes the <see cref="T:System.String" /> value.</value> public string ShowLocation { get { return (string)this.GetValue(BNScheduleAppointment.ShowLocationProperty); } set { this.SetValue(BNScheduleAppointment.ShowLocationProperty, (object)value); } } private static void ShowLocationPropertyChanged(BindableObject bindable, string oldValue, string newValue) { (bindable as BNScheduleAppointment).OnPropertyChanged(BNScheduleAppointment.ShowLocationProperty.PropertyName); } /// <summary> /// Method that will give the customer freedom to change the color to whatever they want. This is a method used for later. /// </summary> /// <param name="color"></param> /// <param name="e"></param> public void SetColor(Color color, SelectedItemChangedEventArgs e) { switch (e.ToString()) { case "FinishedColor": ColorCollection.RemoveAt(0); ColorCollection.Insert(0, color); break; case "UnfinishedColor": ColorCollection.RemoveAt(1); ColorCollection.Insert(1, color); break; } } /// <summary> /// Method that creates colors and adds this to the list. /// [0] is Green, [1] is Red. /// </summary> private void CreateColorCollection() { ColorCollection.Add(Color.FromHex("#00ff00")); ColorCollection.Add(Color.FromHex("#ff0000")); } } } |
namespace BNApp.CustomRenderers { /// <summary> /// Custom class of the AppointmentLoadedEvent. The only thing changed is the usages of the BNScheduleAppointment instead of the regular ScheduleAppointment. /// </summary> public class BNAppointmentLoadedEventArgs : AppointmentLoadedEventArgs { public new AppointmentStyle appointmentStyle { get; set; } public new BNScheduleAppointment appointment { get; set; } public new View view { get; set; } public new Rectangle Bounds { get; set; } public BNAppointmentLoadedEventArgs() { this.appointmentStyle = new AppointmentStyle(); } } } |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Syncfusion.SfSchedule.XForms; using Xamarin.Forms; namespace BNApp.CustomRenderers { public class BNSchedule : SfSchedule { ///// <summary> ///// AppointmentTemplateChanged event is raised while Appointments Changed. ///// </summary> public new event OnAppointmentLoadedEventHandler OnAppointmentLoadedEvent; public BNSchedule() { } public void OnAppointmentLoaded(BNAppointmentLoadedEventArgs args) { // ISSUE: reference to a compiler-generated field if (this.OnAppointmentLoadedEvent == null) return; // ISSUE: reference to a compiler-generated field this.OnAppointmentLoadedEvent((object)this, (BNAppointmentLoadedEventArgs)args); } public new delegate void OnAppointmentLoadedEventHandler(object sender, BNAppointmentLoadedEventArgs args); } |
// does not get in here private void OnLoadedTestMethod(object sender, BNAppointmentLoadedEventArgs args) { if (args.appointment.Subject.Equals("Luuks test afspraak ") && args.appointment.Finished) { Button but = new Button(); but.BackgroundColor = Color.Aqua; but.Text = "doei"; but.Image = "Menu.png"; args.view = but; } } |
private void OnLoadedTestMethod(object sender, AppointmentLoadedEventArgs args) { var c = args as BNAppointmentLoadedEventArgs; var d = args.appointment as BNScheduleAppointment; if (c.appointment.Finished) { // does not work c == null } if (d.Finished) { // does not work b == null } |