コード例 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog theDialog = new OpenFileDialog();

            theDialog.Title            = "Файлро интихоб кунед";
            theDialog.Filter           = "TXT files|*.txt";
            theDialog.InitialDirectory = @"C:\";
            if (theDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    var path  = theDialog.FileName;
                    var lines = File.ReadAllLines(path);
                    foreach (var item in lines)
                    {
                        if (!NewStopWords.Any(s => s == item))
                        {
                            NewStopWords.Add(item);
                            if (!listBox1.Items.Contains(item))
                            {
                                listBox1.Items.Add(item);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Хатогӣ ҳангоми хондани файл: " + ex.Message);
                }
            }
        }
コード例 #2
0
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         if (listBox1.SelectedItem != null)
         {
             var itemToRemove = listBox1.SelectedItem.ToString();
             NewStopWords.Remove(itemToRemove);
             listBox1.Items.Remove(itemToRemove);
         }
     }
     catch
     {
     }
 }
コード例 #3
0
        private void button5_Click(object sender, EventArgs e)
        {
            var newStopWord = ShowDialog("СТОП-КАЛИМА", "Ҳамроҳ кардани калимаи нав").Trim();

            if (newStopWord != "" && newStopWord != null)
            {
                if (!NewStopWords.Any(s => s == newStopWord))
                {
                    NewStopWords.Add(newStopWord);
                    if (!listBox1.Items.Contains(newStopWord))
                    {
                        listBox1.Items.Add(newStopWord);
                    }
                }
            }
        }