first commit

This commit is contained in:
2017-02-02 11:47:45 +09:00
commit 93e1b71a6e
22 changed files with 3452 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
bin/
obj/
.vs/
configure/
log/
publish/
*.user

6
App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

107
Config.cs Normal file
View File

@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace MarketWatchNS
{
static class Config
{
static Dictionary<string, object> m_Data = new Dictionary<string, object>();
static Random m_Random = new Random();
public static void Init()
{
m_Data.Add("account", "");
m_Data.Add("sub-account", "");
m_Data.Add("bid-count", 5);
m_Data.Add("trailing-rate", 1.0f);
m_Data.Add("trailing-count", 2);
Load();
}
static void Load()
{
string strPath = Util.GetConfigPath()+"/config.ini";
if(File.Exists(strPath) == false)
return;
string[] aLines = File.ReadAllLines(strPath);
foreach(string strLine in aLines)
{
if(strLine.Trim().Length <= 0)
continue;
string[] aTokens = strLine.Trim().Split('=');
if(aTokens.Length < 2)
continue;
if(m_Data.ContainsKey(aTokens[0]) == true)
m_Data[aTokens[0]] = Convert.ChangeType(aTokens[1], m_Data[aTokens[0]].GetType());
else
m_Data.Add(aTokens[0], aTokens[1]);
}
}
static void Save()
{
string strContents = "";
foreach(KeyValuePair<string, object> pair in m_Data)
strContents += pair.Key + "=" + pair.Value.ToString() + Environment.NewLine;
string strPath = Util.GetConfigPath()+"/config.ini";
File.WriteAllText(strPath, strContents, new UTF8Encoding(true));
}
public static void SetAccount(string strAccount, string strAccountSub)
{
if(strAccount != null)
m_Data["account"] = strAccount;
m_Data["sub-account"] = strAccountSub;
Save();
}
public static string GetAccount()
{
return (string)m_Data["account"];
}
public static string GetSubAccount()
{
return (string)m_Data["sub-account"];
}
public static void SetBidCount(int iCount)
{
m_Data["bid-count"] = iCount;
Save();
}
public static int GetBidCount()
{
return (int)m_Data["bid-count"];
}
public static void SetTrailing(float fTrailingRate, int iTrailingCnt)
{
m_Data["trailing-rate"] = fTrailingRate;
m_Data["trailing-count"] = iTrailingCnt;
Save();
}
public static float GetTrailingRate()
{
return (float)m_Data["trailing-rate"];
}
public static int GetTrailingCnt()
{
return (int)m_Data["trailing-count"];
}
}
}

219
CybosHelper.cs Normal file
View File

