private void CreateBalanceVisualizer() { ClearBalanceVisualizer(); // Pull the selected index out of the combobox's text int selectedIndex = -1; string selectedText = cboBalanceVector.SelectedItem as string; if (!string.IsNullOrEmpty(selectedText)) { Match match = Regex.Match(selectedText, @"\d+"); if (match.Success) { selectedIndex = Convert.ToInt32(match.Value) - 1; // the text is one based, but selected index is zero based } } _balanceVisualizer = new BalanceVisualizer(_viewport, Convert.ToInt32(trkBalanceCount.Value), chkBalance3D.IsChecked.Value); _balanceVisualizer.SelectedIndex = selectedIndex; _balanceVisualizer.ShowAxiis = chkBalanceAxiis.IsChecked.Value; _balanceVisualizer.TestType = GetBalanceTestType(); _balanceVisualizer.ShowPossibilityLines = chkBalancePossLines.IsChecked.Value; _balanceVisualizer.ShowPossibilityHull = chkBalancePossHull.IsChecked.Value; }
private void ClearBalanceVisualizer() { if (_balanceVisualizer != null) { _balanceVisualizer.Dispose(); } _balanceVisualizer = null; }