|
@@ -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)));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|