protected override void OnNavigatedTo(NavigationEventArgs e) { Relax relax = e.Parameter as Relax; this.relax = relax; PopulatePage(); }
public RelaxControl(Relax relax) { this.InitializeComponent(); this.relax = relax; PopulateControls(); }
private async void changeButton_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; // null value checks TextBox relaxName = (TextBox)this.FindName("relaxName"); TextBox relaxWaitDuration = (TextBox)this.FindName("relaxWaitDuration"); ComboBox relaxWaitUnits = (ComboBox)this.FindName("relaxWaitUnits"); TextBox relaxRelaxDuration = (TextBox)this.FindName("relaxRelaxDuration"); ComboBox relaxRelaxUnits = (ComboBox)this.FindName("relaxRelaxUnits"); if (relaxName.Text == null || relaxName.Text == "") { var dialog = new MessageDialog("You must specify a Name."); dialog.Title = "Missing Information"; await dialog.ShowAsync(); } else if (relaxWaitDuration == null || relaxWaitDuration.Text == "") { var dialog = new MessageDialog("You must specify a Wait Duration."); dialog.Title = "Missing Information"; await dialog.ShowAsync(); } else if (relaxWaitUnits == null || relaxWaitUnits.SelectedValue == null) { var dialog = new MessageDialog("You must specify Wait Units."); dialog.Title = "Missing Information"; await dialog.ShowAsync(); } else if (relaxRelaxDuration == null || relaxRelaxDuration.Text == "") { var dialog = new MessageDialog("You must specify a Relax Duration."); dialog.Title = "Missing Information"; await dialog.ShowAsync(); } else if (relaxRelaxUnits == null || relaxRelaxUnits.SelectedValue == null) { var dialog = new MessageDialog("You must specify Relax Units."); dialog.Title = "Missing Information"; await dialog.ShowAsync(); } else { // construct relax object int waitHours = 0; int waitMinutes = 0; int waitSeconds = 0; ComboBoxItem selectedWaitUnits = (ComboBoxItem)relaxWaitUnits.SelectedValue; if (selectedWaitUnits.Content.ToString() == "Hrs") { waitHours = Int32.Parse(relaxWaitDuration.Text); } else if (selectedWaitUnits.Content.ToString() == "Min") { waitMinutes = Int32.Parse(relaxWaitDuration.Text); } else if (selectedWaitUnits.Content.ToString() == "Sec") { waitSeconds = Int32.Parse(relaxWaitDuration.Text); } TimeSpan waitDuration = new TimeSpan(waitHours, waitMinutes, waitSeconds); int relaxHours = 0; int relaxMinutes = 0; int relaxSeconds = 0; ComboBoxItem selectedRelaxUnits = (ComboBoxItem)relaxRelaxUnits.SelectedValue; if (selectedRelaxUnits.Content.ToString() == "Hrs") { relaxHours = Int32.Parse(relaxRelaxDuration.Text); } else if (selectedRelaxUnits.Content.ToString() == "Min") { relaxMinutes = Int32.Parse(relaxRelaxDuration.Text); } else if (selectedRelaxUnits.Content.ToString() == "Sec") { relaxSeconds = Int32.Parse(relaxRelaxDuration.Text); } TimeSpan relaxDuration = new TimeSpan(relaxHours, relaxMinutes, relaxSeconds); if (button.Content.ToString() == "Add") { this.relax = new Relax(relaxName.Text, waitDuration, relaxDuration); } else if (button.Content.ToString() == "Save") { this.relax.name = relaxName.Text; this.relax.waitDuration = waitDuration; this.relax.relaxDuration = relaxDuration; } this.Frame.Navigate(typeof(MainPage), this.relax); } }