<localView:BeWoView x:Class="BeWo.View.Detail.MedikamentenverordnungslistenEditView"
      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:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
	  xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
	  xmlns:detail="clr-namespace:BeWo.View.Detail"
	  xmlns:converter="clr-namespace:BeWo.Converter"
	  Height="Auto" Width="Auto" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Focusable="True">
	<localView:BeWoView.Resources>
		<converter:BoolVisibilityConverter x:Key="BoolVisibilityConverter" />
	</localView:BeWoView.Resources>
	<Grid Width="Auto" Height="Auto">
		<GroupBox x:Name="rootGroupBox" Style="{StaticResource PopUpWindowStyle}">
			<GroupBox.Header>
				<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0">
					<Image Source="..\..\Ressources\Icons\MenuDisabled.png" RenderTransformOrigin="0.5,0.5" Width="Auto" Height="28" Margin="0,0,0,0">
						<Image.RenderTransform>
							<TransformGroup>
								<ScaleTransform ScaleX="1" ScaleY="1" />
								<SkewTransform AngleX="0" AngleY="0" />
								<RotateTransform Angle="0" />
								<TranslateTransform X="0" Y="0" />
							</TransformGroup>
						</Image.RenderTransform>
					</Image>
					<TextBox Text="Medikamentenverordnungsliste erstellen" Margin="10,4,0,0" Background="{x:Null}" 
                             Foreground="{DynamicResource MainGroupBoxForegroundBrush}" FontSize="20" 
                             BorderBrush="{x:Null}" VerticalAlignment="Stretch" BorderThickness="0,0,0,0" Padding="0,0,0,0" />
				</StackPanel>
			</GroupBox.Header>
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="*" />
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>
				<Grid Grid.Row="0" Margin="0,3,0,6" Background="{StaticResource ObjectEditBackgroundBrush}">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto" />
							<ColumnDefinition Width="*" />
							<ColumnDefinition Width="Auto" />
							<ColumnDefinition Width="*" />
							<ColumnDefinition Width="Auto" />
							<ColumnDefinition Width="*" />
							<ColumnDefinition Width="Auto" />
							<ColumnDefinition Width="*" />
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
						</Grid.RowDefinitions>
						<Label Content="Med_Art:" Grid.Row="0" Grid.Column="0" Margin="3" />
						<dxe:ComboBoxEdit x:Name="MedArtCBE" Grid.Row="0" Grid.Column="1" Margin="3" ItemsSource="{Binding Path=MedArten, RelativeSource={RelativeSource AncestorType={x:Type detail:MedikamentenverordnungslistenEditView}, Mode=FindAncestor}}" IsTextEditable="False" />

						<Label Content="Med_Name:" Grid.Row="0" Grid.Column="2" Margin="3" />
						<dxe:TextEdit x:Name="MedNameTE" Grid.Row="0" Grid.Column="3" Margin="3" Grid.ColumnSpan="3" />

						<Label Content="Darr.form:" Grid.Row="0" Grid.Column="6" Margin="3" />
						<dxe:ComboBoxEdit x:Name="DarrFormCBE" Grid.Row="0" Grid.Column="7" Margin="3" SelectedIndex="0" ItemsSource="{Binding Path=ViewModel.PossibleDarreichungsformen, RelativeSource={RelativeSource AncestorType={x:Type detail:MedikamentenverordnungslistenEditView}, Mode=FindAncestor}}" IsTextEditable="False" />

						<Label Content="Morgens:" Grid.Row="1" Grid.Column="0" Margin="3" />
						<dxe:TextEdit x:Name="MorgensTE" Grid.Row="1" MaskType="Numeric" Grid.Column="1" Margin="3" />

						<Label Content="Mittags:" Grid.Row="1" Grid.Column="2" Margin="3" />
						<dxe:TextEdit x:Name="MittagsTE" Grid.Row="1" MaskType="Numeric" Grid.Column="3" Margin="3" />

						<Label Content="Abends:" Grid.Row="1" Grid.Column="4" Margin="3" />
						<dxe:TextEdit x:Name="AbendsTE" Grid.Row="1" MaskType="Numeric" Grid.Column="5" Margin="3" />

						<Label Content="Nachts:" Grid.Row="1" Grid.Column="6" Margin="3" />
						<dxe:TextEdit x:Name="NachtsTE" Grid.Row="1" MaskType="Numeric" Grid.Column="7" Margin="3" />

						<Label Content="Depot_Menge:" Grid.Row="2" Grid.Column="0" Margin="3" />
						<dxe:TextEdit x:Name="DepotMengeTE" Grid.Row="2" MaskType="RegEx" Mask="[0,1]{1}" Grid.Column="1" Margin="3" />

						<Label Content="Depot_Rhythmus:" Grid.Row="2" Grid.Column="2" Margin="3" />
						<dxe:ComboBoxEdit x:Name="DepotRhythmusCBE" Grid.Row="2" Grid.Column="3" Margin="3" SelectedIndex="0" ItemsSource="{Binding Path=ViewModel.PossibleDepotRhythmen, RelativeSource={RelativeSource AncestorType={x:Type detail:MedikamentenverordnungslistenEditView}, Mode=FindAncestor}}" IsTextEditable="False" />

						<Label Content="Depot_ErsterTag:" Grid.Row="2" Grid.Column="4" Margin="3" />
						<dxe:DateEdit x:Name="DepotErsterTagDE" MaskType="DateTimeAdvancingCaret"  Grid.Row="2" Grid.Column="5" Margin="3" />

						<Label Content="Depot_NächsterTag:" Grid.Row="2" Grid.Column="6" Margin="3" />
						<dxe:DateEdit x:Name="DepotNaechsterTagDE" MaskType="DateTimeAdvancingCaret" Grid.Row="2" Grid.Column="7" Margin="3" />

						<Label Content="Med_Bemerkung:" Grid.Row="3" Grid.Column="0" Margin="3" />
						<dxe:TextEdit x:Name="MedBemerkungTE" Grid.Row="3" Grid.Column="1" Margin="3" Grid.ColumnSpan="3" />

						<Label Content="Datum der Verordnung:" Grid.Row="3" Grid.Column="4" Margin="3" />
						<dxe:DateEdit x:Name="VerordnungsdatumDE" MaskType="DateTimeAdvancingCaret" Grid.Row="3" Grid.Column="5" Margin="3" />
						
						<Label Content="Med_Verordnet:" Grid.Row="3" Grid.Column="6" Margin="3" />
						<dxe:TextEdit x:Name="MedVerordnetTE" Grid.Row="3" Grid.Column="7" Margin="3" />

						<Button Grid.Column="7" Grid.Row="4" Content="Hinzufügen" Margin="3" HorizontalAlignment="Right" Click="VerordnungHinzufuegenClick" />
					</Grid>
				</Grid>
				<dxg:GridControl Grid.Row="1" ItemsSource="{Binding Path=Medikamentenverordnungen}" x:Name="MVGrid">
					<dxg:GridControl.Columns>
						<dxg:GridColumn FieldName="x" Header="">
							<dxg:GridColumn.CellTemplate>
								<DataTemplate>
									<Button Content="r" FontFamily="Webdings" Click="RemoveMVAusListeClick" Width="18" Height="18" VerticalAlignment="Center" />
								</DataTemplate>
							</dxg:GridColumn.CellTemplate>
						</dxg:GridColumn>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.Verordnungsdatum, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Verordnungsdatum" Width="80" >
							<dxg:GridColumn.EditSettings>
								<dxe:DateEditSettings DisplayFormat="d"/>
							</dxg:GridColumn.EditSettings>
						</dxg:GridColumn>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.MedArt, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Med_Art">
							<dxg:GridColumn.EditSettings>
								<dxe:ComboBoxEditSettings ItemsSource="{Binding Path=MedArten, RelativeSource={RelativeSource AncestorType={x:Type detail:MedikamentenverordnungslistenEditView}, Mode=FindAncestor}}" IsTextEditable="False"/>
							</dxg:GridColumn.EditSettings>
						</dxg:GridColumn>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.MedName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Med_Name" ReadOnly="False" EditSettings="{dxe:TextSettings}"/>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.Darreichungsform, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Darr.form" >
							<dxg:GridColumn.EditSettings>
								<dxe:ComboBoxEditSettings ItemsSource="{Binding Path=ViewModel.PossibleDarreichungsformen, RelativeSource={RelativeSource AncestorType={x:Type detail:MedikamentenverordnungslistenEditView}, Mode=FindAncestor}}" IsTextEditable="False" />
							</dxg:GridColumn.EditSettings>
						</dxg:GridColumn>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.Morgens, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Morgens" ReadOnly="False">
							<dxg:GridColumn.EditSettings>
								<dxe:TextEditSettings MaskType="Numeric"/>
							</dxg:GridColumn.EditSettings>
						</dxg:GridColumn>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.Mittags, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Mittags" ReadOnly="False">
							<dxg:GridColumn.EditSettings>
								<dxe:TextEditSettings MaskType="Numeric"/>
							</dxg:GridColumn.EditSettings>
						</dxg:GridColumn>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.Abends, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Abends" ReadOnly="False">
							<dxg:GridColumn.EditSettings>
								<dxe:TextEditSettings MaskType="Numeric"/>
							</dxg:GridColumn.EditSettings>
						</dxg:GridColumn>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.Nachts, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Nachts" ReadOnly="False">
							<dxg:GridColumn.EditSettings>
								<dxe:TextEditSettings MaskType="Numeric"/>
							</dxg:GridColumn.EditSettings>
						</dxg:GridColumn>
						<dxg:GridColumn BestFitMode="AllRows" FieldName="DepotMenge" Header="Depot_Menge">
							<dxg:GridColumn.EditSettings>
								<dxe:TextEditSettings MaskType="RegEx" Mask="[0,1]{1}" />
							</dxg:GridColumn.EditSettings>
						</dxg:GridColumn>
						
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.DepotRhythmus, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Depot_Rhythmus">
							<dxg:GridColumn.EditSettings>
								<dxe:ComboBoxEditSettings ItemsSource="{Binding Path=ViewModel.PossibleDepotRhythmen, RelativeSource={RelativeSource AncestorType={x:Type detail:MedikamentenverordnungslistenEditView}, Mode=FindAncestor}}" IsTextEditable="False"/>
							</dxg:GridColumn.EditSettings>
						</dxg:GridColumn>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.DepotErsterTag, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Depot_ErsterTag" Width="80" >
							<dxg:GridColumn.EditSettings>
								<dxe:DateEditSettings DisplayFormat="d"/>
							</dxg:GridColumn.EditSettings>
						</dxg:GridColumn>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.DepotNaechsterTag, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Depot_NächsterTag" Width="80" >
							<dxg:GridColumn.EditSettings>
								<dxe:DateEditSettings DisplayFormat="d"/>
							</dxg:GridColumn.EditSettings>
						</dxg:GridColumn>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.MedBemerkung, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Med_Bemerkung" ReadOnly="False" EditSettings="{dxe:TextSettings}"/>
						<dxg:GridColumn BestFitMode="AllRows" Binding="{Binding Path=RowData.Row.MedVerordnet, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Med_Verordnet" ReadOnly="False" EditSettings="{dxe:TextSettings}"/>
					</dxg:GridControl.Columns>
					<dxg:GridControl.View>
						<dxg:TableView AutoWidth="True" ShowGroupPanel="False" BestFitMode="AllRows"/>
					</dxg:GridControl.View>
				</dxg:GridControl>
				<Border Grid.Row="2" Height="30" 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>
				<Grid Grid.Row="2" VerticalAlignment="Center" Height="Auto" Margin="5,10,0,0">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="*" />
						<ColumnDefinition Width="Auto" />
					</Grid.ColumnDefinitions>
					<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
						<Button x:Name="SaveBtn" Content="Speichern und schließen" Margin="0,0,3,0" Command="ApplicationCommands.Save" Height="25" />
						<Button Content="Abbrechen" Margin="0,0,3,0" Command="ApplicationCommands.Close" Height="25" />
					</StackPanel>
					<CheckBox Grid.Column="0" IsChecked="{Binding Path=MedListType, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Foreground="White" Visibility="{Binding IsInEditMode, Converter={StaticResource BoolVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type detail:MedikamentenverordnungslistenEditView}, Mode=FindAncestor}}">Bedarfsmedikationsliste</CheckBox>
				</Grid>
			</Grid>
		</GroupBox>
	</Grid>
</localView:BeWoView>
