private void button_Cal_Click(object sender, EventArgs e) { List <int> BlackList = new List <int>(); double [] ans = (double [])MathV.CalExpression(textBox_expression.Text.Replace("\r\n", ""), MainForm.MainDT, ref BlackList); int ColNum = 0; if (checkBox_NewCol.Checked == true) { MainForm.MainDT.Columns.Add(); ColNum = MainForm.MainDT.Columns.Count - 1; } else { ColNum = Tabulation.FindCol(MainForm.MainDT, comboBox_Output.Text); } if (ColNum == -1) { return; } int RealData = 0; int RowsCount = MainForm.MainDT.Rows.Count; for (int i = 0; i < RowsCount; i++) { if (BlackList.IndexOf(i) == -1) { MainForm.MainDT.Rows[i][ColNum] = ans[RealData].ToString(); RealData++; } } Tabulation.InitDataSet(MainForm.MainDT, ref MainForm.nMax, ref MainForm.pageCount, ref MainForm.pageCurrent, ref MainForm.nCurrent, MainForm.S.label_CurrentPage, MainForm.S.label_TotalPage, MainForm.S.dataGridView1, MainForm.S.textBox_CurrentPage, MainForm.pageSize); }
private void button_Split_Click(object sender, EventArgs e) { string Name = ""; int InterestCol = MainForm.MainDT.Columns.IndexOf(comboBox_Cols.Text); int OriginColsCount = MainForm.MainDT.Columns.Count; if (InterestCol != -1) { int RowsCount = MainForm.MainDT.Rows.Count; string AllChoices = textBox_Choices.Text; if (AllChoices != "") { AllChoices = AllChoices.Replace("\r", ""); string[] Choices = AllChoices.Split('\n'); foreach (string Choice in Choices) { if (Choice.Trim() != "") { Name = comboBox_Cols.Text + ": " + Choice.Trim(); if (MainForm.MainDT.Columns.IndexOf(Name) == -1) { MainForm.MainDT.Columns.Add(Name); } else { MainForm.MainDT.Columns.Add(""); } } } int ColNum = 0; string EachCellContent = ""; //记录要寻找的每一个列名 //如果找到了相应的选项,则在相应的列名记上1,否则记0 for (int i = 0; i < RowsCount; i++) { EachCellContent = MainForm.MainDT.Rows[i][InterestCol].ToString(); ColNum = 0; foreach (string Choice in Choices) { if (Choice.Trim() != "") { if (EachCellContent.IndexOf(Choice.Trim()) != -1) { MainForm.MainDT.Rows[i][OriginColsCount + ColNum] = "1"; } else { MainForm.MainDT.Rows[i][OriginColsCount + ColNum] = "0"; } ColNum++; } } } Tabulation.InitDataSet(MainForm.MainDT, ref MainForm.nMax, ref MainForm.pageCount, ref MainForm.pageCurrent, ref MainForm.nCurrent, MainForm.S.label_CurrentPage, MainForm.S.label_TotalPage, MainForm.S.dataGridView1, MainForm.S.textBox_CurrentPage, MainForm.pageSize); } } Tabulation.RenewColsItems(MainForm.MainDT, comboBox_Cols); }
private void 中单元格ToolStripMenuItem_Click(object sender, EventArgs e) { Tabulation.DeleteCellContent(ref MainDT, dataGridView1); Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent, ref nCurrent, label_CurrentPage, label_TotalPage, dataGridView1, textBox_CurrentPage, pageSize); }
private void Import_Click(object sender, EventArgs e) { bool Tab = checkBox_Tab.Checked; bool semicolon = checkBox_semicolon.Checked; bool comma = checkBox_comma.Checked; bool OtherChar = checkBox_OtherChar.Checked; if (Tab == false && semicolon == false && comma == false && OtherChar == false) { MessageBox.Show("请选择分割方式。"); } else { List <char> ch = new List <char> (); if (Tab == true) { ch.Add('\t'); } if (semicolon == true) { ch.Add(';'); } if (comma == true) { ch.Add(','); } if (OtherChar == true) { ch.Add(textBox_SplitChar.Text.ToString()[0]); } if (comboBox_method.Text == "单个导入") { DataTable dt = new DataTable(); dt = Tabulation.LoadFromCSVFile(textBox_path.Text, ch.ToArray()); if (dt != null) { MainForm.MainDT = dt; Tabulation.InitDataSet(MainForm.MainDT, ref MainForm.nMax, ref MainForm.pageCount, ref MainForm.pageCurrent, ref MainForm.nCurrent, MainForm.S.label_CurrentPage, MainForm.S.label_TotalPage, MainForm.S.dataGridView1, MainForm.S.textBox_CurrentPage, MainForm.pageSize); } } else if (comboBox_method.Text == "批量导入") { DataTable dt = new DataTable(); foreach (string EachFile in files) { dt.Merge(Tabulation.LoadFromCSVFile(EachFile, ch.ToArray())); } if (dt != null) { MainForm.MainDT = dt; Tabulation.InitDataSet(MainForm.MainDT, ref MainForm.nMax, ref MainForm.pageCount, ref MainForm.pageCurrent, ref MainForm.nCurrent, MainForm.S.label_CurrentPage, MainForm.S.label_TotalPage, MainForm.S.dataGridView1, MainForm.S.textBox_CurrentPage, MainForm.pageSize); } } this.Close(); } }
private void 中行ToolStripMenuItem_Click(object sender, EventArgs e) { //将选中行转置 MainDT = Tabulation.Transposition(Tabulation.GetChosenTable(MainDT, dataGridView1), MainDT); Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent, ref nCurrent, label_CurrentPage, label_TotalPage, dataGridView1, textBox_CurrentPage, pageSize); }
private void 所有内容ToolStripMenuItem_Click(object sender, EventArgs e) { //将所有内容转置 MainDT = Tabulation.Transposition(MainDT, MainDT, true); Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent, ref nCurrent, label_CurrentPage, label_TotalPage, dataGridView1, textBox_CurrentPage, pageSize); }
private void button_predict_Click(object sender, EventArgs e) { NaiveBayesPrediction(); Tabulation.InitDataSet(MainForm.MainDT, ref MainForm.nMax, ref MainForm.pageCount, ref MainForm.pageCurrent, ref MainForm.nCurrent, MainForm.S.label_CurrentPage, MainForm.S.label_TotalPage, MainForm.S.dataGridView1, MainForm.S.textBox_CurrentPage, MainForm.pageSize); //Tabulation.DataType(dataGridView1); }
private void 新建ToolStripMenuItem_Click(object sender, EventArgs e) { MainDT.Clear(); //dataGridView1.DataSource = null; MainDT = Tabulation.NewTable(50, 15); Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent, ref nCurrent, label_CurrentPage, label_TotalPage, dataGridView1, textBox_CurrentPage, pageSize); }
private void button1_Click(object sender, EventArgs e) { string NewName = textBox_VarName.Text; if (MainForm.MainDT.Columns.IndexOf(NewName) != -1) { MessageBox.Show("不能与现有变量名重复!"); } else { MainForm.MainDT.Columns[MainForm.ColumnNameChange].ColumnName = NewName; Tabulation.InitDataSet(MainForm.MainDT, ref MainForm.nMax, ref MainForm.pageCount, ref MainForm.pageCurrent, ref MainForm.nCurrent, MainForm.S.label_CurrentPage, MainForm.S.label_TotalPage, MainForm.S.dataGridView1, MainForm.S.textBox_CurrentPage, MainForm.pageSize); this.Close(); } }
private void Import_Click(object sender, EventArgs e) { //Tabulation.DataType(MainForm.S.dataGridView1); DataTable dt = new DataTable(); dt = Tabulation.ImportExcel(textBox_path.Text, textBox_tabulation.Text);; if (dt != null) { //dataGridView1.DataSource = dt; MainForm.MainDT = dt; Tabulation.InitDataSet(MainForm.MainDT, ref MainForm.nMax, ref MainForm.pageCount, ref MainForm.pageCurrent, ref MainForm.nCurrent, MainForm.S.label_CurrentPage, MainForm.S.label_TotalPage, MainForm.S.dataGridView1, MainForm.S.textBox_CurrentPage, MainForm.pageSize); //Tabulation.DataType(dataGridView1); this.Close(); } }
private void button_StartSplit_Click(object sender, EventArgs e) { string ColNums = textBox_ChosenCols.Text; if (ColNums.Contains(",")) { MessageBox.Show("一次只能转换一列数据,请选择单列以后再试。"); } else { int ColNum = Convert.ToInt32(ColNums.Trim()) - 1; if (ColNum >= 0 && ColNum < MainForm.S.dataGridView1.ColumnCount) { List <char> separators = new List <char>(); if (checkBox_Tab.Checked == true) { separators.Add('\t'); } if (checkBox_semicolon.Checked == true) { separators.Add(';'); } if (checkBox_comma.Checked == true) { separators.Add(','); } if (checkBox_space.Checked == true) { separators.Add(' '); } if (checkBox_OtherChar.Checked == true) { separators.Add(textBox_SplitChar.Text.ToString()[0]); } MainForm.MainDT = Tabulation.DataTableSplit(MainForm.MainDT, separators.ToArray(), ColNum); Tabulation.InitDataSet(MainForm.MainDT, ref MainForm.nMax, ref MainForm.pageCount, ref MainForm.pageCurrent, ref MainForm.nCurrent, MainForm.S.label_CurrentPage, MainForm.S.label_TotalPage, MainForm.S.dataGridView1, MainForm.S.textBox_CurrentPage, MainForm.pageSize); this.Close(); } } }