-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpriceChart.cs
More file actions
118 lines (88 loc) · 4.01 KB
/
priceChart.cs
File metadata and controls
118 lines (88 loc) · 4.01 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Api_test01 {
public partial class priceChart : Form {
Form parent;
public priceChart(string name, int[] 차선호가, int[] 차선잔량,
int 매도최우선호가, int 매도최우선잔량, int 매수최우선호가, int 매수최우선잔량, int[] 호가, int[] 잔량) {
InitializeComponent();
txtName.Text =name;
lstPrice.DrawItem += ListBox_DrawItem;
lstPrice.DrawMode = DrawMode.OwnerDrawVariable;
lstPrice.ItemHeight = lstPrice.Height / 20;
lstVolume.DrawItem += ListBox_DrawItem;
lstVolume.DrawMode = DrawMode.OwnerDrawVariable;
lstVolume.ItemHeight = lstVolume.Height / 20;
this.parent = parent;
this.lstPrice.Items.Clear();
this.lstVolume.Items.Clear();
for (int i = 0; i < 9; i++) {
this.lstPrice.Items.Add(차선호가[i]);
if (i == 4) {
this.lstVolume.Items.Add(차선잔량[i]);
}
else {
this.lstVolume.Items.Add(차선잔량[i]);
}
}
this.lstPrice.Items.Add(매도최우선호가 + " / 매도최우선호가");
this.lstVolume.Items.Add(매도최우선잔량);
this.lstPrice.Items.Add(매수최우선호가 + " / 매수최우선호가");
this.lstVolume.Items.Add(매수최우선잔량);
for (int i = 0; i < 9; i++) {
if (i == 4) {
this.lstPrice.Items.Add(호가[i] + " / " + (2 + i) + "차선");
this.lstVolume.Items.Add(잔량[i]);
}
else {
this.lstPrice.Items.Add(호가[i] + " / " + (2 + i) + "차선");
this.lstVolume.Items.Add(잔량[i]);
}
}
}
public void ListBox_DrawItem(object sender, DrawItemEventArgs e) {
if (sender.Equals(lstPrice)) {
try {
if (e.Index < 10) {
e.Graphics.FillRectangle(Brushes.LightSteelBlue, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
}
else {
e.Graphics.FillRectangle(Brushes.LightPink, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
}
String value = lstPrice.Items[e.Index].ToString();
Brush brush;
if (value[0] == '-') {
brush = Brushes.Blue;
}
else {
brush = Brushes.Red;
}
int x = e.Bounds.X + e.Font.Height / 2;
int y = e.Bounds.Y + e.Font.Height / 2;
e.Graphics.DrawString(value.Replace("-", ""), e.Font, brush, x, y, StringFormat.GenericDefault);
}
catch (Exception exception) {
Console.WriteLine(exception.Message.ToString());
}
}
else if (sender.Equals(lstVolume)) {
try {
string value = lstVolume.Items[e.Index].ToString();
int x = e.Bounds.X + e.Font.Height / 2 + e.Bounds.Width / 2;
int y = e.Bounds.Y + e.Font.Height / 2;
e.Graphics.DrawString(value, e.Font, Brushes.Black, x, y, StringFormat.GenericDefault);
}
catch (Exception exception) {
Console.WriteLine(exception.Message.ToString());
}
}
}
}
}