private void ShowReceiversForm() { ReceiversForm form = new ReceiversForm(UserSettings.Instance.Receivers); if (form.ShowDialog(this) != DialogResult.OK) return; foreach (IReceiver receiver in form.RemovedReceivers) { TerminateReceiver(receiver); UserSettings.Instance.Receivers.Remove(receiver); } foreach (IReceiver receiver in form.AddedReceivers) { UserSettings.Instance.Receivers.Add(receiver); InitializeReceiver(receiver); } UserSettings.Instance.Save(); }
private void quickLoadBtn_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { if (!File.Exists(openFileDialog1.FileName)) { MessageBox.Show(string.Format("File: {0} does not exists", openFileDialog1.FileName), "Error Opening Log File"); return; } var fileReceivers = new List<IReceiver>(); foreach (var receiver in UserSettings.Instance.Receivers) { if (receiver is CsvFileReceiver) fileReceivers.Add(receiver); } var form = new ReceiversForm(fileReceivers, true); if (form.ShowDialog(this) != DialogResult.OK) return; foreach (IReceiver receiver in form.AddedReceivers) { UserSettings.Instance.Receivers.Add(receiver); InitializeReceiver(receiver); } UserSettings.Instance.Save(); var fileReceiver = form.SelectedReceiver as CsvFileReceiver; if (fileReceiver == null) return; fileReceiver.ShowFromBeginning = true; fileReceiver.FileToWatch = openFileDialog1.FileName; fileReceiver.Attach(this); /* var fileReceiver = new CsvFileReceiver(); fileReceiver.FileToWatch = openFileDialog1.FileName; fileReceiver.ReadHeaderFromFile = true; fileReceiver.ShowFromBeginning = true; fileReceiver.Initialize(); fileReceiver.Attach(this); */ } }