Merge branch 'master' of s442333/DINO_SCRUM into master

This commit is contained in:
s1202077 2019-01-24 00:36:10 +00:00 committed by Gogs
commit 9240057242
14 changed files with 395 additions and 256 deletions

View File

@ -11,10 +11,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Debug|Any CPU.Build.0 = Release|Any CPU
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.Build.0 = 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 = Debug|Any CPU
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -5,6 +5,7 @@ using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
namespace Magazyn
{
@ -13,39 +14,7 @@ namespace Magazyn
/// </summary>
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] });
}
}
}

View File

@ -1,8 +1,11 @@
using System;
using Magazyn.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
namespace Magazyn.DataModels
{
@ -11,9 +14,13 @@ namespace Magazyn.DataModels
int id;
string name;
int quantity;
int quantityMax;
float price;
string imageLink;
BitmapImage imageSource;
public int Id
{
get
@ -38,6 +45,15 @@ namespace Magazyn.DataModels
}
}
public int QuantityMax
{
get
{
return quantityMax;
}
}
public float Price
{
get
@ -54,13 +70,26 @@ 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.name = name;
this.quantity = quantity;
this.quantityMax = quantityMax;
this.price = price;
this.imageLink = imageLink;
imageSource = CacheImage.GetImageSource(new Uri(imageLink));
}
}
}

View File

@ -67,6 +67,7 @@
</ApplicationDefinition>
<Compile Include="DataModels\Fruit.cs" />
<Compile Include="DataModels\WarehousePrice.cs" />
<Compile Include="Tools\CacheImage.cs" />
<Compile Include="Views\FruitView.xaml.cs">
<DependentUpon>FruitView.xaml</DependentUpon>
</Compile>
@ -76,6 +77,9 @@
<Compile Include="Windows\ErrorWindow.xaml.cs">
<DependentUpon>ErrorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\InfoWindow.xaml.cs">
<DependentUpon>InfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\ValueWindow.xaml.cs">
<DependentUpon>ValueWindow.xaml</DependentUpon>
</Compile>
@ -103,6 +107,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\InfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\ValueWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -15,10 +15,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Magazyn"
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>
<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"/>
@ -30,7 +29,7 @@
<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"/>
<TextBlock x:Name="pageBlock" FontSize="16" Margin="274,0,273,59" TextWrapping="Wrap" Text="NaN" Height="19" VerticalAlignment="Bottom"/>
</Grid>

View File

@ -20,6 +20,7 @@ using Newtonsoft.Json.Linq;
using System.Net;
using Magazyn.Windows;
using Magazyn.Tools;
namespace Magazyn
{
@ -34,21 +35,20 @@ namespace Magazyn
HttpClient client;
Size windowSize;
public MainWindow()
{
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();
this.Loaded += MainWindowLoaded;
}
private void MainWindow_Initialized(object sender, EventArgs e)
private void MainWindowLoaded(object sender, EventArgs e)
{
RefreshListOfFruits();
windowSize = new Size(this.Width, this.Height);
this.SizeChanged += Window_SizeChanged;
}
private void FruitViewSaveChangingAmountOfFruits(int amountChanged, Fruit fruit)
@ -85,6 +85,7 @@ namespace Magazyn
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());
while (response.IsCompleted != true) ;
@ -94,6 +95,10 @@ namespace Magazyn
ErrorWindow window = new ErrorWindow("Nastąpił błąd połączenia z serwerem.");
window.Owner = this;
window.ShowDialog();
page = 0;
size = 0;
return;
}
@ -153,15 +158,25 @@ namespace Magazyn
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
Size size = e.NewSize;
double height = size.Height - 124;
this.size = (int)(height / 90);
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 themeCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
private void fruitListMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var app = App.Current as App;
app.ChangeTheme(themeCombo.SelectedIndex);
if (fruitList.SelectedItem != null)
{
InfoWindow window = new InfoWindow((fruitList.SelectedItem as FruitView).fruit);
window.Owner = this;
window.ShowDialog();
}
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
namespace Magazyn.Tools
{
class CacheImage
{
static Dictionary<Uri, BitmapImage> dic = new Dictionary<Uri, BitmapImage>();
static public BitmapImage GetImageSource( Uri url )
{
if (dic.Keys.Contains<Uri>(url)) return dic[url];
else
{
BitmapImage imageSource = new BitmapImage();
imageSource.BeginInit();
imageSource.UriSource = url;
imageSource.CacheOption = BitmapCacheOption.OnLoad;
imageSource.EndInit();
dic.Add(url, imageSource);
return imageSource;
}
}
}
}

View File

@ -24,7 +24,7 @@ namespace Magazyn.Views
/// </summary>
public partial class FruitView : UserControl
{
Fruit fruit;
public Fruit fruit;
public delegate void ChangingAmountOfFruits(int amountChanged, Fruit fruit);
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
@ -42,7 +42,7 @@ namespace Magazyn.Views
try
{
fruitImage.Source = new BitmapImage(new Uri(fruit.ImageLink));
fruitImage.Source = fruit.ImageSource;
}
catch (Exception ex)
{

View File

@ -15,14 +15,14 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Magazyn.Windows"
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>
<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"/>
<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"/>
<Button x:Name="saveButton" Content="Zastosuj" Margin="105,122,0,0" VerticalAlignment="Top" Click="saveButton_Click" Width="90" HorizontalAlignment="Left"/>
<Button x:Name="cancelButton" Content="Anuluj" Margin="10,122,0,0" VerticalAlignment="Top" Click="cancelButton_Click" Width="90" HorizontalAlignment="Left" />
<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="0,0,9,10" VerticalAlignment="Bottom" Click="saveButton_Click" Width="90" HorizontalAlignment="Right"/>
<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"/>
</Grid>

View File

@ -29,6 +29,8 @@ namespace Magazyn.Windows
public delegate void ChangingAmountOfFruits(int amountChanged);
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
bool focusLock = false;
public AmountWindow(Fruit fruit, int type, int quantity)
{
InitializeComponent();
@ -48,13 +50,20 @@ namespace Magazyn.Windows
try
{
fruitImage.Source = new BitmapImage(new Uri(fruit.ImageLink));
fruitImage.Source = fruit.ImageSource;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
this.Loaded += AmountWindowLoaded;
}
private void AmountWindowLoaded(object sender, RoutedEventArgs e)
{
amountToChange.Focus();
}
private void SendNewQuantity()

View 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>

View 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();
}
}
}