예제 #1
0
 private void OnDropDownButtonClick(object sender, EventArgs e)
 {
     Parent.SuspendLayout();
     _monthCalendar = new MonthCalendar
                          {
                              Location =
                                  new Point(_dropButton.ClientRectangle.Left, _dropButton.ClientRectangle.Bottom)
                          };
     _monthCalendar.DateSelected += OnDateSelected;
     _monthCalendar.Location = new Point(_maskedTextBox.Location.X,
                                         _maskedTextBox.Location.Y + _maskedTextBox.Height);
     _monthCalendar.BringToFront();
     Parent.Controls.Add(_monthCalendar);
     Parent.ResumeLayout();
 }
예제 #2
0
        private void startDateText_Click(object ender, EventArgs e)
        {
            date = new MonthCalendar();
            this.Controls.Add(date);
            date.DateSelected += new DateRangeEventHandler(date_DateSelected);
            date.Visible = true;
            date.Location = new Point(date.Parent.Location.X / 2, date.Parent.Location.Y / 2);

            date.BringToFront();
            //date.MinDate = new System.DateTime
        }
예제 #3
0
        private void control_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ControlFactory factory = ControlFactory.Instance;
            if (e.Button == MouseButtons.Left)
            {
                Field field = factory.GetAssociatedField((Control)sender);
                if (field != null)
                {
                    control = (Control)sender;
                    if (field is DateField || field is DateTimeField)
                    {
                            if (!factory.IsPopup)
                        {
                            MonthCalendar customMonthCalendar = new MonthCalendar();
                            customMonthCalendar.DateSelected += new DateRangeEventHandler(customMonthCalendar_DateSelected);
                            customMonthCalendar.Size = new Size(226, 160);
                            int panelbottom = control.Parent.Bottom;
                            int top = control.Location.Y; int right = control.Parent.Right; int left = control.Left;
                            if (panelbottom - top > 185)//checking to see if the Datefield at the bottom of the canvas
                            {
                                if (right - left < 228)//if field is at the right most part of the canvas.
                                    customMonthCalendar.Location = new Point(right - 230, top + 25);
                                else
                                    customMonthCalendar.Location = new Point(control.Location.X - 10, top + 25);
                            }
                            else//if the datefield is very bottom of the canvas and no enough room for popup.
                                if (right - left < 228)  //if field is at the right and bottom most part of the canvas.
                                    customMonthCalendar.Location = new Point(right - 230, top - 165);
                            else
                                customMonthCalendar.Location = new Point(control.Location.X - 10, control.Top - 165);

                            try
                            {
                                control.Parent.Controls.Add(customMonthCalendar);
                                DateTime datetime ;
                                bool isdatetimeparse= DateTime.TryParse(control.Text, out datetime);
                                if (isdatetimeparse)
                                    customMonthCalendar.SetDate(datetime);
                                customMonthCalendar.Visible = true;
                                customMonthCalendar.BringToFront();
                                factory.IsPopup = true;
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
 private void PopupCalendar(object sender, Point location)
 {
     ControlFactory factory = ControlFactory.Instance;
     if (!factory.IsPopup)
     {
         DataGridView grid = (DataGridView)control;
         MonthCalendar customMonthCalendar = new MonthCalendar();
         customMonthCalendar.DateSelected += new DateRangeEventHandler(dataGridview_customMonthCalendar_DateSelected);
         customMonthCalendar.Size = new Size(226, 160);
         int panelbottom = ((Control)sender).Parent.Bottom; int panelright = ((Control)sender).Parent.Right;
         int top = grid.GetCellDisplayRectangle(grid.SelectedCells[0].ColumnIndex, grid.SelectedCells[0].RowIndex, true).Y;
         int x = grid.GetCellDisplayRectangle(grid.SelectedCells[0].ColumnIndex, grid.SelectedCells[0].RowIndex, true).X;
         if (panelbottom - grid.Top > 165)
         {
             if(panelright-grid.Left<228)
                 customMonthCalendar.Location = new Point((grid.Location.X + x) - 226, grid.Location.Y + top + 25);
             else
                 customMonthCalendar.Location = new Point((grid.Location.X + x) - 10, grid.Location.Y + top + 25);
         }
         else
             if (panelright - grid.Left < 228)
                 customMonthCalendar.Location = new Point((grid.Location.X + x) - 226, grid.Location.Y + top + 25);
             else
             customMonthCalendar.Location = new Point((grid.Location.X + x) - 10, (grid.Location.Y + top) - 165);
         ((Control)sender).Parent.Controls.Add(customMonthCalendar);
         DateTime datetime;
         bool isdatetimeparse = DateTime.TryParse(grid.SelectedCells[0].Value.ToString(), out datetime);
         if (isdatetimeparse)
             customMonthCalendar.SetDate(datetime);
         customMonthCalendar.Visible = true;
         customMonthCalendar.BringToFront();
         factory.IsPopup = true;
     }
 }
예제 #5
0
 private void DateText_Click(object sender, EventArgs e)
 {
     TextBox box = (TextBox)sender;
     currentBox = box;
     MonthCalendar date = new MonthCalendar();
     filterPanel.Controls.Add(date);
     date.DateSelected += new DateRangeEventHandler(date_DateSelected);
     date.Visible = true;
     date.Location = new Point(currentBox.Location.X, currentBox.Location.Y - 50);
     date.BringToFront();
 }