Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/aleksanderwlodarczyk/tpum i…
Browse files Browse the repository at this point in the history
…nto main
  • Loading branch information
LinearJester committed Apr 11, 2022
2 parents 5fd5007 + af64098 commit d2f845f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Shop1/ShopPresentation/PresentationModel/ModelAbstractApi.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ShopLogic;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Timers;

namespace TP.ConcurrentProgramming.PresentationModel
{
Expand All @@ -12,6 +13,7 @@ public abstract class ModelAbstractApi
public abstract string BasketViewVisibility { get; }
public abstract WarehousePresentation WarehousePresentation { get; }
public abstract Basket Basket { get; }
public abstract Timer Timer { get; }

public static ModelAbstractApi CreateApi()
{
Expand Down Expand Up @@ -42,6 +44,8 @@ public ModelApi(LogicLayer logicLayer)

public override WarehousePresentation WarehousePresentation => new WarehousePresentation(logicLayer.Shop);

public override Timer Timer => new Timer();

private LogicLayer logicLayer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using ShopLogic;
using Microsoft.Toolkit.Mvvm;
using GalaSoft.MvvmLight.Command;
using System.Timers;

namespace TP.ConcurrentProgramming.PresentationViewModel
{
Expand All @@ -34,6 +35,7 @@ public MainWindowViewModel(ModelAbstractApi modelAbstractApi)
Fruits.Add(fruit);
}
basket = ModelLayer.Basket;
timer = ModelLayer.Timer;
ButtomClick = new GalaSoft.MvvmLight.Command.RelayCommand(() => ClickHandler());
BasketButtonClick = new GalaSoft.MvvmLight.Command.RelayCommand(() => BasketButtonClickHandler());
MainPageButtonClick = new GalaSoft.MvvmLight.Command.RelayCommand(() => MainPagetButtonClickHandler());
Expand All @@ -45,6 +47,22 @@ public MainWindowViewModel(ModelAbstractApi modelAbstractApi)
BuyButtonClick = new GalaSoft.MvvmLight.Command.RelayCommand(() => BuyButtonClickHandler());

FruitButtonClick = new RelayCommand<Guid>((id) => FruitButtonClickHandler(id));
timer.Interval = 2;
timer.Elapsed += Timer_Elapsed;
}

~MainWindowViewModel()
{
timer.Elapsed -= Timer_Elapsed;
}

private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
Fruits.Clear();
foreach (FruitDTO fruit in ModelLayer.WarehousePresentation.GetFruits())
{
Fruits.Add(fruit);
}
}

public string ColorString
Expand Down Expand Up @@ -267,6 +285,7 @@ private void MainPagetButtonClickHandler()
private Basket basket;
private float basketSum;
private ObservableCollection<FruitDTO> fruits;
private Timer timer;
private int b_Radious;
private string b_colorString;
private string b_mainViewVisibility;
Expand Down

0 comments on commit d2f845f

Please sign in to comment.