Пример #1
0
        private void TraVeDoAm_Click(object sender, EventArgs e)
        {
            string var = NhietdoBox_textEdit.Text;

            if (flagL == true && var != "")
            {
                int nhiet = Int32.Parse(var);
                KNN k     = new KNN();
                int _doam = 0;
                k.TemperInput(nhiet, filetxt, ref _doam);
                DoAmBox_textEdit.Text = _doam.ToString();
            }
            else
            {
                MessageBox.Show("Input file train.", "Message");
            }
        }
Пример #2
0
        private void DuBao_simpleButton_Click(object sender, EventArgs e)
        {
            if (NhieuMay_radioButton.Checked || ItMay_radioButton.Checked)
            {
                boxM.Text  = "";
                boxL.Text  = "";
                boxMM.Text = "";
                boxN.Text  = "";
            }
            if (flagL == true)
            {
                if (NhieuMay_radioButton.Checked || ItMay_radioButton.Checked)
                {
                    KNN    kn   = new KNN();
                    string kq   = "";
                    float  _sum = 0;
                    int    t1   = Int32.Parse(NhietdoBox_textEdit.Text);
                    int    h1   = Int32.Parse(DoAmBox_textEdit.Text);
                    if (ItMay_radioButton.Checked == true)
                    {
                        fm = "It";
                    }
                    else
                    {
                        fm = "Nhieu";
                    }
                    kn.InputT_H(t1, h1, fm, filetxt, ref kq, ref _sum);
                    //MessageBox.Show(kq, _sum.ToString());

                    string[] outline = kq.Split('.');
                    float    number  = 0;

                    for (int i = 0; i < outline.Length - 1; i++)
                    {
                        string[] re_kq = outline[i].Split(' ');

                        for (int j = 0; j < re_kq.Length; j++)
                        {
                            //MessageBox.Show
                            if (re_kq[j].Equals("Nang"))
                            {
                                number = Int32.Parse(re_kq[0]);
                                number = (number * 100) / _sum;
                                string x = string.Format("{0:0.##}", number);
                                boxN.Text = x;
                            }
                            if (re_kq[j].Equals("MatMe"))
                            {
                                number = Int32.Parse(re_kq[0]);
                                number = (number * 100) / _sum;
                                string x = string.Format("{0:0.##}", number);
                                boxMM.Text = x;
                            }
                            if (re_kq[j].Equals("Mua"))
                            {
                                number = Int32.Parse(re_kq[0]);
                                number = (number * 100) / _sum;
                                string x = string.Format("{0:0.##}", number);
                                boxM.Text = x;
                            }
                            if (re_kq[j].Equals("Lanh"))
                            {
                                number = Int32.Parse(re_kq[0]);
                                number = (number * 100) / _sum;
                                string x = string.Format("{0:0.##}", number);
                                boxL.Text = x;
                            }
                        }
                    }
                    string _boxN, _boxM, _boxMM, _boxL;
                    //float n, m, mm, l;
                    _boxN  = boxN.Text;
                    _boxM  = boxM.Text;
                    _boxL  = boxL.Text;
                    _boxMM = boxMM.Text;
                    List <float>  ls1 = new List <float>();
                    List <string> ls2 = new List <string>();
                    if (!_boxN.Equals(""))
                    {
                        ls1.Add(float.Parse(_boxN));
                        ls2.Add("N");
                    }
                    if (!_boxM.Equals(""))
                    {
                        ls1.Add(float.Parse(_boxM));
                        ls2.Add("M");
                    }

                    if (!_boxMM.Equals(""))
                    {
                        ls1.Add(float.Parse(_boxMM));
                        ls2.Add("MM");
                    }
                    if (!_boxL.Equals(""))
                    {
                        ls1.Add(float.Parse(_boxL));
                        ls2.Add("L");
                    }
                    float  max = -1;
                    string stt = "";
                    int    flg = 0;
                    for (int i = 0; i < ls1.Count; i++)
                    {
                        if (ls1[i] > max)
                        {
                            max = ls1[i];
                            stt = ls2[i];
                            flg = i;
                        }
                    }
                    //set pic
                    if (stt.Equals("N"))
                    {
                        KetQua_pictureEdit.Image = Image.FromFile("../../pic/n.gif");
                    }
                    if (stt.Equals("L"))
                    {
                        KetQua_pictureEdit.Image = Image.FromFile("../../pic/l.gif");
                    }
                    if (stt.Equals("MM"))
                    {
                        KetQua_pictureEdit.Image = Image.FromFile("../../pic/MM.gif");
                    }
                    if (stt.Equals("M"))
                    {
                        KetQua_pictureEdit.Image = Image.FromFile("../../pic/m.gif");
                    }
                    //MessageBox.Show(ls1[0].ToString());
                    //MessageBox.Show(stt.ToString());
                    chart.Checked    = false;
                    chartGra.Visible = false;
                }
                else
                {
                    MessageBox.Show("Not enough information", "MESSAGE");
                }
            }
            else
            {
                MessageBox.Show("Input file train.", "MESSAGE");
            }
        }