public AddCustomTagDialog(IServiceProvider serviceProvider) : base(serviceProvider) { InitializeComponent(); var container = new CompositeDisposable(); FormClosed += (sender, args) => container.Dispose(); container.Add( Observable.FromEventPattern <EventArgs>(txtName, "TextChanged") .Merge(Observable.FromEventPattern <EventArgs>(txtAttribute, "TextChanged")) .Sample(TimeSpan.FromSeconds(0.5)) .ObserveOn(System.Threading.SynchronizationContext.Current) .Subscribe(evt => { btnOK.Enabled = !string.IsNullOrWhiteSpace(txtName.Text) && !string.IsNullOrWhiteSpace(txtAttribute.Text); })); container.Add( Observable.FromEventPattern <EventArgs>(btnOK, "Click") .ObserveOn(System.Threading.SynchronizationContext.Current) .Subscribe(evt => { Item = new CustomTagItem(null); Item.Name = txtName.Text; Item.Attribute = txtAttribute.Text; DialogResult = DialogResult.OK; })); }
public AddCustomTagsDialog(IServiceProvider serviceProvider) : base(serviceProvider) { InitializeComponent(); var container = new CompositeDisposable(); FormClosed += (sender, args) => container.Dispose(); container.Add( Observable.FromEventPattern <EventArgs>(txtName, "TextChanged") .Sample(TimeSpan.FromSeconds(1)) .ObserveOn(System.Threading.SynchronizationContext.Current) .Subscribe(evt => { btnOK.Enabled = !string.IsNullOrWhiteSpace(txtName.Text); })); container.Add( Observable.FromEventPattern <EventArgs>(btnRemove, "Click") .ObserveOn(System.Threading.SynchronizationContext.Current) .Subscribe(evt => { foreach (DataGridViewRow row in dgvTags.SelectedRows) { if (!row.IsNewRow) { dgvTags.Rows.Remove(row); } } })); container.Add( Observable.FromEventPattern <EventArgs>(btnOK, "Click") .ObserveOn(System.Threading.SynchronizationContext.Current) .Subscribe(evt => { Item = new CustomTagsItem(null); Item.Name = txtName.Text; foreach (DataGridViewRow row in dgvTags.Rows) { var tag = new CustomTagItem(null); tag.Name = row.Cells[0].Value.ToString(); tag.Attribute = row.Cells[1].Value.ToString(); Item.Add(tag); } DialogResult = DialogResult.OK; })); container.Add( Observable.FromEventPattern <DataGridViewCellEventArgs>(dgvTags, "RowEnter") .ObserveOn(System.Threading.SynchronizationContext.Current) .Subscribe(evt => { btnRemove.Enabled = !dgvTags.SelectedRows[0].IsNewRow; })); }
public void Add(CustomTagItem newItem) { // TODO: add }