private void ExecuteMultiplyToValueCommand(object sender, ExecutedRoutedEventArgs e) { if (this.UIModel.MathParameter <= 0 || this.UIModel.MathParameter == 1) { MessageBox.Show("Please enter a value bigger '0' and not '1'", "Invalid operation"); return; } var check = Convert.ToDouble(this.UIModel.MathParameter); Counter counter = new Counter(); DataGrid dg = null; dg = this.MainWindow.m_DataGridFBI; if (this.MainWindow.DataGridTDF.SelectedCells.Count < 1 && dg.SelectedCells.Count < 1) { MessageBox.Show("Please select at least one cell", "Selection invalid"); return; } if (this.MainWindow.DataGridTDF.SelectedCells.Count > 0 && dg.SelectedCells.Count > 0) { MessageBox.Show("You have selected cells in both tables. Please select cells only in one table.\r" + "You can deselect cells with Ctr + left click", "Selection invalid"); return; } int selectedCells = this.MainWindow.DataGridTDF.SelectedCells.Count + dg.SelectedCells.Count; // Weapons counter.Merge(BulkCalculation.CalculateOverAll(this.MainWindow.DataGridTDF, CalculationOperation.Multiply, this.UIModel.MathParameter)); // Units counter.Merge(BulkCalculation.CalculateOverAll(dg, CalculationOperation.Multiply, this.UIModel.MathParameter)); if (counter.OutOfRangeCount > 0 && (selectedCells != counter.SuccessCount)) { MessageBox.Show(counter.SuccessCount + " values have been changed.\r " + (selectedCells - counter.SuccessCount) + " cells could not be changed\r" + counter.OutOfRangeCount + " values were out of range and have been set to default.", "Calculation Errors"); } else if (counter.OutOfRangeCount > 0 && selectedCells.Equals(counter.SuccessCount)) { MessageBox.Show(counter.SuccessCount + " values have been changed.\r" + +counter.OutOfRangeCount + " values were out of range and have been set to default.", "Calculation Errors"); } else if (counter.OutOfRangeCount == 0 && !selectedCells.Equals(counter.SuccessCount)) { MessageBox.Show(counter.SuccessCount + " values have been changed.\r" + +(selectedCells - counter.SuccessCount) + " cells could not be changed.\r", "Calculation Mixed Success"); } else { MessageBox.Show("All " + counter.SuccessCount + " values have been changed successfully.", "Calculation Success"); } }
private void AddCalculation(CalculationOperation operation) { Counter counter = new Counter(); DataGrid dg = null; dg = this.MainWindow.m_DataGridFBI; if (this.MainWindow.DataGridTDF.SelectedCells.Count < 1 && dg.SelectedCells.Count < 1) { MessageBox.Show("Please select at least one cell", "Selection invalid"); return; } if (this.MainWindow.DataGridTDF.SelectedCells.Count > 0 && dg.SelectedCells.Count > 0) { MessageBox.Show("You have selected cells in both tables. Please select cells only in one table.\r" + "You can deselect cells with Ctr + left click", "Selection invalid"); return; } int selectedCells = this.MainWindow.DataGridTDF.SelectedCells.Count + dg.SelectedCells.Count; // Weapons counter.Merge(BulkCalculation.CalculateOverAll(this.MainWindow.DataGridTDF, operation, this.UIModel.MathParameter)); // Units counter.Merge(BulkCalculation.CalculateOverAll(dg, operation, this.UIModel.MathParameter)); if (counter.OutOfRangeCount > 0 && (selectedCells != counter.SuccessCount)) { MessageBox.Show(counter.SuccessCount + " values have been changed.\r " + (selectedCells - counter.SuccessCount) + " cells could not be changed\r" + counter.OutOfRangeCount + " values were out of range and have been set to default.", "Calculation Errors"); } else if (counter.OutOfRangeCount > 0 && selectedCells.Equals(counter.SuccessCount)) { MessageBox.Show(counter.SuccessCount + " values have been changed.\r" + +counter.OutOfRangeCount + " values were out of range and have been set to default.", "Calculation Errors"); } else if (counter.OutOfRangeCount == 0 && !selectedCells.Equals(counter.SuccessCount)) { MessageBox.Show(counter.SuccessCount + " values have been changed.\r" + +(selectedCells - counter.SuccessCount) + " cells could not be changed.\r", "Calculation Mixed Success"); } else { MessageBox.Show("All " + counter.SuccessCount + " values have been changed successfully.", "Calculation Success"); } }