/// Default value. Marks will be displayed only on event day.
/// </summary>
Unique,
+
/// <summary>
/// Marks will be displayed every day after event day.
/// </summary>
Daily,
+
/// <summary>
/// Marks will be displayed every week after event day.
/// </summary>
Weekly,
+
/// <summary>
/// Marks will be displayed every month day that coincides to event day.
/// </summary>
Monthly,
+
/// <summary>
/// Marks will be displayed every year that coincides to event day.
/// </summary>
Annually,
+
/// <summary>
/// Marks will be displayed every last day of month after event day.
/// </summary>
/// Default value. a day is always selected.
/// </summary>
Default,
+
/// <summary>
/// A day is always selected.
/// </summary>
Always,
+
/// <summary>
/// None of the days can be selected.
/// </summary>
None,
+
/// <summary>
/// User may have selected a day or not.
/// </summary>
OnDemand
}
+ [Flags]
+ public enum CalendarSelectable
+ {
+ None = 0,
+ Year = 1 << 0,
+ Month = 1 << 1,
+ Day = 1 << 2
+ }
+
/// <summary>
/// The CalendarMark is a Item for marking a Calendar's type,date and repeat type.
/// </summary>
SmartEvent _displayedMonthChanged;
int _cacheDisplayedMonth;
+ Interop.Elementary.Elm_Calendar_Format_Cb _calendarFormat;
+ DateFormatDelegate _dateFormatDelegate = null;
+
/// <summary>
/// Creates and initializes a new instance of the Calendar class.
/// </summary>
DisplayedMonthChanged?.Invoke(this, new DisplayedMonthChangedEventArgs(_cacheDisplayedMonth, currentDisplayedMonth));
_cacheDisplayedMonth = currentDisplayedMonth;
};
+
+ _calendarFormat = (t) => { return _dateFormatDelegate(t); };
}
/// <summary>
public event EventHandler<DisplayedMonthChangedEventArgs> DisplayedMonthChanged;
/// <summary>
+ /// This delegate type is used to format the string that will be used to display month and year.
+ /// </summary>
+ /// <param name="time">DateTime</param>
+ /// <returns></returns>
+ public delegate string DateFormatDelegate(DateTime time);
+
+ /// <summary>
/// Sets or gets the minimum for year.
/// </summary>
public int MinimumYear
}
/// <summary>
+ /// Gets or sets fields of a datetime will be taken into account, when SelectedDate set is invoked.
+ /// </summary>
+ public CalendarSelectable Selectable
+ {
+ get
+ {
+ return (CalendarSelectable)Interop.Elementary.elm_calendar_selectable_get(RealHandle);
+ }
+ set
+ {
+ Interop.Elementary.elm_calendar_selectable_set(RealHandle, (int)value);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets date format the string that will be used to display month and year.
+ /// By default it uses strftime with "%B %Y" format string.
+ /// It should allocate the memory that will be used by the string, that will be freed by the widget after usage.A pointer to the string and a pointer to the time struct will be provided.
+ /// </summary>
+ public DateFormatDelegate DateFormat
+ {
+ get
+ {
+ return _dateFormatDelegate;
+ }
+ set
+ {
+ _dateFormatDelegate = value;
+ if (value != null)
+ {
+ Interop.Elementary.elm_calendar_format_function_set(RealHandle, _calendarFormat);
+ }
+ else
+ {
+ Interop.Elementary.elm_calendar_format_function_set(RealHandle, null);
+ }
+ }
+ }
+
+ /// <summary>
/// Add a new mark to the calendar.
/// </summary>
/// <param name="type">A string used to define the type of mark. It will be emitted to the theme, that should display a related modification on these days representation.</param>
{
label1.Text = string.Format("Old.Day={0}, Month={1}, Year={2}", e.OldDate.Day, e.OldDate.Month, e.OldDate.Year);
label2.Text = string.Format("New.Day={0}, Month={1}, Year={2}", e.NewDate.Day, e.NewDate.Month, e.NewDate.Year);
+ label3.Text = string.Format("SelectedDate={0}", calendar.SelectedDate);
};
calendar.DisplayedMonthChanged += (object sender, DisplayedMonthChangedEventArgs e) =>
label3.Text = string.Format("Old Month={0}, New Month={1}", e.OldMonth, e.NewMonth);
};
+ var label4 = new Label(window)
+ {
+ Text = string.Format("Selectable={0}", calendar.Selectable),
+ Color = Color.Black,
+ };
+
+ var changeSelectable = new Button(window)
+ {
+ Text = "Change Selectable"
+ };
+
+ calendar.Selectable = CalendarSelectable.Month;
+
+ changeSelectable.Clicked += (s, e) =>
+ {
+ if (calendar.Selectable == CalendarSelectable.None)
+ {
+ calendar.Selectable = CalendarSelectable.Year;
+ }
+ else if (calendar.Selectable == CalendarSelectable.Year)
+ {
+ calendar.Selectable = CalendarSelectable.Month;
+ }
+ else if (calendar.Selectable == CalendarSelectable.Month)
+ {
+ calendar.Selectable = CalendarSelectable.Day;
+ }
+ else
+ {
+ calendar.Selectable = CalendarSelectable.None;
+ }
+ label4.Text = string.Format("Selectable={0}", calendar.Selectable);
+ };
+
+ var setTime = new Button(window)
+ {
+ Text = "Set 2015,1,1",
+ };
+
+ setTime.Clicked += (s, e) =>
+ {
+ calendar.SelectedDate = new DateTime(2015, 1, 1);
+ };
+
calendar.Resize(600, 600);
- calendar.Move(0, 250);
+ calendar.Move(0, 150);
calendar.Show();
- label1.Resize(600, 100);
+ label1.Resize(600, 30);
label1.Move(0, 0);
label1.Show();
- label2.Resize(600, 100);
- label2.Move(0, 50);
+ label2.Resize(600, 30);
+ label2.Move(0, 30);
label2.Show();
- label3.Resize(600, 100);
- label3.Move(0, 100);
+ label3.Resize(600, 30);
+ label3.Move(0, 60);
label3.Show();
- selectMode.Resize(600, 100);
- selectMode.Move(0, 150);
+ selectMode.Resize(600, 30);
+ selectMode.Move(0, 90);
selectMode.Show();
addMark.Resize(600, 100);
- addMark.Move(0, 900);
+ addMark.Move(0, 750);
addMark.Show();
delMark.Resize(600, 100);
- delMark.Move(0, 1000);
+ delMark.Move(0, 850);
delMark.Show();
changeMode.Resize(600, 100);
- changeMode.Move(0, 1100);
+ changeMode.Move(0, 950);
changeMode.Show();
+
+ label4.Resize(600, 30);
+ label4.Move(0, 1050);
+ label4.Show();
+
+ changeSelectable.Resize(600, 100);
+ changeSelectable.Move(0, 1080);
+ changeSelectable.Show();
+
+ setTime.Resize(600, 100);
+ setTime.Move(0, 1180);
+ setTime.Show();
}
}
}
\ No newline at end of file