void showGetDaysForRSRankingDialog() { int defValue = GlobalData.getData().getValueInt("rs_ranking_days"); if (defValue == 0) { defValue = 30; } DlgEnterDay dlg = DlgEnterDay.createDialog("Điểm RS so với VNIndex trong số ngày", defValue); if (dlg.ShowDialog() == DialogResult.OK) { int days = dlg.getDays(); if (days <= 1) { days = 30; } else { GlobalData.getData().setValueInt("rs_ranking_days", days); GlobalData.saveData(); } float[] columnPercents = { 30, 28, 34, 8 }; // code, price, value String[] columnTexts = { "Mã CP", "Giá", "Điểm RS/VNIndex", "" }; int sortType = ShareSortUtils.SORT_RS_RANKING; sortedColumn = columnTexts[2]; _sortType = sortType; xVector sorted = shareGroupToVector(); ShareSortUtils.doSort(sorted, sortType, days); _shareGroup.clear(); for (int i = 0; i < sorted.size(); i++) { Share share = (Share)sorted.elementAt(i); _shareGroup.addCode(share.mCode); } columnTexts[2] = "▼ " + columnTexts[2]; //================== setShareGroup(_shareGroup, sortType); } }
// code | _ref | KL1 | G1 |= GiaKhop | KLKhop | TongKL =| KL1 | G1 |=== TB | Cao | Thap virtual protected void updateQuote() { if (getID() < 0) { return; } Context ctx = Context.getInstance(); stCell c; if (getID() == 0) { // code setCellValue(0, "▼ Mã\nTC", C.COLOR_ORANGE); setCellValue(2, "M3/KL", C.COLOR_GRAY); setCellValue(3, "M2/KL", C.COLOR_GRAY); setCellValue(4, "M1/KL", C.COLOR_GRAY); setCellValue(5, "Khớp", C.COLOR_GRAY); setCellValue(6, "+/-", C.COLOR_GRAY); setCellValue(7, "B1/KL", C.COLOR_GRAY); setCellValue(8, "B2/KL", C.COLOR_GRAY); setCellValue(9, "B3/KL", C.COLOR_GRAY); setCellValue(10, "H/L", C.COLOR_GRAY); setCellValue(11, "TổngKL", C.COLOR_GRAY); /* * c = getCellAt(11); * if (c != null) * { * c.text2 = "DưB"; * c.textColor2 = C.COLOR_GRAY; * } */ if (sortType == ShareSortUtils.SORT_DUMUA_DUBAN) { setCellValue(12, "▼ Dư\nM/B", C.COLOR_ORANGE); } else { setCellValue(12, "▼ " + ShareSortUtils.sortTypeToString(sortType), C.COLOR_ORANGE); } } if (getID() == 0) { return; } String code = (String)getUserData(); if (code == null) { return; } stPriceboardState item = ctx.mPriceboard.getPriceboard(code); stPriceboardState ps = item; if (item == null) { return; } Share share = ctx.mShareManager.getShare(ps.id); if (share == null) { return; } String s; // code uint color; setCellValue(0, code, C.COLOR_WHITE); addCellValue1(0, String.Format("{0:F2}", item.getRef()), C.COLOR_YELLOW); float _ref = item.getRef(); int j = 0; float v; int[] rbc = { 2, 3, 4 }; // remain buy col float[] rb = { ps.getRemainBuyPrice2(), ps.getRemainBuyPrice1(), ps.getRemainBuyPrice0() }; int[] rbv = { ps.getRemainBuyVolume2(), ps.getRemainBuyVolume1(), ps.getRemainBuyVolume0() }; int[] rsc = { 7, 8, 9 }; float[] rs = { ps.getRemainSellPrice0(), ps.getRemainSellPrice1(), ps.getRemainSellPrice2() }; int[] rsv = { ps.getRemainSellVolume0(), ps.getRemainSellVolume1(), ps.getRemainSellVolume2() }; // mua1, mua2, mua3 for (j = 0; j < 3; j++) { // price color = ctx.valToColorF(rb[j], item.getCe(), item.getRef(), item.getFloor()); setCellValue(rbc[j], String.Format("{0:F2}", rb[j]), color); // vol s = volumeToString(rbv[j]); addCellValue1(rbc[j], s); } // Khop float currentPrice = item.getCurrentPrice(); int currentVol = item.getCurrentVolume(); color = ctx.valToColorF(currentPrice, item.getCe(), item.getRef(), item.getFloor()); setCellValue(5, String.Format("{0:F2}", currentPrice), color); s = volumeToString(currentVol); addCellValue1(5, s); // change +/- v = currentPrice - item.getRef(); s = String.Format("{0:F2}", (float)v); if (currentPrice == 0) { s = "-"; } setCellValue(6, s, color); // sell1, sell2, sell3 for (j = 0; j < 3; j++) { // price color = ctx.valToColorF(rs[j], item.getCe(), item.getRef(), item.getFloor()); setCellValue(rsc[j], String.Format("{0:F2}", rs[j]), color); // vol s = volumeToString(rsv[j]); addCellValue1(rsc[j], s); } // cao - thap setCellValue(10, String.Format("{0:F2}", item.getMax()), ctx.valToColorF(item.getMax(), item.getCe(), item.getRef(), item.getFloor())); addCellValue1(10, String.Format("{0:F2}", item.getMin()), ctx.valToColorF(item.getMin(), item.getCe(), item.getRef(), item.getFloor())); // total volume // s = volumeToString(item.getTotalVolume()); // setCellValue(11, s, C.COLOR_WHITE); mVolumeColumn = 11; // cung - cau if (sortType == ShareSortUtils.SORT_DUMUA_DUBAN) { int buy = item.getRemainBuyVolume0() + item.getRemainBuyVolume1() + item.getRemainBuyVolume2(); int sell = item.getRemainSellVolume0() + item.getRemainSellVolume1() + item.getRemainSellVolume2(); String sbuy = volumeToString(buy); String ssell = volumeToString(sell); setCellValue(12, sbuy, C.COLOR_ORANGE); c = getCellAt(12); if (c != null) { c.text2 = ssell; c.textColor2 = C.COLOR_ORANGE; } } else { setCellValue(12, share.mCompareText, C.COLOR_ORANGE); c = getCellAt(12); if (c != null) { c.text2 = null; c.textColor2 = C.COLOR_ORANGE; } } }
public void setShareGroupAsFilterResult(stShareGroup g, int filterType) { mTableType = TABLE_GAINLOSS; this.removeAllControls(); _shareGroup = g; int cnt = g.getTotal(); int y = 0; xLabel l; if (hasTitle) { Font f = Context.getInstance().getFontText(); l = xLabel.createSingleLabel(g.getName(), f, 300); l.setBackgroundColor(C.COLOR_ORANGE); l.setSize(rowW, (int)f.GetHeight() + 4); l.setPosition(0, 0); l.setTextColor(C.COLOR_WHITE); y = (int)l.getBottom() + 1; addControl(l); } // gia tri GD if (filterType <= 0) { filterType = ShareSortUtils.SORT_TRADE_VALUE; xVector v = shareGroupToVector(); if (v != null && v.size() > 0) { ShareSortUtils.evalueSortValueTrade(v); } } //------------------- for (int i = 0; i <= cnt; i++) { int idx = i - 1; int rH = i == 0 ? 36 : rowH; RowNormalShare r = new RowFilterResult(mListener, i, rowW, rH); r.onShowSortMenu += delegateShowSortMenu; r.setSortType(filterType); if (idx >= 0) { String code = g.getCodeAt(idx); if (code != null && code.Length > 0) { r.setData(code); } else { continue; } //r.mAllowDelete = deletable; } r.setParent(this); r.setPosition(0, y); r.invalidate(); addControl(r); vRows.addElement(r); y += rH + 1; } invalidate(); }
void delegateShowSortMenu(Control senderControl) { // show popup menu ContextMenuStrip cm = new ContextMenuStrip(); cm.Items.Add("RSI"); cm.Items.Add("MFI"); cm.Items.Add("Vốn hóa"); cm.Items.Add("Giá trị giao dịch"); cm.Items.Add("EPS"); cm.Items.Add("PE"); cm.Items.Add("Khối lượng"); cm.Items.Add("Khối lượng thay đổi (TB3/TB15)"); cm.Items.Add("Điểm RS/VNIndex"); cm.Items.Add("-"); cm.Items.Add("Xuất danh sách ra file excel(csv)"); cm.ItemClicked += new ToolStripItemClickedEventHandler( (sender, item) => { if (item.ClickedItem.Text.CompareTo("Xuất danh sách ra file excel(csv)") == 0) { xVector filteredShares = shareGroupToVector(); ShareSortUtils.exportGroupToCSV(filteredShares, sortedColumn); return; } float[] columnPercents = { 30, 28, 34, 8 }; // code, price, value String[] columnTexts = { "Mã CP", "Giá", "---", "" }; int sortType = ShareSortUtils.SORT_RSI; if (item.ClickedItem.Text.CompareTo("RSI") == 0) { sortType = ShareSortUtils.SORT_RSI; columnTexts[2] = "RSI"; } else if (item.ClickedItem.Text.CompareTo("MFI") == 0) { sortType = ShareSortUtils.SORT_MFI; columnTexts[2] = "MFI"; } else if (item.ClickedItem.Text.CompareTo("EPS") == 0) { sortType = ShareSortUtils.SORT_EPS; columnTexts[2] = "EPS"; } else if (item.ClickedItem.Text.CompareTo("PE") == 0) { sortType = ShareSortUtils.SORT_PE; columnTexts[2] = "PE"; } else if (item.ClickedItem.Text.CompareTo("Vốn hóa") == 0) { sortType = ShareSortUtils.SORT_VonHoa; columnTexts[2] = "VốnHóa(tỉ)"; } else if (item.ClickedItem.Text.CompareTo("Giá trị giao dịch") == 0) { sortType = ShareSortUtils.SORT_TRADE_VALUE; columnTexts[2] = "GTGD (tỉ)"; } else if (item.ClickedItem.Text.CompareTo("Khối lượng") == 0) { sortType = ShareSortUtils.SORT_VOLUME; columnTexts[2] = "Khối lượng"; } else if (item.ClickedItem.Text.CompareTo("Khối lượng thay đổi (TB3/TB15)") == 0) { sortType = ShareSortUtils.SORT_THAYDOI_VOL; columnTexts[2] = "+/-Vol(%)"; } else if (item.ClickedItem.Text.CompareTo("Điểm RS/VNIndex") == 0) { sortType = ShareSortUtils.SORT_RS_RANKING; columnTexts[2] = "Điểm RS/VNIndex"; showGetDaysForRSRankingDialog(); return; } sortedColumn = columnTexts[2]; _sortType = sortType; xVector sorted = shareGroupToVector(); ShareSortUtils.doSort(sorted, sortType, 0); _shareGroup.clear(); for (int i = 0; i < sorted.size(); i++) { Share share = (Share)sorted.elementAt(i); _shareGroup.addCode(share.mCode); } columnTexts[2] = "▼ " + columnTexts[2]; //================== if (mTableType == TABLE_GAINLOSS) { setShareGroupAsFilterResult(_shareGroup, sortType); } else { setShareGroup(_shareGroup, sortType); } }); int posX = (int)((100 - 7.5f) * rowW); posX /= 100; cm.Show(senderControl.PointToScreen(new Point(posX, 15))); }
// code | ref | KL1 | G1 |= GiaKhop | KLKhop | TongKL =| KL1 | G1 |=== TB | Cao | Thap override protected void updateQuote() { if (getID() < 0) { return; } Context ctx = Context.getInstance(); if (getID() == 0) { // code setCellValue(0, "Mã/Giá", C.COLOR_GRAY); setCellValue(2, "+/-", C.COLOR_GRAY); addCellValue1(2, "%", C.COLOR_GRAY); setCellValue(3, "Khối lượng", C.COLOR_GRAY); setCellValue(4, ShareSortUtils.sortTypeToString(sortType), C.COLOR_ORANGE); } if (getID() == 0) { return; } String code = (String)this.getUserData(); if (code == null) { return; } stPriceboardState item = ctx.mPriceboard.getPriceboard(code); if (item == null) { return; } String s; // code uint color; setCellValue(0, item.getCode(), C.COLOR_WHITE); float reference = item.getRef(); float price = item.getCurrentPrice(); if (price == 0) { price = reference; } color = ctx.valToColorF(item.getCurrentPrice(), item.getCe(), item.getRef(), item.getFloor()); addCellValue1(0, String.Format("{0:F2}", item.getCurrentPrice()), color); int j = 0; // change +/- float v = price - reference; s = String.Format("{0:F2}", (float)v); if (item.getCurrentPrice() == 0) { s = "-"; } setCellValue(2, s, color); // change percent if (reference > 0) { s = String.Format("{0:F1}", (float)((v * 100) / reference)); addCellValue1(2, s, color); } // volume //s = volumeToString(item.getTotalVolume()); //setCellValue(3, s, C.COLOR_WHITE); //Share share = (Share)mFilteredShares.elementAt(row); mVolumeColumn = 3; // short column Share share = Context.getInstance().mShareManager.getShare(getCode()); if (share != null) { setCellValue(4, share.mCompareText, C.COLOR_ORANGE); stCell c = getCellAt(4); if (c != null) { c.text2 = null; c.textColor2 = C.COLOR_ORANGE; } } }