コード例 #1
0
 public void basic_timepicker_render()
 {
     var html = new TimePicker("foo").ToString();
     html.ShouldHaveHtmlNode("foo")
         .ShouldBeNamed(HtmlTag.Input)
         .ShouldHaveAttribute(HtmlAttribute.Type).WithValue(HtmlInputType.Time);
 }
コード例 #2
0
        public TimePickerDemoPage()
        {
            Label header = new Label
            {
                Text = "TimePicker",
                FontSize = 50,
                FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            TimePicker timePicker = new TimePicker
            {
                Format = "T",
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            // Build the page.
            this.Content = new StackLayout
            {
                Children =
                {
                    header,
                    timePicker
                }
            };
        }
コード例 #3
0
ファイル: LetsSee.xaml.cs プロジェクト: potasiyam/Sanitabit
        public LetsSee()
        {
            InitializeComponent();
            if (Database.OpenDatabase("Data").Table<DataRow>("UserData").Count != 0)
            {
                //MessageBox.Show(MealSlider.Value.ToString());
                LoadLastState();
            }
            else
            {

                try
                {
                    InputStackPanel.Children.Clear();

                    for (int i = 0; i < MealSlider.Value; i++)
                    {
                        TimePicker timePicker = new TimePicker();
                        timePicker.Name = "time" + (i + 1).ToString();
                        TimePickerList.Add(timePicker);
                        //timePicker.ValueChanged += timePicker_ValueChanged;
                        InputStackPanel.Children.Add(timePicker);
                    }
                }
                catch (Exception excep)
                { }
            }
        }
コード例 #4
0
        public void SetNewTimeTest()
        {
            AvalonTestRunner.RunInSTA(delegate
            {
                TimePicker picker = new TimePicker();
                picker.SelectedHour = 1;
                picker.SelectedMinute = 2;
                picker.SelectedSecond = 3;
                
                Assert.AreEqual(1, picker.SelectedTime.Hours, "Invalid hour set");
                Assert.AreEqual(2, picker.SelectedTime.Minutes, "Invalid minute set");
                Assert.AreEqual(3, picker.SelectedTime.Seconds, "Invalid second set");

                //try to set some invalid values
                picker = new TimePicker();
                bool hasEventFired = false;
                picker.SelectedTimeChanged += delegate { hasEventFired = true; };
                picker.SelectedHour = 44;
                //check if the event has been fired
                Assert.IsTrue(hasEventFired, "Event not fired");
                hasEventFired = false;
                picker.SelectedMinute = 2;
                Assert.IsTrue(hasEventFired, "Event not fired");
                hasEventFired = false;
                picker.SelectedSecond = 99;
                Assert.IsTrue(hasEventFired, "Event not fired");
                
                Assert.AreEqual(23, picker.SelectedTime.Hours, "Invalid hour set");
                Assert.AreEqual(2, picker.SelectedTime.Minutes, "Invalid minute set");
                Assert.AreEqual(59, picker.SelectedTime.Seconds, "Invalid second set");
            });
        }
コード例 #5
0
        public TimePickerDemoPage()
        {
            Label header = new Label
            {
                Text = "TimePicker",
                Font = Font.BoldSystemFontOfSize(50),
                HorizontalOptions = LayoutOptions.Center
            };

            TimePicker timePicker = new TimePicker
            {
                Format = "T",
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            // Accomodate iPhone status bar.
            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    timePicker
                }
            };
        }
コード例 #6
0
 public async void Add(object sender, DatePicker startDate, TimePicker startTime,
     TextBox subject, TextBox location, TextBox details, ComboBox duration, CheckBox allDay)
 {
     FrameworkElement element = (FrameworkElement)sender;
     GeneralTransform transform = element.TransformToVisual(null);
     Point point = transform.TransformPoint(new Point());
     Rect rect = new Rect(point, new Size(element.ActualWidth, element.ActualHeight));
     DateTimeOffset date = startDate.Date;
     TimeSpan time = startTime.Time;
     int minutes = int.Parse((string)((ComboBoxItem)duration.SelectedItem).Tag);
     Appointment appointment = new Appointment()
     {
         StartTime = new DateTimeOffset(date.Year, date.Month, date.Day,
         time.Hours, time.Minutes, 0, TimeZoneInfo.Local.GetUtcOffset(DateTime.Now)),
         Subject = subject.Text,
         Location = location.Text,
         Details = details.Text,
         Duration = TimeSpan.FromMinutes(minutes),
         AllDay = (bool)allDay.IsChecked
     };
     string id = await AppointmentManager.ShowAddAppointmentAsync(appointment, rect, Placement.Default);
     if (string.IsNullOrEmpty(id))
     {
         Show("Appointment not Added", "Appointment App");
     }
     else
     {
         Show(string.Format("Appointment {0} Added", id), "Appointment App");
     }
 }
コード例 #7
0
ファイル: AppConfig.cs プロジェクト: TomHGTang/AccountBook
 /// <summary>
 /// 加载数据到时间控件
 /// </summary>
 /// <param name="key">键</param>
 /// <param name="TimePicker">时间控件</param>
 /// <returns>是否成功</returns>
 public static bool LoadDataTo(string key, TimePicker TimePicker)
 {
     if (TimePicker == null)
     {
         return false;
     }
     if (items == null)
     {
         ReadFromFile();
     }
     if (!items.ContainsKey(key))
     {
         items.Add(key, "");
     }
     try
     {
         if (!string.IsNullOrEmpty(items[key]))
         {
             //把键值转化为时间格式赋值给时间控件
             TimePicker.Value = new DateTime?(DateTime.Parse(items[key]));
             return true;
         }
         return false;
     }
     catch (Exception)
     {
         return false;
     }
 }
コード例 #8
0
ファイル: DocUITime.cs プロジェクト: 00Green27/DocUI
        /// <summary>
        /// Creates a new instance of the TimeOption
        /// </summary>
        /// <param name="xmlNode">The xmlnode containing the data.</param>
        /// <param name="xsdNode">The corresponding xsdnode.</param>
        /// <param name="panel">The panel on which this option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        public DocUITime(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
            base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            Control = new TimePicker() { Format = TimeFormat.Custom, FormatString = "HH:mm:ss" };
            (Control as TimePicker).ValueChanged += (s, e) => { hasPendingChanges(); };

            setup();
        }
