-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainForm.cs
145 lines (124 loc) · 3.8 KB
/
MainForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Forward_Calculator {
public partial class MainForm : Form {
public int days;
public StockInformation stock {
get { return _stock; }
set { _stock = value;}
}
private StockInformation _stock; //stores stock information
private InterestRegion[] regions; //stores interest region information
public static MainForm Instance;
public int divNumber;
//number that stores where the stock lies in the list
//get and set allows other classes to access
private int _index;
public int index {
get { return _index;}
set {
_index = value;
UpdateViewer();
UpdateForward();
}
}
//value for length of forward in days
private int _timePeriod;
public int timePeriod {
get { return _timePeriod; }
set {
_timePeriod = value;
UpdateForward();}
}
//current region
public InterestRegion interestRegion;
//dividends
private float[] _dividendPrediction;
public float[] dividendPrediction {
get {return _dividendPrediction; }
set {
_dividendPrediction = value;
//UpdateForward();
}
}
public MainForm() {
InitializeComponent();
Init();
}
void Init() {
Instance = this;
this.BackColor = Colours.background;
regions = FileHandling.LoadRegions(); //loading regions
interestRegion = regions[0];
}
//redundant functions when I overhauled gui but kept incase code was useful somewhere else
private void UpdateViewer() {
// online = connection_Viewer.TestConnection();
// stock_Viewer.UpdateLabels(stocks[index]);
// this.Refresh();
// if(online) stock_Viewer.UpdateChart(HtmlHandling.GetChartAddress(stocks[index].name));
//
}
private void UpdateForward() {
// InterestRegion region = new InterestRegion();
// foreach(InterestRegion _reg in regions)
// if(_reg.name == regionName)
// region = _reg;
// float[] _prices = Calculation.GetForwardPrices(stocks[index], dividends, timePeriod, region);
// for(int i = 0; i < _prices.Length; i++)
// _prices[i] = (float)Math.Round(_prices[i], 2);
// calculator_Forward.UpdateForward(_prices);
}
///click event for pictures, opening interfaces
void OptionSelected(object sender, EventArgs e) {
switch((sender as PictureBox).Name) {
case "picb_SelectStock": {
switch(MessageBox.Show("Open Existing Stock?","StockViewer", MessageBoxButtons.YesNoCancel)) {
case DialogResult.Yes: {
StockViewer _stockViewer = new StockViewer(false, "");
break;
}
case DialogResult.No: {
StockViewer _stockViewer = new StockViewer(true, "");
break;
}
case DialogResult.Cancel : break;
}
break;
}
case "picb_DividendForecast": {
DividendForecaster _dividendForecaster = new DividendForecaster();
break;
}
case "picb_CalculateForward": {
if(dividendPrediction == null || stock == null) {
MessageBox.Show("Choose a stock and enter dividends before calculating price");
return;
}
ForwardCalculator _forwardCalculator = new ForwardCalculator();
_forwardCalculator.Show();
break;
}
}
}
public void UpdateStock() {
picb_SelectStock.Image = new Bitmap(Image.FromFile("TEMPstock.png"));
}
public void UpdateStock(int i) {
picb_SelectStock.Image = new Bitmap(100,100);
}
public void UpdateDividend() {
picb_DividendForecast.Image = new Bitmap(Image.FromFile("TEMPdividend.png"));
}
public void UpdateDividend(Bitmap _img) {
picb_DividendForecast.Image = new Bitmap(100,100);
picb_DividendForecast.Image = new Bitmap(_img);
this.Refresh();
}
void UpDn_DaysValueChanged(object sender, EventArgs e) {
days = (int)upDn_Days.Value;
}
}
}