Exemplo n.º 1
0
        protected void DrawBars(    Graphics                    gr, 
                                    WorkingHoursConfiguration   config, 
                                    List< EventEntry >[]        days, 
                                    DateTime                    start_of_week, 
                                    DateTime                    end_of_week, 
                                    out double                  work_hours_week, 
                                    out double                  unlocked_hours_week )
        {
            double work_hours_day       = 0;
            double unlocked_hours_day   = 0;
            int work_days               = 0;
            work_hours_week             = 0;
            unlocked_hours_week         = 0;
            BarCreator bar_creator      = new BarCreator( config, start_of_week, end_of_week );

            for ( int i = 0; i < days.Length; i++ )
            {
                work_hours_day     = 0;
                unlocked_hours_day = 0;

                foreach ( EventEntry ee in days[ i ] )
                {
                    Bar bar = bar_creator.GetBar( ee );
                    if ( config.show_detailed_weeks || bar == null )
                    {
                        DrawBar( gr, config, bar );
                    }
                    else
                    {
                        if ( bar.is_unlocked )
                        {
                            unlocked_hours_day += bar.Height;
                        }
                        else
                        {
                            work_hours_day += bar.Height;
                        }
                    }
                }

                foreach ( Bar b in bar_creator.GetFinalBarsForDay() ) // last unlock - now
                {
                    if ( config.show_detailed_weeks )
                    {
                        DrawBar( gr, config, b );
                    }
                    else
                    {
                        if ( b.is_unlocked )
                        {
                            unlocked_hours_day += b.Height;
                        }
                        else
                        {
                            work_hours_day += b.Height;
                        }
                    }
                }
                if ( !config.show_detailed_weeks )
                {
                    Bar b1 = new Bar( new SolidBrush( config.work_bar_color     ), i, false, start_of_week.AddDays( i ), start_of_week.AddDays( i + work_hours_day     / 24 ) );
                    Bar b2 = new Bar( new SolidBrush( config.unlocked_bar_color ), i, true,  start_of_week.AddDays( i ), start_of_week.AddDays( i + unlocked_hours_day / 24 ) );
                    DrawBar( gr, config, b1 );
                    DrawBar( gr, config, b2 );
                }

                if ( work_hours_day > 0 || unlocked_hours_day > 0 )
                {
                    work_days++;
                }

                work_hours_week     += work_hours_day;
                unlocked_hours_week += unlocked_hours_day;
            }
            work_hours_week     /= work_days;
            unlocked_hours_week /= work_days;
        }
Exemplo n.º 2
0
        protected void DrawBars(Graphics gr,
                                WorkingHoursConfiguration config,
                                List <EventEntry>[]        days,
                                DateTime start_of_week,
                                DateTime end_of_week,
                                out double work_hours_week,
                                out double unlocked_hours_week)
        {
            double work_hours_day     = 0;
            double unlocked_hours_day = 0;
            int    work_days          = 0;

            work_hours_week     = 0;
            unlocked_hours_week = 0;
            BarCreator bar_creator = new BarCreator(config, start_of_week, end_of_week);

            for (int i = 0; i < days.Length; i++)
            {
                work_hours_day     = 0;
                unlocked_hours_day = 0;

                foreach (EventEntry ee in days[i])
                {
                    Bar bar = bar_creator.GetBar(ee);
                    if (config.show_detailed_weeks || bar == null)
                    {
                        DrawBar(gr, config, bar);
                    }
                    else
                    {
                        if (bar.is_unlocked)
                        {
                            unlocked_hours_day += bar.Height;
                        }
                        else
                        {
                            work_hours_day += bar.Height;
                        }
                    }
                }

                foreach (Bar b in bar_creator.GetFinalBarsForDay())   // last unlock - now
                {
                    if (config.show_detailed_weeks)
                    {
                        DrawBar(gr, config, b);
                    }
                    else
                    {
                        if (b.is_unlocked)
                        {
                            unlocked_hours_day += b.Height;
                        }
                        else
                        {
                            work_hours_day += b.Height;
                        }
                    }
                }
                if (!config.show_detailed_weeks)
                {
                    Bar b1 = new Bar(new SolidBrush(config.work_bar_color), i, false, start_of_week.AddDays(i), start_of_week.AddDays(i + work_hours_day / 24));
                    Bar b2 = new Bar(new SolidBrush(config.unlocked_bar_color), i, true, start_of_week.AddDays(i), start_of_week.AddDays(i + unlocked_hours_day / 24));
                    DrawBar(gr, config, b1);
                    DrawBar(gr, config, b2);
                }

                if (work_hours_day > 0 || unlocked_hours_day > 0)
                {
                    work_days++;
                }

                work_hours_week     += work_hours_day;
                unlocked_hours_week += unlocked_hours_day;
            }
            work_hours_week     /= work_days;
            unlocked_hours_week /= work_days;
        }