IsDirty bei ObservColl ImageDC
This commit is contained in:
@@ -8,10 +8,18 @@
|
||||
mc:Ignorable="d">
|
||||
<localView:BeWoView.Resources>
|
||||
<Style TargetType="{x:Type ListBox}" x:Key="PhotoListBoxStyle">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Setter Property="Foreground" Value="Black" />
|
||||
</Style>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Style.Resources>
|
||||
<!--SelectedItem with focus-->
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightBlue" Opacity=".4"/>
|
||||
<!--SelectedItem without focus-->
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey }" Color="LightBlue" Opacity=".4"/>
|
||||
</Style.Resources>
|
||||
</Style>
|
||||
</localView:BeWoView.Resources>
|
||||
<GroupBox Width="1100" Style="{StaticResource PopUpWindowStyle}">
|
||||
<GroupBox Width="1400" Style="{StaticResource PopUpWindowStyle}">
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,0,0">
|
||||
<Image Source="..\..\..\Ressources\Icons\CoinsDisabled.png" Height="28" />
|
||||
@@ -22,38 +30,43 @@
|
||||
</GroupBox.Header>
|
||||
<Grid Background="{StaticResource ObjectEditBackgroundBrush}">
|
||||
<GroupBox Margin="10" Header="Grundrissverwaltung" Style="{StaticResource ObjectEditGroupBox}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<ListBox
|
||||
<ListBox
|
||||
IsSynchronizedWithCurrentItem="True"
|
||||
Name="PhotosListBox"
|
||||
Margin="5"
|
||||
MinHeight="100"
|
||||
MaxHeight="800"
|
||||
ItemsSource="{Binding}"
|
||||
Style="{StaticResource PhotoListBoxStyle}"
|
||||
SelectionMode="Extended"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
SelectedIndex="0">
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Hinzufügen" Click="MenuItem_Add_Click" />
|
||||
<MenuItem Header="Löschen" Click="MenuItem_Del_Click" />
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Rows="3" Columns="3"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<Label Content="{Binding Filename}"/>
|
||||
<Image Source="{Binding ImageData}" Stretch="None"></Image>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</ScrollViewer>
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Hinzufügen" Click="MenuItem_Add_Click" />
|
||||
<MenuItem Header="Löschen" Click="MenuItem_Del_Click" />
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Columns="3"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<Image Source="{Binding ImageData}" Height="150" Stretch="Uniform"></Image>
|
||||
<Label Content="{Binding Filename}" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace BeWo.View.Detail.Wohneinheit
|
||||
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close,
|
||||
(s, e) =>
|
||||
{
|
||||
BeWoApp.MainControl.CloseCurrentPopUp();
|
||||
BeWoApp.MainControl.CloseCurrentPopUp();
|
||||
}));
|
||||
|
||||
Images = images;
|
||||
@@ -49,19 +49,21 @@ namespace BeWo.View.Detail.Wohneinheit
|
||||
// Show open file dialog box
|
||||
bool? result = dialog.ShowDialog();
|
||||
|
||||
// Process open file dialog box results
|
||||
if (result == true)
|
||||
{
|
||||
// Open document
|
||||
string filename = dialog.FileName;
|
||||
if (result != true)
|
||||
return;
|
||||
|
||||
var dc = new ImageDC();
|
||||
var info = new FileInfo(dialog.FileName);
|
||||
|
||||
dc.Filename = filename;
|
||||
dc.ImageData = File.ReadAllBytes(filename);
|
||||
if (!info.Exists)
|
||||
return;
|
||||
|
||||
Images.Add(dc);
|
||||
}
|
||||
var dc = new ImageDC();
|
||||
|
||||
dc.Filename = info.Name;
|
||||
dc.Fullname = info.FullName;
|
||||
dc.ImageData = File.ReadAllBytes(info.FullName);
|
||||
|
||||
Images.Add(dc);
|
||||
}
|
||||
|
||||
private void MenuItem_Del_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace BeWo.ViewModel
|
||||
private string _Zusatznotiz;
|
||||
private string _Stock;
|
||||
private ObservableCollection<ImageDC> _Grundrisse;
|
||||
private bool _GrundrisseIsDirty;
|
||||
|
||||
public WohneinheitVM()
|
||||
{
|
||||
@@ -248,14 +249,29 @@ namespace BeWo.ViewModel
|
||||
}
|
||||
public ObservableCollection<ImageDC> Grundrisse
|
||||
{
|
||||
get => _Grundrisse ?? (_Grundrisse = new ObservableCollection<ImageDC>());
|
||||
get => _Grundrisse ?? (Grundrisse = new ObservableCollection<ImageDC>());
|
||||
set
|
||||
{
|
||||
if (_Grundrisse is object)
|
||||
_Grundrisse.CollectionChanged -= GrundrisseCollectionChanged;
|
||||
|
||||
_Grundrisse = value;
|
||||
|
||||
if (_Grundrisse is object)
|
||||
_Grundrisse.CollectionChanged += GrundrisseCollectionChanged;
|
||||
|
||||
FirePropertyChanged(nameof(Grundrisse));
|
||||
}
|
||||
}
|
||||
|
||||
public void GrundrisseCollectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
_GrundrisseIsDirty = true;
|
||||
FirePropertyChanged(nameof(IsDirty));
|
||||
}
|
||||
|
||||
public override bool IsDirty => base.IsDirty || _GrundrisseIsDirty;
|
||||
|
||||
public bool IsEinzelwohnung => string.IsNullOrEmpty(Zimmername);
|
||||
|
||||
public string Caption => IsEinzelwohnung ? Wohnname : Zimmername ;
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace BS.Shared.DataContracts
|
||||
//[DataMember] public long OwnerOid { get; set; }
|
||||
|
||||
[DataMember] public string Filename { get; set; }
|
||||
[DataMember] public string Fullname { get; set; }
|
||||
[DataMember] public byte[] ImageData { get; set; }
|
||||
|
||||
public BitmapImage BitmapImage
|
||||
|
||||
Reference in New Issue
Block a user