コード例 #9
0
        public TimePickerHtmlBuilderTests()
        {
            time = new TimeSpan(5,27,22);

            timePicker = TimePickerTestHelper.CreateTimePicker();
            timePicker.Name = "TimePicker";
            renderer = new TimePickerHtmlBuilder(timePicker);
        }
コード例 #10
0
 public void New(DatePicker startDate, TimePicker startTime, TextBox subject,
     TextBox location, TextBox details, ComboBox duration, CheckBox allDay)
 {
     startDate.Date = DateTime.Now;
     startTime.Time = DateTime.Now.TimeOfDay;
     subject.Text = string.Empty;
     location.Text = string.Empty;
     details.Text = string.Empty;
     duration.SelectedIndex = 0;
     allDay.IsChecked = false;
 }
コード例 #11
0
 private void InitializeComponent() {
     this.LoadFromXaml(typeof(TimeLogDetailsView));
     btnCancelSC = this.FindByName<Button>("btnCancelSC");
     btnSaveSC = this.FindByName<Button>("btnSaveSC");
     btnDeleteSC = this.FindByName<Button>("btnDeleteSC");
     entryModelName = this.FindByName<Entry>("entryModelName");
     PickerLogDate = this.FindByName<DatePicker>("PickerLogDate");
     PickerLogTime = this.FindByName<TimePicker>("PickerLogTime");
     EntryMinutes = this.FindByName<Entry>("EntryMinutes");
     EntrySeconds = this.FindByName<Entry>("EntrySeconds");
     entryBattery1Name = this.FindByName<Entry>("entryBattery1Name");
     entryBattery2Name = this.FindByName<Entry>("entryBattery2Name");
 }