@@ -0,0 +1,219 @@
using CPSYSDIBLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace MarketWatchNS
{
class CybosHelper
{
MarketWatch m_Listener = null;
CPUTILLib.CpCybos m_CPCybos = new CPUTILLib.CpCybos();
CPFORETRADELib.CpForeTdUtil m_CPUtil = new CPFORETRADELib.CpForeTdUtil();
CpMarketWatchS m_MarketWatch = null;
DSCBO1Lib.StockMst m_CPStockMst = new DSCBO1Lib.StockMst();
object m_StockMstLock = new object();
CPSYSDIBLib.StockChart m_StockChart = new CPSYSDIBLib.StockChart();
object m_StockChartLock = new object();
Dictionary<int, string> m_EventCodeStr = new Dictionary<int, string>();
public CybosHelper(MarketWatch Listener)
{
m_Listener = Listener;
m_EventCodeStr.Add(10, "외국계 증권사 창구 첫 매수");
m_EventCodeStr.Add(11, "외국계 증권사 창구 첫 매도");
m_EventCodeStr.Add(12, "외국인 순매수");
m_EventCodeStr.Add(13, "외국인 순매도");
m_EventCodeStr.Add(21, "전일 거래량 갱신");
m_EventCodeStr.Add(22, "최근5일 거래량최고 갱신");
m_EventCodeStr.Add(23, "최근5일 매물대 돌파");
m_EventCodeStr.Add(24, "최근60일 매물대 돌파");
m_EventCodeStr.Add(28, "최근5일 첫 상한가");
m_EventCodeStr.Add(29, "최근5일 신고가 갱신");
m_EventCodeStr.Add(30, "최근5일 신저가 갱신");
m_EventCodeStr.Add(31, "상한가 직전");
m_EventCodeStr.Add(32, "하한가 직전");
m_EventCodeStr.Add(41, "주가 5MA 상향 돌파");
m_EventCodeStr.Add(42, "주가 5MA 하향 돌파");
m_EventCodeStr.Add(43, "거래량 5MA 상향 돌파");
m_EventCodeStr.Add(44, "주가 데드크로스(5MA < 20MA)");
m_EventCodeStr.Add(45, "주가 골든크로스(5MA > 20MA)");
m_EventCodeStr.Add(46, "MACD 매수-Signal(9) 상향돌파");
m_EventCodeStr.Add(47, "MACD 매도-Signal(9) 하향돌파");
m_EventCodeStr.Add(48, "CCI 매수-기준선(-100) 상향돌파");
m_EventCodeStr.Add(49, "CCI 매도-기준선(100) 하향돌파");
m_EventCodeStr.Add(50, "Stochastic(10, 5, 5)매수- 기준선 상향돌파");
m_EventCodeStr.Add(51, "Stochastic(10, 5, 5)매도- 기준선 하향돌파");
m_EventCodeStr.Add(52, "Stochastic(10, 5, 5)매수- %K%D 교차");
m_EventCodeStr.Add(53, "Stochastic(10, 5, 5)매도- %K%D 교차");
m_EventCodeStr.Add(54, "Sonar 매수-Signal(9) 상향돌파");
m_EventCodeStr.Add(55, "Sonar 매도-Signal(9) 하향돌파");
m_EventCodeStr.Add(56, "Momentum 매수-기준선(100) 상향돌파");
m_EventCodeStr.Add(57, "Momentum 매도-기준선(100) 하향돌파");
m_EventCodeStr.Add(58, "RSI(14) 매수-Signal(9) 상향돌파");
m_EventCodeStr.Add(59, "RSI(14) 매도-Signal(9) 하향돌파");
m_EventCodeStr.Add(60, "Volume Oscillator 매수-Signal(9) 상향돌파");
m_EventCodeStr.Add(61, "Volume Oscillator 매도-Signal(9) 하향돌파");
m_EventCodeStr.Add(62, "Price roc 매수-Signal(9) 상향돌파");
m_EventCodeStr.Add(63, "Price roc 매도-Signal(9) 하향돌파");
m_EventCodeStr.Add(64, "일목균형표 매수-전환선 > 기준선 상향교차");
m_EventCodeStr.Add(65, "일목균형표 매도-전환선 < 기준선 하향교차");
m_EventCodeStr.Add(66, "일목균형표 매수-주가가 선행스팬 상향돌파");
m_EventCodeStr.Add(67, "일목균형표 매도-주가가 선행스팬 하향돌파");
m_EventCodeStr.Add(68, "삼선전환도-양전환");
m_EventCodeStr.Add(69, "삼선전환도-음전환");
m_EventCodeStr.Add(70, "캔들패턴-상승반전형");
m_EventCodeStr.Add(71, "캔들패턴-하락반전형");
m_EventCodeStr.Add(81, "단기급락 후 5MA 상향돌파");
m_EventCodeStr.Add(82, "주가 이동평균밀집-5%이내");
m_EventCodeStr.Add(83, "눌림목 재 상승-20MA 지지");
}
public void InitCybos()
{
short iResult = m_CPUtil.TradeInit();
switch (iResult)
{
case -1:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 오류");
break;
case 0:
Util.Log(Util.LOG_TYPE.VERVOSE, "[TradeInit] 로그인 되었습니다");
break;
case 1:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 업무 키 입력 잘못됨");
break;
case 2:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 계좌 비밀번호가 잘못되었습니다");
break;
case 3:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 취소되었습니다");
break;
}
m_Listener.SetAccountList(m_CPUtil.AccountNumber);
SubscribeMarketWatch();
}
public int GetLimitRemainCountTrade()
{
return m_CPCybos.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_TRADE_REQUEST);
}
public int GetLimitRemainCountRQ()
{
return m_CPCybos.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_NONTRADE_REQUEST);
}
public int GetLimitRemainCountSB()
{
return m_CPCybos.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_SUBSCRIBE);
}
public bool IsConnected()
{
return (m_CPCybos.IsConnect==1);
}
void SubscribeMarketWatch()
{
m_MarketWatch = new CpMarketWatchS();
m_MarketWatch.SetInputValue(0, "*");
m_MarketWatch.Received += MarketWatch_Received;
m_MarketWatch.Subscribe();
}
private void MarketWatch_Received()
{
string strCode = m_MarketWatch.GetHeaderValue(0);
string strCodeName = m_MarketWatch.GetHeaderValue(1);
int iCount = m_MarketWatch.GetHeaderValue(2);
for(int i=0; i<iCount; i++)
{
int iTime = m_MarketWatch.GetDataValue(0, i);
sbyte cType = m_MarketWatch.GetDataValue(1, i);
int iEventCode = m_MarketWatch.GetDataValue(2, i);
m_Listener.OnWatchReceived(iTime, strCode, strCodeName, cType == 'n', iEventCode);
}
}
public void GetLowHighPrice(string strCode, DateTime StartTime, int iAfterMin, out int iLowPrice, out int iHighPrice)
{
iLowPrice = 10000000;
iHighPrice = 0;
lock(m_StockChartLock)
{
if(GetLimitRemainCountRQ() < 5)
return;
string strTime = StartTime.ToString("yyyyMMdd");
m_StockChart.SetInputValue(0, strCode);
m_StockChart.SetInputValue(1, '1');
m_StockChart.SetInputValue(2, strTime);
m_StockChart.SetInputValue(3, strTime);
m_StockChart.SetInputValue(4, 20);
m_StockChart.SetInputValue(5, new int[] { 0, 1, 2, 3, 4, 5, });
m_StockChart.SetInputValue(6, 'm');
m_StockChart.SetInputValue(7, 1);
m_StockChart.BlockRequest2(0);
int iTimeStart;
int.TryParse(StartTime.ToString("HHmm"), out iTimeStart);
int iCount = m_StockChart.GetHeaderValue(3);
for(int i = 0; i<iCount; i++)
{
uint uiDate = m_StockChart.GetDataValue(0, i);
long iTime = m_StockChart.GetDataValue(1, i);
if(iTime >= iTimeStart && iTime <= iTimeStart+iAfterMin)
{
long iPriceStartLocal = m_StockChart.GetDataValue(2, i);
long iPriceHighLocal = m_StockChart.GetDataValue(3, i);
long iPriceLowLocal = m_StockChart.GetDataValue(4, i);
long iPriceEndLocal = m_StockChart.GetDataValue(5, i);
iLowPrice = Math.Min(iLowPrice, (int)iPriceLowLocal);
iHighPrice = Math.Max(iHighPrice, (int)iPriceHighLocal);
}
if(iTime < iTimeStart)
break;
}
}
}
public int GetCurPrice(string strCode)
{
lock(m_StockMstLock)
{
m_CPStockMst.SetInputValue(0, strCode);
Console.WriteLine("[{0}] lock", Thread.CurrentThread.ManagedThreadId);
m_CPStockMst.BlockRequest2(0);
Console.WriteLine("[{0}] unlock", Thread.CurrentThread.ManagedThreadId);
int iCurPrice = m_CPStockMst.GetHeaderValue(11);
return iCurPrice;
}
}
public string GetEventCodeStr(int iEventCode)
{
if(m_EventCodeStr.ContainsKey(iEventCode) == false)
return "";
return m_EventCodeStr[iEventCode];
}
}
}

