private void ShowReceiversForm() { var form = new ReceiversForm(_configuration.Receivers) { Font = _configuration.DefaultFont }; if (form.ShowDialog(this) != DialogResult.OK) { return; } foreach (var receiver in form.RemovedReceivers) { TerminateReceiver(receiver); _configuration.Receivers.Remove(receiver); } foreach (var receiver in form.AddedReceivers) { _configuration.Receivers.Add(receiver); InitializeReceiver(receiver); } _configuration.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); */ } }
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) { return; } if (!File.Exists(openFileDialog1.FileName)) { MessageBox.Show($"File: {openFileDialog1.FileName} does not exists", "Error Opening Log File"); return; } var fileReceivers = new List <IReceiver>(); foreach (var receiver in _configuration.Receivers) { if (receiver is CsvFileReceiver) { fileReceivers.Add(receiver); } } var form = new ReceiversForm(fileReceivers, true) { Font = _configuration.DefaultFont }; if (form.ShowDialog(this) != DialogResult.OK) { return; } foreach (var receiver in form.AddedReceivers) { _configuration.Receivers.Add(receiver); InitializeReceiver(receiver); } _configuration.Save(); if (!(form.SelectedReceiver is CsvFileReceiver fileReceiver)) { 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); */ }