Бобарикке 1 hónapja
szülő
commit
f42813a947

+ 13 - 0
AvaloniaApplication1/ViewModels/MainPageViewModel.cs

@@ -1,9 +1,11 @@
 using Avalonia.Controls;
+using Avalonia.Media.Imaging;
 using AvaloniaApplication1.Models;
 using AvaloniaApplication1.Views;
 using Microsoft.EntityFrameworkCore;
 using ReactiveUI;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Reactive;
 using System.Reactive.Linq;
@@ -18,9 +20,11 @@ namespace AvaloniaApplication1.ViewModels
         List<Gender> genders;
         Gender selectedGender;
         int id;
+        List<Bitmap> images;
         public MainPageViewModel()
         {
             this.smesharikiMain = myConnection.Smesharikis.Include(x => x.GenderNavigation).ToList();
+            ImageSmesh();
             this.smeshariki = this.smesharikiMain;
             genders =
             [
@@ -37,6 +41,7 @@ namespace AvaloniaApplication1.ViewModels
         public List<Gender> Genders { get => genders; set => this.RaiseAndSetIfChanged(ref genders,value); }
         public Gender SelectedGender { get => selectedGender; set { selectedGender = value; AllFilters(); } }
         public List<Smeshariki> Smeshariki { get => smeshariki; set => this.RaiseAndSetIfChanged(ref smeshariki, value); }
+        public List<Bitmap> Images { get => images; set => this.RaiseAndSetIfChanged(ref images, value); }
         public List<Smeshariki> SmesharikiMain { get => smesharikiMain; set => this.RaiseAndSetIfChanged(ref smesharikiMain, value); }
         public void ProfileUser()
         {
@@ -75,6 +80,14 @@ namespace AvaloniaApplication1.ViewModels
             if(!string.IsNullOrEmpty(Search)) Smeshariki = Smeshariki.Where(x => x.Name.ToLower().Contains(Search.ToLower())).ToList();
             if (selectedGender != null && selectedGender.Id != 0) { Smeshariki = Smeshariki.Where(x => x.GenderNavigation == selectedGender).ToList(); }
         }
+        public void ImageSmesh()
+        {
+            foreach (var item in SmesharikiMain)
+            {
+                Images.Add(new Bitmap(new MemoryStream(item.Image)));
+            }
+
+        }
 
 
 

+ 12 - 3
AvaloniaApplication1/Views/MainPage.axaml

@@ -8,9 +8,9 @@
 			 x:DataType="vm:MainPageViewModel">
 
 		<Grid RowDefinitions="50,*,50" ColumnDefinitions="200,*" >
-			<TextBlock Text="Шарарам" Grid.ColumnSpan="2" HorizontalAlignment="Center"	VerticalAlignment="Center" Foreground="Yellow" FontSize="30" FontWeight="Black"></TextBlock>
+			<TextBlock Text="Шарарам" Grid.ColumnSpan="" HorizontalAlignment="Center"	VerticalAlignment="Center" Foreground="Yellow" FontSize="30" FontWeight="Black"></TextBlock>
 			<TextBlock Text="Персонажи"  HorizontalAlignment="Center"  FontSize="30"> </TextBlock>
-			<Grid RowDefinitions="50,*" Grid.Column="1" Grid.Row="1">
+			<Grid RowDefinitions="50,*" ColumnDefinitions="600,*" Grid.Column="1" Grid.Row="1">
 				<StackPanel Orientation="Horizontal">
 					<TextBox Text="{Binding Search}" Width="200" Watermark="Введите имя: "></TextBox>
 					<ComboBox ItemsSource="{Binding Genders}" SelectedItem="{Binding SelectedGender}">
@@ -25,7 +25,7 @@
 						<RadioButton Content="По убыванию" Command="{Binding OrderByAge}" CommandParameter="2"></RadioButton>
 					</StackPanel>
 				</StackPanel>
-				<ListBox ItemsSource="{Binding Smeshariki}" Grid.Row="1">
+				<ListBox ItemsSource="{Binding Smeshariki}" Grid.Row="1" >
 					<ListBox.ItemTemplate>
 						<DataTemplate>
 							<StackPanel>
@@ -39,6 +39,15 @@
 						</DataTemplate>
 					</ListBox.ItemTemplate>
 				</ListBox>
+				<ListBox ItemsSource="{Binding Images}" Grid.Row="1" Grid.Column="1">
+					<ListBox.ItemTemplate>
+						<DataTemplate>
+							<StackPanel>
+								<Image Source=""/>
+							</StackPanel>
+						</DataTemplate>
+					</ListBox.ItemTemplate>
+				</ListBox>
 			</Grid>
 		</Grid>
 </UserControl>

+ 9 - 5
AvaloniaApplication1/Views/UsersMainPage.axaml

@@ -31,11 +31,15 @@
 			<ListBox ItemsSource="{Binding Smeshariki}" Grid.Row="1">
 				<ListBox.ItemTemplate>
 					<DataTemplate>
-						<StackPanel>
-							<TextBlock Text="{Binding Name, StringFormat= Имя: {0}}"></TextBlock>
-							<TextBlock Text="{Binding Animal, StringFormat= Животное: {0}}"></TextBlock>
-							<TextBlock Text="{Binding Age, StringFormat= Возраст: {0}}"></TextBlock>
-							<TextBlock Text="{Binding GenderNavigation.Title, StringFormat= Пол: {0}}"></TextBlock>
+						<StackPanel Orientation="Horizontal">
+							<Image Source="{Binding Image}" Width="100" Height="100"/>
+							<StackPanel>
+								<TextBlock Text="{Binding Name, StringFormat= Имя: {0}}"></TextBlock>
+								<TextBlock Text="{Binding Animal, StringFormat= Животное: {0}}"></TextBlock>
+								<TextBlock Text="{Binding Age, StringFormat= Возраст: {0}}"></TextBlock>
+								<TextBlock Text="{Binding GenderNavigation.Title, StringFormat= Пол: {0}}"></TextBlock>
+
+							</StackPanel>
 						</StackPanel>
 					</DataTemplate>
 				</ListBox.ItemTemplate>