public void CreateFindOptions10() { Create(""); var options = CreateFindOptions(PatternUtil.CreateWholeWord("sample"), SearchKind.Backward, SearchOptions.None); Assert.Equal(FindOptions.WholeWord | FindOptions.MatchCase | FindOptions.SearchReverse, options); }
public void ParseInputTest_NoCenter() { Assert.AreEqual(PatternUtil.ParseInput(new HashSet <int>() { 1, 2, 3, 4 }).Count, 0); }
public void ParseInputTest_InvalidCombinations() { var inputs = new List <HashSet <int> >() { new HashSet <int>() { 1, 3, 5 }, new HashSet <int>() { 2, 4, 5 }, new HashSet <int>() { 6, 8, 5 }, new HashSet <int>() { 1, 3, 9, 5 }, }; for (int i = 0; i < inputs.Count; i++) { var input = inputs[i]; var result = PatternUtil.ParseInput(input); Assert.AreEqual(result.Count, 0); } }
public void FindNextPattern_Regression_InfiniteLoop() { Create("i", "int foo()", "cat"); var pattern = PatternUtil.CreateWholeWord("i"); var result = FindNextPattern(pattern, Path.Backward, _textBuffer.GetPointInLine(2, 1), 1); Assert.True(result.IsFound(0)); }
public void ParseInputTest_MultiplePieces() { var inputs = new List <HashSet <int> >() { new HashSet <int>() { 1, 2, 3, 5 }, new HashSet <int>() { 1, 2, 4, 5 }, new HashSet <int>() { 1, 2, 5, 8, 9 }, new HashSet <int>() { 1, 2, 6, 7, 5 }, }; var expects = new List <List <Pattern> >() { new List <Pattern> { Pattern.A, Pattern.E }, new List <Pattern> { Pattern.A, Pattern.B }, new List <Pattern> { Pattern.A, Pattern.H }, new List <Pattern> { Pattern.A }, }; for (int i = 0; i < inputs.Count; i++) { var input = inputs[i]; var expect = expects[i]; var result = PatternUtil.ParseInput(input); Assert.AreEqual(result.Count, expect.Count); Assert.IsTrue(expect.All(item => result.Contains(item))); } }
public void ParseInputTest_SinglePiece() { var inputs = new List <HashSet <int> >() { new HashSet <int>() { 1, 2, 5 }, new HashSet <int>() { 2, 3, 5 }, new HashSet <int>() { 7, 8, 5 }, new HashSet <int>() { 9, 6, 5 }, }; var expects = new List <Pattern>() { Pattern.A, Pattern.E, Pattern.D, Pattern.G }; for (int i = 0; i < inputs.Count; i++) { var input = inputs[i]; var expect = expects[i]; var result = PatternUtil.ParseInput(input); Assert.AreEqual(result.Count, 1); Assert.IsTrue(result.Contains(expect)); } }
private void btnCreate_Click(object sender, EventArgs e) { int idx = -1; foreach (var item in sourceDatas) { idx++; if (idx < 2) { continue; } if (item.PreCandleItem == null) { continue; } if (item.PreCandleItem.PreCandleItem == null) { continue; } if (item.NextCandleItem == null) { continue; } if (item.NextCandleItem.NextCandleItem == null) { continue; } var p2 = item.PreCandleItem.PreCandleItem; var p1 = item.PreCandleItem; var p0 = item; var n1 = item.NextCandleItem; var n2 = item.NextCandleItem.NextCandleItem; var pList = new List <S_CandleItemData>() { p2, p1, p0 }; var nList = new List <S_CandleItemData>() { n1, n2 }; var cpType = PatternUtil.GetCandlePatternType(p0, pList, nList); if (cpType == CandlePatternTypeEnum.Unknown) { continue; } dgv.Rows[idx].Cells["pattern"].Value = Convert.ToString(cpType); try { var data = new Entities.CandlePattern_Three(); data.CandlePatternType = Convert.ToInt32(cpType).ToString(); data.Item = selectedItem; data.Product = selectedType; data.TimeInterval = Convert.ToInt32(selectedTimeInterval); data.PlusMinusType_P2 = Convert.ToInt32(p2.PlusMinusType).ToString(); data.PlusMinusType_P1 = Convert.ToInt32(p1.PlusMinusType).ToString(); data.PlusMinusType_P0 = Convert.ToInt32(p0.PlusMinusType).ToString(); data.CandleSpaceType_P2 = Convert.ToInt32(p2.SpaceType_C).ToString(); data.CandleSpaceType_P1 = Convert.ToInt32(p1.SpaceType_C).ToString(); data.CandleSpaceType_P0 = Convert.ToInt32(p0.SpaceType_C).ToString(); var timeType = PatternUtil.GetCandleTimeType(p2, p1); data.CandleTimeType_O_P21 = Convert.ToInt32(timeType.openType).ToString(); data.CandleTimeType_C_P21 = Convert.ToInt32(timeType.closeType).ToString(); data.CandleTimeType_H_P21 = Convert.ToInt32(timeType.highType).ToString(); data.CandleTimeType_L_P21 = Convert.ToInt32(timeType.lowType).ToString(); timeType = PatternUtil.GetCandleTimeType(p1, p0); data.CandleTimeType_O_P10 = Convert.ToInt32(timeType.openType).ToString(); data.CandleTimeType_C_P10 = Convert.ToInt32(timeType.closeType).ToString(); data.CandleTimeType_H_P10 = Convert.ToInt32(timeType.highType).ToString(); data.CandleTimeType_L_P10 = Convert.ToInt32(timeType.lowType).ToString(); timeType = PatternUtil.GetCandleTimeType(p2, p0); data.CandleTimeType_O_P20 = Convert.ToInt32(timeType.openType).ToString(); data.CandleTimeType_C_P20 = Convert.ToInt32(timeType.closeType).ToString(); data.CandleTimeType_H_P20 = Convert.ToInt32(timeType.highType).ToString(); data.CandleTimeType_L_P20 = Convert.ToInt32(timeType.lowType).ToString(); var sizeType = PatternUtil.GetCandleBodySizeType(p2, p1); data.CandleSizeType_B_P21 = Convert.ToInt32(sizeType).ToString(); sizeType = PatternUtil.GetCandleBodySizeType(p1, p0); data.CandleSizeType_B_P10 = Convert.ToInt32(sizeType).ToString(); sizeType = PatternUtil.GetCandleBodySizeType(p2, p0); data.CandleSizeType_B_P20 = Convert.ToInt32(sizeType).ToString(); sizeType = PatternUtil.GetCandleTotalSizeType(p2, p1); data.CandleSizeType_T_P21 = Convert.ToInt32(sizeType).ToString(); sizeType = PatternUtil.GetCandleTotalSizeType(p1, p0); data.CandleSizeType_T_P10 = Convert.ToInt32(sizeType).ToString(); sizeType = PatternUtil.GetCandleTotalSizeType(p2, p0); data.CandleSizeType_T_P20 = Convert.ToInt32(sizeType).ToString(); data.StartDT = p2.DTime; data.EndDT = p0.DTime; data.Create(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void dgvList_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } S_CandleItemData data = dgvList.Rows[e.RowIndex].Tag as S_CandleItemData; selCandleData = data; if (e.ColumnIndex == 1) { var pInfo = PatternUtil.GetTwoPatternInfo(selCandleData); pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval); pInfo.Product = selectedType; pInfo.Item = selectedItem; var pList = twoPatterns.GetMatchPatterns(pInfo); dgv.Rows.Clear(); if (pList.Count > 0) { lbNoResult.Visible = false; } else { lbNoResult.Visible = true; } foreach (var p in pList.OrderByDescending(t => t.CandlePatternType)) { int idx = dgv.Rows.Add(p.Item , getIntervalToString(p.TimeInterval) , p.EndDT.ToString("yy.MM.dd HH:mm") , Convert.ToString((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType))); var type = ((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType)); if (type == CandlePatternTypeEnum.Up) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red; } else if (type == CandlePatternTypeEnum.Down) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue; } else if (type == CandlePatternTypeEnum.StrongUp) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkRed; } else if (type == CandlePatternTypeEnum.StrongDown) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkBlue; } dgv.Rows[idx].Tag = p; } } if (e.ColumnIndex == 2) { var pInfo = PatternUtil.GetThreePatternInfo(selCandleData); pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval); pInfo.Product = selectedType; pInfo.Item = selectedItem; var pList = threePatterns.GetMatchPatterns(pInfo); dgv.Rows.Clear(); if (pList.Count > 0) { lbNoResult.Visible = false; } else { lbNoResult.Visible = true; } foreach (var p in pList.OrderByDescending(t => t.CandlePatternType)) { int idx = dgv.Rows.Add(p.Item , getIntervalToString(p.TimeInterval) , p.EndDT.ToString("yy.MM.dd HH:mm") , Convert.ToString((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType))); var type = ((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType)); if (type == CandlePatternTypeEnum.Up) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red; } else if (type == CandlePatternTypeEnum.Down) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue; } else if (type == CandlePatternTypeEnum.StrongUp) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkRed; } else if (type == CandlePatternTypeEnum.StrongDown) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkBlue; } dgv.Rows[idx].Tag = p; } } if (e.ColumnIndex == 3) { var pInfo = PatternUtil.GetFourPatternInfo(selCandleData); pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval); pInfo.Product = selectedType; pInfo.Item = selectedItem; var pList = fourPatterns.GetMatchPatterns(pInfo); dgv.Rows.Clear(); if (pList.Count > 0) { lbNoResult.Visible = false; } else { lbNoResult.Visible = true; } foreach (var p in pList.OrderByDescending(t => t.CandlePatternType)) { int idx = dgv.Rows.Add(p.Item , getIntervalToString(p.TimeInterval) , p.EndDT.ToString("yy.MM.dd HH:mm") , Convert.ToString((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType))); var type = ((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType)); if (type == CandlePatternTypeEnum.Up) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red; } else if (type == CandlePatternTypeEnum.Down) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue; } else if (type == CandlePatternTypeEnum.StrongUp) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkRed; } else if (type == CandlePatternTypeEnum.StrongDown) { dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkBlue; } dgv.Rows[idx].Tag = p; } } chart1.ClearChartLabel("1"); chart1.ClearChartLabel("2"); chart1.DisplayChartLabel(data, Color.Black, "1"); chart1.DisplayView(); }
void loadSiseDataFromDaemon() { if (cbxProduct.SelectedIndex < 3) { selectedItem = (cbxItem.SelectedItem as ItemData).Code; } else { selectedItem = cbxItem.SelectedItem.ToString().Substring(0, 6); } sourceDatas = loadData(selectedType, selectedItem, selectedTimeInterval, null, null); if (sourceDatas == null || sourceDatas.Count == 0) { return; } for (int i = 0; i < sourceDatas.Count; i++) { int pIdx = i - 1 < 0 ? 0 : i - 1; int nIdx = i + 1 == sourceDatas.Count ? i : i + 1; sourceDatas[i].PreCandleItem = sourceDatas[pIdx]; sourceDatas[i].NextCandleItem = sourceDatas[nIdx]; } this.Invoke(new Action(() => { dgvList.Rows.Clear(); dgv.Rows.Clear(); lbNoResult.Visible = false; for (int i = sourceDatas.Count - 1; i >= sourceDatas.Count - 50; i--) { var data = sourceDatas[i]; string date = Convert.ToDateTime(data.DTime).ToString("yy.MM.dd HH:mm"); int index = dgvList.Rows.Add(date, "찾기2", "찾기3", "찾기4"); dgvList.Rows[index].Tag = data; { var pInfo = PatternUtil.GetTwoPatternInfo(data); pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval); pInfo.Product = selectedType; pInfo.Item = selectedItem; var pList = twoPatterns.GetMatchPatterns(pInfo); if (pList.Count == 0) { ((DataGridViewButtonCell)dgvList.Rows[index].Cells[1]).Value = ""; } } { var pInfo = PatternUtil.GetThreePatternInfo(data); pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval); pInfo.Product = selectedType; pInfo.Item = selectedItem; var pList = threePatterns.GetMatchPatterns(pInfo); if (pList.Count == 0) { ((DataGridViewButtonCell)dgvList.Rows[index].Cells[2]).Value = ""; } } { var pInfo = PatternUtil.GetFourPatternInfo(data); pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval); pInfo.Product = selectedType; pInfo.Item = selectedItem; var pList = fourPatterns.GetMatchPatterns(pInfo); if (pList.Count == 0) { ((DataGridViewButtonCell)dgvList.Rows[index].Cells[3]).Value = ""; } } } dgvList.ClearSelection(); Display(); })); }
/// <summary> /// Executes the input /// </summary> /// <param name="touchedNodes"></param> public void ExecuteInput(HashSet <int> touchedNodes) { var consumedPatterns = PatternUtil.ParseInput(touchedNodes); var consumedSlices = this.PlayerPizza.ConsumeSlices(consumedPatterns); }