Ejemplo n.º 1
0
        private void DrawRightTitleInfo(Base.TResultCalendar tResultCalendar, Graphics g)
        {
            string str      = tResultCalendar.m_Location.GetFullName();
            SizeF  textSize = g.MeasureString(str, fontH3);

            g.DrawString(str, fontH3, Brushes.Black, xMarginRight - textSize.Width, yMarginTop);
            float tx = textSize.Height;

            str      = GCStrings.ShortVersionText;
            textSize = g.MeasureString(str, fontS1);
            g.DrawString(str, fontS1, Brushes.Black, xMarginRight - textSize.Width, yMarginTop + tx);
        }
Ejemplo n.º 2
0
        internal void Draw(Graphics graphics, Size size, Base.TResultCalendar tResultCalendar, int nYear, int nMonth)
        {
            Graphics g          = graphics;
            SizeF    textSize   = Size.Empty;
            float    fontH1Size = Math.Min(size.Height - PaddingLeft - PaddingRight, size.Width * 0.707f - PaddingTop - PaddingBottom) / 30;

            xMarginLeft     = PaddingLeft;
            yMarginTop      = PaddingTop;
            xMarginRight    = size.Width - PaddingRight;
            yUnderTitleBar  = 0;
            yUnderMainTitle = 0;
            float        tx;
            float        cellInset  = fontH1Size / 5;
            StringFormat rectFormat = new StringFormat();

            rectFormat.Trimming = StringTrimming.EllipsisWord;
            DateTime dtToday = DateTime.Now;


            InitializeFonts(fontH1Size);

            string str;

            DrawTitle(nYear, nMonth, g);

            if (tResultCalendar == null)
            {
                return;
            }

            DrawRightTitleInfo(tResultCalendar, g);

            g.DrawLine(monthDivider, xMarginLeft, yUnderTitleBar, xMarginRight, yUnderTitleBar);

            firstDayOfWeekGeneral = GCDisplaySettings.Current.getValue(GCDS.GENERAL_FIRST_DOW);
            xCellWidth            = (xMarginRight - xMarginLeft) / 7.0f;

            float tempTextHeight = fontH1Size / 5;

            // draw names of weekdays
            textSize = DrawWeekdayHeader(g, tempTextHeight);

            yTableTop = yUnderTitleBar + 2 * tempTextHeight + textSize.Height;


            yMarginBottom = size.Height - PaddingBottom;
            int firstIndex  = 0;
            int firstDayDow = 0;

            for (int i = 0; i < tResultCalendar.m_nCount; i++)
            {
                GregorianDateTime gdt = tResultCalendar.m_pData[i].date;
                if (gdt.day == 1 && gdt.month == nMonth && gdt.year == nYear)
                {
                    firstIndex  = i;
                    firstDayDow = gdt.dayOfWeek;
                }
            }

            int daysBeforeFirstDay = (firstDayDow - firstDayOfWeekGeneral + 14) % 7;
            int monthDays          = GregorianDateTime.GetMonthMaxDays(nYear, nMonth);

            int totalDays  = daysBeforeFirstDay + monthDays;
            int weeksCount = ((totalDays % 7) == 0) ? (totalDays / 7) : (totalDays / 7 + 1);

            yCellHeight = (yMarginBottom - yTableTop) / weeksCount;

            RectangleF    rcf = new RectangleF();
            int           row, column, di;
            StringBuilder masaText = new StringBuilder();

            for (int i = 1; i <= monthDays; i++)
            {
                di     = daysBeforeFirstDay + i - 1;
                row    = di / 7;
                column = di % 7;

                VAISNAVADAY vd      = tResultCalendar.m_pData[firstIndex + i - 1];
                VAISNAVADAY vd_prev = tResultCalendar.m_pData[firstIndex + i - 2];
                VAISNAVADAY vd_next = tResultCalendar.m_pData[firstIndex + i];

                ConstructMasaText(masaText, i, vd, vd_prev, vd_next);

                yCellMarginTop  = yTableTop + row * yCellHeight + cellInset;
                xCellMarginLeft = xMarginLeft + column * xCellWidth + cellInset;

                rcf.X      = xCellMarginLeft - cellInset;
                rcf.Y      = yCellMarginTop - cellInset;
                rcf.Width  = xCellWidth;
                rcf.Height = yCellHeight;
                if (vd.nFastID == FastType.FAST_EKADASI)
                {
                    g.FillRectangle(Brushes.LightGreen, rcf);
                }
                else if (vd.nFastID != 0)
                {
                    g.FillRectangle(Brushes.LightSkyBlue, rcf);
                }
                if (dtToday.Day == i && dtToday.Month == nMonth && dtToday.Year == nYear)
                {
                    g.DrawRectangle(todayBorder, rcf.Left, rcf.Top, rcf.Width, rcf.Height);
                }


                textSize = DrawCellDayNumber(g, i);

                yCellAnchor1      = yCellMarginTop + textSize.Height + cellInset;
                xCellAnchor1      = xCellMarginLeft + textSize.Width + cellInset;
                xCellMarginRight  = xCellMarginLeft + xCellWidth - 2 * cellInset;
                yCellMarginBottom = yCellMarginTop + yCellHeight - 2 * cellInset;


                tempTextHeight = DrawTithiText(g, vd);

                yCellAnchor1 = Math.Max(tempTextHeight + cellInset, yCellAnchor1);


                rcf.X      = xCellAnchor1;
                rcf.Y      = yCellMarginTop;
                rcf.Width  = xCellMarginRight - xCellAnchor1;
                rcf.Height = textSize.Height + 2;

                str = GetEventsLineText(vd);

                Font f = fontS2;
                textSize = g.MeasureString(str, fontS2, Convert.ToInt32(xCellMarginRight - xCellMarginLeft));
                if (textSize.Height + yCellAnchor1 + cellInset > yCellMarginTop + yCellHeight)
                {
                    f        = fontS3;
                    textSize = g.MeasureString(str, f, Convert.ToInt32(xCellMarginRight - xCellMarginLeft));
                }
                rcf.Y      = yCellAnchor1;
                rcf.X      = xCellMarginLeft;
                rcf.Width  = textSize.Width;
                rcf.Height = Math.Min(yCellMarginBottom - yCellAnchor1, textSize.Height);
                g.DrawString(str, f, Brushes.Black, rcf, rectFormat);
            }

            // masa info text
            g.DrawString(masaText.ToString(), fontS2, Brushes.Black, xMarginLeft, yUnderMainTitle);

            // final step: draw matrix
            for (int i = 0; i < 8; i++)
            {
                g.DrawLine(dayDivider, xMarginLeft + i * xCellWidth, yTableTop, xMarginLeft + i * xCellWidth, yMarginBottom);
            }
            for (int j = 0; j <= weeksCount; j++)
            {
                g.DrawLine(dayDivider, xMarginLeft, yTableTop + j * yCellHeight, xMarginRight, yTableTop + j * yCellHeight);
            }
        }