public virtual void ShouldGenerateTimeItems() { ListTimePickerPopup ltp = new ListTimePickerPopup(); TestAsync( ltp, () => Assert.IsTrue(ltp.TimeItemsSelection.Items.Count > 0)); }
public virtual void ShouldNotAllowSelectingMultipleItems() { ListTimePickerPopup ltp = new ListTimePickerPopup(); ISelectionProvider provider = null; TestAsync( ltp, () => provider = (ISelectionProvider)FrameworkElementAutomationPeer.CreatePeerForElement(ltp), () => Assert.IsFalse(provider.CanSelectMultiple)); }
void btnSelectDateTime_Click(object sender, RoutedEventArgs e) { StackPanel pnl = new StackPanel(); pnl.Orientation = Orientation.Horizontal; //InnerTimePicker.Width = 50; //StackPanel spSpliter = new StackPanel(); //spSpliter.Width = 5; //InnerDatePicker = new SmtDatePicker(); //InnerDatePicker.Style = Application.Current.Resources["DatePickerStyle"] as Style; //InnerDatePicker.Margin = new Thickness(0, 0, 5, 0); //InnerDatePicker.MinWidth = 110; InnerDatePicker = new Calendar(); //InnerDatePicker.Style = Application.Current.Resources["DatePickerStyle"] as Style; InnerDatePicker.Margin = new Thickness(0, 0, 5, 0); InnerDatePicker.SelectedDate = DateTime.Now; //InnerDatePicker.MinWidth = 110; InnerTimePicker = new ListTimePickerPopup(); InnerTimePicker.Value = DateTime.Parse("8:30"); InnerTimePicker.Margin = new Thickness(0, 0, 0, 0); InnerTimePicker.MinWidth = 170; InnerTimePicker.MinHeight = 155; Button btnClose = new Button(); btnClose.Style = Application.Current.Resources["CommonButtonStyle"] as Style; btnClose.BorderThickness = new Thickness(1); btnClose.Click += new RoutedEventHandler(btnClose_Click); btnClose.MinWidth = 30; btnClose.Content = "确定"; pnl.Children.Add(InnerDatePicker); //pnl.Children.Add(spSpliter); pnl.Children.Add(InnerTimePicker); pnl.Children.Add(btnClose); //this.Content = pnl; EndUpdate(); windowSelectdateTime.Content = pnl; double browserHeight = this.txtDateTime.ActualHeight; double browserWidth = this.txtDateTime.ActualWidth; windowSelectdateTime.Margin = new Thickness(browserWidth, browserHeight, 0, 0); windowSelectdateTime.Show(); windowSelectdateTime.Loaded += new RoutedEventHandler(windowSelectdateTime_Loaded); }
public virtual void ShouldUseDatePartFromValueToGenerateItems() { ListTimePickerPopup ltp = new ListTimePickerPopup() { PopupMinutesInterval = 15, Culture = new CultureInfo("nl-NL"), Format = new LongTimeFormat() }; ltp.Value = new DateTime(1900, 2, 2, 13, 0, 0); Assert.IsTrue(ltp.TimeItemsSelection.Items[0].Value.Value.Date == new DateTime(1900, 2, 2)); ltp.Value = new DateTime(2000, 3, 4, 3, 0, 0); Assert.IsTrue(ltp.TimeItemsSelection.Items[0].Value.Value.Date == new DateTime(2000, 3, 4)); }
public virtual void ShouldSelectCorrectItemOnValueChanges() { ListTimePickerPopup ltp = new ListTimePickerPopup() { PopupMinutesInterval = 15, Culture = new CultureInfo("nl-NL"), Format = new LongTimeFormat() }; ltp.Value = new DateTime(1900, 2, 2, 13, 0, 0); Assert.AreEqual("13:00:00", ltp.TimeItemsSelection.SelectedItem.Key); ltp.Value = new DateTime(2000, 3, 3, 15, 5, 0); Assert.AreEqual("15:00:00", ltp.TimeItemsSelection.SelectedItem.Key); }
public virtual void ShouldFillSelectionWithAPeer() { ListTimePickerPopup ltp = new ListTimePickerPopup(); ISelectionProvider provider = null; ItemSelectionHelper <KeyValuePair <string, DateTime?> > helper = null; TestAsync( ltp, () => provider = (ISelectionProvider)FrameworkElementAutomationPeer.CreatePeerForElement(ltp), () => helper = ltp.TimeItemsSelection, () => Assert.IsTrue(provider.GetSelection().Length == 0), () => helper.SelectedItem = helper.Items[3], () => Assert.IsNotNull(provider.GetSelection(), "There have been intermittent Automation problems where the ListBoxAutomationPeer reports null children."), () => Assert.IsTrue(provider.GetSelection().Length == 1)); }
public virtual void ShouldTakeMaximumIntoAccount() { ListTimePickerPopup ltp = new ListTimePickerPopup() { PopupMinutesInterval = 15, Culture = new CultureInfo("nl-NL"), Format = new LongTimeFormat() }; ltp.Maximum = new DateTime(2000, 1, 1, 2, 20, 30); // some settings on mac will do double digits Assert.IsTrue(ltp.TimeItemsSelection.Items[ltp.TimeItemsSelection.Items.Count - 1].Key.EndsWith("2:15:00", StringComparison.OrdinalIgnoreCase)); ltp.Maximum = new DateTime(2000, 1, 1, 5, 0, 0); // some settings on mac will do double digits Assert.IsTrue(ltp.TimeItemsSelection.Items[ltp.TimeItemsSelection.Items.Count - 1].Key.EndsWith("5:00:00", StringComparison.OrdinalIgnoreCase)); }
public virtual void ShouldFormatTimeItems() { ListTimePickerPopup ltp = new ListTimePickerPopup() { PopupMinutesInterval = 15, Culture = new CultureInfo("nl-NL"), Format = new ShortTimeFormat() }; // timeformats are different for mac than win Assert.IsTrue(ltp.TimeItemsSelection.Items[0].Key.EndsWith("0:00", StringComparison.OrdinalIgnoreCase)); ltp.Culture = new CultureInfo("en-US"); Assert.AreEqual("12:00 AM", ltp.TimeItemsSelection.Items[0].Key); ltp.Format = new CustomTimeFormat("HH:mm:ss"); Assert.AreEqual("00:00:00", ltp.TimeItemsSelection.Items[0].Key); }
public virtual void ShouldThrowExceptionWhenSettingTimeItemsSelection() { ListTimePickerPopup ltp = new ListTimePickerPopup(); ltp.SetValue(ListTimePickerPopup.TimeItemsSelectionProperty, new ItemSelectionHelper <KeyValuePair <string, DateTime?> >()); }
public virtual void ShouldThrowExceptionWhenTimeSelectionModeIsNotSupported() { ListTimePickerPopup ltp = new ListTimePickerPopup(); ltp.PopupTimeSelectionMode = PopupTimeSelectionMode.AllowSecondsSelection; }
public virtual void ShouldFillSelectionWithAPeer() { ListTimePickerPopup ltp = new ListTimePickerPopup(); ISelectionProvider provider = null; ItemSelectionHelper<KeyValuePair<string, DateTime?>> helper = null; TestAsync( ltp, () => provider = (ISelectionProvider)FrameworkElementAutomationPeer.CreatePeerForElement(ltp), () => helper = ltp.TimeItemsSelection, () => Assert.IsTrue(provider.GetSelection().Length == 0), () => helper.SelectedItem = helper.Items[3], () => Assert.IsNotNull(provider.GetSelection(), "There have been intermittent Automation problems where the ListBoxAutomationPeer reports null children."), () => Assert.IsTrue(provider.GetSelection().Length == 1)); }
public virtual void ShouldThrowExceptionWhenSettingTimeItemsSelection() { ListTimePickerPopup ltp = new ListTimePickerPopup(); ltp.SetValue(ListTimePickerPopup.TimeItemsSelectionProperty, new ItemSelectionHelper<KeyValuePair<string, DateTime?>>()); }