Esempio n. 1
0
        private void cmdTimePicker_Click(object sender, EventArgs e)
        {
            ChooseTimeDialog chooseTimeDialog = new ChooseTimeDialog();

            chooseTimeDialog.SelectedHour   = int.Parse(txtHour.Text);
            chooseTimeDialog.SelectedMinute = int.Parse(txtMinute.Text);
            Rectangle currentScreen = Screen.FromControl(cmdTimePicker).WorkingArea;

            Point startPoint;

            startPoint = cmdTimePicker.PointToScreen(new Point(0, 0));

            int dialogTop  = startPoint.Y + cmdTimePicker.Height;
            int dialogLeft = startPoint.X;

            if (dialogTop + chooseTimeDialog.Height > currentScreen.Top + currentScreen.Height)
            {
                dialogTop = currentScreen.Top + currentScreen.Height - chooseTimeDialog.Height;
            }
            if (dialogLeft + chooseTimeDialog.Width > currentScreen.Left + currentScreen.Width)
            {
                dialogLeft = currentScreen.Left + currentScreen.Width - chooseTimeDialog.Width;
            }

            if (chooseTimeDialog.ShowDialog(dialogLeft, dialogTop) == DialogResult.OK)
            {
                txtHour.Text   = chooseTimeDialog.SelectedHour.ToString("00");
                txtMinute.Text = chooseTimeDialog.SelectedMinute.ToString("00");
                DoValueAccepted(sender, e);
            }
        }
Esempio n. 2
0
        private void cmdTimePicker_Click(object sender, EventArgs e)
        {
            ChooseTimeDialog chooseTimeDialog = new ChooseTimeDialog();

            chooseTimeDialog.SelectedHour   = int.Parse(txtHour.Text);
            chooseTimeDialog.SelectedMinute = int.Parse(txtMinute.Text);
            if (chooseTimeDialog.ShowDialog(Cursor.Position.X, Cursor.Position.Y + 15) == DialogResult.OK)
            {
                txtHour.Text   = chooseTimeDialog.SelectedHour.ToString("00");
                txtMinute.Text = chooseTimeDialog.SelectedMinute.ToString("00");
                DoValueAccepted(sender, e);
            }

            //TimePicker timePicker = new TimePicker();
            //timePicker.SelectedTime = new DateTime(2000, 1, 1, int.Parse(txtHour.Text), int.Parse(txtMinute.Text), 0);
            //if (timePicker.ShowTimePicker(Cursor.Position.X, Cursor.Position.Y) == DialogResult.OK)
            //{
            //    txtHour.Text = timePicker.SelectedTime.Hour.ToString("00");
            //    txtMinute.Text = timePicker.SelectedTime.Minute.ToString("00");
            //    DoValueAccepted(sender, e);
            //}
        }