示例#1
0
 public CalendarInfo(Calendar calendar, DateTimeFormatInfo format, bool compatibleCalendar)
 {
     _format             = format;
     _calendar           = calendar;
     _compatibleCalendar = compatibleCalendar;
     _name = CalendarStatics.GetCalendarName(_calendar);
 }
示例#2
0
        private string GetTodayDate(int calendarIndex)
        {
            StringBuilder stringBuilder = new StringBuilder(150);

            _today = DateTime.Today;

            Calendar           calendar = CalendarStatics.CalendarsInfo[calendarIndex].Calendar;
            DateTimeFormatInfo format   = CalendarStatics.CalendarsInfo[calendarIndex].Format;

            string calendarName = CalendarStatics.GetCalendarName(CalendarStatics.CalendarsInfo[calendarIndex].Calendar);

            stringBuilder.Append("  ");
            stringBuilder.Append(calendarName);
            stringBuilder.Append(": ");

            if (CalendarStatics.CalendarsInfo[calendarIndex].IsCompatibleCalendar)
            {
                stringBuilder.Append(_today.ToString("D", format));
                stringBuilder.Append(_today.ToString(" gg", format));
            }
            else
            {
                stringBuilder.Append(calendar.GetMonth(_today).ToString(CultureInfo.InvariantCulture));
                stringBuilder.Append("/");
                stringBuilder.Append(calendar.GetDayOfMonth(_today).ToString(CultureInfo.InvariantCulture));
                stringBuilder.Append("/");
                stringBuilder.Append(calendar.GetYear(_today).ToString(CultureInfo.InvariantCulture));
                stringBuilder.Append(" ");
                stringBuilder.Append(format.GetEraName(calendar.GetEra(_today)));
            }

            return(stringBuilder.ToString());
        }
示例#3
0
        public CalendarContainer(
            Calendar calendar,
            DateTimeFormatInfo dateFormatInfo,
            bool canBeOptionalCalendar) : base()
        {
            ShowInTaskbar   = false;
            FormBorderStyle = FormBorderStyle.None;
            ClientSize      = new Size(CalendarStatics.ClientWidth + 2 * CalendarStatics.Margin,
                                       CalendarStatics.ClientHeight + 2 * CalendarStatics.Margin);

            _contextMenu = new ContextMenu(CalendarStatics.GetCalendarMenu(new EventHandler(OnCalendarClick)));

            CalendarForm form = new CalendarForm(this as ICalendarOwner, calendar, dateFormatInfo, canBeOptionalCalendar);

            form.Location   = new Point(CalendarStatics.Margin, CalendarStatics.Margin);
            form.ClientSize = new Size(CalendarStatics.ClientWidth, CalendarStatics.ClientHeight);
            Controls.Add(form);
        }
示例#4
0
        private string GetTodayFromNextCalendar()
        {
            StringBuilder      stringBuilder = new StringBuilder(150);
            Calendar           calendar      = CalendarStatics.CalendarsInfo[_calendarIndex].Calendar;
            DateTimeFormatInfo format        = CalendarStatics.CalendarsInfo[_calendarIndex].Format;
            string             calendarName  = CalendarStatics.GetCalendarName(CalendarStatics.CalendarsInfo[_calendarIndex].Calendar);

            stringBuilder.Append("  ");
            stringBuilder.Append(calendarName);
            stringBuilder.Append(": ");

            if (CalendarStatics.CalendarsInfo[_calendarIndex].IsCompatibleCalendar)
            {
                stringBuilder.Append(_today.ToString("dd MMMM yyyy gg", format));
            }
            else
            {
                stringBuilder.Append("[");
                stringBuilder.Append(calendar.GetEra(_today).ToString(CultureInfo.InvariantCulture));
                stringBuilder.Append("] ");
                stringBuilder.Append(calendar.GetMonth(_today).ToString(CultureInfo.InvariantCulture));
                stringBuilder.Append("/");
                stringBuilder.Append(calendar.GetDayOfMonth(_today).ToString(CultureInfo.InvariantCulture));
                stringBuilder.Append("/");
                stringBuilder.Append(calendar.GetYear(_today).ToString(CultureInfo.InvariantCulture));
            }

            stringBuilder.Append("  ");

            _calendarIndex++;

            if (_calendarIndex >= CalendarStatics.CalendarsInfo.Length)
            {
                _calendarIndex = 0;
            }

            return(stringBuilder.ToString());
        }
