SetDate() public méthode

public SetDate ( System.DateTime date ) : void
date System.DateTime
Résultat void
Exemple #1
0
        /// <summary>
        /// Установка значения даты/времени в элементе управления 'календарь' и
        /// выполнение функции, связанной с изменением значения даты/времени
        /// </summary>
        /// <param name="dt">Устанавливаемая дата</param>
        /// /// <param name="bInitTableHourRows">Признак перестроения строк представления значений в ~ от новой даты (23, 25 ч)</param>
        private void setDate(DateTime dt, bool bInitTableHourRows)
        {
            mcldrDate.SetDate(dt);

            if (bInitTableHourRows == true)
            {
                initTableHourRows();
            }
            else
            {
                ;
            }
        }
Exemple #2
0
            protected override void OnMouseDown(MouseEventArgs e)
            {
                Point p          = new Point(e.X, e.Y);
                Size  cellSize   = parent.cellSize;
                Size  parentDims = parent.calendarDims;
                int   nextPage   = parentDims.Width * parentDims.Height;

                // Fix: Handle long clicks with a timer like ScrollBar does
                if (prevBtnRect.Contains(p))
                {
                    parent.SetDate(GetNewMonthView(parent.selectionStart, -nextPage));
                }
                if (nextBtnRect.Contains(p))
                {
                    parent.SetDate(GetNewMonthView(parent.selectionStart, nextPage));
                }
                if (dayRect.Contains(p))
                {
                    int count = ((p.X - dayRect.Left) / cellSize.Width +
                                 (p.Y - dayRect.Top) / cellSize.Height * 7);
                    if (posHasDate[count])
                    {
                        // Note: monthEndPos denotes the position where
                        // the next month starts
                        if (count >= monthStartPos && count < monthEndPos)
                        {
                            DateTime next = firstDateCell.AddDays(count);
                            parent.SetSelectionInternal(next, next, this.index, false);
                        }
                        else
                        {
                            // refresh all dates
                            DateTime next = firstDateCell.AddDays(count);
                            parent.SetSelectionInternal(next, next, this.index, true);
                        }
                    }
                }
            }
        void TDB_ab_sel_Click_Return(object sender, EventArgs e)
        {
            int     id = -1, rows = 0;
            SelForm Fsel = (SelForm)sender;

            id = Fsel.GetID;
            Sai.Get(id, ref rows);
            Sai_e_id.Text   = Sai.ObjId.ToString();
            Sai_e_bez.Text  = Sai.ObjBez;
            Sai_e_code.Text = Sai.ObjCode;
            Sai_e_text.Text = Sai.ObjText;
            Sai_e_von.SetDate(Sai.ObjFrom);
            Sai_e_bis.SetDate(Sai.ObjTo);
        }
 public void LoadData(System.DateTime dt)
 {
     if (dt.Year < 1900)
     {
         dt = System.DateTime.Now;
     }
     dRet = dt;
     monthCalendar1.SelectionStart = dt;
     numHour.Value   = dt.Hour;
     numMinute.Value = dt.Minute;
     numSec.Value    = dt.Second;
     monthCalendar1.SetDate(dt);
     lblDate.Text = dRet.ToString("u");
 }
Exemple #5
0
        /// <summary>
        /// Установка значения даты/времени в элементе управления 'календарь' и
        /// выполнение функции, связанной с изменением значения даты/времени
        /// </summary>
        /// <param name="dt"></param>
        private void setDate(DateTime dt)
        {
            mcldrDate.SetDate(dt);

            initTableHourRows();
        }
        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)
                            {
                            }
                        }
                    }
                }
            }
        }
 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;
     }
 }
Exemple #8
0
		public void DateChangedEventTest ()
		{
			MonthCalendar myCalendar = new MonthCalendar ();
			
			myCalendar.Tag = false;
			myCalendar.DateChanged += new DateRangeEventHandler (DateChangedEventHandler);
			myCalendar.SetDate (DateTime.Today.AddDays (72));
			Assert.AreEqual (true, (bool) myCalendar.Tag, "#01");
		}
Exemple #9
0
        public static int calender(OptsType opts, ArgsType args)
        {
            Form f = new Form();

              Panel p = new Panel();
              p.Height = 24;
              p.Dock = DockStyle.Bottom;
              f.Controls.Add(p);

              Button b1 = new Button();
              b1.DialogResult = DialogResult.OK;
              b1.Dock = DockStyle.Fill;
              b1.Text = "&OK";
              p.Controls.Add(b1);

              int year = DateTime.Now.Year;
              if (opts.ContainsKey("year")) {
            int val;
            if (int.TryParse(opts["year"], out val)) {
              year = val;
            }
              }

              int month = DateTime.Now.Month;
              if (opts.ContainsKey("month")) {
            int val;
            if (int.TryParse(opts["month"], out val)) {
              month = val;
            }
              }

              int day = DateTime.Now.Day;
              if (opts.ContainsKey("day")) {
            int val;
            if (int.TryParse(opts["day"], out val)) {
              day = val;
            }
              }

              MonthCalendar mc = new MonthCalendar();
              mc.CalendarDimensions = new Size(1, 1);
              mc.MaxSelectionCount = 42;
              mc.SetDate(new DateTime(year, month, day));
              f.Controls.Add(mc);

              f.Text = "fwfw calender";
              if (opts.ContainsKey("title")) {
            f.Text = opts["title"];
              }
              f.MaximizeBox = false;
              f.FormBorderStyle = FormBorderStyle.FixedDialog;
              f.StartPosition = FormStartPosition.CenterScreen;
              f.ClientSize = mc.Size;
              f.Height = f.Height + p.Height;

              if (f.ShowDialog() != DialogResult.OK) {
            return 1;
              }

              var start = mc.SelectionStart.ToShortDateString().Replace('/', '-');
              var end = mc.SelectionEnd.ToShortDateString().Replace('/', '-');

              Console.Out.WriteLine(start);
              if (start != end) {
            Console.Out.WriteLine(end);
              }

              return 0;
        }