public void Edit() { // TODO: how to edit. var dialog = new AddPreConditionDialog(this.Module, this.SelectedItem); if (dialog.ShowDialog() != DialogResult.OK) { return; } var newItem = dialog.Item; var service = (IConfigurationService)this.GetService(typeof(IConfigurationService)); var rulesSection = service.GetSection("system.webServer/rewrite/outboundRules"); ConfigurationElementCollection rulesCollection = rulesSection.GetCollection("preConditions"); if (this.SelectedItem != newItem) { this.Items.Add(newItem); this.SelectedItem = newItem; } else if (newItem.Flag != "Local") { rulesCollection.Remove(newItem.Element); newItem.Flag = "Local"; } newItem.AppendTo(rulesCollection); service.ServerManager.CommitChanges(); this.OnRewriteSettingsSaved(); }
private void BtnEditPreconditionClick(object sender, EventArgs e) { using var dialog = new AddPreConditionDialog(ServiceProvider, _feature.PreConditions.FirstOrDefault(item => item.Name == cbPreCondition.Text)); if (dialog.ShowDialog() == DialogResult.OK) { return; } }
private void CbPreConditionSelectedIndexChanged(object sender, EventArgs e) { if (cbPreCondition.SelectedIndex == cbPreCondition.Items.Count - 1) { var dialog = new AddPreConditionDialog(ServiceProvider, null); if (dialog.ShowDialog() == DialogResult.OK) { cbPreCondition.Items.Insert(0, dialog.Item.Name); _feature.PreConditions.Add(dialog.Item); Rule.PreCondition = dialog.Item.Name; cbPreCondition.SelectedIndex = 0; } } btnEditPrecondition.Enabled = cbPreCondition.SelectedIndex + 2 < cbPreCondition.Items.Count; }