private void AddRuleControls(List<Indicator> indicators, SplittingType splitType) { for (int i = 0; i < indicators.Count; i++) { var index = tblNewUnits.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); // Add control to screen var label = new H3bLabel { AutoSize = true, Text = indicators[i].DisplayName, Margin = new Padding(0, 5, 10, 5) }; label.MakeBold(); tblNewUnits.Controls.Add(label, 0, index); var cntrl = CreateDropdown(indicators[i], GetRuleValues(splitType, indicators[i].DataTypeId)); tblNewUnits.Controls.Add(cntrl, 1, index); } }
private void SplittingAdminLevel_Load(object sender, EventArgs e) { if (!DesignMode) { Localizer.TranslateControl(this); int levelNumber = 0; if (options.SplitType == SplittingType.SplitCombine) levelNumber = options.MergeSources[0].LevelNumber; else levelNumber = options.Source.LevelNumber; for (int i = 0; i < options.SplitIntoNumber.Value; i++) { var index = tblNewUnits.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); var cntrl = new TextBox { Width = 100, Margin = new Padding(0, 5, 10, 5), Tag = i }; var chooser = new AdminUnitChooser(levelNumber); chooser.Margin = new Padding(0, 5, 10, 5); AdminLevel source = null; if (options.SplitType == SplittingType.SplitCombine) { chooser.HideNewLink(); chooser.Select(options.MergeSources[i], true); options.MergeSources[i].Children = repo.GetAdminLevelChildren(options.MergeSources[i].Id); options.MergeSources[i].CurrentDemography = repo.GetRecentDemography(options.MergeSources[i].Id); source = options.MergeSources[i]; } else if (options.SplitType == SplittingType.Split) { if (options.SplitDestinations.Count() >= i + 1) { chooser.Select(options.SplitDestinations[i].Unit, true); cntrl.Text = options.SplitDestinations[i].Percent.ToString(); } source = options.Source; } // Add control to screen choosers.Add(new ChooseAdminLevel { Chooser = chooser, Source = source }); tblNewUnits.Controls.Add(chooser, 0, index); var label = new H3bLabel { AutoSize = true, Text = "0", Margin = new Padding(0, 5, 10, 5) }; label.MakeBold(); labels.Add(label); tblNewUnits.Controls.Add(label, 2, index); cntrl.TextChanged += cntrl_TextChanged; percents.Add(cntrl); tblNewUnits.Controls.Add(cntrl, 1, index); } } }
private void validationWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (this.IsDisposed) return; // Get the validation results List<ValidationResult> validationResults = (List<ValidationResult>)e.Result; // Hide and clear the validation results container while it is being populated tlpValidationResults.Visible = false; this.SuspendLayout(); tlpValidationResults.Controls.Clear(); // Display each result foreach (ValidationResult result in validationResults) { // Add a new row int labelRowIndex = tlpValidationResults.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); int controlRowIndex = tlpValidationResults.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); // Add label tlpValidationResults.Controls.Add( new H3bLabel { Text = TranslationLookup.GetValue(result.ValidationRule.Indicator.DisplayName, result.ValidationRule.Indicator.DisplayName), Name = "ciLabel_" + result.ValidationRule.Indicator.DisplayName, AutoSize = true }, 0, labelRowIndex); // Add val var label = new H3bLabel { Text = result.Message, Name = "ciLabel_Val" + result.ValidationRule.Indicator.DisplayName, AutoSize = true }; // Set the validation message text color if (result.IsSuccess) label.TextColor = Color.FromArgb(0, 160, 0); else { if (result.HadMissingValues) label.TextColor = Color.FromArgb(0, 0, 160); else label.TextColor = Color.FromArgb(160, 0, 0); } label.MakeBold(); tlpValidationResults.Controls.Add(label, 0, controlRowIndex); } this.ResumeLayout(); tlpValidationResults.Visible = true; loadingIndicator.Visible = false; lnkValidateLink.Enabled = true; }
void calcWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (this.IsDisposed) return; List<KeyValuePair<string, string>> calculationResults = (List<KeyValuePair<string, string>>)e.Result; tblIndicators.Visible = false; this.SuspendLayout(); tblIndicators.Controls.Clear(); int count = 0; int labelRowIndex = tblIndicators.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); int controlRowIndex = tblIndicators.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); int columnCount = 0; if (calculationResults.Count == 0) this.Visible = false; foreach (var item in calculationResults) { if (count % 2 == 0) { labelRowIndex = tblIndicators.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); controlRowIndex = tblIndicators.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); columnCount = 0; } // Add label tblIndicators.Controls.Add( new H3bLabel { Text = TranslationLookup.GetValue(item.Key, item.Key), Name = "ciLabel_" + item.Key, AutoSize = true, }, columnCount, labelRowIndex); // Add val var label = new H3bLabel { Text = item.Value, Name = "ciLabel_Val" + item.Key, AutoSize = true, }; label.MakeBold(); tblIndicators.Controls.Add(label, columnCount, controlRowIndex); count++; columnCount = columnCount + 2; } this.ResumeLayout(); tblIndicators.Visible = true; lblCalculating.Visible = false; OnFocus(); }