/// <summary> /// 选择确定 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">事件参数</param> private void buttonX1_Click(object sender, EventArgs e) { if (radioButton1.Checked) // 搜索连接线 { searchType = "Node"; } else if (radioButton2.Checked) // 搜索结点 { searchType = "Line"; } else { MessageBox.Show("请先选择要查找的类型!", "查找", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (radioButton3.Checked) // 搜索ID { contentType = "ID"; searchID = idBox.Value; if (searchID == 0) { MessageBox.Show("要查找的ID不能为空!", "查找", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else if (radioButton4.Checked) // 搜索文本 { contentType = "Text"; searchText = textBox.Text; InitTextList(searchText); if (searchText == "") { MessageBox.Show("要查找的文本不能为空!", "查找", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else if (radioButton5.Checked) // 搜索脚本 { contentType = "Script"; searchText = scriptBox.Text; InitScriptList(searchText); if (searchText == "") { MessageBox.Show("要查找的脚本不能为空!", "查找", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else { MessageBox.Show("请先选择要查找的内容!", "查找", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } List <GraphElement> graphElementList = new List <GraphElement>(); switch (searchType) { case "Node": { switch (contentType) { case "ID": { foreach (GraphElement graphElement in flowChartManager.CurrentGraphManager.SlotContainerList) { if (graphElement.ID == searchID) { graphElementList.Add(graphElement); } } break; } case "Text": { foreach (GraphElement graphElement in flowChartManager.CurrentGraphManager.SlotContainerList) { if (graphElement.Text.Contains(searchText)) { graphElementList.Add(graphElement); } } break; } case "Script": { foreach (GraphElement graphElement in flowChartManager.CurrentGraphManager.SlotContainerList) { DataElement dataElement = flowChartManager.CurrentDataManager.GetDataElement(graphElement); if (dataElement != null) { switch (dataElement.DataType) { case "AIActionNode": { Hashtable infoTable = dataElement.GetOutputArgs(); string scriptContent = infoTable["Script"] as string; if (scriptContent != null) { if (scriptContent.Contains(searchText)) { graphElementList.Add(graphElement); } } break; } case "AIActionsNode": { Hashtable infoTable = dataElement.GetOutputArgs(); List <string> scriptContentList = infoTable["ScriptList"] as List <string>; if (scriptContentList != null) { foreach (string s in scriptContentList) { if (s.Contains(searchText)) { graphElementList.Add(graphElement); break; } } } break; } } } } break; } } break; } case "Line": { switch (contentType) { case "ID": { foreach (GraphElement graphElement in flowChartManager.CurrentGraphManager.ConnectorContainerList) { if (graphElement.ID == searchID) { graphElementList.Add(graphElement); } } break; } case "Text": { foreach (GraphElement graphElement in flowChartManager.CurrentGraphManager.ConnectorContainerList) { if (graphElement.Text.Contains(searchText)) { graphElementList.Add(graphElement); } } break; } } break; } } SearchResultForm sForm = new SearchResultForm(flowChartManager.CurrentGraphManager, graphElementList); sForm.Show(); }
/// <summary> /// 选择确定 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">事件参数</param> private void buttonX1_Click(object sender, EventArgs e) { if (radioButton1.Checked) // 搜索连接线 { searchType = "Node"; } else if (radioButton2.Checked) // 搜索结点 { searchType = "Line"; } else { MessageBox.Show("请先选择要查找的类型!", "查找", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (radioButton3.Checked) // 搜索ID { contentType = "ID"; searchID = idBox.Value; if (searchID == 0) { MessageBox.Show("要查找的ID不能为空!", "查找", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else if (radioButton4.Checked) // 搜索文本 { contentType = "Text"; searchText = textBox.Text; InitTextList(searchText); if (searchText == "") { MessageBox.Show("要查找的文本不能为空!", "查找", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else if (radioButton5.Checked) // 搜索脚本 { contentType = "Script"; searchText = scriptBox.Text; InitScriptList(searchText); if (searchText == "") { MessageBox.Show("要查找的脚本不能为空!", "查找", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else { MessageBox.Show("请先选择要查找的内容!", "查找", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } List<GraphElement> graphElementList = new List<GraphElement>(); switch (searchType) { case "Node": { switch(contentType) { case "ID": { foreach (GraphElement graphElement in flowChartManager.CurrentGraphManager.SlotContainerList) { if (graphElement.ID == searchID) { graphElementList.Add(graphElement); } } break; } case "Text": { foreach(GraphElement graphElement in flowChartManager.CurrentGraphManager.SlotContainerList) { if (graphElement.Text.Contains(searchText)) { graphElementList.Add(graphElement); } } break; } case "Script": { foreach (GraphElement graphElement in flowChartManager.CurrentGraphManager.SlotContainerList) { DataElement dataElement = flowChartManager.CurrentDataManager.GetDataElement(graphElement); if (dataElement != null) { switch (dataElement.DataType) { case "AIActionNode": { Hashtable infoTable = dataElement.GetOutputArgs(); string scriptContent = infoTable["Script"] as string; if (scriptContent != null) { if (scriptContent.Contains(searchText)) { graphElementList.Add(graphElement); } } break; } case "AIActionsNode": { Hashtable infoTable = dataElement.GetOutputArgs(); List<string> scriptContentList = infoTable["ScriptList"] as List<string>; if (scriptContentList != null) { foreach (string s in scriptContentList) { if (s.Contains(searchText)) { graphElementList.Add(graphElement); break; } } } break; } } } } break; } } break; } case "Line": { switch(contentType) { case "ID": { foreach(GraphElement graphElement in flowChartManager.CurrentGraphManager.ConnectorContainerList) { if (graphElement.ID == searchID) { graphElementList.Add(graphElement); } } break; } case "Text": { foreach(GraphElement graphElement in flowChartManager.CurrentGraphManager.ConnectorContainerList) { if (graphElement.Text.Contains(searchText)) { graphElementList.Add(graphElement); } } break; } } break; } } SearchResultForm sForm = new SearchResultForm(flowChartManager.CurrentGraphManager, graphElementList); sForm.Show(); }