private void processFormResults(object sender, RoutedEventArgs e) { List <CheckBox> allCheckboxes = new List <CheckBox>(); allCheckboxes = checkRow1.Children.OfType <CheckBox>().ToList(); allCheckboxes = allCheckboxes.Concat(checkRow2.Children.OfType <CheckBox>().ToList()).ToList(); allCheckboxes = allCheckboxes.Concat(checkRow3.Children.OfType <CheckBox>().ToList()).ToList(); allCheckboxes = allCheckboxes.Concat(checkRow4.Children.OfType <CheckBox>().ToList()).ToList(); allCheckboxes = allCheckboxes.Concat(checkRow5.Children.OfType <CheckBox>().ToList()).ToList(); allCheckboxes = allCheckboxes.Concat(checkRow6.Children.OfType <CheckBox>().ToList()).ToList(); List <CheckBox> selectedBoxes = new List <CheckBox>(); foreach (CheckBox checkbox in allCheckboxes) { StackPanel parent = (StackPanel)checkbox.Parent; parent.UnregisterName(checkbox.Name); parent.Children.Remove(checkbox); if (checkbox.IsChecked.GetValueOrDefault()) { checkbox.IsChecked = false; selectedBoxes.Add(checkbox); Selections.Last().stage3 = int.Parse(checkbox.Name.Split('_')[1]); } } string nums = ""; string questionValues = ""; for (int i = 0; i < QuestionShapeValues.shapeValues.Count(); i++) { questionValues += (i + 1) + ":" + QuestionShapeValues.shapeValues[i] + ", "; } questionValues += "\r\n"; int entryNum = 1; string diagText = ""; List <PatternShapeModel> idealShapes = new List <PatternShapeModel>(); foreach (Phase1Selections selection in Selections) { diagText += "**************Entry Number " + entryNum + "******************\r\n\r\n"; List <PatternShapeModel> patternShapes = new List <PatternShapeModel>() { }; foreach (int stage2Val in selection.stage2) { patternShapes.Add(new PatternShapeModel(QuestionShapeValues.getQuestionValue(stage2Val), stage2Val)); } patternShapes.Add(new PatternShapeModel(QuestionShapeValues.getQuestionValue(selection.stage3), selection.stage3)); // patternShapes.Add(new PatternShapeModel(QuestionShapeValues.getQuestionValue(selection.stage3), selection.stage3)); int[] idealjdqa = PatternShapeFunctions.calculateIdealJDQA(patternShapes); idealShapes.Add(new PatternShapeModel(int.Parse(string.Join("", idealjdqa)), 0, 0, 0)); diagText += "JDQA's to be averaged (Last shape duplicated for darkened circle value):\r\n"; diagText += String.Join("\r\n", patternShapes.Select(ps => ps.QuestionNum + ": " + ps.PS).ToList()); diagText += "\r\nIdeal JDQA:" + string.Join("", idealjdqa) + "\r\n\r\n"; entryNum++; } diagText += "TOTAL IDEAL JDQA: " + string.Join("", PatternShapeFunctions.calculateIdealJDQA(idealShapes)); try { SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = "phase1Debug_" + Guid.NewGuid() + ".txt"; sfd.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; sfd.ShowDialog(); if (sfd.FileName != "") { using (StreamWriter writer = new StreamWriter(sfd.OpenFile())) { writer.Write(diagText); }; } Process.Start(sfd.FileName); } catch (Exception ex) { } }
private void ShowCalculations(Dictionary <string, List <PatternShapeModel> > patternShapes) { List <PatternShapeModel> Z = patternShapes["Z"]; List <PatternShapeModel> X = patternShapes["X"]; ConvertedScoreTable scoreTable = new ConvertedScoreTable(); int[] idealJDQA = PatternShapeFunctions.calculateIdealJDQA(Z); IdealJDQAText.Content = string.Format("Job Demands Quotient: {0}{1}{2}{3}", idealJDQA[0], idealJDQA[1], idealJDQA[2], idealJDQA[3]); List <ConvertedScoreRow> zConvertedScores = new List <ConvertedScoreRow>(); List <ConvertedScoreRow> xConvertedScores = new List <ConvertedScoreRow>(); for (int i = 0; i < Z.Count(); i++) { double r = calculateR(PatternShapeFunctions.sliceCQ(Z[i].PS), idealJDQA); int modifiedR = (int)Math.Round(r * 100, MidpointRounding.AwayFromZero); ConvertedScoreRow zScoreRow = scoreTable.ConversionRows[modifiedR]; zConvertedScores.Add(zScoreRow); double convertedScore = zScoreRow.Score; Label zLabel = new Label(); zLabel.Content = string.Format("z{0} R Value: {1} Converted Score: {2}", i + 1, Math.Round(r, 2), convertedScore); // ZResults.Children.Add(zLabel); } for (int i = 0; i < X.Count(); i++) { double r = calculateR(PatternShapeFunctions.sliceCQ(X[i].PS), idealJDQA); int modifiedR = (int)Math.Round(r * 100, MidpointRounding.AwayFromZero); ConvertedScoreRow xScoreRow = scoreTable.ConversionRows[modifiedR]; xConvertedScores.Add(xScoreRow); double convertedScore = xScoreRow.Score; Label xLabel = new Label(); xLabel.Content = String.Format("x{0} R Value: {1} Converted Score: {2}", i + 1, Math.Round(r, 2), convertedScore); // XResults.Children.Add(xLabel); } double c = zConvertedScores.Sum(z => z.Score); Label cLabel = new Label(); cLabel.Content = String.Format("c value: {0}", c); // CalculatedValues.Children.Add(cLabel); double x1 = c / zConvertedScores.Count(); Label x1Label = new Label(); x1Label.Content = String.Format("x1 value: {0}", Math.Round(x1, 2, MidpointRounding.AwayFromZero)); // CalculatedValues.Children.Add(x1Label); double d = xConvertedScores.Sum(x => x.Score); Label dLabel = new Label(); dLabel.Content = String.Format("d value: {0}", d); // CalculatedValues.Children.Add(dLabel); double x2 = d / xConvertedScores.Count(); Label x2Label = new Label(); x2Label.Content = String.Format("x2 value: {0}", Math.Round(x2, 2, MidpointRounding.AwayFromZero)); // CalculatedValues.Children.Add(x2Label); double a = zConvertedScores.Sum(z => z.Score * z.Score); Label aLabel = new Label(); aLabel.Content = String.Format("a value: {0}", a); // CalculatedValues.Children.Add(aLabel); double b = xConvertedScores.Sum(x => x.Score * x.Score); Label bLabel = new Label(); bLabel.Content = String.Format("b value: {0}", b); // CalculatedValues.Children.Add(bLabel); double n1 = zConvertedScores.Count(); Label n1Label = new Label(); n1Label.Content = String.Format("n1 value: {0}", n1); // CalculatedValues.Children.Add(n1Label); double n2 = xConvertedScores.Count(); Label n2Label = new Label(); n2Label.Content = String.Format("n2 value: {0}", n2); // CalculatedValues.Children.Add(n2Label); double S = (a - ((c * c) / n1)) + (b - ((d * d) / n2)); Label sLabel = new Label(); sLabel.Content = String.Format("S value: {0}", Math.Round(S, 2, MidpointRounding.AwayFromZero)); // CalculatedValues.Children.Add(sLabel); double R = Math.Sqrt((S / ((n1 + n2) - 2)) * ((1 / n1) + (1 / n2))); Label rLabel = new Label(); rLabel.Content = String.Format(@" Regarding individuals being considered for this position, any ITS Self Concept Pattern Shape with a compatibility (COM) of between .70 and 1.00 would be an excellent match from a behavioral stand point. From .40 to .69 would be considered a good match. .10 to .39 a fair match and from - (minus) 1.00 to + .09 a poor match.", R); double T = (x1 - x2) / R; Label tLabel = new Label(); tLabel.Content = String.Format("\r\n T value: {0}", Math.Round(T, 2, MidpointRounding.AwayFromZero)); // CalculatedValues.Children.Add(tLabel); int df = (int)(n1 + n2 - 2); Label dfLabel = new Label(); dfLabel.Content = String.Format("\r\n df value: {0}", df); // CalculatedValues.Children.Add(dfLabel); Label distributionLabel = new Label(); DistributionTable dTable = new DistributionTable(); DistributionRow dr = dTable._distributionRows.ContainsKey(df) ? dTable._distributionRows[df] : dTable._distributionRows[0]; string significanceStatement = getSignificanceStatement(dr, T); Label significanceLabel = new Label(); significanceLabel.Content = significanceStatement; CalculatedValues.Children.Add(significanceLabel); CalculatedValues.Children.Add(rLabel); }