private void btnAppEdit_Click(object sender, System.EventArgs e) { Dictionary <int, FormApplication> updatedList = new Dictionary <int, FormApplication>(); foreach (DataGridViewRow row in dataGridViewApp.Rows) { if (row.Cells[0].Value != null && (bool)row.Cells[0].Value) { // show the form user int appId = (int)row.Cells[1].Value; string appName = (string)row.Cells[2].Value; FormApplication formApp = new FormApplication(appName); formApp.Text = "Edit Application"; formApp.BrowseButtonEnabled = false; formApp.DisplayName = appName; formApp.ExecutablePath = (string)row.Cells[3].Value; formApp.Arguments = (string)row.Cells[4].Value; string[] area = ((string)row.Cells[5].Value).Split(','); int left = int.Parse(area[0]); int top = int.Parse(area[1]); int right = int.Parse(area[2]); int bottom = int.Parse(area[3]); formApp.PositionLeft = left; formApp.PositionTop = top; formApp.Width = right - left; formApp.Height = bottom - top; if (formApp.ShowDialog(this) == System.Windows.Forms.DialogResult.OK && formApp.IsDirty) { // add to database updatedList.Add(appId, formApp); } } } foreach (KeyValuePair <int, FormApplication> data in updatedList) { // add to database applicationPresenter.EditApplication( data.Key, data.Value.DisplayName, data.Value.ExecutablePath, data.Value.Arguments, data.Value.PositionLeft, data.Value.PositionTop, data.Value.PositionLeft + data.Value.Width, data.Value.PositionTop + data.Value.Height); } }
private void btnAppAdd_Click(object sender, System.EventArgs e) { FormApplication fromApp = new FormApplication(String.Empty); fromApp.BrowseButtonEnabled = false; fromApp.Text = "Add Application"; if (fromApp.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { // add to database applicationPresenter.AddApplication( fromApp.DisplayName, fromApp.ExecutablePath, fromApp.Arguments, fromApp.PositionLeft, fromApp.PositionTop, fromApp.PositionLeft + fromApp.Width, fromApp.PositionTop + fromApp.Height); } }