Exemplo n.º 1
0
        private void HourButton_Click(object sender, RoutedEventArgs e)
        {
            AduTimeButton selectedItem = this.PART_Hour.SelectedItem as AduTimeButton;

            if (selectedItem == null)
            {
                return;
            }
            this.SelectedHour = Convert.ToInt32(selectedItem.DataContext);
            this.PART_Hour.AnimateScrollIntoView(selectedItem);
        }
Exemplo n.º 2
0
        public void SetButtonSelected()
        {
            if (!this.SelectedTime.HasValue)
            {
                return;
            }

            this.Hour   = this.SelectedTime.Value.Hour;
            this.Minute = this.SelectedTime.Value.Minute;
            this.Second = this.SelectedTime.Value.Second;

            if (this.PART_Hour != null)
            {
                for (int i = 0; i < this.PART_Hour.Items.Count; i++)
                {
                    AduTimeButton timeButton = this.PART_Hour.Items[i] as AduTimeButton;
                    if (Convert.ToString(timeButton.Content).Equals(Convert.ToString(this.SelectedTime.Value.Hour)))
                    {
                        this.PART_Hour.SelectedIndex = i;
                        this.PART_Hour.AnimateScrollIntoView(timeButton);
                        break;
                    }
                }
            }

            if (this.PART_Minute != null)
            {
                for (int i = 0; i < this.PART_Minute.Items.Count; i++)
                {
                    AduTimeButton timeButton = this.PART_Minute.Items[i] as AduTimeButton;
                    if (Convert.ToString(timeButton.Content).Equals(Convert.ToString(this.SelectedTime.Value.Minute)))
                    {
                        this.PART_Minute.SelectedIndex = i;
                        this.PART_Minute.AnimateScrollIntoView(timeButton);
                        break;
                    }
                }
            }

            if (this.PART_Second != null)
            {
                for (int i = 0; i < this.PART_Second.Items.Count; i++)
                {
                    AduTimeButton timeButton = this.PART_Second.Items[i] as AduTimeButton;
                    if (Convert.ToString(timeButton.Content).Equals(Convert.ToString(this.SelectedTime.Value.Second)))
                    {
                        this.PART_Second.SelectedIndex = i;
                        this.PART_Second.AnimateScrollIntoView(timeButton);
                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
 private void CreateItems(int itemsCount, ObservableCollection <AduTimeButton> list)
 {
     for (int i = 0; i < itemsCount; i++)
     {
         AduTimeButton timeButton = new AduTimeButton();
         timeButton.SetValue(AduTimeButton.HeightProperty, this.ItemHeight);
         timeButton.SetValue(AduTimeButton.DataContextProperty, i);
         timeButton.SetValue(AduTimeButton.ContentProperty, (i < 10) ? "0" + i : i.ToString());
         timeButton.SetValue(AduTimeButton.IsSelectedProperty, false);
         list.Add(timeButton);
     }
 }
Exemplo n.º 4
0
        private void CreateExtraItem(ObservableCollection <AduTimeButton> list)
        {
            double height = this.ItemHeight;

            if (this.Owner != null)
            {
                height = this.Owner.DropDownHeight;
            }
            else
            {
                height = double.IsNaN(this.Height) ? height : this.Height;
            }

            for (int i = 0; i < (height - this.ItemHeight) / this.ItemHeight; i++)
            {
                AduTimeButton timeButton = new AduTimeButton();
                timeButton.SetValue(AduTimeButton.HeightProperty, this.ItemHeight);
                timeButton.SetValue(AduTimeButton.IsEnabledProperty, false);
                timeButton.SetValue(AduTimeButton.IsSelectedProperty, false);
                list.Add(timeButton);
            }
        }