public override GSCore ExecuteMessage(string token, GSCoreCollection args)
        {
            switch (token)
            {
            case "getEndDone":
            {
                GSCore gtObj = args.getSafe(0);
                if (gtObj != null && gtObj is GregorianDateTime)
                {
                    GregorianDateTime gdt = gtObj as GregorianDateTime;
                    if (gdt.GetJulianInteger() < getView().calStartDate.GetJulianInteger() + 7)
                    {
                        gdt = new GregorianDateTime(getView().calStartDate);
                        gdt.AddDays(7);
                    }
                    getView().calEndDate = gdt;
                    //getView().EndDateText(gdt.ToString());
                    getView().Recalculate();
                }
            }
            break;

            case "getCurrentContent":
                return(getView().getCurrentContent());

            default:
                return(base.ExecuteMessage(token, args));
            }

            return(GSCore.Void);
        }
Esempio n. 2
0
        private void printToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (p_mode == 0)
            {
                if (Controller != null)
                {
                    Controller.ExecuteMessage("printContent", m_calendar);
                }
            }
            else if (p_mode == 2)
            {
                PrintDialog pd = new PrintDialog();

                if (pd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                DialogResult dr = MessageBox.Show("Do you want to print a whole year ?", "Time Period", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    printMonthStart = 1;
                    printMonthEnd   = 12;
                    printYearStart  = calendarTableView1.CurrentYear;
                    printYearEnd    = printYearStart;
                }
                else if (dr == DialogResult.No)
                {
                    printMonthEnd  = printMonthStart = calendarTableView1.CurrentMonth;
                    printYearStart = printYearEnd = calendarTableView1.CurrentYear;
                }
                else
                {
                    printMonthStart = printMonthEnd = -1;
                    printYearStart  = printYearEnd = -1;
                }

                if (printYearStart > 0)
                {
                    m_calendarToPrint = new TResultCalendar();
                    GregorianDateTime startDate = new GregorianDateTime(printYearStart, printMonthStart, 1);
                    GregorianDateTime endDate   = new GregorianDateTime(printYearEnd, printMonthEnd, 1);
                    m_calendarToPrint.CalculateCalendar(calLocation, startDate, endDate.GetJulianInteger() - startDate.GetJulianInteger() + 31);
                    printDocumentTable.PrinterSettings = pd.PrinterSettings;
                    printDocumentTable.DocumentName    = string.Format("{0}_{1}", calLocation.Title, printYearStart);
                    printDocumentTable.Print();
                }
            }
        }
Esempio n. 3
0
        public static void ExportTableCalendar(GCLocation calLocation, int printYearStart, int printYearEnd, string folderPath)
        {
            TResultCalendar   m_calendarToPrint = new TResultCalendar();
            GregorianDateTime startDate         = new GregorianDateTime(printYearStart, 1, 1);
            GregorianDateTime endDate           = new GregorianDateTime(printYearEnd, 12, 1);

            m_calendarToPrint.CalculateCalendar(calLocation, startDate, endDate.GetJulianInteger() - startDate.GetJulianInteger() + 31);

            string DocumentName = string.Format("{0}_{1}", calLocation.Title, printYearStart);

            PdfDocument doc = new PdfDocument();

            CalendarPdfDrawer ctd = new CalendarPdfDrawer();

            for (int year = printYearStart; year <= printYearEnd; year++)
            {
                for (int month = 1; month <= 12; month++)
                {
                    PdfPage page = doc.AddPage();
                    page.Size        = PdfSharp.PageSize.A4;
                    page.Orientation = PdfSharp.PageOrientation.Landscape;

                    XGraphics gfx = XGraphics.FromPdfPage(page);

                    SizeF pageSizeF = gfx.PageSize.ToSizeF();
                    ctd.PaddingTop    = Convert.ToInt32(pageSizeF.Height / 20);
                    ctd.PaddingBottom = Convert.ToInt32(pageSizeF.Height / 20);
                    ctd.PaddingLeft   = Convert.ToInt32(pageSizeF.Width / 20);
                    ctd.PaddingRight  = Convert.ToInt32(pageSizeF.Width / 20);

                    ctd.Draw(gfx, gfx.PageSize, m_calendarToPrint, year, month);
                }
            }

            doc.Save(folderPath);
        }