void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.window = ((WPF_millionaire.DiagramWindow)(target)); return; case 2: this.text = ((System.Windows.Controls.TextBlock)(target)); return; case 3: this.rectangleA = ((System.Windows.Shapes.Rectangle)(target)); return; case 4: this.rectangleB = ((System.Windows.Shapes.Rectangle)(target)); return; case 5: this.rectangleC = ((System.Windows.Shapes.Rectangle)(target)); return; case 6: this.rectangleD = ((System.Windows.Shapes.Rectangle)(target)); return; } this._contentLoaded = true; }
public void MethodHall(List <Button> b, string trueAnswer) { if (_hall) { _hall = false; _diagram = new DiagramWindow(); _diagram.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; int count = 0; for (int i = 0; i < 4; i++) { if (!b[i].Content.Equals("")) { count++; } } int trueButton = 0; for (int i = 0; i < b.Count; i++) { string str = b[i].Content.ToString(); if (!str.Equals("") && trueAnswer.Equals(str.Remove(0, 3))) { trueButton = i; } } if (count == 4) { int[] array = { 0, 0, 0, 0 }; array[trueButton] = 5; int index = 0; for (int i = 0; i < 15; i++) { index = _rand.Next(0, 4); array[index]++; } float percent = ((float)_diagram.window.Height - (float)_diagram.text.Height) / 23f; _diagram.rectangleA.Height = array[0] * percent; _diagram.rectangleB.Height = array[1] * percent; _diagram.rectangleC.Height = array[2] * percent; _diagram.rectangleD.Height = array[3] * percent; } else if (count == 2) { int falseButton = 0; int[] array = { 0, 0, 0, 0 }; for (int i = 0; i < 4; i++) { if (!b[i].Content.Equals("") && i != trueButton) { falseButton = i; } } array[trueButton] = 8; float percent = ((float)_diagram.window.Height - (float)_diagram.text.Height) / 23f; int index = 0; for (int i = 0; i < 12; i++) { while (true) { index = _rand.Next(0, 4); if (index == trueButton) { break; } else if (index == falseButton) { break; } } array[index]++; } _diagram.rectangleA.Height = array[0] * percent; _diagram.rectangleB.Height = array[1] * percent; _diagram.rectangleC.Height = array[2] * percent; _diagram.rectangleD.Height = array[3] * percent; } _diagram.Show(); } }