private void LoadData(NatsPlugin plugin) { if (plugin != null) { headerLabel.Text = plugin.Name.ToUpper(); natsPluginBindingSource.CurrentItemChanged -= BindingSource_CurrentItemChanged; natsSecurityBindingSource.CurrentItemChanged -= BindingSource_CurrentItemChanged; natsPluginBindingSource.DataSource = plugin; natsSecurityBindingSource.DataSource = plugin.Security; publishPanel.Controls.Clear(); foreach (var p in plugin.Publishes) { ProfileSubjectControl c = new ProfileSubjectControl(p, plugin); c.PropertyChanged += ProfileSubjectPropertyChanged; publishPanel.Controls.Add(c); } subscribePanel.Controls.Clear(); foreach (var p in plugin.Subscribes) { ProfileSubjectControl c = new ProfileSubjectControl(p, plugin); c.PropertyChanged += ProfileSubjectPropertyChanged; subscribePanel.Controls.Add(c); } natsPluginBindingSource.CurrentItemChanged += BindingSource_CurrentItemChanged; natsSecurityBindingSource.CurrentItemChanged += BindingSource_CurrentItemChanged; } }
private void AddPublishProfileButton_Click(object sender, EventArgs e) { ProfileSelectionForm form = new ProfileSelectionForm(); if (form.ShowDialog() == DialogResult.OK) { var selectedProfiles = form.SelectedProfiles; if (selectedProfiles.Count > 0) { RaisePropertyChangedEvent(new System.ComponentModel.PropertyChangedEventArgs("natsplugin")); } foreach (var p in selectedProfiles) { if (_plugin.Publishes.FirstOrDefault(x => x.Profile == p) == null) { Publish pub = new Publish() { Profile = p, Subject = "*" }; _plugin.Publishes.Add(pub); ProfileSubjectControl c = new ProfileSubjectControl(pub, _plugin); c.PropertyChanged += ProfileSubjectPropertyChanged; publishPanel.Controls.Add(c); } } } }
private void AddSubscribeProfileButton_Click(object sender, EventArgs e) { ProfileSelectionForm form = new ProfileSelectionForm(); if (form.ShowDialog() == DialogResult.OK) { var selectedProfiles = form.SelectedProfiles; foreach (var p in selectedProfiles) { if (_plugin.Subscribes.FirstOrDefault(x => x.Profile == p) == null) { Subscribe sub = new Subscribe() { Profile = p, Subject = "*" }; _plugin.Subscribes.Add(sub); ProfileSubjectControl c = new ProfileSubjectControl(sub, _plugin); c.PropertyChanged += ProfileSubjectPropertyChanged; subscribePanel.Controls.Add(c); } } } }