コード例 #12
0
ファイル: MainPage.xaml.cs プロジェクト: dataalbum/PiScreen
        public MainPage()
        {
            this.InitializeComponent();

            // Setup clock
            DispatcherTimer timer = new DispatcherTimer();
            timer.Tick += timer_Tick;
            timer.Start();

            //Setup Time Picker for 24h format
            TimePicker timePicker1 = new TimePicker();
            timePicker1.ClockIdentifier = Windows.Globalization.ClockIdentifiers.TwentyFourHour;
        }
コード例 #13
0
		public void TestTimeOutOfRange ()
		{
			TimePicker picker = new TimePicker ();

			Assert.That (() => picker.Time = new TimeSpan (1000, 0, 0), Throws.ArgumentException);
			Assert.AreEqual (picker.Time, new TimeSpan ());

			picker.Time = new TimeSpan (8, 30, 0);

			Assert.AreEqual (new TimeSpan (8, 30, 0), picker.Time);

			Assert.That (() => picker.Time = new TimeSpan (-1, 0, 0), Throws.ArgumentException);
			Assert.AreEqual (new TimeSpan (8, 30, 0), picker.Time);
		}
コード例 #14
0
ファイル: DocUIDateTime.cs プロジェクト: 00Green27/DocUI
        /// <summary>
        /// Creates a new instance of the TimeOption
        /// </summary>
        /// <param name="xmlNode">The xmlnode containing the data.</param>
        /// <param name="xsdNode">The corresponding xsdnode.</param>
        /// <param name="contentpanel">The panel on which this option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        public DocUIDateTime(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
            base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            //Control = new DatePicker(); //{ Form Format = TimeFormat.Custom, FormatString = "HH:mm:ss" };
            //(Control as DatePicker).ValueChanged += (s, e) => { hasPendingChanges(); };

            stack = new StackPanel() { Orientation = Orientation.Horizontal };
            Control = stack;
            DateControl = new DatePicker();
            DateControl.SelectedDateChanged += (s, e) => { hasPendingChanges(); };
            TimeControl = new TimePicker() { Format = TimeFormat.Custom, FormatString = "HH:mm:ss" };
            TimeControl.ValueChanged += (s, e) => { hasPendingChanges(); };

            setup();
        }
コード例 #15
0
        public virtual void ShouldBeAbleToSetValueThroughAutomationPeer()
        {
            TimePicker item = new TimePicker();
            item.Culture = new CultureInfo("nl-NL");
            item.Format = new CustomTimeFormat("HH:mm:ss");
            TimePickerAutomationPeer peer = null;
            IValueProvider provider = null;

            TestAsync(
                    item,
                    () => peer = (TimePickerAutomationPeer) FrameworkElementAutomationPeer.CreatePeerForElement(item),
                    () => provider = (IValueProvider) peer.GetPattern(PatternInterface.Value),
                    () => provider.SetValue("03:45:12"),
                    () => Assert.AreEqual(item.Value.Value.TimeOfDay, new DateTime(1900, 1, 1, 3, 45, 12).TimeOfDay));
        }
コード例 #16
0
        public static TimePicker CreateTimePicker()
        {
            Mock<HttpContextBase> httpContext = TestHelper.CreateMockedHttpContext();

            httpContext.Setup(c => c.Request.Browser.CreateHtmlTextWriter(It.IsAny<TextWriter>())).Returns(new HtmlTextWriter(TextWriter.Null));

            Mock<IClientSideObjectWriterFactory> clientSideObjectWriterFactory = new Mock<IClientSideObjectWriterFactory>();
            clientSideObjectWriter = new Mock<IClientSideObjectWriter>();

            viewContext = TestHelper.CreateViewContext();

            clientSideObjectWriterFactory.Setup(c => c.Create(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<TextWriter>())).Returns(clientSideObjectWriter.Object);

            TimePicker timepicker = new TimePicker(viewContext, clientSideObjectWriterFactory.Object);

            return timepicker;
        }
