Hi,
I have a class (TimeScheduleShift) that extends Appointment.
It adds a few extra properties for example EmployeeId and EmployeeName.
It looks like this (other properties revoved for clarity):
I also have my own edit appointment dialog, which is a standard ChildWindow which implements the IScheduleViewDialogHost interface.
I pass the selected appointment in the constructor of my dialog, store it in a public property there so I can fetch it when the dialog is closed.
Inside the dialog I have a ComboBox with employees.
If I open an existing appointment and change the Employee, the EmployeeId and EmployeeName properties are changed correctly on the appointment storde in the dialog.
But in my Dialog_Closed event, if I examine the appointment the EmployeeId property has the new value, but the employeeId property still has the old value.
I guess there must be some glitch in the copy method?
I tried to add employeeId to the CopyFrom method also, but with no luck.
It's the same problem with all my extended properties.
Regards,
HÃ¥kan
I have a class (TimeScheduleShift) that extends Appointment.
It adds a few extra properties for example EmployeeId and EmployeeName.
It looks like this (other properties revoved for clarity):
public
class
TimeScheduleShift : Appointment
{
private
int
employeeId;
public
int
EmployeeId
{
get
{
return
this
.Storage<TimeScheduleShift>().employeeId;
}
set
{
var storage =
this
.Storage<TimeScheduleShift>();
if
(storage.employeeId != value)
{
storage.employeeId = value;
this
.OnPropertyChanged(() =>
this
.EmployeeId);
}
}
}
private
string
employeeName;
public
string
EmployeeName
{
get
{
return
this
.Storage<TimeScheduleShift>().employeeName;
}
set
{
var storage =
this
.Storage<TimeScheduleShift>();
if
(storage.employeeName != value)
{
storage.employeeName = value;
this
.OnPropertyChanged(() =>
this
.EmployeeName);
}
}
}
public
override
IAppointment Copy()
{
var newShift =
new
TimeScheduleShift();
newShift.CopyFrom(
this
);
return
newShift;
}
public
override
void
CopyFrom(IAppointment other)
{
var shift = other
as
TimeScheduleShift;
if
(shift !=
null
)
{
this
.UniqueId = shift.UniqueId;
this
.EmployeeId = shift.EmployeeId;
this
.EmployeeName = shift.EmployeeName;
}
base
.CopyFrom(other);
}
protected
override
void
OnPropertyChanged(
string
propertyName)
{
base
.OnPropertyChanged(propertyName);
// Update label
if
(propertyName ==
"Start"
|| propertyName ==
"End"
|| propertyName ==
"EmployeeName"
)
{
SetLabel();
}
}
public
void
SetLabel(
bool
includeBreak =
true
,
bool
includeEmployeeName =
true
)
{
string
subject = String.Format(
"{0}-{1}"
,
this
.Start.ToShortTimeString(),
this
.End.ToShortTimeString());
subject += String.Format(
" {0}"
,
this
.EmployeeName);
this
.Subject = subject;
}
}
I also have my own edit appointment dialog, which is a standard ChildWindow which implements the IScheduleViewDialogHost interface.
I pass the selected appointment in the constructor of my dialog, store it in a public property there so I can fetch it when the dialog is closed.
Inside the dialog I have a ComboBox with employees.
If I open an existing appointment and change the Employee, the EmployeeId and EmployeeName properties are changed correctly on the appointment storde in the dialog.
But in my Dialog_Closed event, if I examine the appointment the EmployeeId property has the new value, but the employeeId property still has the old value.
I guess there must be some glitch in the copy method?
I tried to add employeeId to the CopyFrom method also, but with no luck.
It's the same problem with all my extended properties.
Regards,
HÃ¥kan