예제 #1
0
        private void CalendarControl_Paint(object sender, PaintEventArgs e)
        {
            Graphics g  = e.Graphics;
            DateTime dt = DateTime.Now;

            g.FillRectangle(SystemBrushes.ControlLightLight, Bounds);


            if (currentMonth < 0)
            {
                currentMonth = dt.Month;
                currentYear  = dt.Year;
            }
            else
            {
                dt = new DateTime(currentYear, currentMonth, 1);
            }
            int firstDow  = dowToInt[mfi.FirstDayOfWeek];
            int cdw       = (dowToInt[dt.DayOfWeek] - firstDow + 7) % 7;
            int line      = 0;
            int monthDays = GPGregorianTime.GetMonthMaxDays(currentYear, currentMonth);

            Rectangle rect = new Rectangle(0, 0, dayWidth * 7, dayHeight + 8);

            g.DrawString(string.Format("{0} {1}", mfi.GetMonthName(currentMonth), currentYear), titleFont, Brushes.Black, rect, centeredFormat);

            int tr = firstDow;

            for (int i = 0; i < 7; i++)
            {
                rect.Y      = dayHeight + 16;
                rect.X      = i * dayWidth;
                rect.Width  = dayWidth;
                rect.Height = dayHeight;
                g.DrawString(mfi.GetAbbreviatedDayName(intToDow[tr]), SystemFonts.MenuFont, Brushes.Gray, rect, centeredFormat);
                tr = (tr + 1) % 7;
            }
            for (int i = 1; i <= monthDays; i++)
            {
                rect.X = cdw * dayWidth;
                rect.Y = 2 * dayHeight + 16 + line * dayHeight;
                g.DrawString(i.ToString(), SystemFonts.MenuFont, Brushes.Black, rect, centeredFormat);
                cdw++;
                if (cdw > 6)
                {
                    cdw = 0;
                    line++;
                }
            }
        }
예제 #2
0
        public void AdjustDayCombo(int month, int year)
        {
            int sel = comboBox1.SelectedIndex;
            int max = GPGregorianTime.GetMonthMaxDays(year, month);

            while (comboBox1.Items.Count > max)
            {
                comboBox1.Items.RemoveAt(comboBox1.Items.Count - 1);
            }

            while (comboBox1.Items.Count < max)
            {
                comboBox1.Items.Add(comboBox1.Items.Count + 1);
            }
            if (sel > max - 1)
            {
                comboBox1.SelectedIndex = (max - 1);
            }
        }
