//========================================== void showDetailOfGroup(stShareGroup g) { viewState = VIEWSTATE_1_NHOMNGANH; if (g.getTotal() == 1 && (g.getName().CompareTo("^VNINDEX") == 0 || g.getName().CompareTo("^HASTC") == 0 || g.getName().CompareTo("^UPCOM") == 0)) { int cnt = mContext.mShareManager.getShareCount(); int[] market = { 0 }; int marketID = 1; if (g.getName().CompareTo("^HASTC") == 0) { marketID = 2; } else if (g.getName().CompareTo("^UPCOM") == 0) { marketID = 3; } for (int i = 0; i < cnt; i++) { int shareID = mContext.mShareManager.getShareIDAt(i, market); if (shareID > 0 && market[0] == marketID) { g.addCode(mContext.mShareManager.getShareCode(shareID)); } } } chartG = new ChartTangtruongGroup(); chartG.setGroup(g); chartG.setPosition(0, 0); chartG.onBack += dismissGroupDetail; //chartG.setSize(mPriceboardContainer); int h = getH();// chartG.estimateH(getH(), g.getTotal()); if (h < getH()) { h = getH(); } //list.setSize(W_PRICEBOARD, mPriceboardH); chartG.setSize(getW() - 20, h); chartG.onBack += dismissGroupDetail; chartG.onHistoryClick += delegateShowHistoryChartOfGroup; chartG.onClickShare += delegateShowHistoryChartOfShare; chartG.onProcessingCompleted += onProcessingCompleted; chartG.onProcessingStart += onProcessingStart; invalidate(); }
//========================================== void loadShareGroup(xDataInput di) { int cnt = di.readInt(); if (cnt > stShareGroup.MAX_SHARES_IN_GROUP) { cnt = stShareGroup.MAX_SHARES_IN_GROUP; } xVector v = shareGroups(); if (cnt > 0) { v.removeAllElements(); } for (int i = 0; i < cnt; i++) { stShareGroup g = new stShareGroup(); g.load(di); if (g.getType() == stShareGroup.ID_GROUP_GAINLOSS || g.getName() == null || g.getName().Length == 0) { continue; } v.addElement(g); } }
public override void onMouseUp(int x, int y) { if (x >= 4 && x < 80 && y >= 4 && y < 20) { if (onBack != null) { onBack(); return; } } if (x >= getW() - 80 && x < getW() && y >= 4 && y < 20) { if (onHistoryClick != null) { mContext.mShareManager.calcIndexOfGroup(shareGroup); onHistoryClick(shareGroup.getName()); return; } } for (int i = 0; i < mButtonPositions.size(); i++) { Rectangle rc = (Rectangle)mButtonPositions.elementAt(i); if (rc.Contains(x, y)) { mPeriod = mPeriods.elementAt(i); isProcessing = true; if (onProcessingStart != null) { onProcessingStart(); } doCalcChanged(); return; } } if (onClickShare != null) { for (int i = 0; i < mChanges.size(); i++) { ShareChanges gc = (ShareChanges)mChanges.elementAt(i); if (x >= gc.x && x <= gc.x + gc.w && y >= gc.y && y <= gc.y + gc.h) { onClickShare(gc.code); } } } }
xDataOutput shareGroupsBlock() { xDataOutput o = new xDataOutput(5 * 1024); xVector v = new xVector(); for (int i = 0; i < _shareGroups.size(); i++) { stShareGroup p = (stShareGroup)_shareGroups.elementAt(i); if (p.getType() == stShareGroup.ID_GROUP_GAINLOSS || p.getName() == null || p.getName().Length == 0) { continue; } v.addElement(p); } // int groupCnt = v.size() < 30? v.size():30; o.writeInt(groupCnt); for (int i = 0; i < groupCnt; i++) { stShareGroup p = (stShareGroup)v.elementAt(i); if (p.getType() == stShareGroup.ID_GROUP_GAINLOSS || p.getName() == null || p.getName().Length == 0) { continue; } p.save(o); } return(o); }
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 setShareGroup(stShareGroup g, int sortType) { if (mTableType == TABLE_GAINLOSS) { setShareGroupAsFilterResult(g, sortType); return; } //========================= this.removeAllControls(); mTableType = TABLE_NORMAL_PRICEBOARD; if (g == null) { return; } _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); addControl(l); y = (int)l.getBottom() + 1; } bool deletable = g.getType() == stShareGroup.ID_GROUP_FAVOR; if (deletable) { Utils.trace("++++++++++===============row is detelable"); } for (int i = 0; i <= cnt; i++) { int idx = i - 1; int rH = i == 0? 36: rowH; RowNormalShare r; if (g.getType() == stShareGroup.ID_GROUP_INDICES) { r = new RowIndice(mListener, i, rowW, rH); if (idx >= 0) { String code = g.getCodeAt(idx); if (code != null && code.Length > 0) { r.setData(code); } else { continue; } //r.mAllowDelete = deletable; } } else { r = new RowNormalShare(mListener, i, rowW, rH); r.onShowSortMenu += delegateShowSortMenu; r.onSortABC += delegateSortABC; if (idx >= 0) { int shareID = g.getIDAt(idx); String code = g.getCodeAt(idx); if (code != null && code.Length > 0 && shareID >= 0) { r.setData(code); } else { continue; } //r.mAllowDelete = deletable; } } r.setParent(this); r.setSortType(sortType); r.setPosition(0, y); r.invalidate(); addControl(r); vRows.addElement(r); y += rH + 1; } if (g.getType() == stShareGroup.ID_GROUP_FAVOR) { xFillBackground bottom = xFillBackground.createFill(rowW, 1, C.COLOR_GRAY_LIGHT); bottom.setPosition(0, y); addControl(bottom); y += 1; l = xLabel.createSingleLabel("Click phím phải chuột để thêm/xóa mã hoặc nhóm"); l.setTextColor(C.COLOR_WHITE); l.setPosition(l.getW() - 4, y + 3); addControl(l); int tmp = l.getX(); // xoa nhom y = (int)l.getBottom() + 4; /* * bt = xUIButton.createButton(listener, C.ID_BUTTON_REMOVE_GROUP, " - ", bw); * bt.setSize(bw, xApplication.point2Pixels(40)); * bt.setPosition(w - bw - 2, y+1); * addControl(bt); * * l = xLabel.createSingleLabel("Xóa nhóm ->", AppContext.getInstance().getFontText()); * l.setTextColor(C.COLOR_RED); * l.setPosition(bt.getX() - l.getW() - 4, y + (bt.getH()-l.getH())/2); * addControl(l); * * y += bt.getH() + 2; */ } xFillBackground fillBottom = xFillBackground.createFill(rowW, 2, C.COLOR_GRAY_LIGHT); fillBottom.setPosition(0, y); addControl(fillBottom); invalidate(); }
void calcChanged(int period) { stCandle c0 = new stCandle(); stCandle c1 = new stCandle(); mChanges.removeAllElements(); Utils.trace("----------------------"); bool isNhomIndex = false; for (int i = 0; i < mGroups.size(); i++) { stShareGroup g = (stShareGroup)mGroups.elementAt(i); GroupChanges gc = new GroupChanges(); gc.group = g; mChanges.addElement(gc); gc.code = g.getName(); Utils.trace(g.getName()); double firstGTGD = 0; double lastGTGD = 0; double totalGTGD0 = 0; double totalGTGD1 = 0; int today = 0; isNhomIndex = false; if (g.getType() == stShareGroup.ID_GROUP_MARKET_OVERVIEW && g.getTotal() == 1) { isNhomIndex = true; String code = g.getCodeAt(0); Share share = mContext.mShareManager.getShare(code); if (share == null) { continue; } share.loadShareFromFile(false); share.appendTodayCandle2(); int last = share.getCandleCnt() - 1; int first = (last > period)?(last - period):0; if (last < 0 || first < 0) { continue; } c0 = share.getCandle(last, c0); c1 = share.getCandle(first, c1); if (c1.close > 0) { double changed = 100 * (c0.close - c1.close) / c1.close; gc.changedPercent += changed; } continue; } for (int j = 0; j < g.getTotal(); j++) { string code = g.getCodeAt(j); Share share = Context.getInstance().mShareManager.getShare(code); int shareID = Context.getInstance().mShareManager.getShareID(code); stCompanyInfo info = Context.getInstance().mShareManager.getCompanyInfo(shareID); if (share != null && info != null) { share.loadShareFromCommonData(true); int last = share.getCandleCnt() - 1; int first = (last > period)?(last - period):0; if (last < 0 || first < 0) { continue; } share.getCandle(last, c0); share.getCandle(first, c1); double changed; if (period == 1 && c0.date < today) { // khong co giao dich hom nay changed = 0; } else { double r = (info.volume * c1.close); changed = 0;// (c0.close - c1.close) * r; changed = 100 * (c0.close - c1.close) / c1.close; changed *= r; } totalGTGD0 += (c0.close * info.volume); totalGTGD1 += (c1.close * info.volume); gc.changedPercent += changed; //String s = String.Format("Code: {0}, Price: Close0/Close1={1}/{2}, r={3} changed/totalChanged: {4}/{5}", //share.getCode(), c0.close, c1.close, r, changed, gc.changedPercent); //Utils.trace(s); } gc.changedPercent = 100 * (totalGTGD0 - totalGTGD1); gc.changedPercent /= totalGTGD1; } //Utils.trace(String.Format("Total changed: {0}", gc.changedPercent)); } // sort if (false)//isNhomIndex) { // khong sort } else { xVector marketOverView = new xVector(); for (int i = 0; i < mChanges.size() - 1; i++) { GroupChanges g = (GroupChanges)mChanges.elementAt(i); if (g.group.getType() == stShareGroup.ID_GROUP_MARKET_OVERVIEW || g.code.IndexOf('#') == 0) { marketOverView.addElement(g); } } for (int i = 0; i < marketOverView.size(); i++) { mChanges.removeElement(marketOverView.elementAt(i)); } //================================ for (int i = 0; i < mChanges.size() - 1; i++) { GroupChanges biggest = (GroupChanges)mChanges.elementAt(i); int biggestIdx = i; for (int j = i + 1; j < mChanges.size(); j++) { GroupChanges gc = (GroupChanges)mChanges.elementAt(j); if (gc.changedPercent > biggest.changedPercent) { biggest = gc; biggestIdx = j; } } if (biggestIdx != i) { mChanges.swap(i, biggestIdx); } } //======================== for (int i = 0; i < mChanges.size(); i++) { marketOverView.addElement(mChanges.elementAt(i)); } mChanges.removeAllElements(); for (int i = 0; i < marketOverView.size(); i++) { mChanges.addElement(marketOverView.elementAt(i)); } } }
public xDataOutput getUserDataAsStreamOldVersion() { xDataOutput o = new xDataOutput(5 * 1024); o.writeInt(FILE_ONLINE_USERDATA_VER); int i; xVector v = new xVector(10); xVector mFavorGroups = shareGroups(); GainLossManager mGainLossManager = gainLossManager(); int groupCnt = mFavorGroups.size() < 30?mFavorGroups.size():30; for (i = 0; i < groupCnt; i++) { stShareGroup p = (stShareGroup)mFavorGroups.elementAt(i); bool added = false; for (int j = 0; j < v.size(); j++) { stShareGroup o1 = (stShareGroup)v.elementAt(j); if (o1.getName().CompareTo(p.getName()) == 0) { added = true; break; } } if (added == false) { v.addElement(p); } } o.writeInt(v.size()); for (i = 0; i < v.size(); i++) { stShareGroup p = (stShareGroup)v.elementAt(i); p.save(o); } // gainloss com.data o.writeInt(FILE_GAINLOSS_SIGNAL); o.writeInt(mGainLossManager.getTotal()); for (i = 0; i < mGainLossManager.getTotal(); i++) { stGainloss g = mGainLossManager.getGainLossAt(i); o.writeUTF(g.code); o.writeInt(g.date); o.writeInt((int)g.price); o.writeInt(g.volume); } // filter sets o.writeInt(FILE_FILTER_SET_VERSION); FilterManager.getInstance().saveFilterSets(o); // down signal group //o.writeInt(FILE_DOWN_SIGNAL); //mAlarmGroup.save(o); return(o); }
/* * protected xBaseControl createShareGroupDroplist(int id, String title, xVector groups) * { * xContainer c = new xContainer(); * xLabel l = xLabel.createSingleLabel(title, mContext.getFontTextB(), 150); * l.setTextColor(C.COLOR_BLUE); * l.setSize(l.getW(), 16); * int w = 150; * l.setPosition(0, 0); * c.addControl(l); * * ComboBox cb = new ComboBox(); * c.addControl(cb); * cb.Size = new Size(w, cb.Size.Height); * cb.Left = 0; * cb.Top = l.getBottom(); * cb.DropDownStyle = ComboBoxStyle.DropDownList; * * stShareGroup current = mContext.getCurrentShareGroup(); * * for (int i = 0; i < groups.size(); i++) * { * stShareGroup favor = (stShareGroup)groups.elementAt(i); * cb.Items.Add(favor.getName()); * * if (current != null && favor.getName().CompareTo(current.getName()) == 0) * { * cb.SelectedIndex = i; * mContext.setCurrentShareGroup(favor); * } * } * * cb.Tag = (Int32)id; * cb.SelectedIndexChanged += new EventHandler(cb_SelectedIndexChanged); * * c.setSize(w, 40); * * return c; * } */ protected xBaseControl createShareGroupList(bool editable, int id, String title, xVector groups, int w, int h) { xContainer c = new xContainer(); c.setSize(w, h); Font f = Context.getInstance().getFontText(); xLabel l = xLabel.createSingleLabel(title, f, w); l.setBackgroundColor(C.COLOR_ORANGE); l.setTextColor(C.COLOR_WHITE); c.addControl(l); int titleH = l.getH(); xContainer c1 = new xContainer(); if (editable) { c1.setSize(w, h - 30 - titleH); } else { c1.setSize(w, h - 6 - titleH); } c1.setPosition(0, l.getH()); c.addControl(c1); stShareGroup current = mContext.getCurrentShareGroup(); string[] ss = { title }; float[] cols = { 100.0f }; xListView list = xListView.createListView(this, ss, cols, w, c1.getH(), Context.getInstance().getImageList(C.IMG_BLANK_ROW_ICON, 1, 21)); list.hideHeader(); list.setID(id); ((ListView)list.getControl()).HideSelection = false; ((ListView)list.getControl()).Scrollable = true; list.setBackgroundColor(C.COLOR_GRAY_DARK); int y = 0; for (int i = 0; i < groups.size(); i++) { stShareGroup favor = (stShareGroup)groups.elementAt(i); xListViewItem item = xListViewItem.createListViewItem(this, new string[] { favor.getName() }); uint color = C.COLOR_WHITE; //if (favor.getGroupType() == stShareGroup.ID_GROUP_MARKET_OVERVIEW) //{ //color = C.COLOR_ORANGE; //} if (favor.getGroupType() == stShareGroup.ID_GROUP_GAINLOSS) { color = C.COLOR_ORANGE; } item.getItem().SubItems[0].Font = mContext.getFontText2(); item.getItem().SubItems[0].ForeColor = Color.FromArgb((int)color); item.setData(favor); list.addRow(item); } c1.addControl(list); //==================== if (editable) { xButton bt; bt = xButton.createStandardButton(C.ID_ADD_GROUP, this, "Thêm nhóm", w / 2 - 2); bt.setPosition(1, c1.getBottom() + 3); c.addControl(bt); bt = xButton.createStandardButton(C.ID_REMOVE_GROUP, this, "Xóa nhóm", w / 2 - 2); bt.setPosition(w / 2 + 1, c1.getBottom() + 3); c.addControl(bt); } return(c); }