Skip to content

Commit 7c12211

Browse files
CalendarTypes sample updated.
1 parent e4d6a87 commit 7c12211

2 files changed

Lines changed: 77 additions & 14 deletions

File tree

CalendarTypes/CalendarTypes/MainWindow.xaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
mc:Ignorable="d">
1010

1111
<Grid>
12+
<Grid.Resources>
13+
<DataTemplate x:Key="specialRegionTemplate">
14+
<Grid Background="{Binding Background}"
15+
Opacity="0.5"
16+
HorizontalAlignment="Stretch"
17+
VerticalAlignment="Stretch">
18+
<Path x:Name="Fork" Data="M11,0 C11.553001,0 12,0.4469986 12,1 L12,15 C12,15.553001 11.553001,16 11,16 10.446999,16 10,15.553001 10,15 L10,7 9,7 C8.4469986,7 8,6.5530014 8,6 L8,3 C8,1.3429985 9.3429985,0 11,0 z M0,0 L1,0 1.2340002,4 1.7810001,4 2,0 3,0 3.2340002,4 3.7810001,4 4,0 5,0 5,4 C5,4.9660001 4.3140001,5.7727499 3.4029064,5.9593439 L3.4007993,5.9597201 3.9114671,14.517 C3.9594617,15.321 3.3195295,16 2.5136147,16 L2.5076156,16 C1.6937013,16 1.0517693,15.309 1.1107631,14.497 L1.7400641,5.9826035 1.6955509,5.9769421 C0.73587513,5.8301721 0,5.0005002 0,4 z" Fill="Black" HorizontalAlignment="Center" Height="16" Stretch="Fill" VerticalAlignment="Center" Width="12"/>
19+
</Grid>
20+
</DataTemplate>
21+
</Grid.Resources>
1222
<Grid.DataContext>
1323
<local:ViewModel/>
1424
</Grid.DataContext>
@@ -39,10 +49,10 @@
3949
AppointmentDisplayCount="2"/>
4050
</syncfusion:SfScheduler.MonthViewSettings>
4151
<syncfusion:SfScheduler.DaysViewSettings>
42-
<syncfusion:DaysViewSettings MinimumAppointmentDuration="0:30:0"/>
52+
<syncfusion:DaysViewSettings MinimumAppointmentDuration="0:30:0" SpecialTimeRegionTemplate="{StaticResource specialRegionTemplate}"/>
4353
</syncfusion:SfScheduler.DaysViewSettings>
4454
<syncfusion:SfScheduler.TimelineViewSettings>
45-
<syncfusion:TimelineViewSettings MinimumAppointmentDuration="0:30:0"/>
55+
<syncfusion:TimelineViewSettings MinimumAppointmentDuration="0:30:0" SpecialTimeRegionTemplate="{StaticResource specialRegionTemplate}"/>
4656
</syncfusion:SfScheduler.TimelineViewSettings>
4757
</syncfusion:SfScheduler>
4858
</Grid>
Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.UI.Xaml;
1+
using Microsoft.UI;
2+
using Microsoft.UI.Xaml;
23
using Microsoft.UI.Xaml.Controls;
34
using Microsoft.UI.Xaml.Controls.Primitives;
45
using Microsoft.UI.Xaml.Data;
@@ -8,6 +9,7 @@
89
using Syncfusion.UI.Xaml.Scheduler;
910
using System;
1011
using System.Collections.Generic;
12+
using System.Collections.ObjectModel;
1113
using System.IO;
1214
using System.Linq;
1315
using System.Runtime.InteropServices.WindowsRuntime;
@@ -19,15 +21,66 @@
1921

2022
namespace CalendarTypes
2123
{
22-
/// <summary>
23-
/// An empty window that can be used on its own or navigated to within a Frame.
24-
/// </summary>
25-
public sealed partial class MainWindow : Window
26-
{
27-
public MainWindow()
28-
{
29-
this.InitializeComponent();
30-
viewtypecombobox.ItemsSource = Enum.GetValues(typeof(SchedulerViewType));
31-
}
32-
}
24+
/// <summary>
25+
/// An empty window that can be used on its own or navigated to within a Frame.
26+
/// </summary>
27+
public sealed partial class MainWindow : Window
28+
{
29+
public MainWindow()
30+
{
31+
this.InitializeComponent();
32+
this.viewtypecombobox.ItemsSource = Enum.GetValues(typeof(SchedulerViewType));
33+
var specialTimeRegions = this.GetSpecialTimeRegions();
34+
this.Schedule.MinimumDate = new DateTime(DateTime.Today.Year, DateTime.Today.AddMonths(-3).Month, 12, 0, 0, 0);
35+
this.Schedule.MaximumDate = new DateTime(DateTime.Today.Year, DateTime.Today.AddMonths(3).Month, 12, 0, 0, 0);
36+
this.Schedule.DisplayDate = DateTime.Today.Date.AddHours(9);
37+
this.Schedule.DaysViewSettings.SpecialTimeRegions = specialTimeRegions;
38+
this.Schedule.TimelineViewSettings.SpecialTimeRegions = specialTimeRegions;
39+
this.Schedule.BlackoutDates = GetBlackoutDates();
40+
}
41+
42+
/// <summary>
43+
/// Method to get Special time region collections.
44+
/// </summary>
45+
/// <returns></returns>
46+
private ObservableCollection<SpecialTimeRegion> GetSpecialTimeRegions()
47+
{
48+
var currentDate = DateTime.Now.AddMonths(-3);
49+
var timeRegion = new SpecialTimeRegion();
50+
timeRegion.StartTime = new DateTime(currentDate.Year, currentDate.Month, 1, 13, 0, 0);
51+
timeRegion.EndTime = timeRegion.StartTime.AddHours(1);
52+
timeRegion.RecurrenceRule = "FREQ=DAILY;INTERVAL=1";
53+
timeRegion.Text = "Lunch";
54+
timeRegion.CanEdit = true;
55+
timeRegion.Background = new SolidColorBrush(Colors.LightGray);
56+
timeRegion.Foreground = new SolidColorBrush(Colors.White);
57+
58+
var specialTimeRegions = new ObservableCollection<SpecialTimeRegion>();
59+
specialTimeRegions.Add(timeRegion);
60+
61+
return specialTimeRegions;
62+
}
63+
64+
65+
66+
/// <summary>
67+
/// Method to get blackout date collections.
68+
/// </summary>
69+
// <returns>The blackoutDateCollection.</returns>
70+
private ObservableCollection<DateTime> GetBlackoutDates()
71+
{
72+
var blackoutDateCollection = new ObservableCollection<DateTime>()
73+
{
74+
DateTime.Now.AddDays(-2),
75+
DateTime.Now.AddDays(-1),
76+
DateTime.Now.AddDays(0),
77+
DateTime.Now.AddDays(1),
78+
DateTime.Now.AddDays(2)
79+
};
80+
81+
return blackoutDateCollection;
82+
}
83+
84+
85+
}
3386
}

0 commit comments

Comments
 (0)