Files
BeWoPlaner/BeWo/View/Detail/TextbausteinView.xaml
2025-12-12 14:15:58 +01:00

306 lines
18 KiB
XML

<view:BeWoView
x:Class="BeWo.View.Detail.TextbausteinView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:detail="clr-namespace:BeWo.View.Detail"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:view="clr-namespace:BeWo.View"
Width="Auto"
Height="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Focusable="True">
<view:BeWoView.Resources>
<detail:IsOnlyForEmployeeRightsConverter x:Key="IsOnlyForEmployeeRightsConverter" />
<detail:TextModuleEditConverter x:Key="TextModuleEditConverter" />
</view:BeWoView.Resources>
<GroupBox
Name="root"
Header="Aktuell definierte Textbausteine"
Style="{StaticResource ObjectEditGroupBox}">
<Grid VerticalAlignment="Stretch">
<Grid.Resources>
<ContextMenu
x:Key="ContextMenuTextModules"
MenuItem.Click="ContextMenuTextModules_Click"
Opened="ContextMenuTextModules_Opened">
<MenuItem Header="Neue Textbausteinkategorie">
<MenuItem.Icon>
<Image Source="..\..\Ressources\Icons\Add24.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Neuer Textbaustein">
<MenuItem.Icon>
<Image Source="..\..\Ressources\Icons\Add24.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label
Grid.Row="0"
Grid.Column="0"
Content="Name" />
<TextBox
Grid.Row="0"
Grid.Column="1"
Width="150"
Text="{Binding Path=NewVM.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Label
Grid.Row="0"
Grid.Column="2"
Content="Text" />
<TextBox
Grid.Row="0"
Grid.RowSpan="4"
Grid.Column="3"
AcceptsReturn="True"
IsEnabled="{Binding Path=NewVM.IsParent, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BoolReverseConverter}}"
Text="{Binding Path=NewVM.Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
VerticalScrollBarVisibility="Auto" />
<Label
Grid.Row="1"
Grid.Column="0"
Content="Textbausteinkategorie" />
<dxe:ComboBoxEdit
Grid.Row="1"
Grid.Column="1"
Width="150"
Height="23"
Margin="3"
EditMode="Standalone"
ItemsSource="{Binding Path=PossibleTextModuleParents}"
SelectedItem="{Binding Path=NewVM.Parent}">
<dxe:ComboBoxEdit.Buttons>
<dxe:ButtonInfo Click="RemoveParentTextModuleFromNewVM_OnClick" GlyphKind="Cancel" />
</dxe:ComboBoxEdit.Buttons>
</dxe:ComboBoxEdit>
<Label
Grid.Row="2"
Grid.Column="0"
Content="Leistungskategorie" />
<dxe:ComboBoxEdit
Grid.Row="2"
Grid.Column="1"
Width="150"
Height="23"
Margin="3"
EditMode="Standalone"
IsEnabled="{Binding Path=NewVM.IsParent, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BoolReverseConverter}}"
ItemsSource="{Binding Path=PossibleCategories}"
SelectedItem="{Binding Path=NewVM.ServiceCategory}">
<dxe:ComboBoxEdit.Buttons>
<dxe:ButtonInfo Click="RemoveServiceCategoryFromNewVM_OnClick" GlyphKind="Cancel" />
</dxe:ComboBoxEdit.Buttons>
</dxe:ComboBoxEdit>
<CheckBox
Grid.Row="3"
Grid.Column="0"
Margin="3"
Checked="IsTextModuleParent_Checked"
Content="Ist Textbausteinkategorie"
IsChecked="{Binding Path=NewVM.IsParent, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Button
Grid.Row="4"
Grid.Column="0"
Grid.ColumnSpan="4"
Margin="3,3,0,3"
HorizontalAlignment="Right"
Click="AddTextModuleButton_Click"
Content="Hinzufügen" />
<dxg:TreeListControl
Name="TreeListControl"
Grid.Row="5"
Grid.Column="0"
Grid.ColumnSpan="4"
Margin="0"
dx:ThemeManager.ThemeName="Office2010Black"
ContextMenu="{StaticResource ContextMenuTextModules}"
ItemsSource="{Binding Path=VMList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSourceChanged="TreeListControl_ItemsSourceChanged"
PreviewMouseDown="TreeListControl_OnPreviewMouseDown">
<dxg:TreeListControl.Columns>
<dxg:TreeListColumn
Width="24"
FieldName="IsDeleteable"
FixedWidth="True"
Header=" "
ReadOnly="True">
<dxg:TreeListColumn.CellTemplate>
<DataTemplate>
<Button
Width="18"
Height="18"
VerticalAlignment="Center"
Click="DeleteButton_Click"
Content="r"
FontFamily="Webdings">
<Button.IsEnabled>
<MultiBinding Converter="{StaticResource TextModuleEditConverter}">
<Binding />
<Binding Path="DataContext.RowData.Row" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</Button.IsEnabled>
</Button>
</DataTemplate>
</dxg:TreeListColumn.CellTemplate>
</dxg:TreeListColumn>
<dxg:TreeListColumn FieldName="Name">
<dxg:TreeListColumn.DisplayTemplate>
<ControlTemplate>
<dxe:TextEdit
EditMode="InplaceInactive"
FontWeight="{Binding Path=DataContext.RowData.Row.FontWeight, RelativeSource={RelativeSource TemplatedParent}}"
Text="{Binding Path=DataContext.RowData.Row.Name, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}">
<dxe:TextEdit.IsEnabled>
<MultiBinding Converter="{StaticResource TextModuleEditConverter}">
<Binding />
<Binding Path="DataContext.RowData.Row" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</dxe:TextEdit.IsEnabled>
</dxe:TextEdit>
</ControlTemplate>
</dxg:TreeListColumn.DisplayTemplate>
<dxg:TreeListColumn.EditTemplate>
<ControlTemplate>
<dxe:TextEdit
x:Name="PART_Editor"
EditMode="InplaceActive"
FontWeight="{Binding Path=DataContext.RowData.Row.FontWeight, RelativeSource={RelativeSource TemplatedParent}}"
Text="{Binding Path=DataContext.RowData.Row.Name, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}">
<dxe:TextEdit.IsEnabled>
<MultiBinding Converter="{StaticResource TextModuleEditConverter}">
<Binding />
<Binding Path="DataContext.RowData.Row" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</dxe:TextEdit.IsEnabled>
</dxe:TextEdit>
</ControlTemplate>
</dxg:TreeListColumn.EditTemplate>
</dxg:TreeListColumn>
<dxg:TreeListColumn FieldName="Text">
<dxg:TreeListColumn.CellTemplate>
<DataTemplate>
<dxe:TextEdit
x:Name="PART_Editor"
AcceptsReturn="True"
AcceptsTab="True"
EditMode="InplaceActive"
IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"
SelectAllOnGotFocus="False"
SelectAllOnMouseUp="False"
Text="{Binding Path=DataContext.RowData.Row.Text, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
TextTrimming="WordEllipsis"
TextWrapping="Wrap" />
</DataTemplate>
</dxg:TreeListColumn.CellTemplate>
</dxg:TreeListColumn>
<dxg:TreeListColumn
AllowEditing="{Binding Path=DataContext.RowData.Row, Converter={StaticResource BoolReverseConverter}, RelativeSource={RelativeSource TemplatedParent}}"
FieldName="ServiceCategory"
Header="Leistungskategorie">
<dxg:TreeListColumn.DisplayTemplate>
<ControlTemplate>
<dxe:ComboBoxEdit
EditMode="InplaceActive"
IsEnabled="{Binding Path=DataContext.RowData.Row.IsParent, Converter={StaticResource BoolReverseConverter}, RelativeSource={RelativeSource TemplatedParent}}"
ItemsSource="{Binding Path=DataContext.PossibleCategories, RelativeSource={RelativeSource FindAncestor, AncestorType=dxg:TreeListControl}}"
SelectedItem="{Binding Path=DataContext.RowData.Row.ServiceCategory, RelativeSource={RelativeSource TemplatedParent}}">
<dxe:ComboBoxEdit.Buttons>
<dxe:ButtonInfo
Click="RemoveServiceCategory_OnClick"
GlyphKind="Cancel"
Tag="{Binding}" />
</dxe:ComboBoxEdit.Buttons>
</dxe:ComboBoxEdit>
</ControlTemplate>
</dxg:TreeListColumn.DisplayTemplate>
<dxg:TreeListColumn.EditTemplate>
<ControlTemplate>
<dxe:ComboBoxEdit
x:Name="PART_Editor"
EditMode="InplaceActive"
IsEnabled="{Binding Path=DataContext.RowData.Row.IsParent, Converter={StaticResource BoolReverseConverter}, RelativeSource={RelativeSource TemplatedParent}}"
ItemsSource="{Binding Path=DataContext.PossibleCategories, RelativeSource={RelativeSource FindAncestor, AncestorType=dxg:TreeListControl}}"
SelectedItem="{Binding Path=DataContext.RowData.Row.ServiceCategory, RelativeSource={RelativeSource TemplatedParent}}">
<dxe:ComboBoxEdit.Buttons>
<dxe:ButtonInfo
Click="RemoveServiceCategory_OnClick"
GlyphKind="Cancel"
Tag="{Binding}" />
</dxe:ComboBoxEdit.Buttons>
</dxe:ComboBoxEdit>
</ControlTemplate>
</dxg:TreeListColumn.EditTemplate>
</dxg:TreeListColumn>
<dxg:TreeListColumn FieldName="Parent" Header="Textbausteinkategorie">
<dxg:TreeListColumn.DisplayTemplate>
<ControlTemplate>
<dxe:ComboBoxEdit
EditMode="InplaceActive"
IsTextEditable="False"
ItemsSource="{Binding Path=DataContext.PossibleTextModuleParents, RelativeSource={RelativeSource FindAncestor, AncestorType=dxg:TreeListControl}}"
Loaded="FrameworkElement_OnLoaded"
SelectedItem="{Binding Path=DataContext.RowData.Row.Parent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
Tag="{Binding Path=DataContext.RowData.Row, RelativeSource={RelativeSource TemplatedParent}}">
<dxe:ComboBoxEdit.Buttons>
<dxe:ButtonInfo
Click="ButtonInfo_OnClick"
GlyphKind="Cancel"
Tag="{Binding}" />
</dxe:ComboBoxEdit.Buttons>
</dxe:ComboBoxEdit>
</ControlTemplate>
</dxg:TreeListColumn.DisplayTemplate>
<dxg:TreeListColumn.EditTemplate>
<ControlTemplate>
<!-- Textbausteinkategorie -->
<dxe:ComboBoxEdit
x:Name="PART_Editor"
EditMode="InplaceActive"
EditValueChanged="PART_Editor_OnEditValueChanged"
IsTextEditable="False"
ItemsSource="{Binding Path=DataContext.PossibleTextModuleParents, RelativeSource={RelativeSource FindAncestor, AncestorType=dxg:TreeListControl}}"
Loaded="FrameworkElement_OnLoaded"
SelectedItem="{Binding Path=DataContext.RowData.Row.Parent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
Tag="{Binding Path=DataContext.RowData.Row, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
<dxe:ComboBoxEdit.Buttons>
<dxe:ButtonInfo
Click="ButtonInfo_OnClick"
GlyphKind="Cancel"
Tag="{Binding}" />
</dxe:ComboBoxEdit.Buttons>
</dxe:ComboBoxEdit>
</ControlTemplate>
</dxg:TreeListColumn.EditTemplate>
</dxg:TreeListColumn>
</dxg:TreeListControl.Columns>
<dxg:TreeListControl.View>
<dxg:TreeListView
Name="TreeListView"
AutoWidth="True"
ExpandStateBinding="{Binding Path=IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
KeyFieldName="KeyField"
ParentFieldName="ParentField" />
</dxg:TreeListControl.View>
</dxg:TreeListControl>
</Grid>
</GroupBox>
</view:BeWoView>