示例#1
0
        //private int count=0;

        ///<summary></summary>
        public ContrCalendar()
        {
            InitializeComponent();
            RowCount     = 6;
            ColCount     = 7;
            FixedHeight  = 25;
            FixedWidth   = 25;
            BGColor      = SystemColors.Window;
            BG2Color     = SystemColors.Control;
            HeadColor    = SystemColors.Control;
            FootColor    = SystemColors.Control;
            DayHeadColor = SystemColors.Window;
            TextColor    = Color.Black; //SystemColors.ControlText;
            DayOpenColor = Color.White; //SystemColors.Window; Was ActiveDayColor
            //SelectedDayColor=Color.White;//SystemColors.Highlight;
            LinePen       = new Pen(Color.SlateGray, 2);
            FontText      = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
            FontText2     = new Font("Microsoft Sans Serif", 8, FontStyle.Regular);
            DayHeadHeight = FontText.GetHeight() + 6;
            FontHeader    = new Font("Microsoft Sans Serif", 9, FontStyle.Bold);
            MaxRowsText   = 5;
            List          = new OneCalendarDay[32];
            for (int i = 0; i < List.Length; i++)
            {
                List[i]            = new OneCalendarDay();
                List[i].RowsOfText = new string[MaxRowsText];
            }
        }
示例#2
0
        private void DisplayDaysInMonth(Graphics grfx)
        {
            int   dayOfWeek;
            int   column;
            int   row = 0;
            float fHeight;
            float fWidth;
            float fHeight2;
            float fWidth2;

            fWidth   = FixedWidth + ColWidth - 1;
            fWidth2  = FixedWidth + ColWidth;
            fHeight  = (FixedHeight * 2) + DayHeadHeight + 2;
            fHeight2 = (FixedHeight * 2) + DayHeadHeight;
            DateTime TempDate = new DateTime(selectedDate.Year, selectedDate.Month, 1);

            dayOfWeek   = (int)TempDate.DayOfWeek;
            column      = dayOfWeek;
            DaysInMonth = DateTime.DaysInMonth(selectedDate.Year, selectedDate.Month);
            for (int i = 1; i <= DaysInMonth; i++)
            {
                if (column == 7)
                {
                    row++;
                    column = 0;
                }
                float xPos = (int)(fWidth + (ColWidth * column) - grfx.MeasureString(i.ToString(), FontText).Width - 3);
                float yPos = (int)(fHeight + (RowHeight * row) + 2);
                RecActDay = new Rectangle((int)Math.Round((fWidth2 + (ColWidth * (column - 1)))), (int)Math.Round((fHeight2 + (RowHeight * row))),
                                          (int)Math.Round(ColWidth), (int)Math.Round(RowHeight));
                List[i].Rec  = RecActDay;
                List[i].Day  = i;
                List[i].xPos = xPos;
                List[i].yPos = yPos;
                List[i].Date = new DateTime(selectedDate.Year, selectedDate.Month, i);
                if (i == DateTime.Today.Day &&
                    selectedDate.Month == DateTime.Today.Month &&
                    selectedDate.Year == DateTime.Today.Year)
                {
                    Today             = List[i];
                    Today.Rec.X      += 1;
                    Today.Rec.Y      += 2;
                    Today.Rec.Width  -= 2;
                    Today.Rec.Height -= 3;
                }
                if (i == SelectedDay)
                {
                    SelectedDay        = i;
                    List[i].IsSelected = true;
                }
                column++;
            }
        }