DB integration added, multiple images for equipment

This commit is contained in:
retr0volkov
2025-07-15 11:14:28 +03:00 Unverified
parent 7a34fc2dbb
commit 8ddce4005f
38 changed files with 627 additions and 297 deletions
+43 -21
View File
@@ -57,28 +57,50 @@
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom).png"/>
</Button>
<Grid Grid.Row="0" Grid.RowSpan="2" Grid.Column="2"
ColumnDefinitions="*,20,4,20,8" RowDefinitions="8,20,*"
IsVisible="{Binding IsImageSelected}">
<Image Grid.ColumnSpan="5" Grid.RowSpan="3"
Source="{Binding Image.FileName, FallbackValue=null}"/>
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
Command="{Binding ViewImageCommand}">
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_eye_show_24_filled (Custom) 16.png"/>
<Panel Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" HorizontalAlignment="Center">
<ScrollViewer HorizontalAlignment="Center">
<StackPanel>
<ItemsRepeater HorizontalAlignment="Center"
ItemsSource="{Binding Images}">
<ItemsRepeater.Layout>
<UniformGridLayout Orientation="Horizontal" MaximumRowsOrColumns="1"/>
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate DataType="vm:ImageViewModel">
<Border Margin="4" CornerRadius="4" Background="LightGray">
<Grid Margin="2" Width="200" Height="200" Background="LightGray"
ColumnDefinitions="*,20,4,20,8" RowDefinitions="8,20,*">
<Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="5"
Source="{Binding FileName}" />
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).ViewImageCommand}"
CommandParameter="{Binding .}">
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_eye_show_24_filled (Custom) 16.png"/>
</Button>
<Button Grid.Row="1" Grid.Column="3" Width="20" Height="20"
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).DeleteImageCommand}"
CommandParameter="{Binding .}">
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
</Button>
</Grid>
</Border>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
<Button HorizontalAlignment="Center" VerticalAlignment="Center" IsVisible="{Binding !IsImagesEmpty}"
Command="{Binding AddImageCommand}"
CommandParameter="{Binding #Window}">
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
</Button>
</StackPanel>
</ScrollViewer>
<Button HorizontalAlignment="Center" VerticalAlignment="Center"
IsVisible="{Binding IsImagesEmpty}"
Command="{Binding AddImageCommand}"
CommandParameter="{Binding #Window}">
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
</Button>
<Button Grid.Row="1" Grid.Column="3" Width="20" Height="20"
Command="{Binding DeleteImageCommand}">
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
</Button>
</Grid>
<Button Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" HorizontalAlignment="Center"
IsVisible="{Binding !IsImageSelected}"
Command="{Binding AddImageCommand}"
CommandParameter="{Binding #Window}">
<Image Width="24" Height="24"
Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
</Button>
</Panel>
<TabControl Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="2">
<TabItem Header="Тех. осмотры">
+1 -1
View File
@@ -118,7 +118,7 @@
<Grid Height="54" HorizontalAlignment="Stretch"
ColumnDefinitions="52, 300, *, Auto">
<Image Height="50" Width="50" Margin="0,2,2,2" HorizontalAlignment="Center" Stretch="Uniform"
Source="{Binding Image.FileName, FallbackValue=null}"/>
Source="{Binding Images[0].FileName, FallbackValue=null}"/>
<TextBlock Grid.Column="1" FontSize="20" VerticalAlignment="Center" Margin="4,0,0,0"
Text="{Binding Name}"/>
<TextBlock Grid.Column="2" FontSize="15" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Stretch"
+14 -7
View File
@@ -82,15 +82,22 @@ public partial class EditPointDialog : Window
};
m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
});
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
try
{
var dialog = new ErrorView
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
{
DataContext = m.Error
};
m.Reply(dialog.ShowDialog<ErrorViewModel?>(w));
});
var dialog = new ErrorView
{
DataContext = m.Error
};
m.Reply(dialog.ShowDialog<ErrorViewModel?>(w));
});
}
catch (Exception)
{
// ignored
}
});
// new property
+18 -8
View File
@@ -2,9 +2,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:anim="https://github.com/whistyun/AnimatedImage.Avalonia"
xmlns:vm="using:GazpromApp.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
Width="1436" Height="720"
mc:Ignorable="d" d:DesignWidth="1024" d:DesignHeight="600"
Width="1024" Height="600"
x:Class="GazpromApp.Views.MainWindow"
x:DataType="vm:MainWindowViewModel"
x:Name="Window"
@@ -70,8 +71,11 @@
</Grid.RowDefinitions>
<ScrollViewer Grid.ColumnSpan="3">
<StackPanel Orientation="Vertical">
<ItemsControl ItemsSource="{Binding Points}">
<ItemsControl.ItemTemplate>
<ItemsRepeater ItemsSource="{Binding Points}">
<ItemsRepeater.Layout>
<StackLayout Orientation="Vertical"/>
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate DataType="vm:PointViewModel">
<Border CornerRadius="4" BorderThickness="1" Margin="6"
Background="{DynamicResource BackgroundBrush}"
@@ -84,8 +88,8 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock FontSize="24" Margin="4" VerticalAlignment="Center"
Grid.Column="0"
Text="{Binding Name}"/>
Grid.Column="0"
Text="{Binding Name}"/>
<TextBlock Margin="4" VerticalAlignment="Center"
Grid.Column="1"
Text="{Binding Description}"/>
@@ -104,10 +108,16 @@
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</StackPanel>
</ScrollViewer>
<Image Width="100" Height="100" VerticalAlignment="Center"
IsVisible="{Binding IsLoading}"
HorizontalAlignment="Center"
Grid.Row="0" Grid.Column="0"
Grid.ColumnSpan="3" Grid.RowSpan="2"
anim:ImageBehavior.AnimatedSource="avares://GazpromApp/Assets/loading.gif"/>
</Grid>
</DockPanel>
</Window>
+32 -23
View File
@@ -34,29 +34,38 @@
<TextBox Grid.Column="1" Grid.Row="1" Margin="8"
Text="{Binding Description}"/>
<Grid Grid.Column="1" Grid.Row="2" Margin="2"
ColumnDefinitions="*,20,8,20,8" RowDefinitions="8,20,*"
IsVisible="True">
<Image Stretch="Uniform" Grid.RowSpan="3" Grid.ColumnSpan="3"
Source="{Binding Image.FileName, FallbackValue=null}"/>
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
IsVisible="{Binding IsImageSelected}"
Command="{Binding AddImageCommand}"
CommandParameter="{Binding #Window}">
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom) 16.png"/>
</Button>
<Button Grid.Row="1" Grid.Column="3" Width="20" Height="20"
IsVisible="{Binding IsImageSelected}"
Command="{Binding DeleteImageCommand}">
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
</Button>
</Grid>
<Button Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center"
IsVisible="{Binding !IsImageSelected}"
Command="{Binding AddImageCommand}"
CommandParameter="{Binding #Window}">
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
</Button>
<Panel Grid.Column="1" Grid.Row="2" Margin="8" IsVisible="{Binding !IsImagesEmpty}">
<ScrollViewer>
<StackPanel>
<ItemsRepeater ItemsSource="{Binding Images}" HorizontalAlignment="Center">
<ItemsRepeater.Layout>
<UniformGridLayout Orientation="Horizontal" MaximumRowsOrColumns="1"/>
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate DataType="vm:ImageViewModel">
<Border Margin="4" CornerRadius="4" Background="LightGray">
<Grid Margin="2" Width="200" Height="200" Background="LightGray"
ColumnDefinitions="*,20,8" RowDefinitions="8,20,*">
<Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="3"
Source="{Binding FileName}" />
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
Command="{Binding #Root.((vm:NewEquipmentDialogViewModel)DataContext).DeleteImageCommand}"
CommandParameter="{Binding .}">
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
</Button>
</Grid>
</Border>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
<Button HorizontalAlignment="Center" IsVisible="True"
Command="{Binding AddImageCommand}"
CommandParameter="{Binding #Window}">
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
</Button>
</StackPanel>
</ScrollViewer>
</Panel>
<Button Grid.Column="0" Grid.Row="3" Margin="8" Content="Отменить"
Command="{Binding CancelEnterEquipmentCommand}"