27
ListViewNF.cs Normal file
View File

@@ -0,0 +1,27 @@
using System.Windows.Forms;
namespace MarketWatchNS
{
public partial class ListViewNF : ListView
{
public ListViewNF()
{
//Activate double buffering
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
//Enable the OnNotifyMessage event so we get a chance to filter out
// Windows messages before they get to the form's WndProc
this.SetStyle(ControlStyles.EnableNotifyMessage, true);
}
protected override void OnNotifyMessage(Message m)
{
//Filter out the WM_ERASEBKGND message
if (m.Msg != 0x14)
{
base.OnNotifyMessage(m);
}
}
}
}

311
MarketWatch.Designer.cs generated Normal file
View File

@@ -0,0 +1,311 @@
namespace MarketWatchNS
{
partial class MarketWatch
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MarketWatch));
this.materialTabSelector1 = new MaterialSkin.Controls.MaterialTabSelector();
this.materialTabControl1 = new MaterialSkin.Controls.MaterialTabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tbLog = new System.Windows.Forms.RichTextBox();
this.btCybos = new MaterialSkin.Controls.MaterialRaisedButton();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.materialLabel3 = new MaterialSkin.Controls.MaterialLabel();
this.lvItems = new MarketWatchNS.ListViewNF();
this.chSeq = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chCBTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chRecvTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chCode = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chCodeName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chEvent = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chStartPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chLowPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chLowP = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chHighPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chHighP = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.lbInfo = new MaterialSkin.Controls.MaterialLabel();
this.materialTabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.SuspendLayout();
//
// materialTabSelector1
//
this.materialTabSelector1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.materialTabSelector1.BaseTabControl = this.materialTabControl1;
this.materialTabSelector1.Depth = 0;
this.materialTabSelector1.Location = new System.Drawing.Point(0, 64);
this.materialTabSelector1.MouseState = MaterialSkin.MouseState.HOVER;
this.materialTabSelector1.Name = "materialTabSelector1";
this.materialTabSelector1.Size = new System.Drawing.Size(1074, 49);
this.materialTabSelector1.TabIndex = 1;
this.materialTabSelector1.Text = "materialTabSelector1";
//
// materialTabControl1
//
this.materialTabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.materialTabControl1.Controls.Add(this.tabPage1);
this.materialTabControl1.Controls.Add(this.tabPage2);
this.materialTabControl1.Depth = 0;
this.materialTabControl1.Location = new System.Drawing.Point(3, 115);
this.materialTabControl1.MouseState = MaterialSkin.MouseState.HOVER;
this.materialTabControl1.Name = "materialTabControl1";
this.materialTabControl1.SelectedIndex = 0;
this.materialTabControl1.Size = new System.Drawing.Size(1068, 572);
this.materialTabControl1.TabIndex = 2;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.lbInfo);
this.tabPage1.Controls.Add(this.splitContainer1);
this.tabPage1.Controls.Add(this.btCybos);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(1060, 546);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Items";
this.tabPage1.UseVisualStyleBackColor = true;
//
// splitContainer1
//
this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.splitContainer1.Location = new System.Drawing.Point(0, 35);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.lvItems);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.tbLog);
this.splitContainer1.Size = new System.Drawing.Size(1060, 511);
this.splitContainer1.SplitterDistance = 355;
this.splitContainer1.TabIndex = 1;
//
// tbLog
//
this.tbLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbLog.Location = new System.Drawing.Point(0, 0);
this.tbLog.Name = "tbLog";
this.tbLog.Size = new System.Drawing.Size(1060, 152);
this.tbLog.TabIndex = 0;
this.tbLog.Text = "";
//
// btCybos
//
this.btCybos.AutoSize = true;
this.btCybos.Depth = 0;
this.btCybos.Location = new System.Drawing.Point(3, 3);
this.btCybos.MouseState = MaterialSkin.MouseState.HOVER;
this.btCybos.Name = "btCybos";
this.btCybos.Primary = true;
this.btCybos.Size = new System.Drawing.Size(66, 28);
this.btCybos.TabIndex = 3;
this.btCybos.Text = "Cybos";
this.btCybos.UseVisualStyleBackColor = true;
this.btCybos.Click += new System.EventHandler(this.btCybos_Click);
//
// tabPage2
//
this.tabPage2.BackColor = System.Drawing.Color.White;
this.tabPage2.Controls.Add(this.materialLabel3);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(1060, 546);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Preference";
//
// materialLabel3
//
this.materialLabel3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.materialLabel3.AutoSize = true;
this.materialLabel3.Depth = 0;
this.materialLabel3.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F);
this.materialLabel3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.materialLabel3.Location = new System.Drawing.Point(6, 524);
this.materialLabel3.MouseState = MaterialSkin.MouseState.HOVER;
this.materialLabel3.Name = "materialLabel3";
this.materialLabel3.Size = new System.Drawing.Size(162, 18);
this.materialLabel3.TabIndex = 6;
this.materialLabel3.Text = "Version : 2017.02.01.09";
//
// lvItems
//
this.lvItems.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.chSeq,
this.chCBTime,
this.chRecvTime,
this.chCode,
this.chCodeName,
this.chEvent,
this.chStartPrice,
this.chLowPrice,
this.chLowP,
this.chHighPrice,
this.chHighP});
this.lvItems.Dock = System.Windows.Forms.DockStyle.Fill;
this.lvItems.FullRowSelect = true;
this.lvItems.GridLines = true;
this.lvItems.Location = new System.Drawing.Point(0, 0);
this.lvItems.Name = "lvItems";
this.lvItems.Size = new System.Drawing.Size(1060, 355);
this.lvItems.TabIndex = 0;
this.lvItems.UseCompatibleStateImageBehavior = false;
this.lvItems.View = System.Windows.Forms.View.Details;
this.lvItems.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvItems_ColumnClick);
//
// chSeq
//
this.chSeq.Text = "Seq.";
this.chSeq.Width = 39;
//
// chCBTime
//
this.chCBTime.Text = "시간";
this.chCBTime.Width = 37;
//
// chRecvTime
//
this.chRecvTime.Text = "받은 시간";
this.chRecvTime.Width = 66;
//
// chCode
//
this.chCode.Text = "코드";
this.chCode.Width = 71;
//
// chCodeName
//
this.chCodeName.Text = "종목명";
this.chCodeName.Width = 102;
//
// chEvent
//
this.chEvent.Text = "신호";
this.chEvent.Width = 308;
//
// chStartPrice
//
this.chStartPrice.Text = "시가";
this.chStartPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.chStartPrice.Width = 71;
//
// chLowPrice
//
this.chLowPrice.Text = "저가";
this.chLowPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// chLowP
//
this.chLowP.Text = "대비";
this.chLowP.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// chHighPrice
//
this.chHighPrice.Text = "고가";
this.chHighPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// chHighP
//
this.chHighP.Text = "대비";
this.chHighP.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// lbInfo
//
this.lbInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lbInfo.AutoSize = true;
this.lbInfo.Depth = 0;
this.lbInfo.Font = new System.Drawing.Font("Roboto", 11F);
this.lbInfo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.lbInfo.Location = new System.Drawing.Point(1007, 6);
this.lbInfo.MouseState = MaterialSkin.MouseState.HOVER;
this.lbInfo.Name = "lbInfo";
this.lbInfo.Size = new System.Drawing.Size(0, 19);
this.lbInfo.TabIndex = 4;
//
// MarketWatch
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1074, 690);
this.Controls.Add(this.materialTabSelector1);
this.Controls.Add(this.materialTabControl1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "MarketWatch";
this.Text = "MarketWatch";
this.materialTabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private MaterialSkin.Controls.MaterialTabSelector materialTabSelector1;
private MaterialSkin.Controls.MaterialTabControl materialTabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.SplitContainer splitContainer1;
private ListViewNF lvItems;
private System.Windows.Forms.ColumnHeader chCodeName;
private System.Windows.Forms.ColumnHeader chStartPrice;
private System.Windows.Forms.RichTextBox tbLog;
private MaterialSkin.Controls.MaterialRaisedButton btCybos;
private System.Windows.Forms.ColumnHeader chCode;
private MaterialSkin.Controls.MaterialLabel materialLabel3;
private System.Windows.Forms.ColumnHeader chLowPrice;
private System.Windows.Forms.ColumnHeader chLowP;
private System.Windows.Forms.ColumnHeader chHighPrice;
private System.Windows.Forms.ColumnHeader chHighP;
private System.Windows.Forms.ColumnHeader chEvent;
private System.Windows.Forms.ColumnHeader chSeq;
private System.Windows.Forms.ColumnHeader chCBTime;
private System.Windows.Forms.ColumnHeader chRecvTime;
private MaterialSkin.Controls.MaterialLabel lbInfo;
}
}

