private void button_refresh_Click(object sender, EventArgs e) { if (MainForm.S.dataGridView1.DataSource != null) { textBox_Cols.Text = Tabulation.GetGridCols(MainForm.S.dataGridView1); } }
private void comboBox_Cols_TextChanged(object sender, EventArgs e) { int ColNum = Tabulation.FindCol(MainForm.MainDT, comboBox_Cols.Text); if (ColNum != -1) { Classification = Tabulation.Classification(MainForm.MainDT, ColNum); int len = Classification.Length; if (len > 0) { listBox_MultiChoices.Items.Clear(); listBox_MultiChoices.Items.AddRange(Classification); textBox_Times.Clear(); for (int i = 0; i < len; i++) { textBox_Times.AppendText("0\r\n"); } CountTimes = Tabulation.LikilihoodCount(Classification, MainForm.MainDT, ColNum); StringBuilder OutPut = new StringBuilder(); for (int i = 0; i < len; i++) { OutPut.Append(Classification[i]); OutPut.Append("\t"); OutPut.Append(CountTimes[i].ToString()); OutPut.Append("\r\n"); } textBox_Likihood.Clear(); textBox_Likihood.AppendText(OutPut.ToString()); } } }
public HypothesisTesting_2Sample() { InitializeComponent(); Tabulation.RenewColsItems(MainForm.MainDT, comboBox_Cols2); Tabulation.RenewColsItems(MainForm.MainDT, comboBox_Cols); this.comboBox_Cols.Focus(); }
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) { Tabulation.DeleteCellContent(ref MainDT, dataGridView1); Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent, ref nCurrent, label_CurrentPage, label_TotalPage, dataGridView1, textBox_CurrentPage, pageSize); }
public static void LoopCI(DataGridView dataGridView1, RichTextBox richTextBox1, string Cols, string Tail, string Statistics, double Significance) { //这个函数的目的是循环对所要求的变量进行参数估计 char[] separator = { ',' }; string[] AllCols = Cols.Split(separator); string result = ""; richTextBox1.AppendText("参数估计: "); richTextBox1.AppendText(Statistics); richTextBox1.AppendText("\r\n"); richTextBox1.AppendText("置信度: "); richTextBox1.AppendText(Significance.ToString()); richTextBox1.AppendText("\t"); richTextBox1.AppendText(Tail); richTextBox1.AppendText("\r\n"); richTextBox1.AppendText(Header); int ColNum = 0; foreach (string EachCol in AllCols) { if (Int32.TryParse(EachCol, out ColNum)) { string[] Numbers = Tabulation.ReadVector(MainForm.MainDT, ColNum - 1).ToArray(); result = CI(dataGridView1.Columns[ColNum - 1].Name, Numbers, Tail, Statistics, Significance); richTextBox1.AppendText(result); } } }
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 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 comboBox_Cols_TextChanged(object sender, EventArgs e) { int ColNum = Tabulation.FindCol(MainForm.MainDT, comboBox_Cols.Text); if (ColNum != -1) { Classification = Tabulation.Classification(MainForm.MainDT, ColNum); int len = Classification.Length; if (len > 0) { if (len > 2) { MessageBox.Show("选项超过两种,请使用多选单选题进行分析!"); } else { listBox_TwoChoices.Items.Clear(); listBox_TwoChoices.Items.AddRange(Classification); CountTimes = Tabulation.LikilihoodCount(Classification, MainForm.MainDT, ColNum); StringBuilder OutPut = new StringBuilder(); for (int i = 0; i < len; i++) { OutPut.Append(Classification[i]); OutPut.Append("\t"); OutPut.Append(CountTimes[i].ToString()); OutPut.Append("\r\n"); } textBox_Likihood.Clear(); textBox_Likihood.AppendText(OutPut.ToString()); label4.Text = "其中有多少样本选择了\"" + listBox_TwoChoices.Items[0].ToString() + "\"?"; } } } }
public Calculator() { InitializeComponent(); string[] Items = Tabulation.RenewColsItems(MainForm.MainDT); comboBox_Output.Items.AddRange(Items); listBox_Vars.Items.AddRange(Items); }
private void button_import_Click(object sender, EventArgs e) { dt.Clear(); dt = Tabulation.GetSubset(MainForm.MainDT, textBox_ChosenCols.Text); dataGridView_subset.DataSource = dt; refresh_Combox(); }
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); }
public Summary() { InitializeComponent(); if (MainForm.S.dataGridView1.DataSource != null) { textBox_Cols.Text = Tabulation.GetGridCols(MainForm.S.dataGridView1); } }
public Timeseries() { InitializeComponent(); if (MainForm.S.dataGridView1.DataSource != null) { texbox_dep.Text = Tabulation.GetGridCols(MainForm.S.dataGridView1); } }
public SpatialMap() { InitializeComponent(); if (MainForm.S.dataGridView1.DataSource != null) { texbox_province.Text = Tabulation.GetGridCols(MainForm.S.dataGridView1); } }
public ParameterEstimation_2Sample() { InitializeComponent(); if (MainForm.S.dataGridView1.DataSource != null) { textBox_ChosenCols1.Text = Tabulation.GetGridCols(MainForm.S.dataGridView1); } }
private void button_LastPage_Click(object sender, EventArgs e) { pageCurrent = pageCount; nCurrent = pageSize * (pageCurrent - 1); Tabulation.LoadData(MainDT, ref pageCurrent, ref pageCount, ref nMax, ref pageSize, ref nCurrent, textBox_CurrentPage, label_CurrentPage, label_TotalPage, dataGridView1); }
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 新建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 textBox_ChosenCols1_TextChanged(object sender, EventArgs e) { try { textBox_VarNames.Text = Tabulation.GetColsName(MainForm.S.dataGridView1, textBox_ChosenCols1.Text) + "," + Tabulation.GetColsName(MainForm.S.dataGridView1, textBox_ChosenCols2.Text); } catch (Exception ex) { } }
public EasyGraph() { InitializeComponent(); EasyGraphForm = this; if (MainForm.S.dataGridView1.DataSource != null) { textBox_ChosenCols.Text = Tabulation.GetGridCols(MainForm.S.dataGridView1); } }
private void textBox_variable_TextChanged(object sender, EventArgs e) { try { textBox_show2.Text = Tabulation.GetColsName(MainForm.S.dataGridView1, textBox_variable.Text); } catch (Exception ex) { } }
private void button_Skip_Click(object sender, EventArgs e) { int SkipPage = Convert.ToInt32(textBox_CurrentPage.Text); if (SkipPage > 0 && SkipPage <= pageCount) { pageCurrent = SkipPage; nCurrent = pageSize * (pageCurrent - 1); Tabulation.LoadData(MainDT, ref pageCurrent, ref pageCount, ref nMax, ref pageSize, ref nCurrent, textBox_CurrentPage, label_CurrentPage, label_TotalPage, dataGridView1); } }
private void button_add_Click(object sender, EventArgs e) { if (comboBox_x.Text.Trim() != "") { QuickPlot.QPlot(dt, chart_basic, Tabulation.FindCol(dt, comboBox_x.Text), Tabulation.FindCol(dt, comboBox_y.Text), comboBox_type.Text, textBox_Legend.Text, checkBox_IsXLabel.Checked); } else { QuickPlot.QPlot(dt, chart_basic, -1, Tabulation.FindCol(dt, comboBox_y.Text), comboBox_type.Text, textBox_Legend.Text, checkBox_IsXLabel.Checked); } }
private void button_NextPage_Click(object sender, EventArgs e) { if (pageCurrent + 1 > pageCount) { MessageBox.Show("已经是最后一页,请点击“上页”查看!"); return; } else { pageCurrent++; nCurrent = pageSize * (pageCurrent - 1); } Tabulation.LoadData(MainDT, ref pageCurrent, ref pageCount, ref nMax, ref pageSize, ref nCurrent, textBox_CurrentPage, label_CurrentPage, label_TotalPage, dataGridView1); }
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 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(); } }
public static void MultiCorr(DataTable dt, int [] ColNums, RichTextBox richTextBox1) { StringBuilder Result = new StringBuilder(); //相关系数输出是一个矩阵,因此要有行名和列名 //例如: // 列1 列2 列3 //列1 1 0 0 //列2 0 1 0 //列3 0 1 1 //自身的相关系数一定是1 Result.Append(StrManipulation.PadLeftX(" ", ' ', 12)); Result.Append("\t"); foreach (int EachCol in ColNums) { Result.Append(StrManipulation.PadLeftX(dt.Columns[EachCol].ColumnName, ' ', 12)); Result.Append("\t"); } Result.Append("\r\n"); foreach (int EachCol in ColNums) { Result.Append(StrManipulation.PadLeftX(dt.Columns[EachCol].ColumnName, ' ', 12)); Result.Append("\t"); foreach (int EveryCol in ColNums) { if (EachCol == EveryCol) { Result.Append(StrManipulation.PadLeftX("1.000", ' ', 12)); Result.Append("\t"); } else { string[] NumberSeries1 = Tabulation.ReadVector(dt, EachCol).ToArray(); string[] NumberSeries2 = Tabulation.ReadVector(dt, EveryCol).ToArray(); Result.Append(StrManipulation.PadLeftX(MathV.NumberPolish(Corr(NumberSeries1, NumberSeries2).ToString()), ' ', 12)); Result.Append("\t"); } } Result.Append("\r\n"); } richTextBox1.AppendText(Result.ToString()); MainForm.S.richTextBox1.Select(); //让RichTextBox获得焦点 MainForm.S.richTextBox1.Select(MainForm.S.richTextBox1.TextLength, 0); //将插入符号置于文本结束处 MainForm.S.richTextBox1.ScrollToCaret(); }
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(); } } }