-
Notifications
You must be signed in to change notification settings - Fork 0
/
DetailWindow.xaml.cs
176 lines (140 loc) · 4.92 KB
/
DetailWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
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.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WPF.Data;
using WPF.Model;
namespace WPF
{
/// <summary>
/// Interaction logic for DetailWindow.xaml
/// </summary>
public partial class DetailWindow : Window
{
RestAPI restAPI = new RestAPI();
bool isMenu4panelopen = false;
public DetailWindow(ProductModel model, string ProductName, double ProductNewPrice, double ProductPrice, string ProductContext, string ProductImages)
{
Uri uri = new Uri(ProductImages,UriKind.Absolute);
ImageSource imageSource = new BitmapImage(uri);
InitializeComponent();
MyProductName.Content = ProductName;
btnId.DataContext = model;
MyProductNewPrice.Text = ProductNewPrice.ToString() + "TL";
MyProductPrice.Text = ProductPrice.ToString() + "TL";
MyProductContext.Text = ProductContext;
MyImage.Source = imageSource;
urun_aciklamalari.Text = ProductContext;
}
public List<Sepet> Sepet;
private void SepeteEkleButton_Clicked(object sender, EventArgs e)
{
var mydetails = btnId.DataContext as ProductModel;
Sepet sepet = new Sepet()
{
Images = mydetails.ProductImages,
Name = mydetails.ProductName,
Price = mydetails.ProductPrice,
new_Price = mydetails.ProductNewPrice,
Count = 2,
};
//restAPI.PostSepet(sepet);
SetSepet setSepet = new SetSepet();
var deneme = setSepet.GetAllItems();
foreach (var item in deneme)
{
if (item.ProductName == mydetails.ProductName && item.ProductPrice==mydetails.ProductPrice)
{
restAPI.DeleteSepetItem(item.Id);
}
}
restAPI.PostSepet(sepet);
//listsepet.ItemsSource = setSepet.GetAllItems();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
private void menu4_click(object sender, RoutedEventArgs e)
{
//dispatcherTimer.Start();
if (isMenu4panelopen)
{
dockpanel.Height = 0;
if (dockpanel.Height == 0)
{
isMenu4panelopen = false;
}
}
else if (!isMenu4panelopen)
{
dockpanel.Height = 160;
if (dockpanel.Height == 160)
{
isMenu4panelopen = true;
}
}
}
private void ListBoxSampuan_Selected(object sender, RoutedEventArgs e)
{
Sampuan sampuan = new Sampuan();
this.Visibility = Visibility.Hidden;
sampuan.Show();
}
private void sepet_window_open(object sender, RoutedEventArgs e)
{
SepetWindow sepetWindow = new SepetWindow();
this.Visibility = Visibility.Hidden;
sepetWindow.Show();
}
private void temsilci_girisi(object sender, RoutedEventArgs e)
{
TemsilciGirisi temsilciGirisi = new TemsilciGirisi();
temsilciGirisi.Show();
}
private void temsilci_ol(object sender, RoutedEventArgs e)
{
TemsilciOlWindow temsilciOlWindow = new TemsilciOlWindow();
temsilciOlWindow.Show();
}
private int currentElement = 0;
private void Left_Click(object sender, RoutedEventArgs e)
{
if (currentElement < 2)
{
currentElement++;
AnimateCarousel();
}
}
private void Right_Click(object sender, RoutedEventArgs e)
{
if (currentElement > 0)
{
currentElement--;
AnimateCarousel();
}
}
private void AnimateCarousel()
{
SetProducts setProducts = new SetProducts();
Carousel.DataContext = setProducts.GetAllItems();
Storyboard storyboard = (this.Resources["CarouselStoryboard"] as Storyboard);
DoubleAnimation animation = storyboard.Children.First() as DoubleAnimation;
animation.To = -this.Width * currentElement;
storyboard.Begin();
}
}
}