<localView:BeWoView x:Class="BeWo.View.Detail.TeamView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:localView="clr-namespace:BeWo.View" xmlns:localSearchView="clr-namespace:BeWo.View.Search" xmlns:val="clr-namespace:BeWo.Validation" xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Focusable="True">
	<Grid x:Name="teamViewMainGrid">
        <Grid.Resources>
            <Style x:Key="myNavigationListItemStyle" TargetType="{x:Type ListBoxItem}">
                <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type ItemsControl}, Mode=FindAncestor}}" />
                <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type ItemsControl}, Mode=FindAncestor}}" />
                <Setter Property="Margin" Value="0,2,0,0" />
                <EventSetter Event="PreviewMouseDoubleClick" Handler="ListBox_OnPreviewMouseDoubleClick"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Grid>
                                <Border x:Name="ItemBorder" CornerRadius="5" MinHeight="30" Background="#FF000000">
                                    <Border.OpacityMask>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#19000000" Offset="0" />
                                            <GradientStop Color="#26000000" Offset="1" />
                                        </LinearGradientBrush>
                                    </Border.OpacityMask>

                                </Border>
                                <Border x:Name="ItemContent" CornerRadius="5" MinHeight="30">
                                    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5,3,5,3" OpacityMask="{x:Null}" SnapsToDevicePixels="True">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="*" />
                                        </Grid.RowDefinitions>
                                        <Image Grid.RowSpan="2" Source="..\..\Ressources\Icons\UserHomeMaleDisabled.png" Margin="0,0,5,0" Height="30" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="Auto" RenderTransformOrigin="0.5,0.5" Grid.Row="0" />
                                        <StackPanel Grid.Column="1" Orientation="Horizontal">
                                            <TextBlock Text="{Binding Path=FirstName}" FontSize="14" Foreground="#FFD2D2D2" FontFamily="Microsoft Sans Serif" />
                                            <TextBlock Text="{Binding Path=LastName}" Margin="3,0,0,0" FontSize="14" Foreground="#FFD2D2D2" FontFamily="Microsoft Sans Serif" />
                                            <TextBlock Text="{Binding Path=DateOfBirth}" Margin="3,0,0,0" FontSize="14" Foreground="#FFD2D2D2" FontFamily="Microsoft Sans Serif" />
                                        </StackPanel>
                                        <StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal">
                                            <TextBlock Text="{Binding Path=Street}" FontSize="14" Foreground="#FFA0A0A0" FontFamily="Microsoft Sans Serif" />
                                            <TextBlock Text="{Binding Path=PostalCode}" Margin="10,0,0,0" FontSize="14" Foreground="#FFA0A0A0" FontFamily="Microsoft Sans Serif" />
                                            <TextBlock Text="{Binding Path=Town}" Margin="3,0,0,0" FontSize="14" Foreground="#FFA0A0A0" FontFamily="Microsoft Sans Serif" />

                                        </StackPanel>
                                    </Grid>

                                </Border>
                            </Grid>

                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="OpacityMask" TargetName="ItemBorder">
                                        <Setter.Value>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#33000000" Offset="0" />
                                                <GradientStop Color="#66000000" Offset="1" />
                                            </LinearGradientBrush>
                                        </Setter.Value>
                                    </Setter>
                                </Trigger>

                                <Trigger Property="ListBoxItem.IsSelected" Value="True">
                                    <Setter Property="OpacityMask" TargetName="ItemBorder">
                                        <Setter.Value>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#99000000" Offset="0" />
                                                <GradientStop Color="#CC000000" Offset="1" />
                                            </LinearGradientBrush>
                                        </Setter.Value>
                                    </Setter>
                                </Trigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="ListBoxItem.IsSelected" Value="True" />
                                        <Condition Property="Selector.IsSelectionActive" Value="False" />
                                    </MultiTrigger.Conditions>
                                    <Setter Property="OpacityMask" TargetName="ItemBorder">
                                        <Setter.Value>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#99000000" Offset="0" />
                                                <GradientStop Color="#B2000000" Offset="1" />
                                            </LinearGradientBrush>
                                        </Setter.Value>
                                    </Setter>

                                </MultiTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>

                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
		<uc:ShadowChrome>
			<GroupBox Style="{StaticResource MainContentGroupBoxStyle}">
				<GroupBox.Header>
					<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom">
						<Image Source="..\..\Ressources\Icons\UserGroupBusinessDisabled.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 Path=Name, Mode=OneWay}" 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="{DynamicResource ObjectEditBackgroundBrush}">
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition Height="*" />
						<RowDefinition Height="Auto" />
					</Grid.RowDefinitions>
					<Rectangle Fill="{DynamicResource TeamContentBrush}" 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">
							<Grid Name="grid_root">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="Auto" />
									<ColumnDefinition Width="250" />
									<ColumnDefinition Width="Auto" />
									<ColumnDefinition Width="*" />
								</Grid.ColumnDefinitions>
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto" />
									<RowDefinition Height="Auto" />
									<RowDefinition Height="Auto" />
									<RowDefinition Height="*" />
									<RowDefinition Height="0" />
								</Grid.RowDefinitions>

								<Label>Teamname</Label>
								<Label Grid.Row="1">Leitung</Label>
								<Label Grid.Column="2">Notiz</Label>

								<TextBox Grid.Column="1" Height="23" Margin="3" Text="{val:ValidationBinding Path=Name, UpdateSourceTrigger=PropertyChanged}" />
								<uc:PopUpEdit IsReadOnly="True" Name="popupedit_leader" 
                                              Grid.Row="1" Grid.Column="1" Height="23" 
                                              DeleteButtonVisibility="Visible" Margin="3" 
                                              PopUpClick="PopUpEdit_PopUpClick" Text="{val:ValidationBinding Path=LeaderString}"
                                              Cursor="Arrow" PreviewMouseDoubleClick="Popupedit_leader_OnPreviewMouseDoubleClick"/>
								<TextBox Grid.Column="3" Grid.RowSpan="3" MaxHeight="78" AcceptsReturn="True" Margin="3" Text="{Binding Path=Notice,UpdateSourceTrigger=PropertyChanged}" VerticalScrollBarVisibility="Auto" MinWidth="100" />

								<GroupBox Grid.Row="3" Grid.ColumnSpan="4" Header="Mitglieder hinzufügen" Margin="3,15,3,3" Style="{DynamicResource ObjectEditGroupBox}">
									<Grid>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="*" />
											<ColumnDefinition Width="Auto" />
											<ColumnDefinition Width="*" />
										</Grid.ColumnDefinitions>
										<Grid.RowDefinitions>
											<RowDefinition Height="Auto" />
											<RowDefinition Height="*" />
										</Grid.RowDefinitions>

										<Label VerticalAlignment="Bottom">
											zugeordnete Mitarbeiter
										</Label>

										<ListBox Name="listbox_teamMember" Grid.Row="1" ItemsSource="{Binding Path=Member}">
                                            <ListBox.ItemContainerStyle>
                                                <Style TargetType="{x:Type ListBoxItem}">
                                                    <EventSetter Event="MouseDoubleClick" Handler="DoubleClickHandler" />
                                                </Style>
                                            </ListBox.ItemContainerStyle>
											<ListBox.ItemTemplate>
												<DataTemplate>
													<StackPanel Orientation="Horizontal">
														<Button Style="{StaticResource {x:Type Button}}" HorizontalAlignment="Center" VerticalAlignment="Center" Height="18" Padding="0" Width="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}" Margin="3 0 0 0" Click="button_remove_Click" Tag="{Binding}" ToolTip="Entfernen">
															<Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
																<Path Stroke="White" StrokeThickness="1.5" Data="M -3,-3 L 3, 3" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
																<Path Stroke="White" StrokeThickness="1.5" Data="M 3,-3 L -3, 3" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
															</Canvas>
														</Button>
														<Label Margin="3 0 0 3" Padding="0" Content="{Binding Path=LastName}" />
														<Label Margin="0" Padding="0" Content=", " />
														<Label Margin="0" Padding="0" Content="{Binding Path=FirstName}" />
													</StackPanel>
												</DataTemplate>
											</ListBox.ItemTemplate>
										</ListBox>

										<Button Name="button_add" Content="&lt;" FontWeight="Bold" Width="25" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Height="25" MinWidth="30" Margin="3" ToolTip="Mitarbeiter dem Team hinzufügen" Click="button_add_Click" />

										<Label VerticalAlignment="Bottom" Grid.Column="2">
											verfügbare Mitarbeiter
										</Label>
										<localSearchView:EmployeeSearchView x:Name="employeesearchview" IsMultiSelect="True" Grid.Column="2" Grid.Row="1" />
									</Grid>
								</GroupBox>


								<Popup Grid.Row="4" Grid.ColumnSpan="4" Margin="10" Name="popup_employee" StaysOpen="False" Placement="MousePoint" Width="370" Height="250" Opened="popup_Opened" Closed="popup_Closed">
									<localSearchView:EmployeeSearchView ItemSelected="EmployeeSearchView_EmployeeSelected" x:Name="leaderSearchView" />
								</Popup>

							</Grid>
						</TabItem>
						<TabItem Header="Dokumente" Name="tabitem_documents" Selector.Selected="tabitem_documents_Selected" />

					</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" />
						<Button x:Name="btnClose" Content="Schließen" Margin="0,0,3,0" Command="ApplicationCommands.Close" Height="25" />
					</StackPanel>
				</Grid>
			</GroupBox>
		</uc:ShadowChrome>
	</Grid>
</localView:BeWoView>