コード例 #17
0
        /****************************************************************
         * Constructors
         **/
        public DateAndTimeScreen()
        {
            InitializeComponent();

            // Temp Value
            m_bIsOn = true;

            m_dateAndTime = this.grou_date_and_time;
            m_txtSwitch = this.txt_switch;
            m_toggleButton = this.ts_toggle;
            m_datePicker = this.dp_picker_date;
            m_datePicker.DataContext = this;
            m_timePicker = this.tp_picler_time;
            m_timePicker.DataContext = this;

            // set date and time to on
            this.UpdateSwitch();
        }
コード例 #18
0
 private void InitializeComponent() {
     this.LoadFromXaml(typeof(ActivityLogDetailsView));
     btnCancelSC = this.FindByName<Button>("btnCancelSC");
     btnSaveSC = this.FindByName<Button>("btnSaveSC");
     btnDeleteSC = this.FindByName<Button>("btnDeleteSC");
     entryActivityType = this.FindByName<Entry>("entryActivityType");
     entryModelName = this.FindByName<Entry>("entryModelName");
     PickerLogDate = this.FindByName<DatePicker>("PickerLogDate");
     PickerLogTime = this.FindByName<TimePicker>("PickerLogTime");
     lblDuration = this.FindByName<Label>("lblDuration");
     EntryMinutes = this.FindByName<Entry>("EntryMinutes");
     lblTimeColon = this.FindByName<Label>("lblTimeColon");
     EntrySeconds = this.FindByName<Entry>("EntrySeconds");
     lblBattery1 = this.FindByName<Label>("lblBattery1");
     entryBattery1Name = this.FindByName<Entry>("entryBattery1Name");
     lblBattery2 = this.FindByName<Label>("lblBattery2");
     entryBattery2Name = this.FindByName<Entry>("entryBattery2Name");
 }
コード例 #19
0
 //sets the selectedTime with the selectedhour, selectedminute and selectedsecond
 private static void SetNewTime(TimePicker timePicker)
 {
     if (!timePicker.isUpdatingTime)
     {
         TimeSpan newTime = new TimeSpan(
             timePicker.SelectedHour,
             timePicker.SelectedMinute,
             timePicker.SelectedSecond);
         //check if the time is the same
         if (timePicker.SelectedTime != newTime)
             timePicker.SelectedTime = newTime;
     }
 }
コード例 #20
0
 public TimePickerBuilderTests()
 {
     timepicker = TimePickerTestHelper.CreateTimePicker();
     builder = new TimePickerBuilder(timepicker);
 }
コード例 #21
0
 public void ExposedDatePicker(ref DatePicker datePicker, ref TimePicker timePicker)
 {
     datePicker = this.datePicker;
     timePicker = this.timePicker;
 }
コード例 #22
0
        private DateTime GetDateTime(Microsoft.Windows.Controls.DatePicker datePicker, TimePicker timePicker)
        {
            
                 DateTime dtDateTime = new DateTime(datePicker.SelectedDate.Value.Year,
                                                    datePicker.SelectedDate.Value.Month,
                                                    datePicker.SelectedDate.Value.Day,
                                                    timePicker.SelectedHour, 
                                                    timePicker.SelectedMinute,
                                                    timePicker.SelectedSecond);

                return dtDateTime;            
          
        }
コード例 #23
0
        public virtual void ShouldOverwriteDefaultIntervalsFromPopup()
        {
            TimePicker tip = new TimePicker();

            tip.PopupSecondsInterval = 20;
            tip.PopupMinutesInterval = 30;

            TestAsync(
                tip, 
                () => Assert.AreEqual(20, tip.PopupSecondsInterval),
                () => Assert.AreEqual(30, tip.PopupMinutesInterval));
        }
コード例 #24
0
 public void timepicker_correctly_formats_timespan_value()
 {
     var value = new TimeSpan(0, 14, 5, 24, 331);
     var element = new TimePicker("test").Value(value);
     element.ValueAttributeShouldEqual("14:05:24.331");
 }
コード例 #25
0
 public void timepicker_correctly_formats_date_value()
 {
     var value = new DateTime(2000, 2, 2, 14, 5, 24, 331);
     var element = new TimePicker("test").Value(value);
     element.ValueAttributeShouldEqual("14:05:24.331");
 }
