private void comBoxLoadTaobaoFileter_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = Directory.GetCurrentDirectory(); if (dlg.ShowDialog() != DialogResult.OK) { return; } comBoxLoadTaobaoFileter.Text = dlg.SafeFileName; //-------------------------------------------- string sLine = ""; StreamReader objReader = new StreamReader(dlg.FileName); listLtTaobaoFilter.Clear(); while (sLine != null) { sLine = objReader.ReadLine(); if (sLine != null && !sLine.Equals(string.Empty)) { LtItem item = new LtItem(); if (item.fromString(sLine) < 0) { MessageBox.Show("Wrong data: " + sLine); return; } listLtTaobaoFilter.Add(item); } } objReader.Close(); LtCounter count = new LtCounter(); List <long> allRed = new List <long>(); List <long> red5s = new List <long>(); foreach (LtItem item in listLtTaobaoFilter) { if (count.getItem(item.red, allRed) == 0) { foreach (long map in allRed) { red5s.Clear(); long mapTmp = map & 0x1FFFFFFFF; if (!mapTaob6.ContainsKey(mapTmp)) { mapTaob6.Add(mapTmp, null); } count.get_6_to_5(mapTmp, red5s); for (int i = 0; i < 6; ++i) { if (!mapTaob5.ContainsKey(red5s[i])) { mapTaob5.Add(red5s[i], null); } } } } allRed.Clear(); } }
private void btFindExist_Click(object sender, EventArgs e) { string numFind = numToFindExist.Text.Trim(); if (numFind.Length < 2) { return; } long ONE = 1; long mapFind = 0; int redCount = 0; int[] red = { 0, 0, 0, 0, 0, 0 }; string[] nums = numFind.Split(' '); for (int i = 0; i < 6 && i < nums.Length; ++i) { red[i] = Int32.Parse(nums[i]); if (red[i] < 1 || red[i] > 33) { return; } mapFind |= ONE << (red[i] - 1); redCount++; } //---------------------------------------------- if (comBoxExistData.SelectedIndex == 0) { if (gridList.Count < 1) { return; } int[] countIndex = { 0, 0, 0, 0, 0, 0, 0 }; gridFindExist.DataSource = listFindExist; listFindExist.Clear(); foreach (LottoryItem item in gridList) { long tmpMap = mapFind & item.map; tmpMap &= 0x1FFFFFFFF; int same = Combin.bit_count(tmpMap); countIndex[same]++; string numStr = string.Format("{0:00} {1:00} {2:00} {3:00} {4:00} {5:00} {6:00}" , item.red[0], item.red[1], item.red[2], item.red[3], item.red[4], item.red[5], item.blue); CountExist countex = new CountExist(item.id, numStr, same); listFindExist.Add(countex); } for (int i = 0; i < 7; ++i) { CountExist countex = new CountExist(i, countIndex[i].ToString(), 10 + i); listFindExist.Add(countex); } gridViewFindExist.SortInfo.Add(gridViewFindExist.Columns[2], ColumnSortOrder.Descending); gridViewFindExist.Focus(); SendKeys.SendWait("^{HOME}"); } else if (comBoxExistData.SelectedIndex == 1) { if (listLtTaobao.Count < 1) { return; } int matchCount = 0; LtCounter count = new LtCounter(); List <long> allRed = new List <long>(); List <long> red5s = new List <long>(); int[] countIndex = { 0, 0, 0, 0, 0, 0, 0 }; gridFindExist.DataSource = listFindExist; listFindExist.Clear(); foreach (LtItem item in listLtTaobao) { matchCount = 0; if (count.getItem(item.red, allRed) == 0) { foreach (long map in allRed) { int mcount = Combin.bit_count(map & mapFind); if (mcount > matchCount) { matchCount = mcount; } red5s.Clear(); long mapTmp = map & 0x1FFFFFFFF; if (!mapTaob6.ContainsKey(mapTmp)) { mapTaob6.Add(mapTmp, null); } count.get_6_to_5(mapTmp, red5s); for (int i = 0; i < 6; ++i) { if (!mapTaob5.ContainsKey(red5s[i])) { mapTaob5.Add(red5s[i], null); } } } countIndex[matchCount]++; CountExist countex = new CountExist(item.user, item.red, matchCount); listFindExist.Add(countex); } allRed.Clear(); } for (int i = 0; i < 7; ++i) { CountExist countex = new CountExist(i, countIndex[i].ToString(), 10 + i); listFindExist.Add(countex); } gridViewFindExist.SortInfo.Add(gridViewFindExist.Columns[2], ColumnSortOrder.Descending); gridViewFindExist.Focus(); SendKeys.SendWait("^{HOME}"); } }