-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainPage.xaml.cs
50 lines (41 loc) · 2.03 KB
/
MainPage.xaml.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
using System;
using DevExpress.Maui.Editors;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;
namespace CalendarExample {
public partial class MainPage : ContentPage {
public static readonly BindablePropertyKey OrientationPropertyKey = BindableProperty.CreateReadOnly("Orientation", typeof(StackOrientation), typeof(MainPage), StackOrientation.Vertical);
public static readonly BindableProperty OrientationProperty = OrientationPropertyKey.BindableProperty;
public StackOrientation Orientation => (StackOrientation)GetValue(OrientationProperty);
public MainPage() {
InitializeComponent();
ViewModel = new ViewModel();
BindingContext = ViewModel;
}
ViewModel ViewModel { get; }
void CustomDayCellAppearance(object sender, CustomSelectableCellAppearanceEventArgs e) {
if (e.Date == DateTime.Today)
return;
if (ViewModel.SelectedDate != null && e.Date == ViewModel.SelectedDate.Value)
return;
SpecialDate specialDate = ViewModel.TryFindSpecialDate(e.Date);
if (specialDate == null)
return;
e.FontAttributes = FontAttributes.Bold;
Color textColor;
if (specialDate.IsHoliday) {
textColor = (Color)Resources["CalendarViewHolidayTextColor"];
e.EllipseBackgroundColor = Color.FromRgba(textColor.Red, textColor.Green, textColor.Blue, 0.25);
e.TextColor = textColor;
return;
}
textColor = (Color)Resources["CalendarViewTextColor"];
e.EllipseBackgroundColor = Color.FromRgba(textColor.Red, textColor.Green, textColor.Blue, 0.15);
e.TextColor = textColor;
}
protected override void OnSizeAllocated(double width, double height) {
base.OnSizeAllocated(width, height);
SetValue(OrientationPropertyKey, width > height ? StackOrientation.Horizontal : StackOrientation.Vertical);
}
}
}