コード例 #26
0
 public TimePickerHtmlBuilder(TimePicker component)
 {
     Component = component;
 }
コード例 #27
0
ファイル: DateTimePicker.cs プロジェクト: Alexz18z35z/Gibbo2D
    public override void OnApplyTemplate()
    {
      base.OnApplyTemplate();

      if( _popup != null )
        _popup.Opened -= Popup_Opened;

      _popup = GetTemplateChild( PART_Popup ) as Popup;

      if( _popup != null )
        _popup.Opened += Popup_Opened;

      if( _calendar != null )
        _calendar.SelectedDatesChanged -= Calendar_SelectedDatesChanged;

      _calendar = GetTemplateChild( PART_Calendar ) as Calendar;

      if( _calendar != null )
      {
        _calendar.SelectedDatesChanged += Calendar_SelectedDatesChanged;
        _calendar.SelectedDate = Value ?? null;
        _calendar.DisplayDate = Value ?? DateTime.Now;
      }

      _timePicker = GetTemplateChild( PART_TimeUpDown ) as TimePicker;
    }
コード例 #28
0
        /// <summary>
        /// Override the default template
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            datePicker = (DatePicker)GetTemplateChild("PART_DatePicker");
            if (datePicker == null) datePicker = new DatePicker();
            timePicker = (TimePicker)GetTemplateChild("PART_TimePicker");
            if (timePicker == null) timePicker = new TimePicker();
            datePicker.SelectedDateChanged += delegate{ SetCurrentDateTime(); };
            timePicker.SelectedTimeChanged += delegate { SetCurrentDateTime(); };
            datePicker.CurrentlySelectedDate = DateTimeSelected;
            timePicker.SelectedTime = DateTimeSelected.TimeOfDay;
            
            //snyc the min and max date for datepicker
            Binding minDateBinding = new Binding("MinDate");
            minDateBinding.Source = this;
            datePicker.SetBinding(DatePicker.MinDateProperty, minDateBinding);
            Binding maxDateBinding = new Binding("MaxDate");
            maxDateBinding.Source = this;
            datePicker.SetBinding(DatePicker.MaxDateProperty, maxDateBinding);

            //snyc the min and max time for timepicker
            Binding minTimeBinding = new Binding("MinDate.TimeOfDay");
            minTimeBinding.Source = this;
            timePicker.SetBinding(TimePicker.MinTimeProperty, minTimeBinding);
            Binding maxTimeBinding = new Binding("MaxDate.TimeOfDay");
            maxTimeBinding.Source = this;
            timePicker.SetBinding(TimePicker.MaxTimeProperty, maxTimeBinding);
            
        }
