From da9a59622b22a9802caa4f79f3797b9a3fc9f974 Mon Sep 17 00:00:00 2001 From: mjjo Date: Thu, 26 Jan 2017 15:43:12 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=90=EB=8F=99=20=EB=A7=A4=EB=8F=84=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 + AutoSeller.Designer.cs | 494 +++++++++++++++++++++---------- AutoSeller.cs | 310 ++++++++++++++++++- AutoSeller.csproj | 58 ++++ AutoSeller.resx | 3 - Config.cs | 89 ++++++ CybosHelper.cs | 257 +++++++++++++--- ListViewNF.cs | 27 ++ Program.cs | 2 +- Properties/Resources.Designer.cs | 2 +- Properties/Settings.Designer.cs | 2 +- Properties/app.manifest | 70 +++++ Util.cs | 15 +- 13 files changed, 1127 insertions(+), 207 deletions(-) create mode 100644 Config.cs create mode 100644 ListViewNF.cs create mode 100644 Properties/app.manifest diff --git a/.gitignore b/.gitignore index cd42ee3..5ad99a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ bin/ obj/ +.vs/ +configure/ +log/ +publish/ +*.user diff --git a/AutoSeller.Designer.cs b/AutoSeller.Designer.cs index 88aee5b..989ebcd 100644 --- a/AutoSeller.Designer.cs +++ b/AutoSeller.Designer.cs @@ -1,4 +1,4 @@ -namespace AutoSeller +namespace AutoSellerNS { partial class AutoSeller { @@ -28,49 +28,53 @@ /// private void InitializeComponent() { - this.materialContextMenuStrip1 = new MaterialSkin.Controls.MaterialContextMenuStrip(); this.materialTabSelector1 = new MaterialSkin.Controls.MaterialTabSelector(); this.materialTabControl1 = new MaterialSkin.Controls.MaterialTabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.btUpdate = new MaterialSkin.Controls.MaterialRaisedButton(); + this.btCybos = new MaterialSkin.Controls.MaterialRaisedButton(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.cbAccount = new System.Windows.Forms.ComboBox(); + this.tbSubAccount = new MaterialSkin.Controls.MaterialSingleLineTextField(); + this.btApply = new MaterialSkin.Controls.MaterialFlatButton(); + this.materialLabel1 = new MaterialSkin.Controls.MaterialLabel(); + this.tbBidCount = new MaterialSkin.Controls.MaterialSingleLineTextField(); + this.materialLabel2 = new MaterialSkin.Controls.MaterialLabel(); + this.btSell = new MaterialSkin.Controls.MaterialRaisedButton(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.lvList = new System.Windows.Forms.ListView(); + this.tbLog = new System.Windows.Forms.RichTextBox(); + this.lvItems = new AutoSellerNS.ListViewNF(); + this.chCode = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chCodeName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chCurPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chBookValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chBookValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chCapitalGains = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chAssessedValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chValuation = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.Yield = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.tbLog = new System.Windows.Forms.TextBox(); - this.tabPage2 = new System.Windows.Forms.TabPage(); - this.materialLabel2 = new MaterialSkin.Controls.MaterialLabel(); - this.splitContainer2 = new System.Windows.Forms.SplitContainer(); - this.lvCurPrice = new System.Windows.Forms.ListView(); + this.chYield = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chMaxPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chCheckCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.lvCurPrice = new AutoSellerNS.ListViewNF(); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chAskCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chCallPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chBidCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.materialLabel3 = 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(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); this.splitContainer2.Panel1.SuspendLayout(); this.splitContainer2.Panel2.SuspendLayout(); this.splitContainer2.SuspendLayout(); + this.tabPage2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); this.SuspendLayout(); // - // materialContextMenuStrip1 - // - this.materialContextMenuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this.materialContextMenuStrip1.Depth = 0; - this.materialContextMenuStrip1.MouseState = MaterialSkin.MouseState.HOVER; - this.materialContextMenuStrip1.Name = "materialContextMenuStrip1"; - this.materialContextMenuStrip1.Size = new System.Drawing.Size(61, 4); - // // materialTabSelector1 // this.materialTabSelector1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -80,7 +84,7 @@ 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(1003, 49); + this.materialTabSelector1.Size = new System.Drawing.Size(1074, 49); this.materialTabSelector1.TabIndex = 1; this.materialTabSelector1.Text = "materialTabSelector1"; // @@ -92,24 +96,191 @@ this.materialTabControl1.Controls.Add(this.tabPage1); this.materialTabControl1.Controls.Add(this.tabPage2); this.materialTabControl1.Depth = 0; - this.materialTabControl1.Location = new System.Drawing.Point(3, 116); + 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(997, 571); + this.materialTabControl1.Size = new System.Drawing.Size(1068, 572); this.materialTabControl1.TabIndex = 2; // // tabPage1 // + this.tabPage1.Controls.Add(this.btSell); this.tabPage1.Controls.Add(this.splitContainer2); + this.tabPage1.Controls.Add(this.btUpdate); + 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(989, 545); + this.tabPage1.Size = new System.Drawing.Size(1060, 546); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Items"; this.tabPage1.UseVisualStyleBackColor = true; // + // splitContainer2 + // + this.splitContainer2.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.splitContainer2.IsSplitterFixed = true; + this.splitContainer2.Location = new System.Drawing.Point(3, 34); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel1 + // + this.splitContainer2.Panel1.Controls.Add(this.splitContainer1); + // + // splitContainer2.Panel2 + // + this.splitContainer2.Panel2.Controls.Add(this.lvCurPrice); + this.splitContainer2.Size = new System.Drawing.Size(1054, 508); + this.splitContainer2.SplitterDistance = 804; + this.splitContainer2.TabIndex = 2; + this.splitContainer2.SizeChanged += new System.EventHandler(this.splitContainer2_SizeChanged); + // + // btUpdate + // + this.btUpdate.AutoSize = true; + this.btUpdate.Depth = 0; + this.btUpdate.Location = new System.Drawing.Point(74, 3); + this.btUpdate.MouseState = MaterialSkin.MouseState.HOVER; + this.btUpdate.Name = "btUpdate"; + this.btUpdate.Primary = true; + this.btUpdate.Size = new System.Drawing.Size(68, 28); + this.btUpdate.TabIndex = 3; + this.btUpdate.Text = "Update"; + this.btUpdate.UseVisualStyleBackColor = true; + this.btUpdate.Click += new System.EventHandler(this.btUpdate_Click); + // + // 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.Controls.Add(this.materialLabel2); + this.tabPage2.Controls.Add(this.tbBidCount); + this.tabPage2.Controls.Add(this.materialLabel1); + this.tabPage2.Controls.Add(this.btApply); + this.tabPage2.Controls.Add(this.tbSubAccount); + this.tabPage2.Controls.Add(this.cbAccount); + 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"; + // + // cbAccount + // + this.cbAccount.FormattingEnabled = true; + this.cbAccount.Location = new System.Drawing.Point(25, 62); + this.cbAccount.Name = "cbAccount"; + this.cbAccount.Size = new System.Drawing.Size(121, 20); + this.cbAccount.TabIndex = 0; + // + // tbSubAccount + // + this.tbSubAccount.Depth = 0; + this.tbSubAccount.Hint = ""; + this.tbSubAccount.Location = new System.Drawing.Point(154, 62); + this.tbSubAccount.MouseState = MaterialSkin.MouseState.HOVER; + this.tbSubAccount.Name = "tbSubAccount"; + this.tbSubAccount.PasswordChar = '\0'; + this.tbSubAccount.SelectedText = ""; + this.tbSubAccount.SelectionLength = 0; + this.tbSubAccount.SelectionStart = 0; + this.tbSubAccount.Size = new System.Drawing.Size(25, 23); + this.tbSubAccount.TabIndex = 1; + this.tbSubAccount.Text = "10"; + this.tbSubAccount.UseSystemPasswordChar = false; + // + // btApply + // + this.btApply.AutoSize = true; + this.btApply.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btApply.Depth = 0; + this.btApply.Location = new System.Drawing.Point(844, 483); + this.btApply.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); + this.btApply.MinimumSize = new System.Drawing.Size(120, 36); + this.btApply.MouseState = MaterialSkin.MouseState.HOVER; + this.btApply.Name = "btApply"; + this.btApply.Primary = false; + this.btApply.Size = new System.Drawing.Size(120, 36); + this.btApply.TabIndex = 2; + this.btApply.Text = "적용하기"; + this.btApply.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.btApply.UseVisualStyleBackColor = true; + this.btApply.Click += new System.EventHandler(this.btApply_Click); + // + // materialLabel1 + // + this.materialLabel1.AutoSize = true; + this.materialLabel1.Depth = 0; + this.materialLabel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); + this.materialLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel1.Location = new System.Drawing.Point(25, 29); + this.materialLabel1.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel1.Name = "materialLabel1"; + this.materialLabel1.Size = new System.Drawing.Size(62, 18); + this.materialLabel1.TabIndex = 3; + this.materialLabel1.Text = "Account"; + // + // tbBidCount + // + this.tbBidCount.Depth = 0; + this.tbBidCount.Hint = ""; + this.tbBidCount.Location = new System.Drawing.Point(116, 144); + this.tbBidCount.MouseState = MaterialSkin.MouseState.HOVER; + this.tbBidCount.Name = "tbBidCount"; + this.tbBidCount.PasswordChar = '\0'; + this.tbBidCount.SelectedText = ""; + this.tbBidCount.SelectionLength = 0; + this.tbBidCount.SelectionStart = 0; + this.tbBidCount.Size = new System.Drawing.Size(30, 23); + this.tbBidCount.TabIndex = 4; + this.tbBidCount.Text = "5"; + this.tbBidCount.UseSystemPasswordChar = false; + // + // materialLabel2 + // + this.materialLabel2.AutoSize = true; + this.materialLabel2.Depth = 0; + this.materialLabel2.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); + this.materialLabel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel2.Location = new System.Drawing.Point(152, 148); + this.materialLabel2.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel2.Name = "materialLabel2"; + this.materialLabel2.Size = new System.Drawing.Size(21, 18); + this.materialLabel2.TabIndex = 5; + this.materialLabel2.Text = "회"; + // + // btSell + // + this.btSell.AutoSize = true; + this.btSell.Depth = 0; + this.btSell.Location = new System.Drawing.Point(148, 3); + this.btSell.MouseState = MaterialSkin.MouseState.HOVER; + this.btSell.Name = "btSell"; + this.btSell.Primary = true; + this.btSell.Size = new System.Drawing.Size(68, 28); + this.btSell.TabIndex = 4; + this.btSell.Text = "Sell"; + this.btSell.UseVisualStyleBackColor = true; + this.btSell.Click += new System.EventHandler(this.btSell_Click); + // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; @@ -119,183 +290,194 @@ // // splitContainer1.Panel1 // - this.splitContainer1.Panel1.Controls.Add(this.lvList); + this.splitContainer1.Panel1.Controls.Add(this.lvItems); // // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.tbLog); - this.splitContainer1.Size = new System.Drawing.Size(738, 539); - this.splitContainer1.SplitterDistance = 375; + this.splitContainer1.Size = new System.Drawing.Size(804, 508); + this.splitContainer1.SplitterDistance = 353; this.splitContainer1.TabIndex = 1; // - // lvList - // - this.lvList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.chCodeName, - this.chCurPrice, - this.chBookValue, - this.chCount, - this.chCapitalGains, - this.chAssessedValue, - this.chValuation, - this.Yield}); - this.lvList.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvList.Location = new System.Drawing.Point(0, 0); - this.lvList.Name = "lvList"; - this.lvList.Size = new System.Drawing.Size(738, 375); - this.lvList.TabIndex = 0; - this.lvList.UseCompatibleStateImageBehavior = false; - this.lvList.View = System.Windows.Forms.View.Details; - // - // chCodeName - // - this.chCodeName.Text = "종목명"; - // - // chCurPrice - // - this.chCurPrice.Text = "현재가"; - // - // chBookValue - // - this.chBookValue.Text = "장부가"; - // - // chCount - // - this.chCount.Text = "잔고수량"; - // - // chCapitalGains - // - this.chCapitalGains.Text = "손익단가"; - // - // chAssessedValue - // - this.chAssessedValue.Text = "평가금액"; - // - // chValuation - // - this.chValuation.Text = "평가손익"; - // - // Yield - // - this.Yield.Text = "수익률"; - // // tbLog // this.tbLog.Dock = System.Windows.Forms.DockStyle.Fill; this.tbLog.Location = new System.Drawing.Point(0, 0); - this.tbLog.Multiline = true; this.tbLog.Name = "tbLog"; - this.tbLog.Size = new System.Drawing.Size(738, 160); + this.tbLog.Size = new System.Drawing.Size(804, 151); this.tbLog.TabIndex = 0; + this.tbLog.Text = ""; // - // tabPage2 + // lvItems // - this.tabPage2.Controls.Add(this.materialLabel2); - 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(776, 545); - this.tabPage2.TabIndex = 1; - this.tabPage2.Text = "Preference"; - this.tabPage2.UseVisualStyleBackColor = true; + this.lvItems.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.chCode, + this.chCodeName, + this.chCurPrice, + this.chCount, + this.chBookValue, + this.chCapitalGains, + this.chAssessedValue, + this.chValuation, + this.chYield, + this.chMaxPrice, + this.chCheckCount}); + 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(804, 353); + this.lvItems.TabIndex = 0; + this.lvItems.UseCompatibleStateImageBehavior = false; + this.lvItems.View = System.Windows.Forms.View.Details; + this.lvItems.SelectedIndexChanged += new System.EventHandler(this.lvList_SelectedIndexChanged); // - // materialLabel2 + // chCode // - this.materialLabel2.AutoSize = true; - this.materialLabel2.Depth = 0; - this.materialLabel2.Font = new System.Drawing.Font("Roboto", 11F); - this.materialLabel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel2.Location = new System.Drawing.Point(339, 156); - this.materialLabel2.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel2.Name = "materialLabel2"; - this.materialLabel2.Size = new System.Drawing.Size(108, 19); - this.materialLabel2.TabIndex = 0; - this.materialLabel2.Text = "materialLabel2"; + this.chCode.Text = "코드"; + this.chCode.Width = 77; // - // splitContainer2 + // chCodeName // - this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer2.IsSplitterFixed = true; - this.splitContainer2.Location = new System.Drawing.Point(3, 3); - this.splitContainer2.Name = "splitContainer2"; + this.chCodeName.Text = "종목명"; + this.chCodeName.Width = 86; // - // splitContainer2.Panel1 + // chCurPrice // - this.splitContainer2.Panel1.Controls.Add(this.splitContainer1); + this.chCurPrice.Text = "현재가"; + this.chCurPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chCurPrice.Width = 71; // - // splitContainer2.Panel2 + // chCount // - this.splitContainer2.Panel2.Controls.Add(this.lvCurPrice); - this.splitContainer2.Size = new System.Drawing.Size(983, 539); - this.splitContainer2.SplitterDistance = 738; - this.splitContainer2.TabIndex = 2; - this.splitContainer2.SizeChanged += new System.EventHandler(this.splitContainer2_SizeChanged); + this.chCount.Text = "잔고수량"; + this.chCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // chBookValue + // + this.chBookValue.Text = "장부가"; + this.chBookValue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chBookValue.Width = 72; + // + // chCapitalGains + // + this.chCapitalGains.Text = "손익단가"; + this.chCapitalGains.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chCapitalGains.Width = 73; + // + // chAssessedValue + // + this.chAssessedValue.Text = "평가금액"; + this.chAssessedValue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chAssessedValue.Width = 76; + // + // chValuation + // + this.chValuation.Text = "평가손익"; + this.chValuation.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chValuation.Width = 79; + // + // chYield + // + this.chYield.Text = "수익률"; + this.chYield.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chYield.Width = 79; + // + // chMaxPrice + // + this.chMaxPrice.Text = "매수후최고가"; + this.chMaxPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // chCheckCount + // + this.chCheckCount.Text = "조건횟수"; + this.chCheckCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // lvCurPrice // this.lvCurPrice.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1, - this.columnHeader2, - this.columnHeader3}); + this.chAskCount, + this.chCallPrice, + this.chBidCount}); this.lvCurPrice.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvCurPrice.FullRowSelect = true; + this.lvCurPrice.GridLines = true; this.lvCurPrice.Location = new System.Drawing.Point(0, 0); this.lvCurPrice.Name = "lvCurPrice"; - this.lvCurPrice.Size = new System.Drawing.Size(241, 539); + this.lvCurPrice.Size = new System.Drawing.Size(246, 508); this.lvCurPrice.TabIndex = 0; this.lvCurPrice.UseCompatibleStateImageBehavior = false; this.lvCurPrice.View = System.Windows.Forms.View.Details; // // columnHeader1 // - this.columnHeader1.Text = "매도잔량"; - this.columnHeader1.Width = 96; + this.columnHeader1.Width = 10; // - // columnHeader2 + // chAskCount // - this.columnHeader2.Text = "호가"; - this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.chAskCount.Text = "매도잔량"; + this.chAskCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chAskCount.Width = 75; // - // columnHeader3 + // chCallPrice // - this.columnHeader3.Text = "매수잔량"; - this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.columnHeader3.Width = 81; + this.chCallPrice.Text = "호가"; + this.chCallPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // - // Material + // chBidCount + // + this.chBidCount.Text = "매수잔량"; + this.chBidCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chBidCount.Width = 75; + // + // materialLabel3 + // + this.materialLabel3.AutoSize = true; + this.materialLabel3.Depth = 0; + this.materialLabel3.Font = new System.Drawing.Font("Roboto", 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(165, 19); + this.materialLabel3.TabIndex = 6; + this.materialLabel3.Text = "Version : 2017.01.26.14"; + // + // AutoSeller // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1003, 690); + this.ClientSize = new System.Drawing.Size(1074, 690); this.Controls.Add(this.materialTabSelector1); this.Controls.Add(this.materialTabControl1); - this.Name = "Material"; - this.Text = "Material"; + this.Name = "AutoSeller"; + this.Text = "AutoSeller"; this.materialTabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.Panel2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - this.tabPage2.ResumeLayout(false); - this.tabPage2.PerformLayout(); + this.tabPage1.PerformLayout(); this.splitContainer2.Panel1.ResumeLayout(false); this.splitContainer2.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); this.splitContainer2.ResumeLayout(false); + this.tabPage2.ResumeLayout(false); + this.tabPage2.PerformLayout(); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); this.ResumeLayout(false); } #endregion - private MaterialSkin.Controls.MaterialContextMenuStrip materialContextMenuStrip1; private MaterialSkin.Controls.MaterialTabSelector materialTabSelector1; private MaterialSkin.Controls.MaterialTabControl materialTabControl1; private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage2; - private MaterialSkin.Controls.MaterialLabel materialLabel2; private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.ListView lvList; + private ListViewNF lvItems; private System.Windows.Forms.ColumnHeader chCodeName; private System.Windows.Forms.ColumnHeader chCurPrice; private System.Windows.Forms.ColumnHeader chBookValue; @@ -303,12 +485,26 @@ private System.Windows.Forms.ColumnHeader chCapitalGains; private System.Windows.Forms.ColumnHeader chAssessedValue; private System.Windows.Forms.ColumnHeader chValuation; - private System.Windows.Forms.ColumnHeader Yield; - private System.Windows.Forms.TextBox tbLog; + private System.Windows.Forms.ColumnHeader chYield; + private System.Windows.Forms.RichTextBox tbLog; private System.Windows.Forms.SplitContainer splitContainer2; - private System.Windows.Forms.ListView lvCurPrice; + private ListViewNF lvCurPrice; + private System.Windows.Forms.ColumnHeader chAskCount; + private System.Windows.Forms.ColumnHeader chCallPrice; + private System.Windows.Forms.ColumnHeader chBidCount; + private MaterialSkin.Controls.MaterialRaisedButton btCybos; + private MaterialSkin.Controls.MaterialRaisedButton btUpdate; + private System.Windows.Forms.ColumnHeader chCode; private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.ColumnHeader columnHeader3; + private MaterialSkin.Controls.MaterialFlatButton btApply; + private MaterialSkin.Controls.MaterialSingleLineTextField tbSubAccount; + private System.Windows.Forms.ComboBox cbAccount; + private MaterialSkin.Controls.MaterialLabel materialLabel1; + private MaterialSkin.Controls.MaterialLabel materialLabel2; + private MaterialSkin.Controls.MaterialSingleLineTextField tbBidCount; + private MaterialSkin.Controls.MaterialRaisedButton btSell; + private System.Windows.Forms.ColumnHeader chMaxPrice; + private System.Windows.Forms.ColumnHeader chCheckCount; + private MaterialSkin.Controls.MaterialLabel materialLabel3; } } \ No newline at end of file diff --git a/AutoSeller.cs b/AutoSeller.cs index c1d0df8..f13586a 100644 --- a/AutoSeller.cs +++ b/AutoSeller.cs @@ -10,15 +10,62 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace AutoSeller +namespace AutoSellerNS { public partial class AutoSeller : MaterialForm { + public class ITEM + { + public string m_strCodeName; + public string m_strCode; + public int m_iItemCnt; + public long m_iAssessedValue; + public long m_iValuationGains; + public double m_dYield; + public int m_iAvailableQuantity; + public double m_dBookUnitPrice; + public long m_iProfitUnitPrice; + public int m_iSellableCnt; + + public int m_iCurPrice; + } + + int m_iCurPricePanelWith; + CybosHelper m_CybosHelper = null; + List m_Items = new List(); + string m_strSelectedCode = ""; + bool m_bSell = false; public AutoSeller() { InitializeComponent(); + Util.SetLogView(tbLog); + Config.Init(); + + btUpdate.Enabled = false; + btSell.Enabled = false; + + + for (int i = 0; i < 21; i++) + { + lvCurPrice.Items.Add(new ListViewItem(new string[] { "", "", "", "" })); + lvCurPrice.Items[i].UseItemStyleForSubItems = false; + if (i < 10) + { + lvCurPrice.Items[i].SubItems[chAskCount.Index].BackColor = Color.FromArgb(215, 233, 255); + lvCurPrice.Items[i].SubItems[chCallPrice.Index].BackColor = Color.FromArgb(215, 233, 255); + } + else if (i > 10) + { + lvCurPrice.Items[i].SubItems[chBidCount.Index].BackColor = Color.FromArgb(255, 227, 227); + lvCurPrice.Items[i].SubItems[chCallPrice.Index].BackColor = Color.FromArgb(255, 227, 227); + } + } + lvCurPrice.Items[10].SubItems[chAskCount.Index].Text = "현재가"; + lvCurPrice.Items[10].SubItems[chCallPrice.Index].Font = new Font(lvCurPrice.Items[0].SubItems[0].Font, FontStyle.Bold); + + m_CybosHelper = new CybosHelper(this); m_iCurPricePanelWith = splitContainer2.Panel2.Width; @@ -28,10 +75,267 @@ namespace AutoSeller materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE); } + public void SetAccountList(string[] aAccountList) + { + cbAccount.Items.Clear(); + cbAccount.Items.AddRange(aAccountList); + foreach (var account in aAccountList) + { + if (account == Config.GetAccount()) + { + cbAccount.SelectedItem = account; + break; + } + } + } + private void splitContainer2_SizeChanged(object sender, EventArgs e) { - int iDist = Math.Min(Math.Max(splitContainer2.Width-m_iCurPricePanelWith, splitContainer2.Panel1MinSize), splitContainer2.Width-splitContainer2.Panel2MinSize); ; - splitContainer2.SplitterDistance = iDist; + //int iDist = Math.Min(Math.Max(splitContainer2.Width-m_iCurPricePanelWith, splitContainer2.Panel1MinSize), splitContainer2.Width-splitContainer2.Panel2MinSize); + //if(iDist >= splitContainer2.Panel1MinSize && iDist <= splitContainer2.Width - splitContainer2.Panel2MinSize) + // splitContainer2.SplitterDistance = iDist; + } + + private void btCybos_Click(object sender, EventArgs e) + { + m_CybosHelper.InitCybos(); + + btCybos.Primary = false; + btCybos.Enabled = false; + + btUpdate.Enabled = true; + btSell.Enabled = true; + + btUpdate_Click(null, null); + } + + private void AddItem(ITEM Item) + { + m_Items.Add(Item); + + if(lvItems.InvokeRequired) + { + lvItems.Invoke(new Action(() => { + lvItems.Items.Add(new ListViewItem(new string[] { + Item.m_strCode, + Item.m_strCodeName, + string.Format("{0:n0}", Item.m_iCurPrice), + string.Format("{0:n0}", Item.m_iAvailableQuantity), + string.Format("{0:n2}", Item.m_dBookUnitPrice), + string.Format("{0:n0}", Item.m_iProfitUnitPrice), + string.Format("{0:n0}", Item.m_iAssessedValue), + string.Format("{0:n0}", Item.m_iValuationGains), + string.Format("{0:n2}", Item.m_dYield), + "", + "", + })); + + var listviewItem = lvItems.Items[lvItems.Items.Count - 1]; + + lvItems.Items[lvItems.Items.Count - 1].UseItemStyleForSubItems = false; + lvItems.Items[lvItems.Items.Count - 1].SubItems[chValuation.Index].ForeColor = (Item.m_iValuationGains > 0) ? Color.Red : (Item.m_iValuationGains < 0) ? Color.Blue : Color.Black; + lvItems.Items[lvItems.Items.Count - 1].SubItems[chYield.Index].ForeColor = (Item.m_dYield > 0) ? Color.Red : (Item.m_dYield < 0) ? Color.Blue : Color.Black; + + m_CybosHelper.Subscribe(Item); + })); + } + else + { + lvItems.Items.Add(new ListViewItem(new string[] { + Item.m_strCode, + Item.m_strCodeName, + string.Format("{0:n0}", Item.m_iCurPrice), + string.Format("{0:n0}", Item.m_iAvailableQuantity), + string.Format("{0:n2}", Item.m_dBookUnitPrice), + string.Format("{0:n0}", Item.m_iProfitUnitPrice), + string.Format("{0:n0}", Item.m_iAssessedValue), + string.Format("{0:n0}", Item.m_iValuationGains), + string.Format("{0:n2}", Item.m_dYield), + "", + "", + })); + + var listviewItem = lvItems.Items[lvItems.Items.Count - 1]; + + lvItems.Items[lvItems.Items.Count - 1].UseItemStyleForSubItems = false; + lvItems.Items[lvItems.Items.Count - 1].SubItems[chValuation.Index].ForeColor = (Item.m_iValuationGains > 0) ? Color.Red : (Item.m_iValuationGains < 0) ? Color.Blue : Color.Black; + lvItems.Items[lvItems.Items.Count - 1].SubItems[chYield.Index].ForeColor = (Item.m_dYield > 0) ? Color.Red : (Item.m_dYield < 0) ? Color.Blue : Color.Black; + + m_CybosHelper.Subscribe(Item); + } + } + + private void btUpdate_Click(object sender, EventArgs e) + { + var Items = m_CybosHelper.UpdateItems(); + + m_Items.Clear(); + lvItems.Items.Clear(); + foreach (var Item in Items) + AddItem(Item); + } + + public void UpdateItem(string strCode, string strCodeName, bool bBid, int iConclusionCnt, int iRemainCnt, int iBookValue) + { + btUpdate_Click(null, null); + //if(lvList.InvokeRequired) + //{ + + //} + //else + //{ + // ListViewItem Item = lvList.Items.Cast().FirstOrDefault(s => s.SubItems[chCode.Index].Text == strCode); + // if(Item == default(ListViewItem) && iRemainCnt > 0) + // { + // // 아이템 추가 + // } + // else + // { + // // 갱신 + // Item.SubItems[chCount.Index].Text = string.Format("{0:n0}", iRemainCnt); + // Item.SubItems[chBookValue.Index].Text = string.Format("{0:n2}", iBookValue); + // } + //} + } + + private void btSell_Click(object sender, EventArgs e) + { + btSell.Primary = !btSell.Primary; + m_bSell = (btSell.Primary == false); + } + + public bool IsSelling() + { + return m_bSell; + } + + public void OnReceivedCurPrice(string strCode, int iPrice, int iMaxPrice, int iCheckCount) + { + ITEM Item = m_Items.FirstOrDefault(s => s.m_strCode == strCode); + if (Item == default(ITEM)) + return; + + Item.m_iCurPrice = iPrice; + Item.m_iAssessedValue = (int)(iPrice * Item.m_iAvailableQuantity * 99.94 / 100); + Item.m_dYield = (Item.m_iCurPrice - Item.m_iProfitUnitPrice) * 100 / (double)Item.m_iProfitUnitPrice; + + if (lvItems.InvokeRequired) + { + lvItems.Invoke(new Action(() => + { + ListViewItem row = lvItems.Items.Cast().FirstOrDefault(s => s.SubItems[chCode.Index].Text == strCode); + if (row == default(ListViewItem)) + return; + + row.SubItems[chCurPrice.Index].Text = string.Format("{0:n0}", Item.m_iCurPrice); + row.SubItems[chAssessedValue.Index].Text = string.Format("{0:n0}", Item.m_iAssessedValue); + row.SubItems[chYield.Index].Text = string.Format("{0:n2}", Item.m_dYield); + row.SubItems[chMaxPrice.Index].Text = string.Format("{0:n0}", iMaxPrice); + row.SubItems[chCheckCount.Index].Text = string.Format("{0:n0}", iCheckCount); + })); + } + else + { + ListViewItem row = lvItems.Items.Cast().FirstOrDefault(s => s.SubItems[chCode.Index].Text == strCode); + if (row == default(ListViewItem)) + return; + + row.SubItems[chCurPrice.Index].Text = string.Format("{0:n0}", Item.m_iCurPrice); + row.SubItems[chAssessedValue.Index].Text = string.Format("{0:n0}", Item.m_iAssessedValue); + row.SubItems[chYield.Index].Text = string.Format("{0:n2}", Item.m_dYield); + row.SubItems[chMaxPrice.Index].Text = string.Format("{0:n0}", iMaxPrice); + row.SubItems[chCheckCount.Index].Text = string.Format("{0:n0}", iCheckCount); + } + + if(strCode == m_strSelectedCode) + { + if (lvCurPrice.InvokeRequired) + { + lvCurPrice.Invoke(new Action(() => { + lvCurPrice.Items[10].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", Item.m_iCurPrice); + })); + } + else + { + lvCurPrice.Items[10].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", Item.m_iCurPrice); + } + } + } + + public void OnReceivedCall(string strCode, int[] aiBidPrice, int[] aiBidCount, int[] aiAskPrice, int[] aiAskCount) + { + if (strCode != m_strSelectedCode) + return; + + ITEM Item = m_Items.FirstOrDefault(s => s.m_strCode == strCode); + if (Item == default(ITEM)) + return; + + if (lvCurPrice.InvokeRequired) + { + lvCurPrice.Invoke(new Action(() => { + for (int i = 0; i < 10; i++) + { + lvCurPrice.Items[i].SubItems[chAskCount.Index].Text = string.Format("{0:n0}", aiAskCount[9-i]); + lvCurPrice.Items[i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiAskPrice[9-i]); + } + + for (int i = 0; i < 10; i++) + { + lvCurPrice.Items[11 + i].SubItems[chBidCount.Index].Text = string.Format("{0:n0}", aiBidCount[i]); + lvCurPrice.Items[11 + i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiBidPrice[i]); + } + })); + } + else + { + for (int i = 0; i < 10; i++) + { + lvCurPrice.Items[i].SubItems[chAskCount.Index].Text = string.Format("{0:n0}", aiAskCount[9-i]); + lvCurPrice.Items[i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiAskPrice[9-i]); + } + + for (int i = 0; i < 10; i++) + { + lvCurPrice.Items[11+i].SubItems[chBidCount.Index].Text = string.Format("{0:n0}", aiBidCount[i]); + lvCurPrice.Items[11+i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiBidPrice[i]); + } + } + } + + public int GetSellableCount(string strCode) + { + ITEM Item = m_Items.FirstOrDefault(s => s.m_strCode == strCode); + if(Item == default(ITEM)) + return 0; + + return Item.m_iSellableCnt; + } + + private void lvList_SelectedIndexChanged(object sender, EventArgs e) + { + if (lvItems.SelectedItems.Count <= 0) + return; + + string strCode = lvItems.SelectedItems[0].SubItems[chCode.Index].Text; + CybosHelper.STOCK_CUR_ITEM Item = m_CybosHelper.GetItem(strCode); + if (Item == null) + return; + + m_strSelectedCode = strCode; + OnReceivedCall(strCode, Item.m_aiBidPrice, Item.m_aiBidCount, Item.m_aiAskPrice, Item.m_aiAskCount); + //OnReceivedCurPrice(strCode, Item.m_iCurPrice); + } + + private void btApply_Click(object sender, EventArgs e) + { + string strAccount = (string)cbAccount.SelectedItem; + string strSubAccount = tbSubAccount.Text; + Config.SetAccount(strAccount, strSubAccount); + + int iBidCount = 0; + int.TryParse(tbBidCount.Text, out iBidCount); + Config.SetBidCount(iBidCount); } } } diff --git a/AutoSeller.csproj b/AutoSeller.csproj index 152e49f..7b89945 100644 --- a/AutoSeller.csproj +++ b/AutoSeller.csproj @@ -12,6 +12,21 @@ v4.5.2 512 true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -32,6 +47,21 @@ prompt 4 + + false + + + false + + + LocalIntranet + + + false + + + Properties\app.manifest + packages\MaterialSkin.0.2.1\lib\MaterialSkin.dll @@ -50,6 +80,7 @@ + Form @@ -57,6 +88,9 @@ AutoSeller.cs + + Component + @@ -73,6 +107,9 @@ Resources.resx + + Designer + SettingsSingleFileGenerator Settings.Designer.cs @@ -151,7 +188,28 @@ True + + + False + Microsoft .NET Framework 4.5.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + if NOT "$(ConfigurationName)" == "Release" (goto :nocopy) + +copy $(TargetPath) $(ProjectDir)publish\ /y +copy $(TargetDir)*.dll $(ProjectDir)publish\ /y + +:nocopy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Util.cs b/Util.cs index f2b2de1..a767fc1 100644 --- a/Util.cs +++ b/Util.cs @@ -8,7 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace AutoSeller +namespace AutoSellerNS { static class Util { @@ -17,13 +17,8 @@ namespace AutoSeller DEBUG, ERROR, VERVOSE, - NEGATIVE, - POSITIVE, - MANUAL_KEYWORD, - MANUAL_CODE, - DUPLICATED, - DENIAL, BUY, + SELL, } static string m_strLogFile = null; static RichTextBox m_LogBox = null; @@ -61,13 +56,9 @@ namespace AutoSeller case LOG_TYPE.VERVOSE: LogColor = Color.Black; break; - case LOG_TYPE.NEGATIVE: - case LOG_TYPE.DENIAL: - case LOG_TYPE.DUPLICATED: + case LOG_TYPE.SELL: LogColor = Color.Blue; break; - case LOG_TYPE.POSITIVE: - case LOG_TYPE.MANUAL_KEYWORD: case LOG_TYPE.BUY: LogColor = Color.Red; break;