Multiple fixes for Views and ViewModels.

This commit is contained in:
Daniel Kraus 2015-08-13 17:59:23 +02:00
parent 3a615eda8b
commit 63447def9b
7 changed files with 79 additions and 25 deletions

View File

@ -49,6 +49,13 @@
<Setter Property="Control.ToolTip" Value="{Binding Path=ToolTip, Mode=OneWay}" /> <Setter Property="Control.ToolTip" Value="{Binding Path=ToolTip, Mode=OneWay}" />
<Setter Property="IsEnabled" Value="{Binding Path=IsEnabled, Mode=OneWay}" /> <Setter Property="IsEnabled" Value="{Binding Path=IsEnabled, Mode=OneWay}" />
</Style> </Style>
<Style TargetType="Image">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.3" />
</Trigger>
</Style.Triggers>
</Style>
<conv:EnumBooleanConverter x:Key="enumBoolConv" /> <conv:EnumBooleanConverter x:Key="enumBoolConv" />
<conv:VisibilityBooleanConverter x:Key="visBoolConv" /> <conv:VisibilityBooleanConverter x:Key="visBoolConv" />
<conv:BooleanNegationConverter x:Key="boolNegConv" /> <conv:BooleanNegationConverter x:Key="boolNegConv" />

View File

@ -11,7 +11,7 @@ Albumin Alb S
Albumin/Creatinin (PU)" ACR U Albumin/Creatinin (PU)" ACR U
"Alk. Phosphatase" AP S "Alk. Phosphatase" AP S
Amylase Amylase S Amylase Amylase S
"anorg. Phosphat" Phosphat S "anorg. Phosphat" P S
"Bakterien (U)" Bakt U "Bakterien (U)" Bakt U
Basenabweichung BE BGA Basenabweichung BE BGA
Basophile Baso E Basophile Baso E
@ -69,6 +69,7 @@ Kalium K S
"Leukozyten (U)" Leu U "Leukozyten (U)" Leu U
Leukozyten Leu E Leukozyten Leu E
Lymphozyten Lym E Lymphozyten Lym E
Magnesium Mg S X
"MCH (HbE)" MCH E "MCH (HbE)" MCH E
MCHC MCHC E MCHC MCHC E
MCV MCV E MCV MCV E
@ -82,7 +83,7 @@ Neutrophile Neu E
NT-proBNP NT-proBNP S NT-proBNP NT-proBNP S
"PCO2 (art.)" pCO2 BGA "PCO2 (art.)" pCO2 BGA
"pH (U)" pH U "pH (U)" pH U
"pH" pH BGA pH pH BGA
"Plattenepithelien (U)" Plattenep U "Plattenepithelien (U)" Plattenep U
"PO2 (art.)" pO2 BGA "PO2 (art.)" pO2 BGA
"Protein (U)" Protein U "Protein (U)" Protein U
@ -112,3 +113,5 @@ Anti-Streptolysin ASL S
TSH TSH S TSH TSH S
HAPTOGLOBIN Haptoglobin S HAPTOGLOBIN Haptoglobin S
FRAGMENTOZYTEN Fragmentozyten E FRAGMENTOZYTEN Fragmentozyten E
"HBc-Antikörper (gesamt)" Anti-HBc S
HBs-Antikörper Anti-HBs S

View File

@ -6,4 +6,5 @@
ng/ml µg/l ng/ml µg/l
mmol/l mM mmol/l mM
n*1000/µl /nl n*1000/µl /nl
n*10E6/µl /fl
Bak/µl /µl Bak/µl /µl

View File

