private void printList(Dictionary <int, StockData> stockPool) { dataGridView_.Rows.Clear(); const int INIT_INDEX = 1; int index = INIT_INDEX; var rankDesc = stockPool.OrderByDescending(num => num.Value.valuation_); foreach (KeyValuePair <int, StockData> keyValue in rankDesc) { int code = keyValue.Key; StockData orgData = keyValue.Value; StockData stockData = (StockData)orgData.Clone(); //정렬을 위해... string column = "2_감시"; if (stockData.isBuyedStock()) { column = "1_보유"; } string valuation = String.Format("{0:D4}", stockData.valuation_); string codeString = stockData.codeString(); string name = stockData.name_; string nowPrice = stockData.nowPrice(priceType_).ToString(); string buyCount = ""; string buyPrice = ""; string totalBuyPrice = ""; string profitPrice = ""; string profitPriceRate = ""; if (stockData.isBuyedStock()) { BuyedStockData buyedStockData = (BuyedStockData)stockData; buyCount = buyedStockData.buyCount_.ToString(); buyPrice = buyedStockData.buyPrice_.ToString(); totalBuyPrice = buyedStockData.totalBuyPrice().ToString(); profitPrice = buyedStockData.profitPrice().ToString(); profitPriceRate = buyedStockData.profitPriceRate().ToString(); } string indexStr = String.Format("{0:D3}", index); string[] row = new string[] { column, valuation, indexStr, codeString, name, nowPrice, buyCount, buyPrice, totalBuyPrice, profitPrice, profitPriceRate }; dataGridView_.Rows.Add(row); index++; } dataGridView_.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); //첫열을 기준으로 정렬을 시켜서 구입한 주식을 위로 올린다. dataGridView_.Sort(dataGridView_.Columns[0], System.ComponentModel.ListSortDirection.Ascending); }
private void setTitle() { string title = stockData_.codeString() + ":" + stockData_.name_ + " / " + priceType_.ToString(); if (titleFont_ != null) { titleFont_ = null; } titleFont_ = this.getFont(14.0F, FontStyle.Bold); chartStock_.Titles[0].Font = titleFont_; chartStock_.Titles[0].Text = title; chartStock_.ChartAreas[0].BorderDashStyle = ChartDashStyle.Solid; /* Border 영역 줄 긋기 */ chartMacd_.Titles[0].Font = titleFont_; chartMacd_.Titles[0].Text = title; chartMacd_.ChartAreas[0].BorderDashStyle = ChartDashStyle.Solid; /* Border 영역 줄 긋기 */ }
// 셀을 선택했을때 처리 public void cellClick(Object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || e.RowIndex >= (dataGridView_.RowCount - 1)) { return; } int stockCode = int.Parse(dataGridView_.Rows[e.RowIndex].Cells[3].Value.ToString()); StockData stockData = StockManager.getInstance.stockData(stockCode); if (stockData == null) { return; } //TODO : 주식 선택시 다른 정보 표시를 하고 싶으면 이 이하에 추가 한다. StockChart.getInstance.drawStock(stockData); StockWebBrowser.getInstance.searchWeb(stockData.codeString()); }
private void consolePrintList(Dictionary <int, StockData> stockPool) { Logger.getInstance.consolePrint("============================================================="); foreach (KeyValuePair <int, StockData> keyValue in stockPool) { int code = keyValue.Key; StockData orgData = keyValue.Value; StockData stockData = (StockData)orgData.Clone(); //정렬을 위해... string column = "2_감시"; if (stockData.isBuyedStock()) { column = "1_보유"; } string codeString = stockData.codeString(); string name = stockData.name_; string nowPrice = stockData.nowPrice(priceType_).ToString(); string buyCount = ""; string buyPrice = ""; string totalBuyPrice = ""; string profitPrice = ""; string profitPriceRate = ""; if (stockData.isBuyedStock()) { BuyedStockData buyedStockData = (BuyedStockData)stockData; buyCount = buyedStockData.buyCount_.ToString(); buyPrice = buyedStockData.buyPrice_.ToString(); totalBuyPrice = buyedStockData.totalBuyPrice().ToString(); profitPrice = buyedStockData.profitPrice().ToString(); profitPriceRate = buyedStockData.profitPriceRate().ToString(); } Logger.getInstance.consolePrint("{0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8}", column, codeString, name, nowPrice, buyCount, buyPrice, totalBuyPrice, profitPrice, profitPriceRate); } }