Mini Kabibi Habibi
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows
Imports SchedulerDemo
Imports DevExpress.XtraScheduler
Imports DevExpress.Xpf.Scheduler
Imports System.Windows.Input
Imports DevExpress.Xpf.Scheduler.UI
Imports System.ComponentModel
Namespace SchedulerDemo
Partial Public Class CustomMenu
Inherits SchedulerDemoModule
Private commandsCollection_Renamed As CustomMenuDemoAppointmentCommandsCollection
Public Sub New()
InitializeComponent()
InitializeScheduler()
AddHandler scheduler.PopupMenuShowing, AddressOf PopupMenuShowing
CustomMenuModule.DataContext = Me
commandsCollection_Renamed = New CustomMenuDemoAppointmentCommandsCollection(scheduler)
End Sub
Public ReadOnly Property CommandsCollection() As CustomMenuDemoAppointmentCommandsCollection
Get
Return commandsCollection_Renamed
End Get
End Property
Private Sub PopupMenuShowing(ByVal sender As Object, ByVal e As SchedulerMenuEventArgs)
If e.Menu.Name = SchedulerMenuItemName.AppointmentMenu Then
e.Customizations.Add(changeAppointment)
End If
End Sub
End Class
Public MustInherit Class AppointmentCommandBase
Inherits DependencyObject
Implements ICommand
Public Shared ReadOnly ControlProperty As DependencyProperty = DependencyProperty.Register("Control", GetType(SchedulerControl), GetType(AppointmentCommandBase), New PropertyMetadata(Nothing))
Private subject_Renamed As String
Private labelId_Renamed As Integer
Public Sub New(ByVal control As SchedulerControl, ByVal subject As String, ByVal labelId As Integer)
Me.Control = control
Me.subject_Renamed = subject
Me.labelId_Renamed = labelId
End Sub
Public Sub New()
Me.New(Nothing, String.Empty, 0)
End Sub
Public Property Control() As SchedulerControl
Get
Return CType(GetValue(ControlProperty), SchedulerControl)
End Get
Set(ByVal value As SchedulerControl)
SetValue(ControlProperty, value)
End Set
End Property
Public Property Subject() As String
Get
Return subject_Renamed
End Get
Set(ByVal value As String)
subject_Renamed = value
End Set
End Property
Public Property LabelId() As Integer
Get
Return labelId_Renamed
End Get
Set(ByVal value As Integer)
labelId_Renamed = value
End Set
End Property
#Region "ICommand Members"
Public Function CanExecute(ByVal parameter As Object) As Boolean Implements ICommand.CanExecute
Return True
End Function
Public Event CanExecuteChanged As EventHandler Implements ICommand.CanExecuteChanged
Protected Sub FakeMethod()
RaiseEvent CanExecuteChanged(Me, EventArgs.Empty)
End Sub
Public MustOverride Sub Execute(ByVal parameter As Object) Implements ICommand.Execute
#End Region
End Class
Public Class CreateAppointmentCommand
Inherits AppointmentCommandBase
Public Sub New(ByVal control As SchedulerControl, ByVal subject As String, ByVal labelId As Integer)
MyBase.New(control, subject, labelId)
End Sub
Public Sub New()
Me.New(Nothing, String.Empty, 0)
End Sub
Public Overrides Sub Execute(ByVal parameter As Object)
Dim apt As Appointment = Control.Storage.CreateAppointment(AppointmentType.Normal)
apt.Subject = Subject
apt.Start = Control.ActiveView.SelectedInterval.Start
apt.End = Control.ActiveView.SelectedInterval.End
apt.ResourceId = Control.ActiveView.SelectedResource.Id
apt.StatusId = 1
apt.LabelId = LabelId
Control.Storage.AppointmentStorage.Add(apt)
End Sub
End Class
Public Class ChangeAppointmentCommand
Inherits AppointmentCommandBase
Public Sub New(ByVal control As SchedulerControl, ByVal subject As String, ByVal labelId As Integer)
MyBase.New(control, subject, labelId)
End Sub
Public Sub New()
Me.New(Nothing, String.Empty, 0)
End Sub
Public Overrides Sub Execute(ByVal parameter As Object)
Dim appointments As AppointmentBaseCollection = Control.SelectedAppointments
For i As Integer = 0 To appointments.Count - 1
Dim apt As Appointment = appointments(i)
apt.Subject = Subject
apt.StatusId = 1
apt.LabelId = LabelId
Next i
End Sub
End Class
Public Class CustomMenuDemoAppointmentCommandsCollection
Implements INotifyPropertyChanged
Private changeCheckEngineOilCommand_Renamed As ChangeAppointmentCommand
Private createCheckEngineOilCommand_Renamed As CreateAppointmentCommand
Private changeWashTheCarCommand_Renamed As ChangeAppointmentCommand
Private createWashTheCarCommand_Renamed As CreateAppointmentCommand
Private changeWaxTheCarCommand_Renamed As ChangeAppointmentCommand
Private createWaxTheCarCommand_Renamed As CreateAppointmentCommand
Private changeCheckTransmissionFluidCommand_Renamed As ChangeAppointmentCommand
Private createCheckTransmissionFluidCommand_Renamed As CreateAppointmentCommand
Private changeInspectByMechanicCommand_Renamed As ChangeAppointmentCommand
Private createInspectByMechanicCommand_Renamed As CreateAppointmentCommand
Public Sub New(ByVal control As SchedulerControl)
changeCheckEngineOilCommand_Renamed = New ChangeAppointmentCommand(control, "Check engine oil", 1)
createCheckEngineOilCommand_Renamed = New CreateAppointmentCommand(control, "Check engine oil", 1)
changeWashTheCarCommand_Renamed = New ChangeAppointmentCommand(control, "Wash the car", 2)
createWashTheCarCommand_Renamed = New CreateAppointmentCommand(control, "Wash the car", 2)
changeWaxTheCarCommand_Renamed = New ChangeAppointmentCommand(control, "Wax the car", 3)
createWaxTheCarCommand_Renamed = New CreateAppointmentCommand(control, "Wax the car", 3)
changeCheckTransmissionFluidCommand_Renamed = New ChangeAppointmentCommand(control, "Check transmission fluid", 4)
createCheckTransmissionFluidCommand_Renamed = New CreateAppointmentCommand(control, "Check transmission fluid", 4)
changeInspectByMechanicCommand_Renamed = New ChangeAppointmentCommand(control, "Inspect by mechanic", 5)
createInspectByMechanicCommand_Renamed = New CreateAppointmentCommand(control, "Inspect by mechanic", 5)
End Sub
Public ReadOnly Property ChangeCheckEngineOilCommand() As ChangeAppointmentCommand
Get
Return changeCheckEngineOilCommand_Renamed
End Get
End Property
Public ReadOnly Property CreateCheckEngineOilCommand() As CreateAppointmentCommand
Get
Return createCheckEngineOilCommand_Renamed
End Get
End Property
Public ReadOnly Property ChangeWashTheCarCommand() As ChangeAppointmentCommand
Get
Return changeWashTheCarCommand_Renamed
End Get
End Property
Public ReadOnly Property CreateWashTheCarCommand() As CreateAppointmentCommand
Get
Return createWashTheCarCommand_Renamed
End Get
End Property
Public ReadOnly Property ChangeWaxTheCarCommand() As ChangeAppointmentCommand
Get
Return changeWaxTheCarCommand_Renamed
End Get
End Property
Public ReadOnly Property CreateWaxTheCarCommand() As CreateAppointmentCommand
Get
Return createWaxTheCarCommand_Renamed
End Get
End Property
Public ReadOnly Property ChangeCheckTransmissionFluidCommand() As ChangeAppointmentCommand
Get
Return changeCheckTransmissionFluidCommand_Renamed
End Get
End Property
Public ReadOnly Property CreateCheckTransmissionFluidCommand() As CreateAppointmentCommand
Get
Return createCheckTransmissionFluidCommand_Renamed
End Get
End Property
Public ReadOnly Property ChangeInspectByMechanicCommand() As ChangeAppointmentCommand
Get
Return changeInspectByMechanicCommand_Renamed
End Get
End Property
Public ReadOnly Property CreateInspectByMechanicCommand() As CreateAppointmentCommand
Get
Return createInspectByMechanicCommand_Renamed
End Get
End Property
#Region "INotifyPropertyChanged"
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Protected Sub RaisePropertyChanged(ByVal name As String)
If PropertyChangedEvent Is Nothing Then
Return
End If
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(name))
End Sub
#End Region
End Class
End Namespace