private void blankTextBox_LostFocus(object sender, RoutedEventArgs e) { NumberOnlyTextBox textBox = sender as NumberOnlyTextBox; if (textBox == null) { return; } if (string.IsNullOrEmpty(textBox.Text)) { return; } QuestionBlank blank = textBox.Tag as QuestionBlank; if (this.fibQuestion.IsContentCorrect(blank.Id, new QuestionContent(textBox.Text, ContentType.Text))) { textBox.Foreground = new SolidColorBrush(Colors.Green); } else { textBox.Foreground = new SolidColorBrush(Colors.Red); } }
private void CreateBlank(QuestionBlank blank, int index) { StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Horizontal; panel.Margin = new Thickness(2); this.blankPanel.Children.Add(panel); // Index Label indexLabel = new Label(); indexLabel.Content = string.Format("{0}).", index + 1); indexLabel.FontSize = 20; indexLabel.Width = 60; indexLabel.VerticalAlignment = System.Windows.VerticalAlignment.Center; indexLabel.Margin = new Thickness(5); panel.Children.Add(indexLabel); // Blank NumberOnlyTextBox blankTextBox = new NumberOnlyTextBox(); blankTextBox.Tag = blank; blankTextBox.Width = 80; blankTextBox.VerticalAlignment = System.Windows.VerticalAlignment.Center; blankTextBox.FontSize = 20; blankTextBox.Margin = new Thickness(5); blankTextBox.LostFocus += new RoutedEventHandler(blankTextBox_LostFocus); blankTextBox.TextChanged += new TextChangedEventHandler(blankTextBox_TextChanged); panel.Children.Add(blankTextBox); }
public static UIElement CreateUIPart(QuestionContentPart part) { if (part is QuestionBlank) { NumberOnlyTextBox blankTextBox = new NumberOnlyTextBox(); blankTextBox.Tag = part; blankTextBox.Width = 80; blankTextBox.VerticalAlignment = System.Windows.VerticalAlignment.Center; blankTextBox.FontSize = 20; blankTextBox.Margin = new Thickness(1); return(blankTextBox); } else if (part is ArithmeticDecimalValuePart) { ArithmeticDecimalValuePart decimalPart = part as ArithmeticDecimalValuePart; if (decimalPart.Value == null) { return(CreateText(string.Empty)); } return(CreateText(decimalPart.Value.ToString())); } else if (part is ArithmeticFractionValuePart) { ArithmeticFractionValuePart fractionPart = part as ArithmeticFractionValuePart; FractionControl fractionControl = new FractionControl(20, FontWeights.Medium, 2, new SolidColorBrush(Colors.Black)); fractionControl.Numerator = fractionPart.Numerator; fractionControl.Denominator = fractionPart.Denominator; fractionControl.FontSize = 20; fractionControl.FontWeight = FontWeights.Medium; fractionControl.VerticalAlignment = VerticalAlignment.Center; return(fractionControl); } else if (part is ArithmeticSignPart) { } else if (part is QuestionTextPart) { QuestionTextPart textPart = part as QuestionTextPart; return(CreateText(textPart.Text)); } else if (part is QuestionPowerExponentPart) { PowerExponentControl powerExponentControl = new PowerExponentControl(20, FontWeights.Medium, new SolidColorBrush(Colors.Black)); powerExponentControl.PowerExponentPart = part as QuestionPowerExponentPart; return(powerExponentControl); } else if (part is QuestionPowerPart) { } else if (part is QuestionFlowDocumentPart) { } throw new NotSupportedException(); }
private void blankTextBox_TextChanged(object sender, TextChangedEventArgs e) { NumberOnlyTextBox textBox = sender as NumberOnlyTextBox; if (textBox == null) { return; } QuestionBlank blank = textBox.Tag as QuestionBlank; QuestionBlankResponse blankResponse = this.fibResponse.GetBlankResponse(blank.Id, true); blankResponse.BlankContent.Content = textBox.Text; }
private void CreateBlank(QuestionBlank blank) { // Blank NumberOnlyTextBox blankTextBox = new NumberOnlyTextBox(); blankTextBox.Tag = blank; blankTextBox.Width = 80; blankTextBox.VerticalAlignment = System.Windows.VerticalAlignment.Center; blankTextBox.FontSize = 20; blankTextBox.Margin = new Thickness(5); blankTextBox.LostFocus += new RoutedEventHandler(blankTextBox_LostFocus); blankTextBox.TextChanged += new TextChangedEventHandler(blankTextBox_TextChanged); this.questionBodyPanel.Children.Add(blankTextBox); }
private void readCountResultListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListBox lb = sender as ListBox; ReadCountItem readCountItem = lb.SelectedItem as ReadCountItem; if (readCountItem == null) { return; } ListBoxItem item = lb.ItemContainerGenerator.ContainerFromItem(readCountItem) as ListBoxItem; FocusItem(item, "numberTextBox"); NumberOnlyTextBox textBox = GC_UIHelper.FindChild <NumberOnlyTextBox>(item, "numberTextBox"); if (textBox != null) { textBox.SelectAll(); } }
public WLPackageSendCanvas(GlobalGUIManager global) : base(global.rootcvs) { Width = 20 + textBoxes.Length * WindowDistance + 20; Height = 60; Background = Brushes.DarkGreen; //title Children.Add(new Label() { IsHitTestVisible = false, Content = "Wireless Package Sender", Margin = new Thickness(30, 0, 0, 0) }); //remove AddClickPoint(new RemoveClickPoint(0, 0, this)); for (int i = 0; i < textBoxes.Length; i++) { textBoxes[i] = new NumberOnlyTextBox() { Margin = new Thickness(20 + WindowDistance * i, 20, 0, 0), Width = WindowDistance, }; Children.Add(textBoxes[i]); } ClickEventPoint clickEventPoint = new ClickEventPoint(20, 40) { Width = 10, Height = 10, Background = Brushes.LightGreen }; clickEventPoint.OnClickEvent += Submit; AddClickPoint(clickEventPoint); signal = new WirelessSignal(global.rootcvs, dev, 20, 20); Children.Add(signal); timer.Tick += Update; timer.Interval = TimeSpan.FromMilliseconds(200); timer.Start(); }