257
MarketWatch.cs Normal file
View File

@@ -0,0 +1,257 @@
using MaterialSkin;
using MaterialSkin.Controls;
using System;
using System.Collections;
using System.Collections.Concurrent;
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 MarketWatchNS
{
public partial class MarketWatch : MaterialForm
{
CybosHelper m_CybosHelper = null;
class ITEM
{
public int m_iSeq;
public string m_strCode;
public string m_strCodeName;
public int m_iEventCode;
public DateTime m_RecevedTime;
public int m_iStartPrice = 0;
public int m_iLowPrice = 10000000;
public float m_fLowP = 0.0f;
public int m_iHighPrice = 0;
public float m_fHighP = 0.0f;
}
ConcurrentQueue<ITEM> m_ItemList = new ConcurrentQueue<ITEM>();
System.Timers.Timer m_PriceCheckTimer = new System.Timers.Timer();
System.Timers.Timer m_SystemTimer = new System.Timers.Timer();
public MarketWatch()
{
InitializeComponent();
lvItems.ListViewItemSorter = new ListViewItemComparer(chSeq.Index, SortOrder.Ascending);
lvItems.Sorting = SortOrder.Ascending;
Util.SetLogView(tbLog);
Config.Init();
m_CybosHelper = new CybosHelper(this);
var materialSkinManager = MaterialSkinManager.Instance;
materialSkinManager.AddFormToManage(this);
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();
}
private void SystemTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if(lbInfo.InvokeRequired)
{
lbInfo.Invoke(new Action(() => {
lbInfo.Text = string.Format("{0}|{1}",
m_CybosHelper.GetLimitRemainCountRQ(),
m_CybosHelper.GetLimitRemainCountSB());
}));
}
else
{
lbInfo.Text = string.Format("{0}|{1}",
m_CybosHelper.GetLimitRemainCountRQ(),
m_CybosHelper.GetLimitRemainCountSB());
}
}
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;
}
}
}
}
public void SetAccountList(string[] aAccountList)
{
}
private void btCybos_Click(object sender, EventArgs e)
{
m_CybosHelper.InitCybos();
btCybos.Primary = false;
btCybos.Enabled = false;
}
public void OnWatchReceived(int iTime, string strCode, string strCodeName, bool bNew, int iEventCode)
{
if(bNew == false)
return;
int iSeq = lvItems.Items.Count+1;
ITEM Item = new ITEM();
Item.m_iSeq = iSeq;
Item.m_strCode = strCode;
Item.m_strCodeName = strCodeName;
Item.m_iEventCode = iEventCode;
Item.m_RecevedTime = DateTime.Now;
Item.m_iStartPrice = m_CybosHelper.GetCurPrice(strCode);
m_ItemList.Enqueue(Item);
if(lvItems.InvokeRequired)
{
lvItems.Invoke(new Action(() => {
lvItems.Items.Add(new ListViewItem(new string[]
{
iSeq.ToString(),
string.Format("{0}:{1}", iTime/100, iTime%100),
DateTime.Now.ToString("hh:MM:ss:fff"),
strCode,
strCodeName,
m_CybosHelper.GetEventCodeStr(iEventCode),
string.Format("{0:n0}",
Item.m_iStartPrice),
"",
"",
"",
""
}));
lvItems.Items[lvItems.Items.Count-1].UseItemStyleForSubItems = false;
}));
}
else
{
lvItems.Items.Add(new ListViewItem(new string[]
{
iSeq.ToString(),
string.Format("{0}:{1}", iTime/100, iTime%100),
DateTime.Now.ToString("hh:MM:ss:fff"),
strCode,
strCodeName,
m_CybosHelper.GetEventCodeStr(iEventCode),
string.Format("{0:n0}",
Item.m_iStartPrice),
"",
"",
"",
""
}));
lvItems.Items[lvItems.Items.Count-1].UseItemStyleForSubItems = false;
}
}
private void lvItems_ColumnClick(object sender, ColumnClickEventArgs e)
{
SortOrder Order = (lvItems.Sorting == SortOrder.Descending || lvItems.Sorting == SortOrder.None) ? SortOrder.Ascending : SortOrder.Descending;
lvItems.ListViewItemSorter = new ListViewItemComparer(e.Column, Order);
lvItems.Sorting = Order;
lvItems.Sort();
}
}
class ListViewItemComparer : IComparer
{
int m_iColumn = 0;
SortOrder m_Order = SortOrder.Ascending;
public ListViewItemComparer(int column, SortOrder Order)
{
m_iColumn = column;
m_Order = Order;
}
public int Compare(object x, object y)
{
ListViewItem item1 = (ListViewItem)x;
ListViewItem item2 = (ListViewItem)y;
double num1;
double num2;
if(double.TryParse(item1.SubItems[m_iColumn].Text, out num1) &&
double.TryParse(item2.SubItems[m_iColumn].Text, out num2))
{
return (num1>num2) ? 1 : -1;
}
else
{
if(m_Order == SortOrder.Ascending)
return string.Compare(item1.SubItems[m_iColumn].Text, item2.SubItems[m_iColumn].Text);
else
return string.Compare(item2.SubItems[m_iColumn].Text, item1.SubItems[m_iColumn].Text);
}
}
}
}

