Exemplo n.º 1
0
        private void OpenFileButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog fd = new OpenFileDialog();

            fd.Filter = "文件|*.CSV";
            fd.Title  = "打开文件夹";
            string path = "";

            fd.FilterIndex = 1;
            string file = System.Environment.CurrentDirectory.ToString();

            //fd.InitialDirectory = "C:\\Users\\Administrator\\Documents\\Magnifi\\Projects\\Default\\DemoData4.3";
            fd.InitialDirectory = file;
            if (fd.ShowDialog() == DialogResult.OK)
            {
                path  = fd.FileName;
                table = ImportCsvToDataTable(path);

                TableWidth  = table.Rows.Count;
                TableLength = table.Columns.Count;
                for (int i = 0; i < TableWidth - 1; i++)
                {
                    for (int j = 0; j < TableLength - 1; j++)
                    {
                        InputDataSample ids = new InputDataSample();
                        ids.x     = i;
                        ids.y     = j;
                        ids.value = Convert.ToInt16(table.Rows[i][j].ToString());
                        ids.color = Color.Green;
                        sampleList.Add(ids);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 生成质心
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GenerateCeterButton_Click(object sender, EventArgs e)
        {
            CenterList.Clear();
            int    k    = Convert.ToInt16(KTextBox.Text);
            Random rand = new Random();

            for (int i = 0; i < k; i++)
            {
                InputDataSample ids_Center = new InputDataSample();
                ids_Center.x = rand.Next(TableWidth - 1);
                ids_Center.y = rand.Next(TableLength - 1);
                //ids_Center.value = Convert.ToInt16(table.Rows[ids_Center.x][ids_Center.x].ToString());
                ids_Center.value     = i - 2;
                ids_Center.type      = i;
                ids_Center.colorType = i;
                if (i < colorArray.Count())
                {
                    ids_Center.color = colorArray[CenterList.Count()];
                }
                else
                {
                    ids_Center.color = Color.FromArgb(rand.Next(1, 255), rand.Next(1, 255), rand.Next(1, 255));
                }
                CenterList.Add(ids_Center);
            }
        }