private void EditOtherWindow_Loaded(object sender, RoutedEventArgs e) { FullDepartmentNameTextBox.SetBinding(TextBox.TextProperty, new Binding("Value") { Source = Context.EntitiesVmRegistry.Settings[(int)Settings.FullDepartmentName] }); ShortDepartmentNameTextBox.SetBinding(TextBox.TextProperty, new Binding("Value") { Source = Context.EntitiesVmRegistry.Settings[(int)Settings.ShortDepartmentName] }); var multiBinding = new MultiBinding { Converter = new YearTextBoxMultiBindingConverter() }; multiBinding.Bindings.Add(new Binding("Value") { Source = Context.EntitiesVmRegistry.Settings[(int)Settings.StartYear] }); multiBinding.Bindings.Add(new Binding("Value") { Source = Context.EntitiesVmRegistry.Settings[(int)Settings.EndYear] }); multiBinding.NotifyOnSourceUpdated = true; //this is important. YearTextBox.SetBinding(TextBox.TextProperty, multiBinding); }
/// <summary> /// Performs checks on user input and displays appropriate error message if input /// is not valid. If all inputs are valid, saves the edits in the database as well. /// </summary> /// <returns></returns> private bool SaveTextEdits() { //numpages int pages; if (int.TryParse(PagesTextBox.Text, out pages)) //make sure that input is an integer. { if (pages < 0) //make sure that the integer is positive { ErrorLabel.Content = "Please enter a positive number for the number of pages."; PagesTextBox.Focus(); return(false); } } else { ErrorLabel.Content = "Please enter an integer for the number of pages."; PagesTextBox.Focus(); return(false); } //year int year; if (int.TryParse(YearTextBox.Text, out year)) //make sure that input is an integer { if (year < MIN_YEAR_PUBLISHED) //Ensure that the year published is not below minimum year { ErrorLabel.Content = String.Format("The minimum year possible is {0}", MIN_YEAR_PUBLISHED); YearTextBox.Focus(); return(false); } else if (year > DateTime.Now.Year) //Make sure that the year published is not at a future time. { ErrorLabel.Content = "Year published cannot be in a future year."; YearTextBox.Focus(); return(false); } } else { ErrorLabel.Content = "Please enter a positive integer for the year published."; return(false); } //Assign content to Book Book.Title = TitleTextBox.Text; Book.NumPages = pages; Book.Subject = SubjectTextBox.Text; Book.Description = DescriptionTextBox.Text; Book.Publisher = PublisherTextBox.Text; Book.YearPublished = year; Book.Language = LanguagesTextBox.Text; //Save Changes controller.Save(); return(true); }
private void resetToolStripMenuItem_Click(object sender, EventArgs e) { //When user wants to reset form, they will click on Reset NameTextBox.Clear(); FeelTextBox.Clear(); YearTextBox.Clear(); ProfileTextBox.Clear(); }
//Is supposed to update the maximum weeks in comboboxes, I don't think it works though private void UpdateWeeksInYear(object sender, TextCompositionEventArgs e) { int a; if (int.TryParse(YearTextBox.ToString(), out a)) { SetWeekComboBoxes(); e.Handled = SetWeekComboBoxes(); } }