Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports C1.Silverlight.Schedule

Namespace CustomViews
	Partial Public Class MainPage
		Inherits UserControl
		Implements IDisposable
		Public Sub New()
			InitializeComponent()
			sched1.ChangeStyle(sched1.WeekStyle)
		End Sub
		Private Sub btnToday_Click(ByVal sender As Object, ByVal e As C1.Silverlight.SourcedEventArgs)
			sched1.VisibleDates.BeginUpdate()
			sched1.VisibleDates.Clear()
			sched1.VisibleDates.Add(Date.Today)
			sched1.VisibleDates.EndUpdate()
		End Sub

		' Change view from Month View mode to 2 Week mode if selection 
		' contains 2 full weeks.
		Private Sub sched1_BeforeViewChange(ByVal sender As Object, ByVal e As BeforeViewChangeEventArgs)
            If e.Dates.Length = 14 AndAlso e.Style Is sched1.MonthStyle Then
                Dim s As Style = CType(Me.Resources("TwoWeekStyle"), Style)
                If s IsNot Nothing Then
                    e.Style = s
                End If
            End If
		End Sub

		Private Sub btnDay_Click(ByVal sender As Object, ByVal e As C1.Silverlight.SourcedEventArgs)
			sched1.ChangeStyle(sched1.OneDayStyle)
		End Sub

		Private Sub btnWorkWeek_Click(ByVal sender As Object, ByVal e As C1.Silverlight.SourcedEventArgs)
			sched1.ChangeStyle(sched1.WorkingWeekStyle)
		End Sub

		Private Sub btnWeek_Click(ByVal sender As Object, ByVal e As C1.Silverlight.SourcedEventArgs)
			sched1.ChangeStyle(sched1.WeekStyle)
		End Sub

		Private Sub btn2Week_Click(ByVal sender As Object, ByVal e As C1.Silverlight.SourcedEventArgs)
			sched1.ChangeStyle(Resources("TwoWeekStyle"))
		End Sub

		Private Sub btnMonth_Click(ByVal sender As Object, ByVal e As C1.Silverlight.SourcedEventArgs)
			sched1.ChangeStyle(sched1.MonthStyle)
		End Sub

		Private Sub btnTimeLine_Click(ByVal sender As Object, ByVal e As C1.Silverlight.SourcedEventArgs)
			sched1.ChangeStyle(sched1.TimeLineStyle)
		End Sub

		Private Sub btnImport_Click(ByVal sender As Object, ByVal e As C1.Silverlight.SourcedEventArgs)
			C1Scheduler.ImportCommand.Execute(Nothing, sched1)
		End Sub

		Private Sub btnExport_Click(ByVal sender As Object, ByVal e As C1.Silverlight.SourcedEventArgs)
			C1Scheduler.ExportCommand.Execute(Nothing, sched1)
		End Sub

		#Region "IDisposable Members"

		Public Sub Dispose() Implements IDisposable.Dispose
			sched1.Dispose()
		End Sub

		#End Region

	End Class
End Namespace
