forked from s434786/DINO_SCRUM
Pagination optymalization, infoWindow about fruits, deleted list of themes, focusing keyboard on value input
This commit is contained in:
parent
f16b345bfc
commit
1465eead02
@ -11,10 +11,10 @@ Global
|
|||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Debug|Any CPU.Build.0 = Release|Any CPU
|
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.Build.0 = Debug|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Cyan.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Cyan.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</Application>
|
||||||
|
@ -5,6 +5,7 @@ using System.Data;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
namespace Magazyn
|
namespace Magazyn
|
||||||
{
|
{
|
||||||
@ -13,39 +14,7 @@ namespace Magazyn
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
public void ChangeTheme(int index)
|
|
||||||
{
|
|
||||||
Resources.MergedDictionaries.Clear();
|
|
||||||
Uri[] uris = new Uri[4];
|
|
||||||
|
|
||||||
uris[1] = new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml");
|
|
||||||
|
|
||||||
switch (index % 3) {
|
|
||||||
case 0:
|
|
||||||
uris[0] = new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml");
|
|
||||||
uris[2] = new Uri("pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml");
|
|
||||||
uris[3] = new Uri("pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Cyan.xaml");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
uris[0] = new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml");
|
|
||||||
uris[2] = new Uri("pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Lime.xaml");
|
|
||||||
uris[3] = new Uri("pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Green.xaml");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
uris[0] = new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml");
|
|
||||||
uris[2] = new Uri("pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepOrange.xaml");
|
|
||||||
uris[3] = new Uri("pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Orange.xaml");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = uris[0] });
|
|
||||||
Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = uris[1] });
|
|
||||||
Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = uris[2] });
|
|
||||||
Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = uris[3] });
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
namespace Magazyn.DataModels
|
namespace Magazyn.DataModels
|
||||||
{
|
{
|
||||||
@ -11,10 +12,14 @@ namespace Magazyn.DataModels
|
|||||||
int id;
|
int id;
|
||||||
string name;
|
string name;
|
||||||
int quantity;
|
int quantity;
|
||||||
float price;
|
int quantityMax;
|
||||||
|
float price;
|
||||||
string imageLink;
|
string imageLink;
|
||||||
|
|
||||||
public int Id
|
BitmapImage imageSource;
|
||||||
|
|
||||||
|
|
||||||
|
public int Id
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -38,7 +43,16 @@ namespace Magazyn.DataModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float Price
|
public int QuantityMax
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return quantityMax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public float Price
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -54,13 +68,29 @@ namespace Magazyn.DataModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fruit(int id, string name, int quantity, float price, string imageLink)
|
public BitmapImage ImageSource
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return imageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Fruit(int id, string name, int quantity, int quantityMax, float price, string imageLink)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
this.price = price;
|
this.quantityMax = quantityMax;
|
||||||
|
this.price = price;
|
||||||
this.imageLink = imageLink;
|
this.imageLink = imageLink;
|
||||||
}
|
|
||||||
|
imageSource = new BitmapImage();
|
||||||
|
imageSource.BeginInit();
|
||||||
|
imageSource.UriSource = new Uri(imageLink);
|
||||||
|
imageSource.CacheOption = BitmapCacheOption.OnLoad;
|
||||||
|
imageSource.EndInit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,9 @@
|
|||||||
<Compile Include="Windows\ErrorWindow.xaml.cs">
|
<Compile Include="Windows\ErrorWindow.xaml.cs">
|
||||||
<DependentUpon>ErrorWindow.xaml</DependentUpon>
|
<DependentUpon>ErrorWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Windows\InfoWindow.xaml.cs">
|
||||||
|
<DependentUpon>InfoWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Windows\ValueWindow.xaml.cs">
|
<Compile Include="Windows\ValueWindow.xaml.cs">
|
||||||
<DependentUpon>ValueWindow.xaml</DependentUpon>
|
<DependentUpon>ValueWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -103,6 +106,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Windows\InfoWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Windows\ValueWindow.xaml">
|
<Page Include="Windows\ValueWindow.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
@ -15,24 +15,23 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Magazyn"
|
xmlns:local="clr-namespace:Magazyn"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Magazyn Owoców" Height="500" MaxWidth="590" MinWidth="590" Width="590" SizeChanged="Window_SizeChanged">
|
Title="Magazyn Owoców" MinHeight="259" Height="500" MaxWidth="590" MinWidth="590" Width="590" >
|
||||||
<Grid>
|
<Grid>
|
||||||
<ListBox x:Name="fruitList" Margin="10,51,10,89"/>
|
<ListBox MouseDoubleClick="fruitListMouseDoubleClick" x:Name="fruitList" Margin="10,51,10,89"/>
|
||||||
|
<Button Name="sum" Content="Wartość magazynu" Margin="0,0,10,10" VerticalAlignment="Bottom" Height="35" Click="Value_Click" HorizontalAlignment="Right" Width="163"/>
|
||||||
|
<Label Content="Lista owoców:" FontWeight="Bold" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Width="100"/>
|
||||||
|
<Label Content="Nazwa owocu:" FontWeight="Bold" HorizontalAlignment="Left" Margin="91,25,0,0" VerticalAlignment="Top" Width="100"/>
|
||||||
|
|
||||||
<Button Name="sum" Content="Wartość magazynu" Margin="0,0,10,10" VerticalAlignment="Bottom" Height="35" Click="Value_Click" HorizontalAlignment="Right" Width="163"/>
|
<Label Content="Ilość:" FontWeight="Bold" HorizontalAlignment="Left" Margin="283,25,0,0" VerticalAlignment="Top" Width="46"/>
|
||||||
<Label Content="Lista owoców:" FontWeight="Bold" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Width="100"/>
|
|
||||||
<Label Content="Nazwa owocu:" FontWeight="Bold" HorizontalAlignment="Left" Margin="91,25,0,0" VerticalAlignment="Top" Width="100"/>
|
|
||||||
|
|
||||||
<Label Content="Ilość:" FontWeight="Bold" HorizontalAlignment="Left" Margin="283,25,0,0" VerticalAlignment="Top" Width="46"/>
|
<Label Content="Cena 1szt:" FontWeight="Bold" HorizontalAlignment="Left" Margin="360,25,0,0" VerticalAlignment="Top" Width="73"/>
|
||||||
|
<Label Content="Wartość:" FontWeight="Bold" HorizontalAlignment="Left" Margin="438,25,0,0" VerticalAlignment="Top" Width="65"/>
|
||||||
|
|
||||||
<Label Content="Cena 1szt:" FontWeight="Bold" HorizontalAlignment="Left" Margin="360,25,0,0" VerticalAlignment="Top" Width="73"/>
|
<Button x:Name="prevButton" Content="Poprzednia" HorizontalAlignment="Left" Margin="10,0,0,52" VerticalAlignment="Bottom" Width="105" Click="prevButton_Click"/>
|
||||||
<Label Content="Wartość:" FontWeight="Bold" HorizontalAlignment="Left" Margin="438,25,0,0" VerticalAlignment="Top" Width="65"/>
|
<Button x:Name="nextButton" Content="Następna" HorizontalAlignment="Right" Margin="0,0,10,52" VerticalAlignment="Bottom" Width="105" Click="nextButton_Click"/>
|
||||||
|
<TextBlock x:Name="pageBlock" FontSize="16" Margin="274,0,273,59" TextWrapping="Wrap" Text="NaN" Height="19" VerticalAlignment="Bottom"/>
|
||||||
<Button x:Name="prevButton" Content="Poprzednia" HorizontalAlignment="Left" Margin="10,0,0,52" VerticalAlignment="Bottom" Width="105" Click="prevButton_Click"/>
|
|
||||||
<Button x:Name="nextButton" Content="Następna" HorizontalAlignment="Right" Margin="0,0,10,52" VerticalAlignment="Bottom" Width="105" Click="nextButton_Click"/>
|
|
||||||
<ComboBox SelectionChanged="themeCombo_SelectionChanged" x:Name="themeCombo" HorizontalAlignment="Left" Margin="10,0,0,10" VerticalAlignment="Bottom" Width="162"/>
|
|
||||||
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
||||||
|
@ -23,146 +23,160 @@ using Magazyn.Windows;
|
|||||||
|
|
||||||
namespace Magazyn
|
namespace Magazyn
|
||||||
{
|
{
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
|
||||||
public int size = 4;
|
public int size = 4;
|
||||||
public int page = 0;
|
public int page = 0;
|
||||||
|
|
||||||
bool firstPage;
|
bool firstPage;
|
||||||
bool lastPage;
|
bool lastPage;
|
||||||
|
|
||||||
HttpClient client;
|
HttpClient client;
|
||||||
|
|
||||||
public MainWindow()
|
Size windowSize;
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.Initialized += MainWindow_Initialized;
|
|
||||||
themeCombo.Items.Add("Jasno/Niebieski");
|
|
||||||
themeCombo.Items.Add("Jasno/Zielony");
|
|
||||||
themeCombo.Items.Add("Ciemno/Pomarańczowy");
|
|
||||||
themeCombo.SelectedIndex = 0;
|
|
||||||
|
|
||||||
client = new HttpClient();
|
public MainWindow()
|
||||||
}
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
client = new HttpClient();
|
||||||
|
this.Loaded += MainWindowLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
private void MainWindow_Initialized(object sender, EventArgs e)
|
private void MainWindowLoaded(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
RefreshListOfFruits();
|
RefreshListOfFruits();
|
||||||
}
|
windowSize = new Size(this.Width, this.Height);
|
||||||
|
this.SizeChanged += Window_SizeChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private void FruitViewSaveChangingAmountOfFruits(int amountChanged, Fruit fruit)
|
private void FruitViewSaveChangingAmountOfFruits(int amountChanged, Fruit fruit)
|
||||||
{
|
{
|
||||||
string json = "{\"id\": " + fruit.Id.ToString() + ", \"change\": " + amountChanged.ToString() + " }";
|
string json = "{\"id\": " + fruit.Id.ToString() + ", \"change\": " + amountChanged.ToString() + " }";
|
||||||
|
|
||||||
Task<HttpResponseMessage> response = client.PostAsync("https://sysmag.herokuapp.com/api/product/change-quantity", new StringContent(json, Encoding.UTF8, "application/json"));
|
Task<HttpResponseMessage> response = client.PostAsync("https://sysmag.herokuapp.com/api/product/change-quantity", new StringContent(json, Encoding.UTF8, "application/json"));
|
||||||
while (response.IsCompleted != true) ;
|
while (response.IsCompleted != true) ;
|
||||||
|
|
||||||
if (response.Result.StatusCode == HttpStatusCode.BadRequest)
|
if (response.Result.StatusCode == HttpStatusCode.BadRequest)
|
||||||
{
|
{
|
||||||
JObject data = JObject.Parse(response.Result.Content.ReadAsStringAsync().Result.ToString());
|
JObject data = JObject.Parse(response.Result.Content.ReadAsStringAsync().Result.ToString());
|
||||||
|
|
||||||
ErrorWindow window;
|
ErrorWindow window;
|
||||||
|
|
||||||
if (data["message"].ToString().Contains("Too low"))
|
if (data["message"].ToString().Contains("Too low"))
|
||||||
{
|
{
|
||||||
window = new ErrorWindow("Wystąpił błąd niedomiaru. Próbujesz usunąć więcej owoców niż masz w magazynie.");
|
window = new ErrorWindow("Wystąpił błąd niedomiaru. Próbujesz usunąć więcej owoców niż masz w magazynie.");
|
||||||
}
|
}
|
||||||
else if (data["message"].ToString().Contains("Over max"))
|
else if (data["message"].ToString().Contains("Over max"))
|
||||||
{
|
{
|
||||||
window = new ErrorWindow("Wystąpił błąd nadmiaru. Próbujesz dodać więcej owoców niż pomieści magazyn.");
|
window = new ErrorWindow("Wystąpił błąd nadmiaru. Próbujesz dodać więcej owoców niż pomieści magazyn.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window = new ErrorWindow("Nieznany błąd.");
|
window = new ErrorWindow("Nieznany błąd.");
|
||||||
}
|
}
|
||||||
window.Owner = this;
|
window.Owner = this;
|
||||||
window.ShowDialog();
|
window.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshListOfFruits();
|
RefreshListOfFruits();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshListOfFruits()
|
private void RefreshListOfFruits()
|
||||||
{
|
{
|
||||||
|
pageBlock.Text = page.ToString();
|
||||||
|
|
||||||
Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-all?page=" + page.ToString() + "&size=" + size.ToString());
|
Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-all?page=" + page.ToString() + "&size=" + size.ToString());
|
||||||
while (response.IsCompleted != true) ;
|
while (response.IsCompleted != true) ;
|
||||||
|
|
||||||
if (response.Result.StatusCode != HttpStatusCode.OK)
|
if (response.Result.StatusCode != HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
ErrorWindow window = new ErrorWindow("Nastąpił błąd połączenia z serwerem.");
|
ErrorWindow window = new ErrorWindow("Nastąpił błąd połączenia z serwerem.");
|
||||||
window.Owner = this;
|
window.Owner = this;
|
||||||
window.ShowDialog();
|
window.ShowDialog();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string responseString = response.Result.Content.ReadAsStringAsync().Result;
|
page = 0;
|
||||||
|
size = 0;
|
||||||
|
|
||||||
JObject replay = JObject.Parse(responseString);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
firstPage = bool.Parse(replay["first"].ToString());
|
string responseString = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
lastPage = bool.Parse(replay["last"].ToString());
|
|
||||||
|
|
||||||
Fruit[] fruits = JsonConvert.DeserializeObject<Fruit[]>(replay["content"].ToString());
|
JObject replay = JObject.Parse(responseString);
|
||||||
|
|
||||||
UpdateListOfFruits(fruits);
|
firstPage = bool.Parse(replay["first"].ToString());
|
||||||
}
|
lastPage = bool.Parse(replay["last"].ToString());
|
||||||
|
|
||||||
private void UpdateListOfFruits(Fruit[] list)
|
Fruit[] fruits = JsonConvert.DeserializeObject<Fruit[]>(replay["content"].ToString());
|
||||||
{
|
|
||||||
fruitList.Items.Clear();
|
|
||||||
|
|
||||||
foreach (Fruit item in list)
|
UpdateListOfFruits(fruits);
|
||||||
{
|
}
|
||||||
FruitView fruitView = new FruitView(item);
|
|
||||||
fruitView.SaveChangingAmountOfFruits += FruitViewSaveChangingAmountOfFruits;
|
|
||||||
fruitList.Items.Add(fruitView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private WarehousePrice GetWarehousePrice()
|
private void UpdateListOfFruits(Fruit[] list)
|
||||||
{
|
{
|
||||||
Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-price-of-all");
|
fruitList.Items.Clear();
|
||||||
while (response.IsCompleted != true) ;
|
|
||||||
|
|
||||||
WarehousePrice price = JsonConvert.DeserializeObject<WarehousePrice>(response.Result.Content.ReadAsStringAsync().Result.ToString());
|
foreach (Fruit item in list)
|
||||||
|
{
|
||||||
|
FruitView fruitView = new FruitView(item);
|
||||||
|
fruitView.SaveChangingAmountOfFruits += FruitViewSaveChangingAmountOfFruits;
|
||||||
|
fruitList.Items.Add(fruitView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return price;
|
private WarehousePrice GetWarehousePrice()
|
||||||
}
|
{
|
||||||
|
Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-price-of-all");
|
||||||
|
while (response.IsCompleted != true) ;
|
||||||
|
|
||||||
private void Value_Click(object sender, RoutedEventArgs e)
|
WarehousePrice price = JsonConvert.DeserializeObject<WarehousePrice>(response.Result.Content.ReadAsStringAsync().Result.ToString());
|
||||||
{
|
|
||||||
ValueWindow window = new ValueWindow(GetWarehousePrice().Price);
|
|
||||||
window.Owner = this;
|
|
||||||
window.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void prevButton_Click(object sender, RoutedEventArgs e)
|
return price;
|
||||||
{
|
}
|
||||||
if (firstPage != true) page--;
|
|
||||||
RefreshListOfFruits();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void nextButton_Click(object sender, RoutedEventArgs e)
|
private void Value_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (lastPage != true) page++;
|
ValueWindow window = new ValueWindow(GetWarehousePrice().Price);
|
||||||
RefreshListOfFruits();
|
window.Owner = this;
|
||||||
}
|
window.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
private void prevButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Size size = e.NewSize;
|
if (firstPage != true) page--;
|
||||||
double height = size.Height - 124;
|
RefreshListOfFruits();
|
||||||
this.size = (int)(height / 90);
|
}
|
||||||
RefreshListOfFruits();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void themeCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void nextButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var app = App.Current as App;
|
if (lastPage != true) page++;
|
||||||
app.ChangeTheme(themeCombo.SelectedIndex);
|
RefreshListOfFruits();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||||
|
{
|
||||||
|
Size size = e.NewSize;
|
||||||
|
|
||||||
|
if( Math.Abs(windowSize.Height - size.Height) >= 40 )
|
||||||
|
{
|
||||||
|
//size -> number of elementy by page
|
||||||
|
this.size = (int)((size.Height - 124) / 80);
|
||||||
|
page = 0;
|
||||||
|
windowSize = size;
|
||||||
|
RefreshListOfFruits();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fruitListMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (fruitList.SelectedItem != null)
|
||||||
|
{
|
||||||
|
InfoWindow window = new InfoWindow((fruitList.SelectedItem as FruitView).fruit);
|
||||||
|
window.Owner = this;
|
||||||
|
window.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace Magazyn.Views
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FruitView : UserControl
|
public partial class FruitView : UserControl
|
||||||
{
|
{
|
||||||
Fruit fruit;
|
public Fruit fruit;
|
||||||
|
|
||||||
public delegate void ChangingAmountOfFruits(int amountChanged, Fruit fruit);
|
public delegate void ChangingAmountOfFruits(int amountChanged, Fruit fruit);
|
||||||
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
|
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
|
||||||
@ -42,18 +42,18 @@ namespace Magazyn.Views
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fruitImage.Source = new BitmapImage(new Uri(fruit.ImageLink));
|
fruitImage.Source = fruit.ImageSource;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message);
|
MessageBox.Show(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void subaddButton_Click(object sender, RoutedEventArgs e)
|
private void subaddButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
AmountWindow window = new AmountWindow(fruit, ((sender as Image).Name == "minusImage")?-1:1, fruit.Quantity);
|
AmountWindow window = new AmountWindow(fruit, ((sender as Image).Name == "minusImage")?-1:1, fruit.Quantity);
|
||||||
window.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
|
window.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
|
||||||
window.Owner = Application.Current.MainWindow;
|
window.Owner = Application.Current.MainWindow;
|
||||||
window.ShowDialog();
|
window.ShowDialog();
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Magazyn.Windows"
|
xmlns:local="clr-namespace:Magazyn.Windows"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Magazyn" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown">
|
Title="" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown">
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="10,82,0,0" TextWrapping="Wrap" Text="fruitName" Width="64" Height="16" VerticalAlignment="Top"/>
|
<TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="10,82,0,0" TextWrapping="Wrap" Text="fruitName" Width="64" Height="16" VerticalAlignment="Top"/>
|
||||||
<TextBlock x:Name="messageBox" HorizontalAlignment="Left" Margin="80,10,0,0" TextWrapping="Wrap" Text="messageBox" VerticalAlignment="Top" Width="125" Height="64"/>
|
<TextBlock x:Name="messageBox" HorizontalAlignment="Left" Margin="80,10,0,0" TextWrapping="Wrap" Text="messageBox" VerticalAlignment="Top" Width="125" Height="64"/>
|
||||||
<TextBox x:Name="amountToChange" Margin="0,71,9,0" TextWrapping="Wrap" Text="0" RenderTransformOrigin="1.456,0.316" Height="32" VerticalAlignment="Top" HorizontalAlignment="Right" Width="64"/>
|
<TextBox x:Name="amountToChange" Margin="0,71,9,0" TextWrapping="Wrap" Text="" RenderTransformOrigin="1.456,0.316" Height="32" VerticalAlignment="Top" HorizontalAlignment="Right" Width="64"/>
|
||||||
<Button x:Name="saveButton" Content="Zastosuj" Margin="105,122,0,0" VerticalAlignment="Top" Click="saveButton_Click" Width="90" HorizontalAlignment="Left"/>
|
<Button x:Name="saveButton" Content="Zastosuj" Margin="0,0,9,10" VerticalAlignment="Bottom" Click="saveButton_Click" Width="90" HorizontalAlignment="Right"/>
|
||||||
<Button x:Name="cancelButton" Content="Anuluj" Margin="10,122,0,0" VerticalAlignment="Top" Click="cancelButton_Click" Width="90" HorizontalAlignment="Left" />
|
<Button x:Name="cancelButton" Content="Anuluj" Margin="10,0,0,10" VerticalAlignment="Bottom" Click="cancelButton_Click" Width="90" HorizontalAlignment="Left" />
|
||||||
<Image x:Name="fruitImage" HorizontalAlignment="Left" Height="64" Margin="10,10,0,0" VerticalAlignment="Top" Width="64"/>
|
<Image x:Name="fruitImage" HorizontalAlignment="Left" Height="64" Margin="10,10,0,0" VerticalAlignment="Top" Width="64"/>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -15,85 +15,94 @@ using System.Windows.Shapes;
|
|||||||
|
|
||||||
namespace Magazyn.Windows
|
namespace Magazyn.Windows
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for AmountWindow.xaml
|
/// Interaction logic for AmountWindow.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
///
|
///
|
||||||
|
|
||||||
public partial class AmountWindow : Window
|
public partial class AmountWindow : Window
|
||||||
{
|
{
|
||||||
Fruit fruit;
|
Fruit fruit;
|
||||||
int type;
|
int type;
|
||||||
int quantity;
|
int quantity;
|
||||||
|
|
||||||
public delegate void ChangingAmountOfFruits(int amountChanged);
|
public delegate void ChangingAmountOfFruits(int amountChanged);
|
||||||
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
|
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
|
||||||
|
|
||||||
public AmountWindow(Fruit fruit, int type, int quantity)
|
bool focusLock = false;
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.fruit = fruit;
|
|
||||||
this.type = type;
|
|
||||||
|
|
||||||
this.quantity = quantity;
|
public AmountWindow(Fruit fruit, int type, int quantity)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.fruit = fruit;
|
||||||
|
this.type = type;
|
||||||
|
|
||||||
if (type == -1)
|
this.quantity = quantity;
|
||||||
this.Title = "Zmniejsz ilość: " + fruit.Name;
|
|
||||||
else
|
|
||||||
this.Title = "Zwiększ ilość: " + fruit.Name;
|
|
||||||
|
|
||||||
fruitName.Text = fruit.Name;
|
if (type == -1)
|
||||||
|
this.Title = "Zmniejsz ilość: " + fruit.Name;
|
||||||
|
else
|
||||||
|
this.Title = "Zwiększ ilość: " + fruit.Name;
|
||||||
|
|
||||||
messageBox.Text = String.Format("Jaką ilość produktu chcesz {0} do magazynu?", (type > 0) ? "dodać" : "odjąć");
|
fruitName.Text = fruit.Name;
|
||||||
|
|
||||||
try
|
messageBox.Text = String.Format("Jaką ilość produktu chcesz {0} do magazynu?", (type > 0) ? "dodać" : "odjąć");
|
||||||
{
|
|
||||||
fruitImage.Source = new BitmapImage(new Uri(fruit.ImageLink));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
try
|
||||||
|
{
|
||||||
|
fruitImage.Source = fruit.ImageSource;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
private void SendNewQuantity()
|
this.Loaded += AmountWindowLoaded;
|
||||||
{
|
|
||||||
int amount = int.Parse(amountToChange.Text);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (amount < 0)
|
|
||||||
{
|
|
||||||
ErrorWindow window = new ErrorWindow("Podana wartość jest nieprawidłowa, proszę podać wartość dodatnią.");
|
|
||||||
window.Owner = Application.Current.MainWindow;
|
|
||||||
window.ShowDialog();
|
|
||||||
amountToChange.Text = "0";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException(ex.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
SaveChangingAmountOfFruits.Invoke((type > 0) ? amount : -amount);
|
private void AmountWindowLoaded(object sender, RoutedEventArgs e)
|
||||||
this.Close();
|
{
|
||||||
}
|
amountToChange.Focus();
|
||||||
|
}
|
||||||
|
|
||||||
private void saveButton_Click(object sender, RoutedEventArgs e)
|
private void SendNewQuantity()
|
||||||
{
|
{
|
||||||
SendNewQuantity();
|
int amount = int.Parse(amountToChange.Text);
|
||||||
}
|
try
|
||||||
|
{
|
||||||
|
if (amount < 0)
|
||||||
|
{
|
||||||
|
ErrorWindow window = new ErrorWindow("Podana wartość jest nieprawidłowa, proszę podać wartość dodatnią.");
|
||||||
|
window.Owner = Application.Current.MainWindow;
|
||||||
|
window.ShowDialog();
|
||||||
|
amountToChange.Text = "0";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
private void cancelButton_Click(object sender, RoutedEventArgs e)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
this.Close();
|
{
|
||||||
}
|
throw new NotImplementedException(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
private void Window_KeyDown(object sender, KeyEventArgs e)
|
SaveChangingAmountOfFruits.Invoke((type > 0) ? amount : -amount);
|
||||||
{
|
this.Close();
|
||||||
if (e.Key == Key.Return) SendNewQuantity();
|
}
|
||||||
}
|
|
||||||
}
|
private void saveButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
SendNewQuantity();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Window_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Return) SendNewQuantity();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Magazyn.Windows"
|
xmlns:local="clr-namespace:Magazyn.Windows"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Błąd" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize">
|
Title="Błąd" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Button x:Name="okButton" Content="Ok" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="75" Click="okButton_Click"/>
|
<Button x:Name="okButton" Content="Ok" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="75" Click="okButton_Click"/>
|
||||||
<TextBlock x:Name="messageBlock" FontSize="16" Margin="10,10,10,0" TextWrapping="Wrap" Text="messageBlock" VerticalAlignment="Top"/>
|
<TextBlock x:Name="messageBlock" FontSize="16" Margin="10,10,10,0" TextWrapping="Wrap" Text="messageBlock" VerticalAlignment="Top"/>
|
||||||
|
28
Magazyn_Client/Magazyn/Windows/InfoWindow.xaml
Normal file
28
Magazyn_Client/Magazyn/Windows/InfoWindow.xaml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<Window x:Class="Magazyn.Windows.InfoWindow"
|
||||||
|
|
||||||
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
|
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||||
|
TextElement.FontWeight="Regular"
|
||||||
|
TextElement.FontSize="13"
|
||||||
|
TextOptions.TextFormattingMode="Ideal"
|
||||||
|
TextOptions.TextRenderingMode="Auto"
|
||||||
|
Background="{DynamicResource MaterialDesignPaper}"
|
||||||
|
FontFamily="{DynamicResource MaterialDesignFont}"
|
||||||
|
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:Magazyn.Windows"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Informacje o: " WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize">
|
||||||
|
<Grid>
|
||||||
|
<TextBlock x:Name="fruitName" Margin="79,10,9,0" TextWrapping="Wrap" Text="fruitName" Height="16" VerticalAlignment="Top"/>
|
||||||
|
<TextBlock x:Name="fruitPrice" Margin="79,31,10,0" TextWrapping="Wrap" Text="fruitPrice" Height="16" VerticalAlignment="Top"/>
|
||||||
|
<TextBlock x:Name="fruitQuantity" Margin="79,52,10,0" TextWrapping="Wrap" Text="fruitQuantity" Height="16" VerticalAlignment="Top"/>
|
||||||
|
<TextBlock x:Name="fruitQuantityMax" Margin="79,73,10,0" TextWrapping="Wrap" Text="fruitQuantityMax" Height="16" VerticalAlignment="Top"/>
|
||||||
|
<TextBlock x:Name="fruitValue" Margin="79,94,10,0" TextWrapping="Wrap" Text="fruitValue" Height="16" VerticalAlignment="Top"/>
|
||||||
|
<Button x:Name="okButton" Content="Ok" Margin="0,0,9,10" VerticalAlignment="Bottom" Click="okButton_Click" Width="75" HorizontalAlignment="Right"/>
|
||||||
|
<Image x:Name="fruitImage" HorizontalAlignment="Left" Height="64" Margin="10,10,0,0" VerticalAlignment="Top" Width="64"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
53
Magazyn_Client/Magazyn/Windows/InfoWindow.xaml.cs
Normal file
53
Magazyn_Client/Magazyn/Windows/InfoWindow.xaml.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using Magazyn.DataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
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 Magazyn.Windows
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for InfoWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class InfoWindow : Window
|
||||||
|
{
|
||||||
|
Fruit fruit;
|
||||||
|
public InfoWindow(Fruit fruit)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.fruit = fruit;
|
||||||
|
|
||||||
|
fruitName.Text = "Owoc: " + fruit.Name;
|
||||||
|
this.Title = this.Title + fruit.Name;
|
||||||
|
|
||||||
|
fruitPrice.Text = "Cena: " + fruit.Price.ToString() + "zł";
|
||||||
|
fruitQuantity.Text = "Ilość: " + fruit.Quantity.ToString();
|
||||||
|
fruitQuantityMax.Text = "Ilość maks: " + fruit.QuantityMax.ToString();
|
||||||
|
|
||||||
|
fruitValue.Text = "Wartość: " + (fruit.Price * fruit.Quantity).ToString() + "zł";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fruitImage.Source = fruit.ImageSource;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void okButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user