コード例 #29
0
        //creates the panel for adding a new entry
        private StackPanel createNewEntryPanel()
        {
            StackPanel newEntryPanel = new StackPanel();
            newEntryPanel.Margin = new Thickness(0, 10, 0, 0);

            WrapPanel entryPanel = new WrapPanel();

            newEntryPanel.Children.Add(entryPanel);

            cbRegion = new ComboBox();
            cbRegion.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbRegion.Width = 150;
            cbRegion.DisplayMemberPath = "Name";
            cbRegion.SelectedValuePath = "Name";
            cbRegion.SelectionChanged += cbRegion_SelectionChanged;
            cbRegion.Items.Add(Regions.GetRegion("100"));

            List<Region> regions = GameObject.GetInstance().HumanAirline.Routes.Where(r => r.Destination1.Profile.Country.Region == r.Destination2.Profile.Country.Region).Select(r => r.Destination1.Profile.Country.Region).ToList();
            regions.AddRange(GameObject.GetInstance().HumanAirline.Routes.Where(r => r.Destination1.Profile.Country == GameObject.GetInstance().HumanAirline.Profile.Country).Select(r => r.Destination2.Profile.Country.Region));
            regions.AddRange(GameObject.GetInstance().HumanAirline.Routes.Where(r => r.Destination2.Profile.Country == GameObject.GetInstance().HumanAirline.Profile.Country).Select(r => r.Destination1.Profile.Country.Region));

            foreach (Region region in regions.Distinct())
                cbRegion.Items.Add(region);

            entryPanel.Children.Add(cbRegion);

            cbRoute = new ComboBox();

            cbRoute.ItemTemplate = this.Resources["RouteItem"] as DataTemplate;
            cbRoute.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbRoute.SelectionChanged += new SelectionChangedEventHandler(cbRoute_SelectionChanged);

            long requiredRunway = this.Airliner.Airliner.Type.MinRunwaylength;

            foreach (Route route in this.Airliner.Airliner.Airline.Routes.FindAll(r => this.Airliner.Airliner.Type.Range > r.getDistance() && !r.Banned && r.Destination1.getMaxRunwayLength() >= requiredRunway && r.Destination2.getMaxRunwayLength() >= requiredRunway).OrderBy(r => new AirportCodeConverter().Convert(r.Destination1)).ThenBy(r=>new AirportCodeConverter().Convert(r.Destination2)))
            {
                string outboundRoute;

                if (route.HasStopovers)
                {
                    string stopovers= string.Join("-", from s in route.Stopovers select new AirportCodeConverter().Convert(s.Stopover));
                    outboundRoute = string.Format("{0}-{1}-{2}",new AirportCodeConverter().Convert(route.Destination1), stopovers,new AirportCodeConverter().Convert(route.Destination2));
                }
                else
                    outboundRoute = string.Format("{0}-{1}", new AirportCodeConverter().Convert(route.Destination1), new AirportCodeConverter().Convert(route.Destination2));

                ComboBoxItem item1 = new ComboBoxItem();
                item1.Tag = new KeyValuePair<Route, Airport>(route, route.Destination2);
                item1.Content = outboundRoute;
                cbRoute.Items.Add(item1);

                string inboundRoute;

                if (route.HasStopovers)
                {
                    var lStopovers = route.Stopovers;
                    lStopovers.Reverse();
                    string stopovers = string.Join("-", from s in lStopovers select new AirportCodeConverter().Convert(s.Stopover));

                    inboundRoute = string.Format("{2}-{1}-{0}", new AirportCodeConverter().Convert(route.Destination1), stopovers, new AirportCodeConverter().Convert(route.Destination2));

                }
                else
                    inboundRoute = string.Format("{0}-{1}", new AirportCodeConverter().Convert(route.Destination2), new AirportCodeConverter().Convert(route.Destination1));

                ComboBoxItem item2 = new ComboBoxItem();
                item2.Tag = new KeyValuePair<Route, Airport>(route, route.Destination1);
                item2.Content = inboundRoute;
                cbRoute.Items.Add(item2);
            }

            entryPanel.Children.Add(cbRoute);

            cbDay = new ComboBox();
            cbDay.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbDay.Width = 100;
            cbDay.Margin = new Thickness(10, 0, 0, 0);
            cbDay.Items.Add("Daily");

            foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)))
                cbDay.Items.Add(day);

            cbDay.SelectedIndex = 0;

            entryPanel.Children.Add(cbDay);

            tpTime = new TimePicker();
            tpTime.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            tpTime.EndTime = new TimeSpan(22, 0, 0);
            tpTime.StartTime = new TimeSpan(6, 0, 0);
            tpTime.Value = new DateTime(2011, 1, 1, 13, 0, 0);
            tpTime.Format = TimeFormat.ShortTime;
            tpTime.Background = Brushes.Transparent;
            tpTime.SetResourceReference(TimePicker.ForegroundProperty, "TextColor");
            tpTime.BorderBrush = Brushes.Black;

            entryPanel.Children.Add(tpTime);

            cbFlightCode = new ComboBox();
            cbFlightCode.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");

            foreach (string flightCode in this.Airliner.Airliner.Airline.getFlightCodes())
                cbFlightCode.Items.Add(flightCode);

            cbFlightCode.SelectedIndex = 0;

            entryPanel.Children.Add(cbFlightCode);

            Button btnAdd = new Button();
            btnAdd.Uid = "104";
            btnAdd.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnAdd.Height = Double.NaN;
            btnAdd.Width = Double.NaN;
            btnAdd.Click += new RoutedEventHandler(btnAdd_Click);
            btnAdd.Margin = new Thickness(5, 0, 0, 0);
            btnAdd.Content = Translator.GetInstance().GetString("General", btnAdd.Uid);
            btnAdd.IsEnabled = cbRoute.Items.Count > 0;
            btnAdd.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            btnAdd.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");

            entryPanel.Children.Add(btnAdd);

            txtFlightTime = new TextBlock();
            txtFlightTime.Text = "Flight time: ";

            newEntryPanel.Children.Add(txtFlightTime);

            //cbRoute.SelectedIndex = 0;
            cbRegion.SelectedIndex = 0;

            return newEntryPanel;
        }