예제 #3
0
파일: CELSearch.cs 프로젝트: vijeetgv/GCAL
        protected override void Execute()
        {
            ResultsList.Clear();
            //ClearControlList();
            int limit;

            if (Location == null || p_text == null || p_text.Length == 0)
            {
                return;
            }
            // find in texts

            StringBuilder   sb  = new StringBuilder();
            Results         res = new Results(this, p_text);
            GPGregorianTime vc  = new GPGregorianTime(Location);

            vc.Today();

            //
            // today results (this day, tomorrow and day after
            //
            #region today screen results
            limit = GPUserDefaults.IntForKey("search.today.days", 3);
            for (int i = 0; i < limit; i++)
            {
                sb.Remove(0, sb.Length);
                FormaterPlain.AvcGetTodayInfo(vc, Location, sb);
                res.Title = GPAppHelper.getDateText(vc);
                res.Type  = GPStrings.getString(174);
                res.ScanText(p_text, sb);
                if (res.Lines.Count > 0)
                {
                    res.Operation = GPCalculationOperation.Today;
                    res.Parameters.Add(GPCalculationParameters.LocationProvider, Location);
                    res.Parameters.Add(GPCalculationParameters.StartWesternDate, vc.Copy());
                    res.ActionScript += string.Format("scriptObject.setMyDate({0},{1},{2});", vc.getYear(), vc.getMonth(), vc.getDay());
                    res.ActionScript += "window.location.href='today.html'";
                    ResultsList.Add(res);
                    res = new Results(this, p_text);
                }
                vc.NextDay();
            }

            // move results to control
            if (!ShouldCancel)
            {
                FlushResultsToControl();
            }

            #endregion

            #region calendar results
            limit = GPUserDefaults.IntForKey("search.calendar.months", 12);
            GPCalendarResults rcal = new GPCalendarResults();

            vc.Today();
            vc.AddDays(1 - vc.getDay());
            for (int i = 0; i < limit; i++)
            {
                rcal.CalculateCalendar(vc, GPGregorianTime.GetMonthMaxDays(vc.getYear(), vc.getMonth()));
                FormaterPlain.FormatCalendarPlain(rcal, sb);
                res.Title = string.Format("{0} {1}", GPStrings.getString(759 + vc.getMonth()), vc.getYear());
                res.Type  = GPStrings.getString(44);
                res.ScanText(p_text, sb);
                if (res.Lines.Count > 0)
                {
                    res.Operation = GPCalculationOperation.Calendar;
                    res.Parameters.Add(GPCalculationParameters.LocationProvider, Location);
                    res.Parameters.Add(GPCalculationParameters.StartWesternDate, vc.Copy());
                    GPGregorianTime vc2 = vc.Copy();
                    vc2.AddMonths(1);
                    res.Parameters.Add(GPCalculationParameters.EndWesternDate, vc2);
                    res.ActionScript += "saveString('locationtype', 'mylocation');";
                    res.ActionScript += "saveString('startyear', '" + vc.getYear() + "');";
                    res.ActionScript += "saveString('startmonth', '" + vc.getMonth() + "');";
                    res.ActionScript += "saveString('startday', '" + vc.getDay() + "');";
                    res.ActionScript += "saveString('endperiodtype', '3');";
                    res.ActionScript += "saveString('endperiodlength', '1');";
                    res.ActionScript += "window.location.href='calendar.html'";
                    ResultsList.Add(res);
                    res = new Results(this, p_text);
                }
                vc.AddMonths(1);
            }

            // move results to control
            if (!ShouldCancel)
            {
                FlushResultsToControl();
            }

            #endregion

            #region core events results
            limit = GPUserDefaults.IntForKey("search.coreevents.months", 1);
            GPCoreEventResults reve = new GPCoreEventResults();
            vc.Today();
            vc.AddDays(1 - vc.getDay());
            for (int i = 0; i < limit; i++)
            {
                sb.Remove(0, sb.Length);
                GPGregorianTime vcEnd = vc.Copy();
                vcEnd.AddDays(31);
                reve.CalculateEvents(Location, vc, vcEnd);
                FormaterPlain.FormatEventsText(reve, sb);
                res.Title = string.Format("{0} {1}", GPStrings.getString(759 + vc.getMonth()), vc.getYear());
                res.Type  = GPStrings.getString(46);
                res.ScanText(p_text, sb);
                if (res.Lines.Count > 0)
                {
                    res.Operation = GPCalculationOperation.CoreEvents;
                    res.Parameters.Add(GPCalculationParameters.LocationProvider, Location);
                    res.Parameters.Add(GPCalculationParameters.StartWesternDate, vc.Copy());
                    res.Parameters.Add(GPCalculationParameters.EndWesternDate, vcEnd);
                    res.ActionScript += "saveString('locationtype', 'mylocation');";
                    res.ActionScript += "saveString('startyear', '" + vc.getYear() + "');";
                    res.ActionScript += "saveString('startmonth', '" + vc.getMonth() + "');";
                    res.ActionScript += "saveString('startday', '" + vc.getDay() + "');";
                    res.ActionScript += "saveString('endperiodtype', '3');";
                    res.ActionScript += "saveString('endperiodlength', '1');";
                    res.ActionScript += "window.location.href='coreevents.html'";
                    ResultsList.Add(res);
                    res = new Results(this, p_text);
                }
                vc.AddMonths(1);
            }

            // move results to control
            if (!ShouldCancel)
            {
                FlushResultsToControl();
            }

            #endregion

            #region masa list
            limit = GPUserDefaults.IntForKey("search.masalist.years", 3);
            GPMasaListResults rmas = new GPMasaListResults();
            vc.Today();
            for (int i = 0; i < limit; i++)
            {
                sb.Remove(0, sb.Length);
                rmas.CalcMasaList(Location, vc.getYear(), 1);
                FormaterPlain.FormatMasaListText(rmas, sb);
                res.Title = string.Format("{0}", vc.getYear());
                res.Type  = GPStrings.getString(48);
                res.ScanText(p_text, sb);
                if (res.Lines.Count > 0)
                {
                    res.Operation = GPCalculationOperation.MasaList;
                    res.Parameters.Add(GPCalculationParameters.LocationProvider, Location);
                    res.Parameters.Add(GPCalculationParameters.StartYear, vc.getYear());
                    res.Parameters.Add(GPCalculationParameters.CountYear, 1);
                    res.ActionScript += "saveString('locationtype', 'mylocation');";
                    res.ActionScript += "saveString('startyear', '" + vc.getYear() + "');";
                    res.ActionScript += "saveString('yearcount', '1');";
                    res.ActionScript += "window.location.href='masalist.html'";
                    ResultsList.Add(res);
                    res = new Results(this, p_text);
                }
                vc.AddYears(1);
            }

            // move results to control
            if (!ShouldCancel)
            {
                FlushResultsToControl();
            }

            #endregion

            finished = true;
        }