Option Explicit On
Option Strict On
Option Compare Text
Option Infer
Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Design
Imports System.IO
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.Sql
Public Class AppointmentBookControl
Inherits System.Windows.Forms.UserControl
#Region "Main Properties"
<Description(AppointmentBookControlResources.MonthlyOverviewSliderDescription)> _
Public Property ShowMonthlyOverviewSlider() As Boolean
Get
Return Me.Theme.ShowMonthlyOverviewSlider
End Get
Set(ByVal value As Boolean)
Me.Theme.ShowMonthlyOverviewSlider = value
Me.UserInterface.MonthlyOverviewSliderVisibleChange(value)
Me.Invalidate()
End Set
End Property
<Description(AppointmentBookControlResources.MonthlyOverviewSliderDockDescription)> _
Public Property MonthlyOverviewSliderDock() As DockStyle
Get
Return Me.Theme.MonthlyOverviewSliderDock
End Get
Set(ByVal value As DockStyle)
Me.Theme.MonthlyOverviewSliderDock = value
Me.UserInterface.MonthlyOverviewSliderDockChange(value)
Me.Invalidate()
End Set
End Property
' Boarder for now has some known issues. First and mostly the containers and objects are drawn overtop boarder.
' Also boarder thickness calculation needs to be tweeks to display adjusted width correctly.
<Browsable(False)> _
Public Property ShowBoarder() As Boolean
Get
Return Me.Theme.ShowBoarder
End Get
Set(ByVal value As Boolean)
Me.Theme.ShowBoarder = value
Me.Invalidate()
End Set
End Property
Private _Year As Integer = Today.Year
Public Property Year As Integer
Get
Return Me._Year
End Get
Set(ByVal value As Integer)
Me._Year = value
End Set
End Property
Private _Month As Integer = Today.Month
Public Property Month As Integer
Get
Return Me._Month
End Get
Set(ByVal value As Integer)
Me._Month = value
End Set
End Property
#End Region
Private UserInterface As New AppointmentBookControlUserInterface(Me)
Private Theme As New AppointmentBookControlTheme(Me)
#Region "Constructors"
Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
'UserControl overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.SuspendLayout()
'
'AppointmentBookControl
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.DoubleBuffered = True
Me.SetStyle(System.Windows.Forms.ControlStyles.UserPaint Or _
System.Windows.Forms.ControlStyles.AllPaintingInWmPaint Or _
System.Windows.Forms.ControlStyles.ResizeRedraw Or _
System.Windows.Forms.ControlStyles.OptimizedDoubleBuffer, True)
Me.UpdateStyles()
Me.Name = "AppointmentBookControl"
Me.ResumeLayout(False)
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
#End Region
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
UserInterface.OnLoad(e)
Me.Invalidate()
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Theme.OnPaint(e) ' Paint theme.
End Sub
' Nested classes.
Private Class AppointmentBookControlUserInterface
<Browsable(False)> _
Private Property Owner As AppointmentBookControl
Private Toolbar As AppointmentBookControlToolbar
Private DaySelectionbar As AppointmentBookControlDaySelectionBar
Private MonthlyOverviewSlider As AppointmentBookControlMonthlyOverviewSlider
Private ScheduleGridBody As AppointmentBookControlScheduleGridBody
Sub New(ByRef Owner As AppointmentBookControl)
MyBase.New()
Me.Owner = Owner ' Pass on the reference.
Toolbar = New AppointmentBookControlToolbar(Owner)
DaySelectionbar = New AppointmentBookControlDaySelectionBar(Owner)
MonthlyOverviewSlider = New AppointmentBookControlMonthlyOverviewSlider(Owner)
ScheduleGridBody = New AppointmentBookControlScheduleGridBody(Owner)
End Sub
Public Sub OnLoad(ByVal e As System.EventArgs)
ScheduleGridBody.InitializeComponent()
DaySelectionbar.InitializeComponent()
Toolbar.InitializeComponent()
MonthlyOverviewSlider.InitializeComponent()
End Sub
Public Sub MonthlyOverviewSliderVisibleChange(ByVal Visible As Boolean)
MonthlyOverviewSlider.Container.Visible = (Visible)
End Sub
Public Sub MonthlyOverviewSliderDockChange(ByVal DockStyle As DockStyle)
MonthlyOverviewSlider.Container.Dock = DockStyle
End Sub
' Nested classes for each of the four user interface divisions.
Private Class AppointmentBookControlToolbar
<Browsable(False)> _
Private Property Parent() As AppointmentBookControl
Private ReadOnly Property Skin() As AppointmentBookControlTheme.AppointmentBookControlThemeSkin
Get
If Parent IsNot Nothing Then
Return Me.Parent.Theme.Skin
Else Return Nothing
End If
End Get
End Property
Private ReadOnly Property [Region]() As Rectangle
Get
If Parent IsNot Nothing Then
Return Me.Parent.Theme.Structures.ToolBarRect
Else Return Nothing
End If
End Get
End Property
Private WithEvents Container As New AppointmentBookControl.AppointmentBookControlPanelControl
Private WithEvents Button1 As New AppointmentBookControl.AppointmentBookControlButtonControl
Private WithEvents Button2 As New AppointmentBookControl.AppointmentBookControlButtonControl
#Region "Constructor"
Sub New(ByRef Parent As AppointmentBookControl)
MyBase.New()
Me.Parent = Parent ' Pass on the reference.
End Sub
Public Sub InitializeComponent()
Me.Parent.SuspendLayout()
'
' Container
'
Me.Parent.Controls.Add(Container)
With Container
.Width = [Region].Width
.Height = [Region].Height
.Location = New Point([Region].Left, [Region].Top)
.Dock = DockStyle.Top
'.BackColor = color.Red ' < Indicator
End With
'
' Button 1
'
Me.Container.Controls.Add(Button1)
With Button1
.Location = New Point(8, 8)
.Size = New Size(Container.Height*2-16, Container.Height-16)
.Curvature = 4
.Name = "ButtonControl1"
.Caption = "Button 1"
End With
'
' Button 2
'
Me.Container.Controls.Add(Button2)
With Button2
.Location = New Point(Button1.Width+16, 8)
.Size = New Size(Container.Height*2-16, Container.Height-16)
.Curvature = 4
.Name = "ButtonControl2"
.Caption = "Button 2"
End With
Me.Parent.ResumeLayout(True)
End Sub
#End Region
Public Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim Graphic As Graphics = e.Graphics
Graphic.TranslateTransform([Region].Left, [Region].Top)
Try
Graphic.DrawString("Toolbar", Skin.Font, Brushes.Black, New Point(0, 0))
Catch ex As Exception
Finally
Graphic.ResetTransform()
Graphic = Nothing
End Try
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'Beep
End Sub
End Class
End Class
End Class