コード例 #30
0
        //creates the panel for adding a new entry
        private StackPanel createNewEntryPanel()
        {
            StackPanel newEntryPanel = new StackPanel();
            newEntryPanel.Margin = new Thickness(0, 10, 0, 0);

            WrapPanel entryPanel = new WrapPanel();

            newEntryPanel.Children.Add(entryPanel);

            Route.RouteType type = this.Airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Cargo ? Route.RouteType.Cargo : Route.RouteType.Passenger;

            var origins = this.Airliner.Airliner.Airline.Routes.Where(r=>r.Type == type).SelectMany(r => r.getDestinations()).Distinct();
            origins.OrderBy(a => a.Profile.Name);

            cbOrigin = new ComboBox();
            cbOrigin.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbOrigin.SetResourceReference(ComboBox.ItemTemplateProperty, "AirportIATACountryItem");
            cbOrigin.Width = 100;
            cbOrigin.SelectionChanged += cbOrigin_SelectionChanged;

            foreach (Airport origin in origins)
                cbOrigin.Items.Add(origin);

            entryPanel.Children.Add(cbOrigin);

            TextBlock txtTo = UICreator.CreateTextBlock("->");
            txtTo.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            txtTo.Margin = new Thickness(5, 0, 5, 0);
            entryPanel.Children.Add(txtTo);

            cbDestination = new ComboBox();
            cbDestination.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbDestination.SelectionChanged += cbDestination_SelectionChanged;
            cbDestination.Width = 100;

            entryPanel.Children.Add(cbDestination);

            cbDay = new ComboBox();
            cbDay.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbDay.Width = 100;
            cbDay.Margin = new Thickness(10, 0, 0, 0);
            cbDay.Items.Add("Daily");

            foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)))
                cbDay.Items.Add(day);

            cbDay.SelectedIndex = 0;

            entryPanel.Children.Add(cbDay);

            tpTime = new TimePicker();
            tpTime.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            tpTime.EndTime = new TimeSpan(22, 0, 0);
            tpTime.StartTime = new TimeSpan(6, 0, 0);
            tpTime.Value = new DateTime(2011, 1, 1, 13, 0, 0);
            tpTime.Format = TimeFormat.ShortTime;
            tpTime.Background = Brushes.Transparent;
            tpTime.SetResourceReference(TimePicker.ForegroundProperty, "TextColor");
            tpTime.BorderBrush = Brushes.Black;

            entryPanel.Children.Add(tpTime);

            cbFlightCode = new ComboBox();
            cbFlightCode.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");

            foreach (string flightCode in this.Airliner.Airliner.Airline.getFlightCodes())
                cbFlightCode.Items.Add(flightCode);

            cbFlightCode.SelectedIndex = 0;

            entryPanel.Children.Add(cbFlightCode);

            Button btnAdd = new Button();
            btnAdd.Uid = "104";
            btnAdd.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnAdd.Height = Double.NaN;
            btnAdd.Width = Double.NaN;
            btnAdd.Click += new RoutedEventHandler(btnAdd_Click);
            btnAdd.Margin = new Thickness(5, 0, 0, 0);
            btnAdd.Content = Translator.GetInstance().GetString("General", btnAdd.Uid);
            btnAdd.IsEnabled = cbOrigin.Items.Count > 0;
            btnAdd.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            btnAdd.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");

            entryPanel.Children.Add(btnAdd);

            return newEntryPanel;
        }