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="IsEnabled" Value="{Binding Path=IsEnabled, Mode=OneWay}" />
</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:VisibilityBooleanConverter x:Key="visBoolConv" />
<conv:BooleanNegationConverter x:Key="boolNegConv" />

View File

@ -11,7 +11,7 @@ Albumin Alb S
Albumin/Creatinin (PU)" ACR U
"Alk. Phosphatase" AP S
Amylase Amylase S
"anorg. Phosphat" Phosphat S
"anorg. Phosphat" P S
"Bakterien (U)" Bakt U
Basenabweichung BE BGA
Basophile Baso E
@ -69,6 +69,7 @@ Kalium K S
"Leukozyten (U)" Leu U
Leukozyten Leu E
Lymphozyten Lym E
Magnesium Mg S X
"MCH (HbE)" MCH E
MCHC MCHC E
MCV MCV E
@ -82,7 +83,7 @@ Neutrophile Neu E
NT-proBNP NT-proBNP S
"PCO2 (art.)" pCO2 BGA
"pH (U)" pH U
"pH" pH BGA
pH pH BGA
"Plattenepithelien (U)" Plattenep U
"PO2 (art.)" pO2 BGA
"Protein (U)" Protein U
@ -112,3 +113,5 @@ Anti-Streptolysin ASL S
TSH TSH S
HAPTOGLOBIN Haptoglobin S
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
mmol/l mM
n*1000/µl /nl
n*10E6/µl /fl
Bak/µl /µl

View File

@ -342,13 +342,24 @@ namespace zaaReloaded2.ViewModels
{
// Create a new element picker; it will automatically create and
// 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) =>
{
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;
DoEditElement();
if (newVM is FormatElementViewModel) DoEditElement();
};
AddElementMessage.Send(new ViewModelMessageContent(picker));
}
@ -389,11 +400,16 @@ namespace zaaReloaded2.ViewModels
{
// Replace the previously selected element with the new
// one that we get from the ElementPickerViewModel.
int index = Elements.IndexOf(LastSelectedElement);
ElementViewModel newVM = args.Content.ViewModel as ElementViewModel;
Elements.Insert(
Elements.IndexOf(LastSelectedElement),
newVM);
Elements.Remove(LastSelectedElement);
ControlElementBase oldModel = LastSelectedElement.RevealModelObject() as ControlElementBase;
ControlElementBase newModel = newVM.RevealModelObject() as ControlElementBase;
// Caveat: once we modify the Elements collection, LastSelectedElement will change!
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.IsSelected = true;
};
@ -452,12 +468,16 @@ namespace zaaReloaded2.ViewModels
{
if (IsTopLevelElement())
{
AddElementViewModel(LastSelectedElement.Clone() as ElementViewModel);
ElementViewModel newControlVM = LastSelectedElement.Clone() as ElementViewModel;
AddElementViewModel(newControlVM);
newControlVM.IsSelected = true;
}
else
{
FormatElementViewModel formatVM = LastSelectedElement as FormatElementViewModel;
formatVM.Parent.AddChildElement(formatVM.Clone() as FormatElementViewModel);
FormatElementViewModel originalVM = LastSelectedElement 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.Insert(
index - 1,
LastSelectedElement.RevealModelObject() as ElementBase);
lastSelectedElement.RevealModelObject() as ElementBase);
}
else
{
@ -588,7 +608,7 @@ namespace zaaReloaded2.ViewModels
_settings.Elements.RemoveAt(index);
_settings.Elements.Insert(
index + 1,
LastSelectedElement.RevealModelObject() as ElementBase);
lastSelectedElement.RevealModelObject() as ElementBase);
}
else
{

View File

@ -61,7 +61,8 @@
<DockPanel Margin="10">
<Label DockPanel.Dock="Top" Target="{Binding ElementName=settingsList}">Bitte Stil auswählen:</Label>
<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">
<Image Source="/zaaReloaded2;component/Icons/f.png" Width="32" />
<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">
<Image Source="/zaaReloaded2;component/Icons/minus.png" Width="24" />
</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" />
</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" />
</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" />
</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" />
</Button>
<Button Command="{Binding ResetSettingsCommand}" ToolTip="Auf Werkseinstellungen zurücksetzen"
@ -98,6 +99,15 @@
<ListBox ItemsSource="{Binding SettingsList}"
DisplayMemberPath="Name"
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>
</Window>

View File

@ -72,27 +72,35 @@
<Button Command="{Binding AddElementCommand}" ToolTip="Neues Element" Margin="0 0 5 10">
<Image Source="/zaaReloaded2;component/Icons/plus.png" Width="24" />
</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" />
</Button>
<Button Command="{Binding AddChildElementCommand}" ToolTip="Neues Kindelement" Margin="0 0 5 10">
<Image Source="/zaaReloaded2;component/Icons/plus-child.png" Width="24" />
</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" />
</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" />
</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" />
</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" />
</Button>
</UniformGrid>
</StackPanel>
<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>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />

View File

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