227
MarketWatch.csproj Normal file
View File

@@ -0,0 +1,227 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D22B6894-B97F-4B53-92D3-D2B77FC929D5}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MarketWatchNS</RootNamespace>
<AssemblyName>MarketWatch</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="MaterialSkin, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\MaterialSkin.0.2.1\lib\MaterialSkin.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="CybosHelper.cs" />
<Compile Include="MarketWatch.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MarketWatch.Designer.cs">
<DependentUpon>MarketWatch.cs</DependentUpon>
</Compile>
<Compile Include="ListViewNF.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Util.cs" />
<EmbeddedResource Include="MarketWatch.resx">
<DependentUpon>MarketWatch.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\app.manifest">
<SubType>Designer</SubType>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<COMReference Include="CPFOREDIBLIB">
<Guid>{ABA39D6F-5AF4-4D10-8389-031055C13A75}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="CPFORETRADELib">
<Guid>{1E3BC2CB-4AC7-46BB-AF63-11DEA8628E3C}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="CpIndexesLib">
<Guid>{3DC4496B-C823-4440-ABD4-A248A716F7C6}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="CPSYSDIBLib">
<Guid>{9C31B76A-7189-49A3-9781-3C6DD6ED5AD3}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="CPTRADELib">
<Guid>{1F7D5E5A-05AB-4236-B6F3-3D383B09203A}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="CPUTILLib">
<Guid>{2DA9C35C-FE59-4A32-A942-325EE8A6F659}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="DSCBO1Lib">
<Guid>{859343F1-08FD-11D4-8231-00105A7C4F8C}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if NOT "$(ConfigurationName)" == "Release" (goto :nocopy)
copy $(TargetPath) $(ProjectDir)publish\ /y
copy $(TargetDir)*.dll $(ProjectDir)publish\ /y
:nocopy
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

