From e058f5cef9b39ae5af6048e58c9b3db9919169a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Pierzy=C5=84ski?= Date: Sun, 13 Jan 2019 16:36:26 +0100 Subject: [PATCH 1/6] Added project in C# wpf with some logic --- Magazyn_Client/.gitignore | 341 ++++++++++++++++++ Magazyn_Client/Magazyn.sln | 25 ++ Magazyn_Client/Magazyn/App.config | 6 + Magazyn_Client/Magazyn/App.xaml | 9 + Magazyn_Client/Magazyn/App.xaml.cs | 17 + Magazyn_Client/Magazyn/DataModels/Fruit.cs | 66 ++++ Magazyn_Client/Magazyn/Images/add.png | Bin 0 -> 215 bytes Magazyn_Client/Magazyn/Images/sub.png | Bin 0 -> 197 bytes Magazyn_Client/Magazyn/Magazyn.csproj | 120 ++++++ Magazyn_Client/Magazyn/MainWindow.xaml | 15 + Magazyn_Client/Magazyn/MainWindow.xaml.cs | 85 +++++ .../Magazyn/Properties/AssemblyInfo.cs | 55 +++ .../Magazyn/Properties/Resources.Designer.cs | 71 ++++ .../Magazyn/Properties/Resources.resx | 117 ++++++ .../Magazyn/Properties/Settings.Designer.cs | 30 ++ .../Magazyn/Properties/Settings.settings | 7 + Magazyn_Client/Magazyn/Views/FruitView.xaml | 23 ++ .../Magazyn/Views/FruitView.xaml.cs | 72 ++++ .../Magazyn/Windows/AmountWindow.xaml | 15 + .../Magazyn/Windows/AmountWindow.xaml.cs | 53 +++ Magazyn_Client/Magazyn/packages.config | 4 + 21 files changed, 1131 insertions(+) create mode 100644 Magazyn_Client/.gitignore create mode 100644 Magazyn_Client/Magazyn.sln create mode 100644 Magazyn_Client/Magazyn/App.config create mode 100644 Magazyn_Client/Magazyn/App.xaml create mode 100644 Magazyn_Client/Magazyn/App.xaml.cs create mode 100644 Magazyn_Client/Magazyn/DataModels/Fruit.cs create mode 100644 Magazyn_Client/Magazyn/Images/add.png create mode 100644 Magazyn_Client/Magazyn/Images/sub.png create mode 100644 Magazyn_Client/Magazyn/Magazyn.csproj create mode 100644 Magazyn_Client/Magazyn/MainWindow.xaml create mode 100644 Magazyn_Client/Magazyn/MainWindow.xaml.cs create mode 100644 Magazyn_Client/Magazyn/Properties/AssemblyInfo.cs create mode 100644 Magazyn_Client/Magazyn/Properties/Resources.Designer.cs create mode 100644 Magazyn_Client/Magazyn/Properties/Resources.resx create mode 100644 Magazyn_Client/Magazyn/Properties/Settings.Designer.cs create mode 100644 Magazyn_Client/Magazyn/Properties/Settings.settings create mode 100644 Magazyn_Client/Magazyn/Views/FruitView.xaml create mode 100644 Magazyn_Client/Magazyn/Views/FruitView.xaml.cs create mode 100644 Magazyn_Client/Magazyn/Windows/AmountWindow.xaml create mode 100644 Magazyn_Client/Magazyn/Windows/AmountWindow.xaml.cs create mode 100644 Magazyn_Client/Magazyn/packages.config diff --git a/Magazyn_Client/.gitignore b/Magazyn_Client/.gitignore new file mode 100644 index 0000000..84c9832 --- /dev/null +++ b/Magazyn_Client/.gitignore @@ -0,0 +1,341 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ +# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true +**/wwwroot/lib/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb \ No newline at end of file diff --git a/Magazyn_Client/Magazyn.sln b/Magazyn_Client/Magazyn.sln new file mode 100644 index 0000000..741d861 --- /dev/null +++ b/Magazyn_Client/Magazyn.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.15 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Magazyn", "Magazyn\Magazyn.csproj", "{C50EC6F3-86E6-405C-991F-1B4157C04B34}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {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 = Release|Any CPU + {C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BD938214-689F-4C4B-846E-9D7E3A4CD156} + EndGlobalSection +EndGlobal diff --git a/Magazyn_Client/Magazyn/App.config b/Magazyn_Client/Magazyn/App.config new file mode 100644 index 0000000..00bfd11 --- /dev/null +++ b/Magazyn_Client/Magazyn/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Magazyn_Client/Magazyn/App.xaml b/Magazyn_Client/Magazyn/App.xaml new file mode 100644 index 0000000..4ce9918 --- /dev/null +++ b/Magazyn_Client/Magazyn/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Magazyn_Client/Magazyn/App.xaml.cs b/Magazyn_Client/Magazyn/App.xaml.cs new file mode 100644 index 0000000..4461381 --- /dev/null +++ b/Magazyn_Client/Magazyn/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Magazyn +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Magazyn_Client/Magazyn/DataModels/Fruit.cs b/Magazyn_Client/Magazyn/DataModels/Fruit.cs new file mode 100644 index 0000000..6c97d6a --- /dev/null +++ b/Magazyn_Client/Magazyn/DataModels/Fruit.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Magazyn.DataModels +{ + public class Fruit + { + int id; + string name; + int quantity; + float price; + string imageLink; + + public int Id + { + get + { + return id; + } + } + + public string Name + { + get + { + return name; + } + } + + public int Quantity + { + get + { + return quantity; + } + } + + public float Price + { + get + { + return price; + } + } + + public string ImageLink + { + get + { + return imageLink; + } + } + + public Fruit(int id, string name, int quantity, float price, string imageLink) + { + this.id = id; + this.name = name; + this.quantity = quantity; + this.price = price; + this.imageLink = imageLink; + } + } +} diff --git a/Magazyn_Client/Magazyn/Images/add.png b/Magazyn_Client/Magazyn/Images/add.png new file mode 100644 index 0000000000000000000000000000000000000000..eb457bc6cee334c177ed94b6ecce1e0104df4e77 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kmUKs7M+SzC{oH>NS%G}c0*}aI z1_r)EAj~ML;ne^Xlq_+LC<)F_D=AMbN@XZW%*-p%%S$a$Fwry6Gc-5Oo1Y9+6yoXP z7@`rpwQnP*gCY-W?2%{ZA8!&{_vLy;k&{A}j*gC>$DU>tPw9Bwrc(afOdJ1J3bK`j=QYNKKJ*Z{qn5d&!%23rl!Rn2v1<-s3Pgg&ebxsLQ E0BN&9asU7T literal 0 HcmV?d00001 diff --git a/Magazyn_Client/Magazyn/Images/sub.png b/Magazyn_Client/Magazyn/Images/sub.png new file mode 100644 index 0000000000000000000000000000000000000000..aab09d51f5384a49e5e275fd222b3933438f695e GIT binary patch literal 197 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kmUKs7M+SzC{oH>NS%G}c0*}aI z1_r)EAj~ML;ne^Xlq_+LC<)F_D=AMbN@XZW%*-p%%S$a$Fwry6Gc-5Oo1Y9+ + + + + Debug + AnyCPU + {C50EC6F3-86E6-405C-991F-1B4157C04B34} + WinExe + Magazyn + Magazyn + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + FruitView.xaml + + + AmountWindow.xaml + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + \ No newline at end of file diff --git a/Magazyn_Client/Magazyn/MainWindow.xaml b/Magazyn_Client/Magazyn/MainWindow.xaml new file mode 100644 index 0000000..764fe25 --- /dev/null +++ b/Magazyn_Client/Magazyn/MainWindow.xaml @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/Magazyn_Client/Magazyn/Views/FruitView.xaml.cs b/Magazyn_Client/Magazyn/Views/FruitView.xaml.cs new file mode 100644 index 0000000..2c25e01 --- /dev/null +++ b/Magazyn_Client/Magazyn/Views/FruitView.xaml.cs @@ -0,0 +1,72 @@ +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 +{ + /// + /// Interaction logic for FruitView.xaml + /// + 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); + } + } +} diff --git a/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml b/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml new file mode 100644 index 0000000..c2617e5 --- /dev/null +++ b/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml @@ -0,0 +1,15 @@ + + + + + - + diff --git a/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml b/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml index c2617e5..ea7b7ef 100644 --- a/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml +++ b/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml @@ -5,10 +5,10 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Magazyn.Windows" mc:Ignorable="d" - Title="Change Amount Window" Height="100" Width="300"> + Title="Change Quantity" Height="100" Width="300"> - +