private void TilesGenerate()
        {
            //Looking for startDate and finishDate
            Diapazon diapazon   = new Diapazon(KeyDate);
            DateTime startDate  = diapazon.startDate;
            DateTime finishDate = diapazon.finishDate;

            DateTime date          = startDate;
            int      baseLeft      = 40;
            int      tileWidth     = 49;
            int      betweenTilesV = 1;
            int      betweenTilesH = 7;
            int      baseTop       = 60;
            int      tileHeight    = 6;

            tiles.Clear();
            for (int day = 0; day < 21; day++) //Three weeks
            {
                for (int unit = 0; unit < 24 * 4; unit++)
                { //for possible lesson unit per hour
                    Tile tile = new Tile();

                    tile.left  = baseLeft + day * (tileWidth + betweenTilesH);
                    tile.width = tileWidth;

                    tile.top    = baseTop + unit * (tileHeight + betweenTilesV);
                    tile.height = tileHeight;

                    //tile.text = "Tile"
                    bool isEvenHour = unit / 4 % 2 == 0;
                    if (isEvenHour)
                    {
                        tile.color = Color.LightSeaGreen;
                    }

                    tiles.Add(tile);
                }
            }

            LessonsListManager lessonsListManager = new LessonsListManager(dbPath);
            List <LessonInfo>  lessonInfos        = lessonsListManager.getLessonsList(startDate, finishDate);

            for (int i = 0; i < lessonInfos.Count; i++)
            {
                LessonInfo lessonInfo = lessonInfos[i];

                int      tileNum        = 0;
                DateTime lessonDateTime = startDate;
                while (lessonDateTime < lessonInfo.DateAndTime)
                {
                    lessonDateTime = lessonDateTime.AddMinutes(15); //***
                    tileNum++;
                }

                tiles[tileNum].height = lessonInfo.duration * tileHeight + (lessonInfo.duration - 1) * betweenTilesV;
                tiles[tileNum].text   = lessonInfo.studentInfo.name;
                tiles[tileNum].color  = Color.LightGreen;
                tiles[tileNum].free   = false;
            }
        }
Пример #2
0
 public LessonsForm(string dbPath)
 {
     this.dbPath        = dbPath;
     lessonsListManager = new LessonsListManager(dbPath);
     InitializeComponent();
     dateTimePicker.Format = DateTimePickerFormat.Custom;
     //dateTimePicker.CustomFormat = "MM/dd/yyyy hh:mm:ss";
     dateTimePicker.CustomFormat = "dd/MM/yyyy hh:mm:ss";
 }