public virtual void CalcCurrentCells(DateTime dt)
        {
            int hour = dt.Hour;

            if (hour > 11)
            {
                hour  -= 12;
                Format = CellsList[CellsList.Count - 1];
            }
            else
            {
                Format = CellsList[CellsList.Count - 2];
            }
            hour        = hour == 0 ? 12 : hour;
            FocusedHour = CellsList[hour - 1];

            double minute = dt.Minute;
            double temp   = minute / 5;

            string[] minuteString = temp.ToString().Split('.');
            int      minuteIndex  = int.Parse(minuteString[0]);

            if (minuteString.Length > 1)
            {
                int leftover = int.Parse(minuteString[1]);
                if (leftover > 5)
                {
                    minuteIndex += 1;
                }
            }
            FocusedMinute = CellsList[12 + minuteIndex];
        }
Ejemplo n.º 2
0
        private void CalcClientSize()
        {
            CellViewInfo upperRightCell = ViewInfo.CellsList[14];
            int          controlWidth   = upperRightCell.cellBounds.X + upperRightCell.cellBounds.Width + indent;
            int          controlHeight  = buttonOK.Location.Y + buttonOK.Height + indent;

            ClientSize = new Size(controlWidth, controlHeight);
        }
        private PointF CalcLabelPoint(CellViewInfo cell, SizeF textSize)
        {
            const int indent = 2;
            float     x      = cell.cellBounds.X + cell.cellBounds.Width / 2 - textSize.Width / 2;
            float     y      = cell.cellBounds.Y - textSize.Height - indent;

            return(new PointF(x, y));
        }
        private PointF SetTextPoint(CellViewInfo cellInfo, Graphics g)
        {
            SizeF textSize = g.MeasureString(cellInfo.CellText, PopupViewInfo.PopupAppearance.Font);
            float x        = cellInfo.cellBounds.X + cellInfo.cellBounds.Width - 3 - textSize.Width;
            float y        = cellInfo.cellBounds.Y + cellInfo.cellBounds.Height - 1 - textSize.Height;

            return(new PointF(x, y));
        }
Ejemplo n.º 5
0
 private void Clear()
 {
     emptyCell       = null;
     OwnerEdit       = null;
     isReady         = false;
     LostFocus      -= TimeEditPopupControl_LostFocus;
     buttonOK.Click -= buttonOK_Click;
     buttonOK.Dispose();
 }
        protected virtual void CreateCellsList()
        {
            const int midIndent = 6;

            AddCellsBlock(new Point(3, 20), CellViewInfo.CellType.Hour);
            CellViewInfo upperRightCell = CellsList[2];

            AddCellsBlock(new Point(upperRightCell.cellBounds.X + upperRightCell.cellBounds.Width + midIndent, upperRightCell.cellBounds.Y), CellViewInfo.CellType.Minute);
            AddAmPmCells();
        }
 private void Clear()
 {
     PopupAppearance.Dispose();
     CellsList.Clear();
     Bounds         = Rectangle.Empty;
     ownerControl   = null;
     HotPointedCell = null;
     FocusedMinute  = null;
     FocusedHour    = null;
     Format         = null;
 }
        private void AddAmPmCells()
        {
            const int    indent        = 3;
            CellViewInfo lowerLeftCell = CellsList[9];
            Point        startPoint    = new Point(lowerLeftCell.cellBounds.X, lowerLeftCell.cellBounds.Y + lowerLeftCell.cellBounds.Height + indent);
            Rectangle    cellRect      = new Rectangle(startPoint, new Size(30, 20));

            CellsList.Add(new CellViewInfo(PopupAppearance.Font, "AM", cellRect, CellViewInfo.CellType.Format));
            cellRect.Location = new Point(cellRect.Location.X + CellsList[CellsList.Count - 1].cellBounds.Width, cellRect.Location.Y);
            CellsList.Add(new CellViewInfo(PopupAppearance.Font, "PM", cellRect, CellViewInfo.CellType.Format));
        }
Ejemplo n.º 9
0
        private void AddOkButton()
        {
            CellViewInfo lowerRightCell = ViewInfo.CellsList[23];

            buttonOK = new SimpleButton();
            buttonOK.LookAndFeel.Assign(OwnerEdit.LookAndFeel);
            buttonOK.Size       = new Size(30, 20);
            buttonOK.AllowFocus = false;
            buttonOK.Text       = "OK";
            buttonOK.Location   = new Point(lowerRightCell.cellBounds.X + lowerRightCell.cellBounds.Width - buttonOK.Width,
                                            lowerRightCell.cellBounds.Y + lowerRightCell.cellBounds.Height + indent);
            buttonOK.Click += buttonOK_Click;
            Controls.Add(buttonOK);
        }
        protected virtual SkinElementInfo GetCellElementInfo(CellViewInfo cell, GraphicsCache cache, bool selected)
        {
            Skin            skin = CommonSkins.GetSkin(PopupViewInfo.ownerControl.OwnerEdit.LookAndFeel.ActiveLookAndFeel);
            SkinElementInfo skinInfo;

            if (selected)
            {
                skinInfo = new SkinElementInfo(skin[CommonSkins.SkinSelection], cell.cellBounds);
            }
            else
            {
                skinInfo = new SkinElementInfo(skin[CommonSkins.SkinHighlightedItem], cell.cellBounds);
            }
            skinInfo.Cache = cache;
            return(skinInfo);
        }
Ejemplo n.º 11
0
        public TimeEditPopupControl(PopupTimeEdit ownerEdit)
        {
            DoubleBuffered = true;
            Appearance.Assign(ownerEdit.Properties.Appearance);
            InitializeComponent();

            OwnerEdit = ownerEdit;
            emptyCell = new CellViewInfo();

            CreateViewInfo();
            CreatePainter();

            AddOkButton();
            CalcClientSize();

            LostFocus += TimeEditPopupControl_LostFocus;
        }