Esempio n. 1
0
        private void EditRow(DataGridViewRow row)
        {
            Models.NetworkCredential credential          = (Models.NetworkCredential)row.DataBoundItem;
            Models.NetworkCredential untouchedCredential = credential.Clone() as Models.NetworkCredential;

            using (var form = new AddEditNetworkCredentialForm(credential))
            {
                form.Canceled += (object sender2, NetworkCredentialActionEventArgs e2) =>
                {
                    // Revert changes.
                    credential.RevertTo(untouchedCredential);
                };

                form.Confirmed += (object sender2, NetworkCredentialActionEventArgs e2) =>
                {
                    bool isNew = Added.Contains(credential);
                    if (!isNew)
                    {
                        Modified.Add(e2.Credential);
                        dgvCredentials.InvalidateRow(row.Index);
                    }
                };

                form.ShowDialog(this);
            }
        }
Esempio n. 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Models.NetworkCredential credential = new Models.NetworkCredential();
            using (var form = new AddEditNetworkCredentialForm(credential))
            {
                form.Canceled += (object sender2, NetworkCredentialActionEventArgs e2) =>
                {
                    // Do nothing.
                };

                form.Confirmed += (object sender2, NetworkCredentialActionEventArgs e2) =>
                {
                    Added.Add(e2.Credential);
                    All.Add(e2.Credential);
                    RefreshDataGrid();
                };

                form.ShowDialog(this);
            }
        }