|
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
-
- namespace ProductionControl.UIExtend
- {
- public class TextBoxRemind
- {
- private string[] array = null;
- private static string workPath = Directory.GetCurrentDirectory();
- private static string textPath = Path.Combine(workPath, "TextRemind.txt");
- public void InitAutoCompleteCustomSource(TextBox text)
- {
- array = ReadText();
- if (array != null && array.Length > 0)
- {
- AutoCompleteStringCollection ACSC = new AutoCompleteStringCollection();
- for (int i = 0; i < array.Length; i++)
- ACSC.Add(array[i]);
-
- text.AutoCompleteCustomSource = ACSC;
- }
- }
- string[] ReadText()
- {
- try
- {
- if (!File.Exists(textPath))
- return null;
-
- return File.ReadAllLines(textPath);
- }
- catch
- {
- return null;
- }
- }
-
- public void Remind(string str)
- {
- try
- {
- if(array == null || !array.Contains(str))
- {
- File.AppendAllLines(textPath,new string[] { str });
- }
- }
- catch
- {
- }
- }
- }
- }
|