- 설정 저장
- 체크 이후 색상 변환
This commit is contained in:
186
MarketWatch.cs
186
MarketWatch.cs
@@ -34,8 +34,8 @@ namespace MarketWatchNS
|
||||
public float m_fHighP = 0.0f;
|
||||
}
|
||||
|
||||
ConcurrentQueue<ITEM> m_ItemList = new ConcurrentQueue<ITEM>();
|
||||
System.Timers.Timer m_PriceCheckTimer = new System.Timers.Timer();
|
||||
List<ITEM> m_ItemList = new List<ITEM>();
|
||||
List<PriceCheck> m_PriceCheckList = new List<PriceCheck>();
|
||||
System.Timers.Timer m_SystemTimer = new System.Timers.Timer();
|
||||
|
||||
public MarketWatch()
|
||||
@@ -47,6 +47,8 @@ namespace MarketWatchNS
|
||||
Util.SetLogView(tbLog);
|
||||
Config.Init();
|
||||
|
||||
tbCheckTime.Text = Config.GetCheckTime().ToString();
|
||||
|
||||
m_CybosHelper = new CybosHelper(this);
|
||||
|
||||
var materialSkinManager = MaterialSkinManager.Instance;
|
||||
@@ -54,13 +56,8 @@ namespace MarketWatchNS
|
||||
materialSkinManager.Theme = MaterialSkinManager.Themes.DARK;
|
||||
materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
|
||||
|
||||
m_PriceCheckTimer.Interval = 500;
|
||||
m_PriceCheckTimer.Elapsed += PriceCheckTimer_Elapsed;
|
||||
m_PriceCheckTimer.Start();
|
||||
|
||||
m_SystemTimer.Interval = 100;
|
||||
m_SystemTimer.Elapsed += SystemTimer_Elapsed;
|
||||
;
|
||||
m_SystemTimer.Start();
|
||||
}
|
||||
|
||||
@@ -69,75 +66,25 @@ namespace MarketWatchNS
|
||||
if(lbInfo.InvokeRequired)
|
||||
{
|
||||
lbInfo.Invoke(new Action(() => {
|
||||
lbInfo.Text = string.Format("{0}|{1}",
|
||||
m_CybosHelper.GetLimitRemainCountRQ(),
|
||||
m_CybosHelper.GetLimitRemainCountSB());
|
||||
lbInfo.Text = string.Format("{0} | {1} | {2}",
|
||||
m_CybosHelper.GetLimitRemainCountRQ(),
|
||||
m_CybosHelper.GetLimitRemainCountSB(),
|
||||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
}));
|
||||
|
||||
//lbInfo.Location = new Point(lbInfo.Parent.Width-lbInfo.Width, lbInfo.Top);
|
||||
}
|
||||
else
|
||||
{
|
||||
lbInfo.Text = string.Format("{0}|{1}",
|
||||
m_CybosHelper.GetLimitRemainCountRQ(),
|
||||
m_CybosHelper.GetLimitRemainCountSB());
|
||||
lbInfo.Text = string.Format("{0} | {1}",
|
||||
m_CybosHelper.GetLimitRemainCountRQ(),
|
||||
m_CybosHelper.GetLimitRemainCountSB(),
|
||||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
//lbInfo.Location = new Point(lbInfo.Parent.Width-lbInfo.Width, lbInfo.Top);
|
||||
}
|
||||
}
|
||||
|
||||
private void PriceCheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
foreach(ITEM Item in m_ItemList)
|
||||
{
|
||||
if(Item.m_iHighPrice > 0)
|
||||
continue;
|
||||
|
||||
if((DateTime.Now-Item.m_RecevedTime).Seconds < 20)
|
||||
continue;
|
||||
|
||||
m_CybosHelper.GetLowHighPrice(Item.m_strCode, Item.m_RecevedTime, 5, out Item.m_iLowPrice, out Item.m_iHighPrice);
|
||||
Item.m_fLowP = (Item.m_iLowPrice-Item.m_iStartPrice)*100/(float)Item.m_iStartPrice;
|
||||
Item.m_fHighP = (Item.m_iHighPrice-Item.m_iStartPrice)*100/(float)Item.m_iStartPrice;
|
||||
|
||||
if(Item.m_iHighPrice > 0)
|
||||
{
|
||||
if(lvItems.InvokeRequired)
|
||||
{
|
||||
lvItems.Invoke(new Action(() => {
|
||||
ListViewItem item = lvItems.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chSeq.Index].Text == Item.m_iSeq.ToString());
|
||||
|
||||
item.SubItems[chLowPrice.Index].Text = string.Format("{0:n0}", Item.m_iLowPrice);
|
||||
item.SubItems[chLowP.Index].Text = string.Format("{0:n2}", Item.m_fLowP);
|
||||
if(Item.m_fLowP > 0)
|
||||
item.SubItems[chLowP.Index].ForeColor = Color.Red;
|
||||
else if(Item.m_fLowP < 0)
|
||||
item.SubItems[chLowP.Index].ForeColor = Color.Blue;
|
||||
|
||||
item.SubItems[chHighPrice.Index].Text = string.Format("{0:n0}", Item.m_iHighPrice);
|
||||
item.SubItems[chHighP.Index].Text = string.Format("{0:n2}", Item.m_fHighP);
|
||||
if(Item.m_fHighP > 0)
|
||||
item.SubItems[chHighP.Index].ForeColor = Color.Red;
|
||||
else if(Item.m_fHighP < 0)
|
||||
item.SubItems[chHighP.Index].ForeColor = Color.Blue;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
ListViewItem item = lvItems.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chSeq.Index].Text == Item.m_iSeq.ToString());
|
||||
|
||||
item.SubItems[chLowPrice.Index].Text = string.Format("{0:n0}", Item.m_iLowPrice);
|
||||
item.SubItems[chLowP.Index].Text = string.Format("{0:n2}", Item.m_fLowP);
|
||||
if(Item.m_fLowP > 0)
|
||||
item.SubItems[chLowP.Index].ForeColor = Color.Red;
|
||||
else if(Item.m_fLowP < 0)
|
||||
item.SubItems[chLowP.Index].ForeColor = Color.Blue;
|
||||
|
||||
item.SubItems[chHighPrice.Index].Text = string.Format("{0:n0}", Item.m_iHighPrice);
|
||||
item.SubItems[chHighP.Index].Text = string.Format("{0:n2}", Item.m_fHighP);
|
||||
if(Item.m_fHighP > 0)
|
||||
item.SubItems[chHighP.Index].ForeColor = Color.Red;
|
||||
else if(Item.m_fHighP < 0)
|
||||
item.SubItems[chHighP.Index].ForeColor = Color.Blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_PriceCheckList.RemoveAll(s => s.IsEnd());
|
||||
}
|
||||
|
||||
public void SetAccountList(string[] aAccountList)
|
||||
@@ -165,9 +112,8 @@ namespace MarketWatchNS
|
||||
Item.m_strCodeName = strCodeName;
|
||||
Item.m_iEventCode = iEventCode;
|
||||
Item.m_RecevedTime = DateTime.Now;
|
||||
Item.m_iStartPrice = m_CybosHelper.GetCurPrice(strCode);
|
||||
|
||||
m_ItemList.Enqueue(Item);
|
||||
Item.m_iStartPrice = 0;
|
||||
m_ItemList.Add(Item);
|
||||
|
||||
|
||||
if(lvItems.InvokeRequired)
|
||||
@@ -176,13 +122,13 @@ namespace MarketWatchNS
|
||||
lvItems.Items.Add(new ListViewItem(new string[]
|
||||
{
|
||||
iSeq.ToString(),
|
||||
string.Format("{0}:{1}", iTime/100, iTime%100),
|
||||
DateTime.Now.ToString("hh:MM:ss:fff"),
|
||||
string.Format("{0:00}:{1:00}", iTime/100, iTime%100),
|
||||
DateTime.Now.ToString("hh:mm:ss.fff"),
|
||||
strCode,
|
||||
strCodeName,
|
||||
m_CybosHelper.GetEventCodeStr(iEventCode),
|
||||
string.Format("{0:n0}",
|
||||
Item.m_iStartPrice),
|
||||
""),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
@@ -196,13 +142,13 @@ namespace MarketWatchNS
|
||||
lvItems.Items.Add(new ListViewItem(new string[]
|
||||
{
|
||||
iSeq.ToString(),
|
||||
string.Format("{0}:{1}", iTime/100, iTime%100),
|
||||
DateTime.Now.ToString("hh:MM:ss:fff"),
|
||||
string.Format("{0:00}:{1:00}", iTime/100, iTime%100),
|
||||
DateTime.Now.ToString("hh:mm:ss.fff"),
|
||||
strCode,
|
||||
strCodeName,
|
||||
m_CybosHelper.GetEventCodeStr(iEventCode),
|
||||
string.Format("{0:n0}",
|
||||
Item.m_iStartPrice),
|
||||
""),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
@@ -210,6 +156,80 @@ namespace MarketWatchNS
|
||||
}));
|
||||
lvItems.Items[lvItems.Items.Count-1].UseItemStyleForSubItems = false;
|
||||
}
|
||||
|
||||
m_PriceCheckList.Add(new PriceCheck(iSeq, strCode, strCodeName, this, Config.GetCheckTime()*60));
|
||||
}
|
||||
|
||||
public void OnReceivedStartPrice(int iSeq, int iStartPrice)
|
||||
{
|
||||
var Item = lvItems.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chSeq.Index].Text == iSeq.ToString());
|
||||
if(Item == default(ListViewItem))
|
||||
return;
|
||||
|
||||
if(lvItems.InvokeRequired)
|
||||
{
|
||||
lvItems.Invoke(new Action(() => {
|
||||
Item.SubItems[chStartPrice.Index].Text = string.Format("{0:n0}", iStartPrice);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
Item.SubItems[chStartPrice.Index].Text = string.Format("{0:n0}", iStartPrice);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPriceCheckEnd(int iSeq, int iStartPrice, int iLowPrice, float fLowP, int iHighPrice, float fHighP)
|
||||
{
|
||||
if(lvItems.InvokeRequired)
|
||||
{
|
||||
lvItems.Invoke(new Action(() => {
|
||||
var Item = lvItems.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chSeq.Index].Text == iSeq.ToString());
|
||||
if(Item == default(ListViewItem))
|
||||
return;
|
||||
|
||||
Item.SubItems[chStartPrice.Index].BackColor = Color.FromArgb(255, 245, 245, 245);
|
||||
Item.SubItems[chLowPrice.Index].BackColor = Color.FromArgb(255, 245, 245, 245);
|
||||
Item.SubItems[chLowP.Index].BackColor = Color.FromArgb(255, 245, 245, 245);
|
||||
Item.SubItems[chHighPrice.Index].BackColor = Color.FromArgb(255, 245, 245, 245);
|
||||
Item.SubItems[chHighP.Index].BackColor = Color.FromArgb(255, 245, 245, 245);
|
||||
|
||||
if(iHighPrice > 0)
|
||||
{
|
||||
Item.SubItems[chLowPrice.Index].Text = string.Format("{0:n0}", iLowPrice);
|
||||
Item.SubItems[chLowPrice.Index].ForeColor = (iLowPrice > iStartPrice) ? Color.Red : (iLowPrice < iStartPrice) ? Color.Blue : Color.Black;
|
||||
Item.SubItems[chLowP.Index].Text = string.Format("{0:n2}", fLowP-1.0f);
|
||||
Item.SubItems[chLowP.Index].ForeColor = (fLowP > 1.0f) ? Color.Red : (fLowP < 1.0f) ? Color.Blue : Color.Black;
|
||||
Item.SubItems[chHighPrice.Index].Text = string.Format("{0:n0}", iHighPrice);
|
||||
Item.SubItems[chHighPrice.Index].ForeColor = (iHighPrice > iStartPrice) ? Color.Red : (iHighPrice < iStartPrice) ? Color.Blue : Color.Black;
|
||||
Item.SubItems[chHighP.Index].Text = string.Format("{0:n2}", fHighP-1.0f);
|
||||
Item.SubItems[chHighP.Index].ForeColor = (fHighP > 1.0f) ? Color.Red : (fHighP < 1.0f) ? Color.Blue : Color.Black;
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
var Item = lvItems.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chSeq.Index].Text == iSeq.ToString());
|
||||
if(Item == default(ListViewItem))
|
||||
return;
|
||||
|
||||
Item.SubItems[chStartPrice.Index].BackColor = Color.FromArgb(255, 245, 245, 245);
|
||||
Item.SubItems[chLowPrice.Index].BackColor = Color.FromArgb(255, 245, 245, 245);
|
||||
Item.SubItems[chLowP.Index].BackColor = Color.FromArgb(255, 245, 245, 245);
|
||||
Item.SubItems[chHighPrice.Index].BackColor = Color.FromArgb(255, 245, 245, 245);
|
||||
Item.SubItems[chHighP.Index].BackColor = Color.FromArgb(255, 245, 245, 245);
|
||||
|
||||
if(iHighPrice > 0)
|
||||
{
|
||||
Item.SubItems[chLowPrice.Index].Text = string.Format("{0:n0}", iLowPrice);
|
||||
Item.SubItems[chLowPrice.Index].ForeColor = (iLowPrice > iStartPrice) ? Color.Red : (iLowPrice < iStartPrice) ? Color.Blue : Color.Black;
|
||||
Item.SubItems[chLowP.Index].Text = string.Format("{0:n2}", fLowP-1.0f);
|
||||
Item.SubItems[chLowP.Index].ForeColor = (fLowP > 1.0f) ? Color.Red : (fLowP < 1.0f) ? Color.Blue : Color.Black;
|
||||
Item.SubItems[chHighPrice.Index].Text = string.Format("{0:n0}", iHighPrice);
|
||||
Item.SubItems[chHighPrice.Index].ForeColor = (iHighPrice > iStartPrice) ? Color.Red : (iHighPrice < iStartPrice) ? Color.Blue : Color.Black;
|
||||
Item.SubItems[chHighP.Index].Text = string.Format("{0:n2}", fHighP-1.0f);
|
||||
Item.SubItems[chHighP.Index].ForeColor = (fHighP > 1.0f) ? Color.Red : (fHighP < 1.0f) ? Color.Blue : Color.Black;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void lvItems_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||
@@ -220,6 +240,14 @@ namespace MarketWatchNS
|
||||
lvItems.Sorting = Order;
|
||||
lvItems.Sort();
|
||||
}
|
||||
|
||||
private void btApply_Click(object sender, EventArgs e)
|
||||
{
|
||||
int iCheckTime;
|
||||
bool bParsed = int.TryParse(tbCheckTime.Text, out iCheckTime);
|
||||
if(bParsed == true)
|
||||
Config.SetCheckTime(iCheckTime);
|
||||
}
|
||||
}
|
||||
|
||||
class ListViewItemComparer : IComparer
|
||||
|
||||
Reference in New Issue
Block a user