123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace SneakersSkakunov
- {
- /// <summary>
- /// Логика взаимодействия для RedactPhotoUser.xaml
- /// </summary>
- public partial class RedactPhotoUser : Window
- {
- public RedactPhotoUser()
- {
- InitializeComponent();
- }
- Sniker snk = new Sniker();
- Users user = new Users();
- List<PhotoUsers> Phs = new List<PhotoUsers>();
- int n = 0;
- int id;
- public RedactPhotoUser(int UsId)
- {
- InitializeComponent();
- user = snk.Users.Where(x => x.id_Users == UsId).FirstOrDefault();
- Phs = snk.PhotoUsers.Where(x => x.id_Users == UsId).ToList();
- byte[] bt = Phs[n].PhotoUser;
- ShowImage(bt, foto);
- id = user.id_Users;
- }
- private void BackPhoto(object sender, RoutedEventArgs e)
- {
- try
- {
- n--;
- byte[] bt = Phs[n].PhotoUser;
- ShowImage(bt, foto);
- }
- catch (ArgumentOutOfRangeException)
- {
- n = Phs.Count - 1;
- byte[] bt = Phs[n].PhotoUser;
- ShowImage(bt, foto);
- }
- }
- private void NextPhoto(object sender, RoutedEventArgs e)
- {
- try
- {
- n++;
- byte[] bt = Phs[n].PhotoUser;
- ShowImage(bt, foto);
- }
- catch (ArgumentOutOfRangeException)
- {
- n = 0;
- byte[] bt = Phs[n].PhotoUser;
- ShowImage(bt, foto);
- }
- }
- private void SelectThis(object sender, RoutedEventArgs e)
- {
- user.id_photouser = Phs[n].id_photouser;
- snk.SaveChanges();
- MessageBox.Show("Фото обновлено");
- MainFrame.mframe.Navigate(new UserPage(user.id_Users));
- }
- private void Back(object sender, RoutedEventArgs e)
- {
- this.Close();
- }
- void ShowImage(byte[] arr, System.Windows.Controls.Image img)
- {
- BitmapImage BI = new BitmapImage();
- BI.BeginInit();
- BI.StreamSource = new MemoryStream(arr);
- BI.EndInit();
- img.Source = BI;
- }
- }
- }
|