Beim Ändern eines Serientermins kommt es nicht mehr zu einer Exception.
Wenn man bei einem Serientermin die CustomFields ändert und andere Standardfelder, werden beide Änderungen übernommen. Bisher wurden nur die Änderungen der CustomFields übernommen.
164 lines
5.2 KiB
C#
164 lines
5.2 KiB
C#
using System;
|
|
using System.Windows.Controls;
|
|
|
|
using DevExpress.Xpf.Scheduler;
|
|
using DevExpress.Xpf.Scheduler.Drawing;
|
|
using DevExpress.XtraScheduler;
|
|
using DevExpress.Xpf.Scheduler.UI;
|
|
using SchedulerControl = DevExpress.Xpf.Scheduler.SchedulerControl;
|
|
|
|
using System.Globalization;
|
|
using System.Windows;
|
|
using System.Windows.Media;
|
|
|
|
namespace BeWo.Scheduler.View
|
|
{
|
|
public class AbstractAppointmentEditForm : UserControl
|
|
{
|
|
protected AbstractAppointmentEditForm() { }
|
|
|
|
public AbstractAppointmentEditForm(SchedulerControl schedulerControl, Appointment appointment)
|
|
{
|
|
Control = schedulerControl;
|
|
Appointment = appointment;
|
|
|
|
Controller = CreateFormController(Control, Appointment);
|
|
RecurrenceVisualController = new RecurrenceVisualController(Controller);
|
|
}
|
|
|
|
public virtual AppointmentFormController CreateFormController(SchedulerControl schedulerControl, Appointment appointment)
|
|
{
|
|
return new AppointmentFormController(schedulerControl, appointment);
|
|
}
|
|
|
|
public SchedulerControl Control { get; }
|
|
|
|
public Appointment Appointment { get; }
|
|
|
|
public AppointmentFormController Controller { get; }
|
|
|
|
public string TimeEditMask => CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern;
|
|
public RecurrenceVisualController RecurrenceVisualController { get; }
|
|
|
|
protected internal bool IsNewAppointment => Controller == null || Controller.IsNewAppointment;
|
|
|
|
protected bool ShouldShowRecurrence => !Appointment.IsOccurrence && Controller.ShouldShowRecurrenceButton;
|
|
|
|
protected virtual bool ApplyChanges()
|
|
{
|
|
if (!Controller.IsConflictResolved())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (ShouldShowRecurrence)
|
|
{
|
|
RecurrenceVisualController.ApplyRecurrence();
|
|
}
|
|
|
|
try
|
|
{
|
|
Controller.ApplyChanges();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show($"Es ist leider ein Fehler aufgetreten. Die von Ihnen getätigten Änderungen am Termin konnten leider nicht übernommen werden.\n{e.Message}\n{e.StackTrace}", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
}
|
|
|
|
SchedulerFormBehavior.Close(this, true);
|
|
|
|
return true;
|
|
}
|
|
|
|
protected virtual void Cancel()
|
|
{
|
|
SchedulerFormBehavior.Close(this, false);
|
|
}
|
|
|
|
protected virtual void DeleteAppointment()
|
|
{
|
|
if (IsNewAppointment)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Controller.DeleteAppointment();
|
|
SchedulerFormBehavior.Close(this, false);
|
|
}
|
|
|
|
protected static void LocalizeVisualChild(DependencyObject obj)
|
|
{
|
|
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
|
|
{
|
|
var child = VisualTreeHelper.GetChild(obj, i);
|
|
if (child is WeekOfMonthEdit)
|
|
{
|
|
var edt = child as WeekOfMonthEdit;
|
|
|
|
edt.CustomDisplayText -= EditCustomDisplayText;
|
|
edt.CustomDisplayText += EditCustomDisplayText;
|
|
|
|
foreach (var womEditItem in edt.Items)
|
|
{
|
|
var ne = womEditItem as NamedElement;
|
|
if (ne != null)
|
|
{
|
|
ne.Caption = Translate(ne.Caption);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (child is WeekDaysEdit)
|
|
{
|
|
var edt = child as WeekDaysEdit;
|
|
|
|
edt.CustomDisplayText -= EditCustomDisplayText;
|
|
edt.CustomDisplayText += EditCustomDisplayText;
|
|
|
|
foreach (var womEditItem in edt.Items)
|
|
{
|
|
var ne = womEditItem as NamedElement;
|
|
if (ne != null)
|
|
{
|
|
ne.Caption = Translate(ne.Caption);
|
|
}
|
|
}
|
|
}
|
|
|
|
LocalizeVisualChild(child);
|
|
}
|
|
}
|
|
|
|
private static void EditCustomDisplayText(object sender, DevExpress.Xpf.Editors.CustomDisplayTextEventArgs e)
|
|
{
|
|
e.DisplayText = Translate(e.DisplayText);
|
|
e.Handled = true;
|
|
}
|
|
|
|
private static string Translate(string text)
|
|
{
|
|
switch (text)
|
|
{
|
|
case "First":
|
|
return "Ersten";
|
|
case "Second":
|
|
return "Zweiten";
|
|
case "Third":
|
|
return "Dritten";
|
|
case "Fourth":
|
|
return "Vierten";
|
|
case "Last":
|
|
return "Letzten";
|
|
case "Day":
|
|
return "Tag";
|
|
case "Weekday":
|
|
return "Arbeitstag";
|
|
case "Weekend day":
|
|
return "Wochenendtag";
|
|
default:
|
|
return text;
|
|
}
|
|
}
|
|
}
|
|
}
|