<localSchView:AbstractAppointmentEditForm x:Class="BeWo.Scheduler.View.CustomerAppointmentEditForm"
                                          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                                          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                                          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                                          xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls"
                                          xmlns:localSchView="clr-namespace:BeWo.Scheduler.View"
                                          xmlns:localSchConv="clr-namespace:BeWo.Scheduler.Converter"
                                          xmlns:localSearchView="clr-namespace:BeWo.View.Search"
                                          xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
                                          xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
                                          xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/scheduler"
                                          xmlns:dxschint="http://schemas.devexpress.com/winfx/2008/xaml/scheduler/internal" 
                                          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                                          mc:Ignorable="d" MinWidth="460" MinHeight="200" d:DesignHeight="505" d:DesignWidth="460">
    <localSchView:AbstractAppointmentEditForm.Resources>
        <dxschint:TimeSpanToDateTimeConverter x:Key="TimeSpanToDateTimeConverter"/>
        <dxschint:InvertedBoolConverter x:Key="InvertedBoolConverter"/>
        <localSchConv:Recurrence2GermanConverter x:Key="Recurrence2GermanConverter"/>
    </localSchView:AbstractAppointmentEditForm.Resources>

    <Grid Margin="3">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="120" />
            <ColumnDefinition Width="80" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Label Grid.Row="0" VerticalAlignment="Center">Betreff</Label>
        <dxe:TextEdit Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3" Margin="3" Text="{Binding Controller.Subject, UpdateSourceTrigger=PropertyChanged}" Height="23"/>

        <Label Grid.Row="1" Grid.Column="0" VerticalAlignment="Center">Start</Label>
        <dxe:DateEdit MaskType="DateTimeAdvancingCaret" Grid.Row="1" Grid.Column="1" Background="White" Height="23" MinWidth="80" Margin="3"
                      EditValue="{Binding Controller.DisplayStartDate}" />
        <dxe:TextEdit Grid.Column="2" Grid.Row="1" MaskType="DateTime" Mask="t" MaskUseAsDisplayFormat="True" Margin="3" Height="23"
                                                   EditValue ="{Binding Controller.DisplayStartTime, Converter={StaticResource TimeSpanToDateTimeConverter}}" IsEnabled="{Binding ElementName=ChkAllDay, Path=IsChecked, Converter={StaticResource InvertedBoolConverter}}"/>
        <dxe:CheckEdit x:Name="ChkAllDay" Grid.Column="3" Grid.Row="1" Content="Ganztägiges Ereignis" EditValue ="{Binding Controller.AllDay}"/>
        
        <Label Grid.Row="2" Grid.Column="0" VerticalAlignment="Center">Ende</Label>
        <dxe:DateEdit MaskType="DateTimeAdvancingCaret" Grid.Column="1" Grid.Row="2" MinWidth="80" Height="23" Margin="3"
                      EditValue="{Binding Controller.DisplayEndDate}" />
        <dxe:TextEdit Grid.Column="2" Grid.Row="2" MaskType="DateTime" Mask="t" MaskUseAsDisplayFormat="True" Margin="3" Height="23"
                                                    EditValue ="{Binding Controller.DisplayEndTime, Converter={StaticResource TimeSpanToDateTimeConverter}}" IsEnabled="{Binding ElementName=ChkAllDay, Path=IsChecked, Converter={StaticResource InvertedBoolConverter}}"/>
        
        <Label Grid.Row="3" Grid.Column="0" VerticalAlignment="Center">Klient/in</Label>
        <uc:PopUpEdit Height="23" IsReadOnly="True" Margin="3" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" DeleteButtonVisibility="Collapsed" HorizontalAlignment="Stretch" Name="PopupeditCustomer" PopUpClick="popupedit_customer_PopUpClick" />
        <Popup Margin="10" Grid.Row="3" Grid.Column="0" Name="PopupCustomer" StaysOpen="False" Placement="MousePoint" Width="370" Height="300" >
            <localSearchView:CustomerSearchView ItemSelected="CustomerSearchView_CustomerSelected" />
        </Popup>

        <Label Grid.Row="4" Grid.Column="0" VerticalAlignment="Center">Kategorie</Label>
        <dxe:ComboBoxEdit x:Name="LabelEdit"
                Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2"
                Margin="3" Height="23" IsTextEditable="False" EditValueChanged="labelEdit_EditValueChanged" ApplyItemTemplateToSelectedItem="True">
            <dxe:ComboBoxEdit.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Border Background="{Binding Brush}" Height="15" Width="15" BorderThickness="1" BorderBrush="Black" Margin="3,0,0,0" />
                        <TextBlock Margin="5,0,3,0" Text="{Binding DisplayName}" VerticalAlignment="Center" />
                    </StackPanel>
                </DataTemplate>
            </dxe:ComboBoxEdit.ItemTemplate>
        </dxe:ComboBoxEdit>
        
        <Label Grid.Row="5" Grid.Column="0" Content="Mitarbeiter" />
        <dxe:ComboBoxEdit Height="23" Margin="3" Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2" IsTextEditable="False" />
        <uc:PopUpEdit Height="23" Margin="3" Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2" DeleteButtonVisibility="Collapsed" HorizontalAlignment="Stretch"
                                                IsReadOnly="True" Name="PopupeditEmployee" PopUpClick="popupedit_employee_PopUpClick" />
        <Popup Margin="10" Grid.Row="5" Grid.Column="0" Name="PopupEmployee" StaysOpen="False"
                                        Placement="MousePoint" Width="370" Height="300" >
            <localSearchView:EmployeeSearchView ItemSelected="EmployeeSearchView_EmployeeSelected" />
        </Popup>

        <Label Grid.Row="6" Grid.Column="0" Content="Bemerkungen" />
        <TextBox Grid.Column="1" Grid.Row="6" Grid.ColumnSpan="3" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Height="45" Margin="3" Text="{Binding Path=Controller.Description, UpdateSourceTrigger=PropertyChanged}" />
        
        <StackPanel Grid.Row="9" Grid.ColumnSpan="4" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0">
            <Button Margin="3,0,3,0" Click="button_ok_Click" Height="25" Width="80">OK</Button>
            <Button Margin="3,0,3,0" Click="button_cancel_Click" Height="25" Width="80">Abbrechen</Button>
            <Button Margin="3,0,3,0" Click="button_delete_Click" Height="25" Width="80">Löschen</Button>
        </StackPanel>
        <Label x:Name="LblRecurrenceType" Grid.Row="7" Grid.Column="0" VerticalAlignment="Center">Serientyp</Label>
        <dxe:ComboBoxEdit Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="2" x:Name="EdtRecurrenceType" Margin="3"
                    ItemsSource="{Binding RecurrenceVisualController.RecurrenceElements}" 
                    EditValue="{Binding RecurrenceVisualController.RecurrenceElement, UpdateSourceTrigger=PropertyChanged}" IsTextEditable="False" EditValueChanged="edtRecurrenceType_EditValueChanged">
            <dxe:ComboBoxEdit.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Description, Converter={StaticResource Recurrence2GermanConverter}}" />
                </DataTemplate>
            </dxe:ComboBoxEdit.ItemTemplate>
        </dxe:ComboBoxEdit>
        <Grid Grid.Row="8" Grid.ColumnSpan="4" Grid.Column="0" Visibility="{Binding RecurrenceVisualController.EnableRecurrence, Converter={StaticResource BoolVisibilityConverter}}">
            <StackPanel >
                <dx:GroupFrame Header="Serienmuster" Margin="3">
                    <StackPanel>
                        <dxsch:DailyRecurrenceControl
                            Visibility="{Binding RecurrenceVisualController.IsDailyRecurrence, Converter={dxschint:BoolToVisibilityConverter}}" RecurrenceInfo="{Binding RecurrenceVisualController.RecurrenceInfo}"  />
                        <dxsch:WeeklyRecurrenceControl
                            Visibility="{Binding RecurrenceVisualController.IsWeeklyRecurrence, Converter={dxschint:BoolToVisibilityConverter}}" RecurrenceInfo="{Binding RecurrenceVisualController.RecurrenceInfo}" />
                        <dxsch:MonthlyRecurrenceControl x:Name="MonthlyRecurrenceControl" Visibility="{Binding RecurrenceVisualController.IsMonthlyRecurrence, Converter={dxschint:BoolToVisibilityConverter}}" RecurrenceInfo="{Binding RecurrenceVisualController.RecurrenceInfo}" />
                        <dxsch:YearlyRecurrenceControl x:Name="YearlyRecurrenceControl" Visibility="{Binding RecurrenceVisualController.IsYearlyRecurrence, Converter={dxschint:BoolToVisibilityConverter}}" RecurrenceInfo="{Binding RecurrenceVisualController.RecurrenceInfo}" />
                    </StackPanel>
                </dx:GroupFrame>
                <dx:GroupFrame  Header="Seriendauer" Margin="3" >
                    <dxsch:RecurrenceRangeControl 
                                RecurrenceInfo="{Binding RecurrenceVisualController.RecurrenceInfo}"
                                TimeZoneHelper="{Binding ElementName=AptForm, Path=TimeZoneHelper, Mode=OneTime}"
                                Pattern="{Binding Controller.PatternCopy}" />
                </dx:GroupFrame>
            </StackPanel>
        </Grid>
    </Grid>
</localSchView:AbstractAppointmentEditForm>