@ -342,13 +342,24 @@ namespace zaaReloaded2.ViewModels
{ {
// Create a new element picker; it will automatically create and // Create a new element picker; it will automatically create and
// send us a new element view model if one is chosen by the view. // send us a new element view model if one is chosen by the view.
ElementPickerViewModel picker = new ElementPickerViewModel(true); ElementPickerViewModel picker = new ElementPickerViewModel(
allowControlElements: IsTopLevelElement());
picker.ElementChosenMessage.Sent += (sender, args) => picker.ElementChosenMessage.Sent += (sender, args) =>
{ {
ElementViewModel newVM = args.Content.ViewModel as ElementViewModel; ElementViewModel newVM = args.Content.ViewModel as ElementViewModel;
AddElementViewModel(newVM); if (IsTopLevelElement())
{
AddElementViewModel(newVM);
}
else
{
// If the selected element is on the second level, it
// must be a FormatElementViewModel.
ControlElementViewModel parent = ((FormatElementViewModel)LastSelectedElement).Parent;
AddChildElementViewModel(parent, newVM as FormatElementViewModel);
}
newVM.IsSelected = true; newVM.IsSelected = true;
DoEditElement(); if (newVM is FormatElementViewModel) DoEditElement();
}; };
AddElementMessage.Send(new ViewModelMessageContent(picker)); AddElementMessage.Send(new ViewModelMessageContent(picker));
} }
@ -389,11 +400,16 @@ namespace zaaReloaded2.ViewModels
{ {
// Replace the previously selected element with the new // Replace the previously selected element with the new
// one that we get from the ElementPickerViewModel. // one that we get from the ElementPickerViewModel.
int index = Elements.IndexOf(LastSelectedElement);
ElementViewModel newVM = args.Content.ViewModel as ElementViewModel; ElementViewModel newVM = args.Content.ViewModel as ElementViewModel;
Elements.Insert( ControlElementBase oldModel = LastSelectedElement.RevealModelObject() as ControlElementBase;
Elements.IndexOf(LastSelectedElement), ControlElementBase newModel = newVM.RevealModelObject() as ControlElementBase;
newVM); // Caveat: once we modify the Elements collection, LastSelectedElement will change!
Elements.Remove(LastSelectedElement); Elements.RemoveAt(index);
Elements.Insert(index, newVM);
newModel.Children = oldModel.Children;
_settings.Elements.RemoveAt(index);
_settings.Elements.Insert(index, newModel);
newVM.PropertyChanged += ElementViewModel_PropertyChanged; newVM.PropertyChanged += ElementViewModel_PropertyChanged;
newVM.IsSelected = true; newVM.IsSelected = true;
}; };
@ -452,12 +468,16 @@ namespace zaaReloaded2.ViewModels
{ {
if (IsTopLevelElement()) if (IsTopLevelElement())
{ {
AddElementViewModel(LastSelectedElement.Clone() as ElementViewModel); ElementViewModel newControlVM = LastSelectedElement.Clone() as ElementViewModel;
AddElementViewModel(newControlVM);
newControlVM.IsSelected = true;
} }
else else
{ {
FormatElementViewModel formatVM = LastSelectedElement as FormatElementViewModel; FormatElementViewModel originalVM = LastSelectedElement as FormatElementViewModel;
formatVM.Parent.AddChildElement(formatVM.Clone() as FormatElementViewModel); FormatElementViewModel newFormatVM = originalVM.Clone() as FormatElementViewModel;
originalVM.Parent.AddChildElement(newFormatVM);
newFormatVM.IsSelected = true;
} }
} }
} }
@ -492,7 +512,7 @@ namespace zaaReloaded2.ViewModels
_settings.Elements.RemoveAt(index); _settings.Elements.RemoveAt(index);
_settings.Elements.Insert( _settings.Elements.Insert(
index - 1, index - 1,
LastSelectedElement.RevealModelObject() as ElementBase); lastSelectedElement.RevealModelObject() as ElementBase);
} }
else else
{ {
@ -588,7 +608,7 @@ namespace zaaReloaded2.ViewModels
_settings.Elements.RemoveAt(index); _settings.Elements.RemoveAt(index);
_settings.Elements.Insert( _settings.Elements.Insert(
index + 1, index + 1,
LastSelectedElement.RevealModelObject() as ElementBase); lastSelectedElement.RevealModelObject() as ElementBase);
} }
else else
{ {

View File

@ -61,7 +61,8 @@
<DockPanel Margin="10"> <DockPanel Margin="10">
<Label DockPanel.Dock="Top" Target="{Binding ElementName=settingsList}">Bitte Stil auswählen:</Label> <Label DockPanel.Dock="Top" Target="{Binding ElementName=settingsList}">Bitte Stil auswählen:</Label>
<StackPanel DockPanel.Dock="Right" Margin="10 0 0 0"> <StackPanel DockPanel.Dock="Right" Margin="10 0 0 0">
<Button Command="{Binding UseSettingsCommand}" IsDefault="True" x:Name="OkButton"> <Button Command="{Binding UseSettingsCommand}" IsDefault="True" x:Name="OkButton"
ToolTip="Stil auswählen und Textblock damit formatieren (Enter)">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Image Source="/zaaReloaded2;component/Icons/f.png" Width="32" /> <Image Source="/zaaReloaded2;component/Icons/f.png" Width="32" />
<TextBlock VerticalAlignment="Center" Margin="10 0 0 0">Auswählen</TextBlock> <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">Auswählen</TextBlock>
@ -74,16 +75,16 @@
<Button Command="{Binding DeleteSettingsCommand}" ToolTip="Entfernen" Margin="5 0 0 5"> <Button Command="{Binding DeleteSettingsCommand}" ToolTip="Entfernen" Margin="5 0 0 5">
<Image Source="/zaaReloaded2;component/Icons/minus.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/minus.png" Width="24" />
</Button> </Button>
<Button Command="{Binding EditSettingsCommand}" ToolTip="Bearbeiten" Margin="0 5 5 5"> <Button Command="{Binding EditSettingsCommand}" ToolTip="Bearbeiten (Leertaste)" Margin="0 5 5 5">
<Image Source="/zaaReloaded2;component/Icons/pen.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/pen.png" Width="24" />
</Button> </Button>
<Button Command="{Binding CopySettingsCommand}" ToolTip="Kopieren" Margin="5 5 0 5"> <Button Command="{Binding CopySettingsCommand}" ToolTip="Kopieren (STRG+D)" Margin="5 5 0 5">
<Image Source="/zaaReloaded2;component/Icons/duplicate.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/duplicate.png" Width="24" />
</Button> </Button>
<Button Command="{Binding ExportSettingsCommand}" ToolTip="Exportieren" Margin="0 5 5 5"> <Button Command="{Binding ExportSettingsCommand}" ToolTip="Exportieren (STRG+S)" Margin="0 5 5 5">
<Image Source="/zaaReloaded2;component/Icons/export.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/export.png" Width="24" />
</Button> </Button>
<Button Command="{Binding ImportSettingsCommand}" ToolTip="Importieren" Margin="5 5 0 5"> <Button Command="{Binding ImportSettingsCommand}" ToolTip="Importieren (STRG+O)" Margin="5 5 0 5">
<Image Source="/zaaReloaded2;component/Icons/import.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/import.png" Width="24" />
</Button> </Button>
<Button Command="{Binding ResetSettingsCommand}" ToolTip="Auf Werkseinstellungen zurücksetzen" <Button Command="{Binding ResetSettingsCommand}" ToolTip="Auf Werkseinstellungen zurücksetzen"
@ -98,6 +99,15 @@
<ListBox ItemsSource="{Binding SettingsList}" <ListBox ItemsSource="{Binding SettingsList}"
DisplayMemberPath="Name" DisplayMemberPath="Name"
ItemContainerStyle="{DynamicResource ResourceKey=ViewModelListBox}" ItemContainerStyle="{DynamicResource ResourceKey=ViewModelListBox}"
x:Name="settingsList" /> x:Name="settingsList">
<ListBox.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding UseSettingsCommand}" />
<KeyBinding Key="Space" Command="{Binding EditSettingsCommand}" />
<KeyBinding Key="Delete" Command="{Binding DeleteSettingsCommand}" />
<KeyBinding Key="S" Modifiers="Control" Command="{Binding ExportSettingsCommand}" />
<KeyBinding Key="O" Modifiers="Control" Command="{Binding ImportSettingsCommand}" />
<KeyBinding Key="D" Modifiers="Control" Command="{Binding CopySettingsCommand}" />
</ListBox.InputBindings>
</ListBox>
</DockPanel> </DockPanel>
</Window> </Window>

View File

@ -72,27 +72,35 @@
<Button Command="{Binding AddElementCommand}" ToolTip="Neues Element" Margin="0 0 5 10"> <Button Command="{Binding AddElementCommand}" ToolTip="Neues Element" Margin="0 0 5 10">
<Image Source="/zaaReloaded2;component/Icons/plus.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/plus.png" Width="24" />
</Button> </Button>
<Button Command="{Binding EditElementCommand}" IsDefault="True" ToolTip="Bearbeiten" Margin="5 0 0 10"> <Button Command="{Binding EditElementCommand}" IsDefault="True" ToolTip="Bearbeiten (Leertaste)" Margin="5 0 0 10">
<Image Source="/zaaReloaded2;component/Icons/pen.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/pen.png" Width="24" />
</Button> </Button>
<Button Command="{Binding AddChildElementCommand}" ToolTip="Neues Kindelement" Margin="0 0 5 10"> <Button Command="{Binding AddChildElementCommand}" ToolTip="Neues Kindelement" Margin="0 0 5 10">
<Image Source="/zaaReloaded2;component/Icons/plus-child.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/plus-child.png" Width="24" />
</Button> </Button>
<Button Command="{Binding MoveElementUpCommand}" ToolTip="Nach oben" Margin="5 0 0 10"> <Button Command="{Binding MoveElementUpCommand}" ToolTip="Nach oben (STRG+HOCH)" Margin="5 0 0 10">
<Image Source="/zaaReloaded2;component/Icons/up.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/up.png" Width="24" />
</Button> </Button>
<Button Command="{Binding DeleteElementCommand}" ToolTip="Entfernen" Margin="0 0 5 10"> <Button Command="{Binding DeleteElementCommand}" ToolTip="Entfernen (Entf)" Margin="0 0 5 10">
<Image Source="/zaaReloaded2;component/Icons/minus.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/minus.png" Width="24" />
</Button> </Button>
<Button Command="{Binding MoveElementDownCommand}" ToolTip="Nach unten" Margin="5 0 0 10"> <Button Command="{Binding MoveElementDownCommand}" ToolTip="Nach unten (STRG+RUNTER)" Margin="5 0 0 10">
<Image Source="/zaaReloaded2;component/Icons/down.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/down.png" Width="24" />
</Button> </Button>
<Button Command="{Binding CopyElementCommand}" ToolTip="Kopieren" Margin="0 0 5 10"> <Button Command="{Binding CopyElementCommand}" ToolTip="Kopieren (STRG+D)" Margin="0 0 5 10">
<Image Source="/zaaReloaded2;component/Icons/duplicate.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/duplicate.png" Width="24" />
</Button> </Button>
</UniformGrid> </UniformGrid>
</StackPanel> </StackPanel>
<TreeView ItemsSource="{Binding Elements}"> <TreeView ItemsSource="{Binding Elements}">
<TreeView.InputBindings>
<MouseBinding Gesture="MiddleClick" Command="{Binding EditElementCommand}" />
<KeyBinding Key="Space" Command="{Binding EditElementCommand}" />
<KeyBinding Key="Delete" Command="{Binding DeleteElementCommand}" />
<KeyBinding Key="Up" Modifiers="Control" Command="{Binding MoveElementUpCommand}" />
<KeyBinding Key="Down" Modifiers="Control" Command="{Binding MoveElementDownCommand}" />
<KeyBinding Key="D" Modifiers="Control" Command="{Binding CopyElementDownCommand}" />
</TreeView.InputBindings>
<TreeView.ItemContainerStyle> <TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}"> <Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /> <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />

View File

@ -29,5 +29,10 @@ namespace zaaReloaded2.Views
{ {
InitializeComponent(); InitializeComponent();
} }
private void TreeView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
}
} }
} }