1787
MarketWatch.resx Normal file

File diff suppressed because it is too large Load Diff

22
MarketWatch.sln Normal file
View File

@@ -0,0 +1,22 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarketWatch", "MarketWatch.csproj", "{D22B6894-B97F-4B53-92D3-D2B77FC929D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D22B6894-B97F-4B53-92D3-D2B77FC929D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D22B6894-B97F-4B53-92D3-D2B77FC929D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D22B6894-B97F-4B53-92D3-D2B77FC929D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D22B6894-B97F-4B53-92D3-D2B77FC929D5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

22
Program.cs Normal file
View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MarketWatchNS
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MarketWatch());
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MarketWatch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MarketWatch")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d22b6894-b97f-4b53-92d3-d2b77fc929d5")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

63
Properties/Resources.Designer.cs generated Normal file
View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MarketWatchNS.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MarketWatchNS.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

117
Properties/Resources.resx Normal file
View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

26
Properties/Settings.Designer.cs generated Normal file
View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MarketWatchNS.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

70
Properties/app.manifest Normal file
View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>

137
Util.cs Normal file
View File

@@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MarketWatchNS
{
static class Util
{
public enum LOG_TYPE
{
DEBUG,
ERROR,
VERVOSE,
BUY,
SELL,
}
static string m_strLogFile = null;
static RichTextBox m_LogBox = null;
delegate void InsertLogDelegate(RichTextBox LogBox, LOG_TYPE enType, string strLog);
static InsertLogDelegate m_InsertLogDelegate = new InsertLogDelegate(InsertLog);
public static void SetLogView(RichTextBox logBox)
{
m_LogBox = logBox;
}
public static void Clear()
{
m_LogBox = null;
}
static void InsertLog(RichTextBox LogBox, LOG_TYPE enType, string strLog)
{
if(LogBox.InvokeRequired)
{
LogBox.Invoke(m_InsertLogDelegate, LogBox, enType, strLog);
}
else
{
Color LogColor;
switch(enType)
{
case LOG_TYPE.DEBUG:
LogColor = Color.Gray;
break;
case LOG_TYPE.ERROR:
LogColor = Color.DarkRed;
break;
case LOG_TYPE.VERVOSE:
LogColor = Color.Black;
break;
case LOG_TYPE.SELL:
LogColor = Color.Blue;
break;
case LOG_TYPE.BUY:
LogColor = Color.Red;
break;
default:
LogColor = Color.Black;
break;
}
LogBox.SelectionStart = LogBox.TextLength;
LogBox.SelectionLength = 0;
LogBox.SelectionColor = LogColor;
LogBox.AppendText(strLog);
LogBox.SelectionColor = LogBox.ForeColor;
LogBox.SelectionStart = LogBox.TextLength;
LogBox.ScrollToCaret();
}
}
public static void Log(LOG_TYPE enType, string strLog)
{
if(Directory.Exists(GetLogPath()) == false)
Directory.CreateDirectory(GetLogPath());
if(m_strLogFile == null)
{
string strToday = DateTime.Now.ToString("yyyy-MM-dd");
m_strLogFile = GetLogPath()+"/MarketWatchLog-"+strToday+".txt";
}
string strLogLevel = "["+enType+"] ";
string strTime = DateTime.Now.ToString("[HH:mm:ss:fff] ");
string strMessage = strTime+strLogLevel+strLog;
File.AppendAllText(m_strLogFile, strMessage+Environment.NewLine, new UTF8Encoding(true));
if(m_LogBox != null)
InsertLog(m_LogBox, enType, strMessage+Environment.NewLine);
Console.WriteLine(strMessage);
}
public static bool IsDebugging()
{
return Debugger.IsAttached;
}
public static string GetConfigPath()
{
string strPath = "";
if(IsDebugging())
strPath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()));
else
strPath = Directory.GetCurrentDirectory();
strPath += "/configure";
if(Directory.Exists(strPath) == false)
Directory.CreateDirectory(strPath);
return strPath;
}
public static string GetLogPath()
{
string strPath = "";
if(IsDebugging())
strPath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()));
else
strPath = Directory.GetCurrentDirectory();
strPath += "/log";
return strPath;
}
}
}

BIN
icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

4
packages.config Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MaterialSkin" version="0.2.1" targetFramework="net452" />
</packages>

Binary file not shown.

Binary file not shown.