private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { var form = new SubscriptionForm(Globals.AMPSAddin.Application.ActiveWorkbook); var sd = _subs[e.RowIndex]; form.SubscriptionName = sd.Name; // don't let the user modify this name. form.txtName.Enabled = false; form.ServerName = sd.ServerName; form.Topic = sd.Topic; form.Filter = sd.Filter; form.WorksheetRange = sd.WorksheetRange; bool wasActive = ActiveSub.isActive(sd); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { sd.Name = form.SubscriptionName; sd.ServerName = form.ServerName; sd.Topic = form.Topic; sd.Filter = form.Filter; sd.WorksheetRange = form.WorksheetRange; DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; if (wasActive) { row.Cells[0].Value = false; deactivate(e.RowIndex); var wbInfo = Globals.AMPSAddin.getWorkbookInfo( Globals.AMPSAddin.Application.ActiveWorkbook); wbInfo.createOrUpdate(sd); if (activate(e.RowIndex)) { row.Cells[0].Value = true; } } row.Cells[1].Value = sd.Name; row.Cells[2].Value = sd.ServerName; row.Cells[3].Value = sd.Topic; row.Cells[4].Value = sd.Filter; row.Cells[5].Value = sd.WorksheetRange; } }
private void ManageSubsForm_Load(object sender, EventArgs e) { // get our current workbook var workbook = Globals.AMPSAddin.Application.ActiveWorkbook; _subs = new AMPSAddin.SubscriptionDefinition[Globals.AMPSAddin.getWorkbookInfo(workbook).Subscriptions.Count]; int i = 0; foreach (var sub in Globals.AMPSAddin.getWorkbookInfo(workbook).Subscriptions.Values) { bool active = ActiveSub.isActive(sub); this.dataGridView1.Rows.Add( active, sub.Name, sub.ServerName, sub.Topic, sub.Filter, sub.WorksheetRange, "X"); _subs[i++] = sub; } }