-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.vb
78 lines (69 loc) · 2.17 KB
/
MainWindow.xaml.vb
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Imports DevExpress.Xpf.Scheduling.iCalendar
Imports Microsoft.Win32
Imports System.IO
Imports System.Windows
Namespace WpfApplication1
Partial Public Class MainWindow
Inherits DevExpress.Xpf.Core.DXWindow
Public Sub New()
InitializeComponent()
End Sub
#Region "#Import_Button"
Private Sub Import_Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim dialog As New OpenFileDialog()
dialog.Filter = "iCalendar files (*.ics)|*.ics"
dialog.FilterIndex = 1
If Not dialog.ShowDialog().Equals(True) Then
Return
End If
Using stream As Stream = dialog.OpenFile()
ImportAppointments(stream)
End Using
End Sub
#End Region ' #Import_Button
#Region "#Import_Drop"
Private Sub schedulerControl1_Drop(ByVal sender As Object, ByVal e As DragEventArgs)
Dim fileNames() As String = TryCast(e.Data.GetData(DataFormats.FileDrop), String())
If fileNames Is Nothing OrElse fileNames.Length = 0 Then
Return
End If
For Each fileName As String In fileNames
If File.Exists(fileName) Then
Using stream As Stream = File.Open(fileName, FileMode.Open)
ImportAppointments(stream)
End Using
End If
Next fileName
End Sub
#End Region ' #Import_Drop
#Region "#Import"
Private Sub ImportAppointments(ByVal stream As Stream)
If stream Is Nothing Then
Return
End If
Dim importer As New ICalendarImporter(schedulerControl1)
importer.Import(stream)
End Sub
#End Region ' #Import
#Region "#Export"
Private Sub Export_Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim dialog As New SaveFileDialog()
dialog.Filter = "iCalendar files (*.ics)|*.ics"
dialog.FilterIndex = 1
If dialog.ShowDialog().Equals(True) Then
Using stream As Stream = dialog.OpenFile()
ExportAppointments(stream)
End Using
End If
End Sub
Private Sub ExportAppointments(ByVal stream As Stream)
If stream Is Nothing Then
Return
End If
Dim exporter As New ICalendarExporter(schedulerControl1)
exporter.ProductIdentifier = "-//Developer Express Inc.//DXScheduler iCalendarExchange Example//EN"
exporter.Export(stream)
End Sub
#End Region ' #Export
End Class
End Namespace