Exemplo n.º 1
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (SelectedDatePart == DateInfoType.None)
            {
                return;
            }
            int selectedDatePartValue = (int)SelectedDatePart;

            if (e.KeyData == Keys.Up)
            {
                Date = GetPreviousDate(SelectedDatePart);
            }
            if (e.KeyData == Keys.Down)
            {
                Date = GetNextDate(SelectedDatePart);
            }
            if (e.KeyData == Keys.Left)
            {
                if (selectedDatePartValue > 1)
                {
                    SelectedDatePart = (DateInfoType)((int)SelectedDatePart - 1);
                }
            }
            if (e.KeyData == Keys.Right)
            {
                if (selectedDatePartValue < Enum.GetValues(typeof(DateInfoType)).Length - 1)
                {
                    SelectedDatePart = (DateInfoType)((int)SelectedDatePart + 1);
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            Select();
            DateHitInfo hitInfo = CalcHitInfo(e.Location);

            SelectedDatePart = hitInfo.HitInfoType;
        }
 public string GetCurrentDayValue(DateInfoType datePart, DateTime dt)
 {
     if (datePart == DateInfoType.Day)
     {
         return(dt.ToString("M"));
     }
     if (datePart == DateInfoType.Hour)
     {
         return(dt.Hour.ToString());
     }
     return(dt.Minute.ToString());
 }
 public string GetDayValueByPosition(DateInfoType datePart, PositionType positionType, DateTime dt)
 {
     if (positionType == PositionType.Top)
     {
         return(GetPreviousDayValue(datePart, dt));
     }
     if (positionType == PositionType.Middle)
     {
         return(GetCurrentDayValue(datePart, dt));
     }
     return(GetNextDayValue(datePart, dt));
 }
Exemplo n.º 5
0
 public DateTime GetNextDate(DateInfoType datePart)
 {
     if (datePart == DateInfoType.Day)
     {
         return(Date.AddDays(1));
     }
     if (datePart == DateInfoType.Hour)
     {
         return(Date.AddHours(1));
     }
     return(Date.AddMinutes(1));
 }
 public string GetPreviousDayValue(DateInfoType datePart, DateTime dt)
 {
     dt = GetPreviousDate(datePart, dt);
     if (datePart == DateInfoType.Day)
     {
         return(dt.ToString("M"));
     }
     if (datePart == DateInfoType.Hour)
     {
         return(dt.Hour.ToString());
     }
     return(dt.Minute.ToString());
 }
 public DateTime GetDate(DateInfoType datePart, DateTime dt, int val)
 {
     try
     {
         if (datePart == DateInfoType.Day)
         {
             return(dt.AddDays(val));
         }
         if (datePart == DateInfoType.Hour)
         {
             return(dt.AddHours(val));
         }
         return(dt.AddMinutes(val));
     }
     catch { }
     return(dt);
 }
Exemplo n.º 8
0
        protected virtual void DrawDigit(System.Drawing.Graphics graphics, DateTapeViewInfo dateViewInfo, Rectangle rect, DateInfoType datePart)
        {
            Array positions = Enum.GetValues(typeof(PositionType));

            foreach (PositionType positionType in positions)
            {
                Rectangle    dateRect       = dateViewInfo.GetRect(rect, positionType);
                DateTapeEdit edit           = dateViewInfo.OwnerEdit as DateTapeEdit;
                bool         isSelectedPart = edit != null && edit.SelectedDatePart == datePart;
                if (isSelectedPart && positionType != PositionType.Middle)
                {
                    using (Brush br = GetSelectedBackBrush())
                        graphics.FillRectangle(br, dateRect);
                }

                RepositoryItemDateTapeEdit item = dateViewInfo.Item as RepositoryItemDateTapeEdit;
                DateTime dt       = Convert.ToDateTime(dateViewInfo.EditValue);
                string   dayValue = item.GetDayValueByPosition(datePart, positionType, dt).ToString();
                using (Brush br = GetForeBrush(positionType, isSelectedPart))
                    graphics.DrawString(dayValue, dateViewInfo.PaintAppearance.Font, br, dateRect);
            }
        }
 public DateTime GetNextDate(DateInfoType datePart, DateTime dt)
 {
     return(GetDate(datePart, dt, 1));
 }
 public DateTime GetPreviousDate(DateInfoType datePart, DateTime dt)
 {
     return(GetDate(datePart, dt, -1));
 }
Exemplo n.º 11
0
        protected virtual void DrawDigit(System.Drawing.Graphics graphics, DateViewInfo dateViewInfo, Rectangle rect, DateInfoType datePart)
        {
            Array positions = Enum.GetValues(typeof(PositionType));
            Brush brush     = Brushes.LightGray;

            foreach (PositionType positionType in positions)
            {
                Rectangle dateRect = dateViewInfo.GetRect(rect, positionType);
                if (dateViewInfo.Owner.SelectedDatePart == datePart)
                {
                    graphics.FillRectangle(Brushes.CornflowerBlue, dateRect);
                }

                string dayValue = dateViewInfo.Owner.GetDayValueByPosition(datePart, positionType).ToString();
                graphics.DrawString(dayValue, dateViewInfo.Font, GetBrush(positionType), dateRect);
            }
        }