<localView:BeWoView x:Class="BeWo.View.Detail.WohnheimView" 
					xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
					xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
					xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls" 
					xmlns:localView="clr-namespace:BeWo.View" 
					xmlns:localSearchView="clr-namespace:BeWo.View.Search"
                    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
					xmlns:val="clr-namespace:BeWo.Validation"
					Height="Auto" Width="Auto" HorizontalAlignment="Stretch" 
					VerticalAlignment="Stretch" Focusable="True" GotFocus="UserControl_GotFocus">
    <Grid x:Name="rootGrid">
        <uc:ShadowChrome>
            <GroupBox Style="{StaticResource MainContentGroupBoxStyle}">
                <GroupBox.Header>
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom">
                        <Image Source="..\..\Ressources\Icons\OfficeBulidingBlackDisabled.png" RenderTransformOrigin="0.5,0.5" Stretch="Uniform" Width="32">
                            <Image.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="1" ScaleY="1" />
                                    <SkewTransform AngleX="0" AngleY="0" />
                                    <RotateTransform Angle="0" />
                                    <TranslateTransform X="0" Y="5" />
                                </TransformGroup>
                            </Image.RenderTransform>
                        </Image>
                        <TextBox Text="{Binding WohnheimName}" Margin="10,0,0,0" Background="{x:Null}" Foreground="#FFFFFFFF" FontSize="22" BorderBrush="{x:Null}" VerticalAlignment="Bottom" Padding="0,0,0,0" />
                    </StackPanel>
                </GroupBox.Header>
                <Grid Margin="0,3,0,0" Background="{StaticResource ObjectEditBackgroundBrush}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Rectangle Fill="{DynamicResource WohnheimContentBrush}" Height="6" />
                    <TabControl x:Name="root" Grid.Row="1" Style="{StaticResource ObjectEditTabControl}" BorderThickness="0,0,0,0" Padding="4,4,4,4">
                        <TabItem Header="Details" IsSelected="True">
                            <ScrollViewer VerticalScrollBarVisibility="Auto">
                                <Grid x:Name="grid_details">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>

                                    <GroupBox Grid.Row="0" Header="Details" Style="{StaticResource ObjectEditGroupBox}" Grid.ColumnSpan="1">
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                            </Grid.RowDefinitions>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="115"  />
                                                <ColumnDefinition Width="Auto" />
                                            </Grid.ColumnDefinitions>

                                            <Label Grid.Column="0" Grid.Row="0" Margin="3" VerticalAlignment="Center">Name</Label>
                                            <Label Grid.Column="0" Grid.Row="1" Margin="3" VerticalAlignment="Center">Strasse</Label>
                                            <Label Grid.Column="0" Grid.Row="2" Margin="3" VerticalAlignment="Center">Postleitzahl</Label>
                                            <Label Grid.Column="0" Grid.Row="3" Margin="3" VerticalAlignment="Center">Ort</Label>
                                            <Label Grid.Column="0" Grid.Row="4" Margin="3" VerticalAlignment="Top">Bemerkung</Label>
                                            <Label x:Name="lblArchiviert" Grid.Column="0" Grid.Row="5" Margin="3" VerticalAlignment="Center">Archiviert</Label>
                                          
                                            <TextBox x:Name="textbox_first" Grid.Column="1" Grid.Row="0" Margin="3" Height="23" Text="{Binding Path=WohnheimName, UpdateSourceTrigger=PropertyChanged}" Width="200" HorizontalAlignment="Left"/>
                                            <TextBox Grid.Column="1" Grid.Row="1" Margin="3" Height="23" Text="{Binding Path=Strasse, UpdateSourceTrigger=PropertyChanged}" Width="200" HorizontalAlignment="Left"/>
                                            <TextBox Grid.Column="1" Grid.Row="2" Margin="3" Height="23" Text="{Binding Path=PLZ, UpdateSourceTrigger=PropertyChanged}" Width="200" HorizontalAlignment="Left"/>
                                            <TextBox Grid.Column="1" Grid.Row="3" Margin="3" Height="23" Text="{Binding Path=Ort, UpdateSourceTrigger=PropertyChanged}" Width="200" HorizontalAlignment="Left"/>
                                            <TextBox TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" Grid.Column="1" Grid.Row="4" Margin="3" Height="100" Width="500" Text="{Binding Path=Bemerkung, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" />

                                          
                                          <CheckBox x:Name="chkArchiviert" Grid.Column="1" Grid.Row="5" Margin="3" Height="23" 
                                            IsChecked="{Binding Path=IsArchived, UpdateSourceTrigger=PropertyChanged}" />
                                        </Grid>
                                          
                                    </GroupBox>
                                </Grid>
                            </ScrollViewer>
                        </TabItem>
                        <TabItem Header="Klienten">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <GroupBox Visibility="Visible" x:Name="groupbox_newWohnheimRel" Header="Zugeordnete Klienten" Style="{StaticResource ObjectEditGroupBox}">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="*" />
                                        </Grid.RowDefinitions>

                                        <Button Grid.Row="0" Grid.ColumnSpan="1" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="25" Margin="3" Content="Klienten Hinzufügen" x:Name="button_addKlientRelation" Click="button_addKlientRelation_Klick" />
                                       
                                        <dxg:GridControl x:Name="grid_CustomerRelation" Grid.Row="1" VerticalAlignment="Stretch" DataSource="{Binding Path=WohnheimCustomerRelations.VMList}"
			                                HorizontalAlignment="Stretch">
                                            <dxg:GridControl.Columns>
                                                <dxg:GridColumn FieldName="Notice" Header="" FixedWidth="True" Width="24" ReadOnly="True">
                                                    <dxg:GridColumn.CellTemplate>
                                                        <DataTemplate>
                                                            <Button Content="r" FontFamily="Webdings" Click="Button_RemoveCustomerRelation_Click" Width="18" Height="18"
								                                                     VerticalAlignment="Center" />
                                                        </DataTemplate>
                                                    </dxg:GridColumn.CellTemplate>
                                                </dxg:GridColumn>
                                                <dxg:GridColumn AllowEditing="False" FieldName="Customer" Header="Klient(in)" Width="150" />
                                                <dxg:GridColumn FieldName="Notice" Header="Bemerkung" Width="250" />
                                            </dxg:GridControl.Columns>
                                            <dxg:GridControl.View>
                                                <dxg:TableView AutoWidth="true" ShowGroupPanel="False" ShowGroupedColumns="false" ShowTotalSummary="False"
					                                                      NavigationStyle="Cell" RowDoubleClick="TableViewCustomer_OnRowDoubleClick" />
                                            </dxg:GridControl.View>
                                        </dxg:GridControl>

                                        <Popup Grid.Row="0" x:Name="popup_newKlientRel" Width="350" StaysOpen="True" Placement="MousePoint">
                                            <Border Background="White" Padding="3" BorderThickness="1" BorderBrush="Gray">
                                                <GroupBox x:Name="groupbox_newKlientRel" Header="Klienten zuordnen" Style="{StaticResource ObjectEditGroupBox}">
                                                    <Grid>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="Auto" />
                                                            <RowDefinition Height="Auto" />
                                                            <RowDefinition Height="Auto" />
                                                            <RowDefinition Height="Auto" />
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="Auto" />
                                                            <ColumnDefinition Width="*" />
                                                            <ColumnDefinition Width="Auto" />
                                                        </Grid.ColumnDefinitions>
                                                        <Label VerticalAlignment="Center" Content="Klient" />
                                                        <uc:PopUpEdit IsReadOnly="True"
																  DeleteButtonVisibility="Collapsed"
																  Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" Margin="3" Height="23" x:Name="popupedit_KlientRelations"
																  Text="{val:ValidationBinding Path=WohnheimCustomerRelations.NewVM.CustomerString}"
																  PopUpClick="popupedit_KlientRelations_PopUpClick"
																  PreviewMouseDoubleClick="Popupedit_KlientRelations_OnPreviewMouseDoubleClick"
																  Cursor="Arrow"  />

                                                        <Label Content="Notiz" Grid.Row="2" Grid.Column="0" VerticalAlignment="Top" />

                                                        <TextBox Grid.Row="2" Grid.Column="1" Height="50" Margin="3" Grid.ColumnSpan="2"
															 Text="{Binding Path=WohnheimCustomerRelations.NewVM.Notice, UpdateSourceTrigger=PropertyChanged}" />

                                                        <Button Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Height="25"
															Margin="3" Content="Hinzufügen" x:Name="button_addklientRelation"
															Click="button_addKlientRelation_Click" />

                                                        <Button Grid.Row="3" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="25"
															Margin="3" Content="Abbrechen" x:Name="button_cancelKlientRelation"
															Click="button_cancelKlientRelation_Click" />
                                                    </Grid>
                                                </GroupBox>
                                            </Border>
                                        </Popup>
                                    </Grid>
                                </GroupBox>
                            </Grid>
                        </TabItem>
                        <TabItem Header="Mitarbeiter">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <GroupBox Visibility="Visible" x:Name="groupbox_newMitarbeiterRel" Header="Zugeordnete Mitarbeiter" Style="{StaticResource ObjectEditGroupBox}">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="*" />
                                        </Grid.RowDefinitions>
                                        <Button  Grid.Row="0" Grid.ColumnSpan="1" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="25" Margin="3" Content="Mitarbeiter Hinzufügen" x:Name="button_addMitarbeiterRelation_Click" Click="button_addMitarbeiterRelation_Klick" />
                                        <Popup Grid.Row="0" x:Name="popup_newEmployeeRel" Width="350" StaysOpen="True" Placement="MousePoint">
                                            <Border Background="White" Padding="3" BorderThickness="1" BorderBrush="Gray">
                                                <GroupBox x:Name="groupbox_newEmployeeRel" Header="Mitarbeiter zuordnen" Style="{StaticResource ObjectEditGroupBox}">
                                                    <Grid>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="Auto" />
                                                            <RowDefinition Height="Auto" />
                                                            <RowDefinition Height="Auto" />
                                                            <RowDefinition Height="Auto" />
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="Auto" />
                                                            <ColumnDefinition Width="*" />
                                                            <ColumnDefinition Width="Auto" />

                                                        </Grid.ColumnDefinitions>
                                                        <Label VerticalAlignment="Center" Content="Mitarbeiter" />
                                                        <uc:PopUpEdit IsReadOnly="True"
																  DeleteButtonVisibility="Collapsed"
																  Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" Margin="3" Height="23" x:Name="popupedit_EmployeeRelations"
																  Text="{val:ValidationBinding Path=WohnheimEmployeeRelations.NewVM.EmployeeString}"
																  PopUpClick="popupedit_EmployeeRelations_PopUpClick"
																  PreviewMouseDoubleClick="Popupedit_EmployeeRelations_OnPreviewMouseDoubleClick"
																  Cursor="Arrow" />

                                                        <Label Content="Notiz" Grid.Row="2" Grid.Column="0" VerticalAlignment="Top" />

                                                        <TextBox Grid.Row="2" Grid.Column="1" Height="50" Margin="3" Grid.ColumnSpan="2"
															 Text="{Binding Path=WohnheimEmployeeRelations.NewVM.Notice, UpdateSourceTrigger=PropertyChanged}" />

                                                        <Button Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Height="25"
															Margin="3" Content="Hinzufügen" x:Name="button_addEmployeeRelation"
															Click="button_addEmployeeRelation_Click" />

                                                        <Button Grid.Row="3" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="25"
															Margin="3" Content="Abbrechen" x:Name="button_cancelEmployeeRelation"
															Click="button_cancelEmployeeRelation_Click" />
                                                    </Grid>
                                                </GroupBox>
                                            </Border>
                                        </Popup>
                                        <dxg:GridControl x:Name="grid_EmployeeRelation" Grid.Row="1" VerticalAlignment="Stretch" DataSource="{Binding Path=WohnheimEmployeeRelations.VMList}" HorizontalAlignment="Stretch">
                                            <dxg:GridControl.Columns>
                                                <dxg:GridColumn FieldName="Notice" Header="" FixedWidth="True" Width="24" ReadOnly="True">
                                                    <dxg:GridColumn.CellTemplate>
                                                        <DataTemplate>
                                                            <Button Content="r" FontFamily="Webdings" Click="button_removeEmployeeRelation_Click" Width="18" Height="18" VerticalAlignment="Center" />
                                                        </DataTemplate>
                                                    </dxg:GridColumn.CellTemplate>
                                                </dxg:GridColumn>
                                                <dxg:GridColumn AllowEditing="False" FieldName="Employee" Header="Betreuer(in)" Width="150" />
                                                <dxg:GridColumn FieldName="Notice" Header="Bemerkung" Width="250" />
                                            </dxg:GridControl.Columns>
                                            <dxg:GridControl.View>
                                                <dxg:TableView AutoWidth="true" ShowGroupPanel="False" ShowGroupedColumns="false" ShowTotalSummary="False" NavigationStyle="Cell" RowDoubleClick="TableViewEmployee_OnRowDoubleClick" />
                                            </dxg:GridControl.View>
                                        </dxg:GridControl>
                                    </Grid>
                                </GroupBox>
                            </Grid>
                        </TabItem>
                    </TabControl>
                    <Border Grid.Row="2" Grid.ColumnSpan="3" Height="40" Margin="0,10,0,0" VerticalAlignment="Stretch" Background="#FF000000">
                        <Border.OpacityMask>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#19000000" Offset="0" />
                                <GradientStop Color="#33FFFFFF" Offset="1" />
                            </LinearGradientBrush>
                        </Border.OpacityMask>
                    </Border>
                    <StackPanel Grid.ColumnSpan="3" Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center" Height="Auto" Margin="5,10,0,0" HorizontalAlignment="Right">
                        <Button x:Name="btnSave" Content="Speichern" Margin="0,0,2,0" Command="ApplicationCommands.Save" Height="25" Style="{DynamicResource {x:Type Button}}"/>
                        <Button x:Name="btnClose" Content="Schließen" Margin="0,0,3,0" Command="ApplicationCommands.Close" Height="25"/>
                    </StackPanel>
                </Grid>
            </GroupBox>
        </uc:ShadowChrome>
        <Popup Margin="10" x:Name="popup_klient" StaysOpen="False" Placement="MousePoint" Width="370" Height="250"
		       Closed="popup_Closed" Opened="popup_Opened">
            <localSearchView:CustomerSearchView x:Name="klientsearchview" />
        </Popup>
        <Popup Margin="10" x:Name="popup_employee" StaysOpen="False" Placement="MousePoint" Width="370" Height="250"
		       Closed="popup_Closed" Opened="popup_Opened">
            <localSearchView:EmployeeSearchView x:Name="employeesearchview" />
        </Popup>
    </Grid>
</localView:BeWoView>  