Exemplo n.º 1
0
        public void renderSchedule(Graphics g, int h, int w, Color backC, WeeklyScheduler.ScheduleList schList)
        {
            int leftOffset = 20;
            int topOffset = 20;
            int dayWidth;
            int numOfDays;
            if (renderWeekend)
            {
                numOfDays = 7;
            }
            else
            {
                numOfDays = 5;
            }

            dayWidth = (w - leftOffset) / numOfDays;
            double minHeight = (double)(h - topOffset) / (24d * 60d);
            if (backC != Color.Transparent) g.Clear(backC);
            for (int i = 0; i < numOfDays; i++)
            {
                g.DrawLine(Pens.Black, new Point(i * dayWidth + leftOffset, 0), new Point(i * dayWidth + leftOffset, h));
                g.DrawString(Enum.GetName(typeof(DayOfWeek), i + 1), new Font("Arial", 8), Brushes.Black, new PointF(i * dayWidth + leftOffset, 5));
            }

            for (int i = 0; i < 24; i++)
            {
                g.DrawString(formatHour(i), new Font("Arail", 8), Brushes.Black, new PointF(0, (float)((minHeight * i * 60) + topOffset)));
                g.DrawLine(Pens.Black, (float)leftOffset, (float)((minHeight * i * 60) + topOffset), w, (float)((minHeight * i * 60) + topOffset));
            }
            if (schList == null) return;

            foreach (WeeklyScheduler.ClassSection cs in schList.classes)
            {
                foreach (WeeklyScheduler.TimeFrame tf in cs.Times)
                {
                    if (((int)tf.StartTime.Day - 1) < numOfDays)
                    {
                        g.FillRectangle(Brushes.Yellow, ((int)tf.StartTime.Day - 1) * dayWidth + 5 + leftOffset, (float)((tf.StartTime.Minute + tf.StartTime.Hour * 60) * minHeight + topOffset),
                            dayWidth - 10, (float)(((tf.EndTime.Minute + tf.EndTime.Hour * 60) - (tf.StartTime.Minute + tf.StartTime.Hour * 60)) * minHeight));
                        g.DrawRectangle(Pens.Black, ((int)tf.StartTime.Day - 1) * dayWidth + 5 + leftOffset, (float)((tf.StartTime.Minute + tf.StartTime.Hour * 60) * minHeight + topOffset),
                           dayWidth - 10, (float)(((tf.EndTime.Minute + tf.EndTime.Hour * 60) - (tf.StartTime.Minute + tf.StartTime.Hour * 60)) * minHeight));
                        g.DrawString(cs.parentClass.Title, new Font("Arial", 8f), Brushes.Black, new RectangleF(((int)tf.StartTime.Day - 1) * dayWidth + 5 + leftOffset, (float)((tf.StartTime.Minute + tf.StartTime.Hour * 60) * minHeight + topOffset + 1),
                            dayWidth - 10, (float)(((tf.EndTime.Minute + tf.EndTime.Hour * 60) - (tf.StartTime.Minute + tf.StartTime.Hour * 60)) * minHeight)));
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void GetTimeframFromForm(WeeklyScheduler.TimeFrame tf)
        {
            tf.StartTime.Day = (DayOfWeek)timeframe_day.SelectedIndex;
            tf.StartTime.Minute = Int32.Parse(start_min.Text);
            if (start_PM.Checked)
            {
                if (Int32.Parse(start_hour.Text) == 12)
                {
                    tf.StartTime.Hour = 12;
                }
                else
                {
                    tf.StartTime.Hour = Int32.Parse(start_hour.Text) + 12;
                }
            }
            else
            {
                tf.StartTime.Hour = Int32.Parse(start_hour.Text);
            }

            tf.EndTime.Minute = Int32.Parse(end_min.Text);
            if (end_PM.Checked)
            {
                if (Int32.Parse(end_hour.Text) == 12)
                {
                    tf.EndTime.Hour = 12;
                }
                else
                {
                    tf.EndTime.Hour = Int32.Parse(end_hour.Text) + 12;
                }
            }
            else
            {
                tf.EndTime.Hour = Int32.Parse(end_hour.Text);
            }
        }