示例#5
0
        public void CreateMenus()
        {
            MenuItem exitItem = new MenuItem("Exit");

            exitItem.Click += new System.EventHandler(OnExit);

            MenuItem[] subMenus = new MenuItem[1];
            subMenus[0] = exitItem;
            MenuItem menuFile     = new MenuItem("&File", subMenus);
            MenuItem menuCalendar = new MenuItem("&Calendars", CalendarStatics.GetCalendarMenu(new System.EventHandler(OnCalendarClick)));

            MainMenu mainMenu = new MainMenu();

            mainMenu.MenuItems.Add(menuFile);
            mainMenu.MenuItems.Add(menuCalendar);

            Menu = mainMenu;

            _contextMenu.MenuItems.AddRange(new MenuItem[] {
                exitItem.CloneMenu(),
                new MenuItem("&Calendar", CalendarStatics.GetCalendarMenu(new System.EventHandler(OnCalendarClick)))
            }
                                            );
        }
示例#6
0
        public CalendarForm(
            ICalendarOwner navigator,
            Calendar calendar,
            DateTimeFormatInfo dateFormatInfo,
            bool canBeOptionalCalendar) : base()
        {
            _hostedCalendar        = calendar;
            _formatInfo            = dateFormatInfo;
            _container             = navigator;
            _canBeOptionalCalendar = canBeOptionalCalendar;
            _dayNames     = _formatInfo.ShortestDayNames;
            _calendarName = CalendarStatics.GetCalendarName(_hostedCalendar);

            //
            // Notifications events
            //
            MouseDown += new System.Windows.Forms.MouseEventHandler(OnMouseDown);
            MouseUp   += new System.Windows.Forms.MouseEventHandler(OnMouseUp);
            MouseMove += new System.Windows.Forms.MouseEventHandler(OnMouseMove);

            //
            // Close button
            //

            Button closeButton = new Button();

            closeButton.ClientSize = new Size(15, 18);
            closeButton.Location   = new Point(CalendarStatics.ClientWidth - 20, 4);
            closeButton.Text       = "X";
            closeButton.TabStop    = false;
            closeButton.Font       = CalendarStatics.Arial825Font;
            closeButton.BackColor  = Color.Red;
            closeButton.ForeColor  = Color.White;
            closeButton.Click     += new EventHandler(OnClose);
            Controls.Add(closeButton);

            //
            // Year Label
            //

            Label yearLabel = new Label();

            yearLabel.Text       = "Year/Month/Era";
            yearLabel.Location   = new Point(CalendarStatics.Margin, CalendarStatics.ClientHeight - 49);
            yearLabel.ClientSize = new Size(83, 15);
            yearLabel.BackColor  = SystemColors.Window;
            Controls.Add(yearLabel);

            //
            // Year TextBox
            //

            _yearTextBox            = new TextBox();
            _yearTextBox.MaxLength  = 9;
            _yearTextBox.Location   = new Point(CalendarStatics.Margin + 84, CalendarStatics.ClientHeight - 49);
            _yearTextBox.ClientSize = new Size(53, 17);
            _yearTextBox.KeyDown   += new KeyEventHandler(OnKeyDown);
            _yearTextBox.KeyPress  += new KeyPressEventHandler(OnKeyPress);
            Controls.Add(_yearTextBox);

            //
            // Navigator bar
            //

            _dateNavigator.Location = new Point(3, CalendarStatics.ClientHeight - 27);
            _dateNavigator.Changed += new EventHandler(OnNotification);
            Controls.Add(_dateNavigator);

            if (!navigator.GetSyncedDates(ref _startDate, ref _endDate, ref _markedDay, this))
            {
                GoToToday();
            }
            else
            {
                ValidateDates();
            }

            SetYearText();
        }