void ModifySendMenuItemClick(object sender, EventArgs e) { if (_domainGrid.SelectedRows.Count == 0) { Log(@"No commands to send."); return; } // don`t resend set of commands if (_domainGrid.SelectedRows.Count > 1) { Log("Selected too many commands. Please, select only one!"); return; } try { var items = _domainGrid.SelectedRows .Cast <DataGridViewRow>() .Select(i => (DomainLogDisplayItem)i.DataBoundItem) .SelectMany(d => d.Item.Items) .ToList(); // don`t resend set of commands if (items.Count > 1) { Log("Too many commands in selected envelope. Please, select only one!"); return; } var envelope = items.Single(); using (var m = new ModifyMessage()) { m.BindMessage(envelope.MappedType, envelope.Content); if (m.ShowDialog(this) != DialogResult.OK) { return; } var result = m.GetMessage(); if ( MessageBox.Show(this, @"Do you really want to send this message?", @"Sending confirmation", MessageBoxButtons.YesNo) == DialogResult.No) { return; } _services.SendCommand((IRecipeCommand)result); } } catch (Exception ex) { MessageBox.Show(this, ex.ToString(), @"Error"); } }
void ModifySendMenuItemClick(object sender, EventArgs e) { if (_domainGrid.SelectedRows.Count == 0) { Log(@"No commands to send."); return; } // don`t resend set of commands if (_domainGrid.SelectedRows.Count > 1) { Log("Selected too many commands. Please, select only one!"); return; } try { var items = _domainGrid.SelectedRows .Cast<DataGridViewRow>() .Select(i => (DomainLogDisplayItem) i.DataBoundItem) .SelectMany(d => d.Item.Items) .ToList(); // don`t resend set of commands if (items.Count > 1) { Log("Too many commands in selected envelope. Please, select only one!"); return; } var envelope = items.Single(); using (var m = new ModifyMessage()) { m.BindMessage(envelope.MappedType, envelope.Content); if (m.ShowDialog(this) != DialogResult.OK) { return; } var result = m.GetMessage(); if ( MessageBox.Show(this, @"Do you really want to send this message?", @"Sending confirmation", MessageBoxButtons.YesNo) == DialogResult.No) return; _services.SendCommand((ISampleCommand) result); } } catch (Exception ex) { MessageBox.Show(this, ex.ToString(), @"Error"); } }