public GetTimeDialog() : base(string.Empty, string.Empty, MessageBoxButtons.OkCancel, MessageBoxIcons.Information, DesktopManager.ScreenWidth / 2, 170) { int txtWidth = (_mWidth - margin * 3) / 2; AddChild(new Label("Hour", margin, 55 + 15 - Fonts.ArialBold.Height / 2, txtWidth, 25) { CenterText = true, Font = Fonts.ArialBold }); AddChild(new Label("Minute", margin * 2 + txtWidth, 55 + 15 - Fonts.Arial.Height / 2, txtWidth, 25) { CenterText = true, Font = Fonts.ArialBold }); AddChild(cmbHour = new ComboBox(margin, 85, txtWidth, 30)); AddChild(cmbMinute = new ComboBox(margin * 2 + txtWidth, 85, txtWidth, 30)); for (int i = 0; i < 24; i++) cmbHour.AddItem(i); for (int i = 0; i < 60; i++) cmbMinute.AddItem(i); }
public GetDateDialog() : base(string.Empty, string.Empty, MessageBoxButtons.OkCancel, MessageBoxIcons.Information, DesktopManager.ScreenWidth / 2, 170) { int availableWidth = _mWidth - margin * 4; const int dayRatio = 2; const int monthRatio = 3; const int yearRatio = 2; const int totalRatio = dayRatio + monthRatio + yearRatio; int dayWidth = availableWidth * dayRatio / totalRatio; int monthWidth = availableWidth * monthRatio / totalRatio; int yearWidth = availableWidth * yearRatio / totalRatio; AddChild(new Label("Day", margin, 55 + 15 - Fonts.ArialBold.Height / 2, dayWidth, 25) { CenterText = true, Font = Fonts.ArialBold }); AddChild(new Label("Month", margin * 2 + dayWidth, 55 + 15 - Fonts.Arial.Height / 2, monthWidth, 25) { CenterText = true, Font = Fonts.ArialBold }); AddChild(new Label("Year", margin * 3 + dayWidth + monthWidth, 55 + 15 - Fonts.Arial.Height / 2, yearWidth, 25) { CenterText = true, Font = Fonts.ArialBold }); AddChild(cmbDay = new ComboBox(margin, 85, dayWidth, 30)); AddChild(cmbMonth = new ComboBox(margin * 2 + dayWidth, 85, monthWidth, 30)); AddChild(cmbYear = new ComboBox(margin * 3 + dayWidth + monthWidth, 85, yearWidth, 30)); for (int i = 2009; i <= 2030; i++) cmbYear.AddItem(i); for (int i = 1; i <= 12; i++) cmbMonth.AddItem(_monthNames[i]); UiEventHandler remakeDaysEvent = (s) => { int prevSelected = cmbDay.SelectedIndex; cmbDay.ClearItems(); for (int i = 1; i <= DateTime.DaysInMonth((int)cmbYear.SelectedItem, (int)cmbMonth.SelectedIndex + 1); i++) cmbDay.AddItem(i); if (prevSelected != -1 && prevSelected < cmbDay.ItemsCount) cmbDay.SelectedIndex = prevSelected; else cmbDay.SelectedIndex = cmbDay.ItemsCount - 1; }; cmbMonth.OnSelectedItemChanged += remakeDaysEvent; cmbYear.OnSelectedItemChanged += remakeDaysEvent; }