73 lines
1.8 KiB
C#
73 lines
1.8 KiB
C#
|
using Magazyn.DataModels;
|
|||
|
using Magazyn.Windows;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
using System.Net;
|
|||
|
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.Navigation;
|
|||
|
using System.Windows.Shapes;
|
|||
|
|
|||
|
namespace Magazyn.Views
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Interaction logic for FruitView.xaml
|
|||
|
/// </summary>
|
|||
|
public partial class FruitView : UserControl
|
|||
|
{
|
|||
|
Fruit fruit;
|
|||
|
|
|||
|
public delegate void ChangingAmountOfFruits(int amountChanged, Fruit fruit);
|
|||
|
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
|
|||
|
|
|||
|
public FruitView(Fruit fruit)
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
|
|||
|
this.fruit = fruit;
|
|||
|
|
|||
|
fruitName.Text = fruit.Name;
|
|||
|
fruitAmount.Text = fruit.Quantity.ToString();
|
|||
|
fruitPrice.Text = fruit.Price.ToString();
|
|||
|
allPrice.Text = (fruit.Quantity * fruit.Price).ToString();
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
imges.Source = new BitmapImage(new Uri(fruit.ImageLink));
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void subButton_Click(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
AmountWindow window = new AmountWindow(fruit, -1);
|
|||
|
window.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
|
|||
|
window.Show();
|
|||
|
}
|
|||
|
|
|||
|
private void addButton_Click(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
AmountWindow window = new AmountWindow(fruit, 1);
|
|||
|
window.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
|
|||
|
window.Show();
|
|||
|
}
|
|||
|
|
|||
|
private void WindowSaveChangingAmountOfFruits(int amountChanged)
|
|||
|
{
|
|||
|
SaveChangingAmountOfFruits.Invoke(amountChanged, fruit);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|