Infered timercontrol and continous update
This commit is contained in:
@ -9,7 +9,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
//
|
||||
namespace RepositoryPattern
|
||||
{
|
||||
public partial class frmMyStocks : Form
|
||||
@ -38,6 +38,10 @@ namespace RepositoryPattern
|
||||
private void ReloadData()
|
||||
{
|
||||
CurrentStocks = _stockMemberRepository.GetStocks();
|
||||
lvMyStocks.Items.Clear();
|
||||
BoughtSum = 0m;
|
||||
TotalDiff = 0m;
|
||||
CurrentSum = 0m;
|
||||
foreach(var stock in CurrentStocks)
|
||||
{
|
||||
stock.ActValue = Stocks[stock.StockId.Trim()].LatestPrice;
|
||||
@ -54,6 +58,12 @@ namespace RepositoryPattern
|
||||
txtTotDiff.Refresh();
|
||||
}
|
||||
|
||||
private void TotalReload()
|
||||
{
|
||||
Stocks = _stockMarketRepository.StockMarketList;
|
||||
ReloadData();
|
||||
}
|
||||
|
||||
private void lvMyStocks_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
|
||||
{
|
||||
using (Brush hBr = new SolidBrush(hdrColor))
|
||||
@ -85,11 +95,11 @@ namespace RepositoryPattern
|
||||
lv.SubItems.Add(owned.ToString());
|
||||
if (diffValue < 0)
|
||||
{
|
||||
lv.BackColor = Color.Red;
|
||||
lv.BackColor = Color.Pink;
|
||||
}
|
||||
else
|
||||
{
|
||||
lv.BackColor = Color.Green;
|
||||
lv.BackColor = Color.LightGreen;
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,5 +107,15 @@ namespace RepositoryPattern
|
||||
{
|
||||
ReloadData();
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
TotalReload();
|
||||
}
|
||||
|
||||
private void chkAutoReload_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
timer1.Enabled = chkAutoReload.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user