コード例 #1
0
ファイル: Colors.cs プロジェクト: mike-ward/Calendar
 public Colors(MonthCalendarEx monthCalendar, Settings settings, Calendar form)
 {
     InitializeComponent();
     this.monthCalendar = monthCalendar;
     this.settings      = settings;
     this.form          = form;
 }
コード例 #2
0
        // -------------------------------------------------------------
        // nth: 1-7 (5=last, 6=1st full week, 7=last full week)
        // weekday: 0=Sunday, 1=Monday, etc.
        // month: 0-11
        // year: 4 digit
        // return: day (1-31)
        public static int NthWeekday(int nth, int weekday, int month, int year)
        {
            var firstFullWeek = false;
            var lastFullWeek  = false;

            if (nth == 6)
            {
                nth           = 1;
                firstFullWeek = true;
            }

            if (nth == 7)
            {
                nth          = 5;
                lastFullWeek = true;
            }

            var daysInMonth = MonthCalendarEx.GetDaysInMonth(year, month);
            var day         = Math.Min(nth * 7, daysInMonth);
            var date        = new DateTime(year, month, day);

            while ((int)date.DayOfWeek != weekday)
            {
                date = date.AddDays(-1);
            }

            if (firstFullWeek)
            {
                if ((date.Day - weekday) <= 0)
                {
                    date = date.AddDays(7);
                }
            }

            if (lastFullWeek)
            {
                if (((date.Day - weekday) + 6) > daysInMonth)
                {
                    date = date.AddDays(-7);
                }
            }

            return(date.Day);
        }
コード例 #3
0
        // ---------------------------------------------------------------------
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            var resources = new System.ComponentModel.ComponentResourceManager(typeof(Calendar));

            this.calendarControl        = new BlueOnion.MonthCalendarEx();
            this.contextMenu            = new System.Windows.Forms.ContextMenu();
            this.menuItemGoToToday      = new System.Windows.Forms.MenuItem();
            this.menuItem3              = new System.Windows.Forms.MenuItem();
            this.menuItemEvents         = new System.Windows.Forms.MenuItem();
            this.menuItemColors         = new System.Windows.Forms.MenuItem();
            this.menuItemQuickTips      = new System.Windows.Forms.MenuItem();
            this.menuItemHelp           = new System.Windows.Forms.MenuItem();
            this.menuItemAbout          = new System.Windows.Forms.MenuItem();
            this.menuItem1              = new System.Windows.Forms.MenuItem();
            this.menuItemShowToday      = new System.Windows.Forms.MenuItem();
            this.menuItemCircleToday    = new System.Windows.Forms.MenuItem();
            this.menuItemWeekNumbers    = new System.Windows.Forms.MenuItem();
            this.menuItemTopMost        = new System.Windows.Forms.MenuItem();
            this.menuItemShowInTray     = new System.Windows.Forms.MenuItem();
            this.menuItem4              = new System.Windows.Forms.MenuItem();
            this.menuItemBorder         = new System.Windows.Forms.MenuItem();
            this.menuItemBorderThick    = new System.Windows.Forms.MenuItem();
            this.menuItemBorderThin     = new System.Windows.Forms.MenuItem();
            this.menuItemBorderNone     = new System.Windows.Forms.MenuItem();
            this.menuItemFirstDayOfWeek = new System.Windows.Forms.MenuItem();
            this.menuItemSunday         = new System.Windows.Forms.MenuItem();
            this.menuItemMonday         = new System.Windows.Forms.MenuItem();
            this.menuItemTuesday        = new System.Windows.Forms.MenuItem();
            this.menuItemWednesday      = new System.Windows.Forms.MenuItem();
            this.menuItemThursday       = new System.Windows.Forms.MenuItem();
            this.menuItemFriday         = new System.Windows.Forms.MenuItem();
            this.menuItemSaturday       = new System.Windows.Forms.MenuItem();
            this.menuItem2              = new System.Windows.Forms.MenuItem();
            this.menuItemExit           = new System.Windows.Forms.MenuItem();
            this.toolTip      = new System.Windows.Forms.ToolTip(this.components);
            this.welcomeTimer = new System.Windows.Forms.Timer(this.components);
            this.notifyIcon   = new System.Windows.Forms.NotifyIcon(this.components);
            this.timer        = new System.Windows.Forms.Timer(this.components);
            this.SuspendLayout();
            //
            // calendarControl
            //
            this.calendarControl.BoldedDates           = null;
            this.calendarControl.ColoredDates          = null;
            this.calendarControl.ContextMenu           = this.contextMenu;
            this.calendarControl.Dock                  = System.Windows.Forms.DockStyle.Fill;
            this.calendarControl.FirstDayOfWeek        = System.DayOfWeek.Sunday;
            this.calendarControl.Gridlines             = false;
            this.calendarControl.GridlinesColor        = System.Drawing.SystemColors.GrayText;
            this.calendarControl.HighlightDayTextColor = System.Drawing.Color.DarkRed;
            this.calendarControl.Location              = new System.Drawing.Point(0, 0);
            this.calendarControl.MaxSelectionCount     = 1;
            this.calendarControl.Name                  = "calendarControl";
            this.calendarControl.ShowToday             = true;
            this.calendarControl.ShowTodayCircle       = false;
            this.calendarControl.ShowWeekNumbers       = false;
            this.calendarControl.Size                  = new System.Drawing.Size(181, 158);
            this.calendarControl.TabIndex              = 0;
            this.calendarControl.TitleBackColor        = System.Drawing.SystemColors.ActiveCaption;
            this.calendarControl.TitleForeColor        = System.Drawing.SystemColors.ActiveCaptionText;
            this.calendarControl.TrailingForeColor     = System.Drawing.SystemColors.GrayText;
            this.calendarControl.WeekdayBackColor      = System.Drawing.SystemColors.ActiveCaptionText;
            this.calendarControl.WeekdayBarColor       = System.Drawing.SystemColors.WindowText;
            this.calendarControl.WeekdayForeColor      = System.Drawing.SystemColors.ActiveCaption;
            this.calendarControl.WeeknumberBackColor   = System.Drawing.SystemColors.ActiveCaptionText;
            this.calendarControl.WeeknumberForeColor   = System.Drawing.SystemColors.ActiveCaption;
            this.calendarControl.HelpRequested        += new System.Windows.Forms.HelpEventHandler(this.calendarControl_HelpRequested);
            this.calendarControl.MouseMove            += new System.Windows.Forms.MouseEventHandler(this.calendarControl_MouseMove);
            this.calendarControl.DateChanged          += new System.Windows.Forms.DateRangeEventHandler(this.calendarControl_DateChanged);
            //
            // contextMenu
            //
            this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[]
            {
                this.menuItemGoToToday,
                this.menuItem3,
                this.menuItemEvents,
                this.menuItemColors,
                this.menuItemQuickTips,
                this.menuItemHelp,
                this.menuItemAbout,
                this.menuItem1,
                this.menuItemShowToday,
                this.menuItemCircleToday,
                this.menuItemWeekNumbers,
                this.menuItemTopMost,
                this.menuItemShowInTray,
                this.menuItem4,
                this.menuItemBorder,
                this.menuItemFirstDayOfWeek,
                this.menuItem2,
                this.menuItemExit
            });
            this.contextMenu.Popup += new System.EventHandler(this.contextMenu_Popup);
            //
            // menuItemGoToToday
            //
            this.menuItemGoToToday.Index  = 0;
            this.menuItemGoToToday.Text   = "Go to Today";
            this.menuItemGoToToday.Click += new System.EventHandler(this.menuItemGoToToday_Click);
            //
            // menuItem3
            //
            this.menuItem3.Index = 1;
            this.menuItem3.Text  = "-";
            //
            // menuItemEvents
            //
            this.menuItemEvents.Index  = 2;
            this.menuItemEvents.Text   = "Events...";
            this.menuItemEvents.Click += new System.EventHandler(this.menuItemDates_Click);
            //
            // menuItemColors
            //
            this.menuItemColors.Index  = 3;
            this.menuItemColors.Text   = "Appearance...";
            this.menuItemColors.Click += new System.EventHandler(this.menuItemColors_Click);
            //
            // menuItemQuickTips
            //
            this.menuItemQuickTips.Index  = 4;
            this.menuItemQuickTips.Text   = "Quick Tips...";
            this.menuItemQuickTips.Click += new System.EventHandler(this.menuItemQuickTips_Click);
            //
            // menuItemHelp
            //
            this.menuItemHelp.Index  = 5;
            this.menuItemHelp.Text   = "Help...";
            this.menuItemHelp.Click += new System.EventHandler(this.menuItemHelp_Click);
            //
            // menuItemAbout
            //
            this.menuItemAbout.Index  = 6;
            this.menuItemAbout.Text   = "About...";
            this.menuItemAbout.Click += new System.EventHandler(this.menuItemAbout_Click);
            //
            // menuItem1
            //
            this.menuItem1.Index = 7;
            this.menuItem1.Text  = "-";
            //
            // menuItemShowToday
            //
            this.menuItemShowToday.Index  = 8;
            this.menuItemShowToday.Text   = "Show Today";
            this.menuItemShowToday.Click += new System.EventHandler(this.menuItemShowToday_Click);
            //
            // menuItemCircleToday
            //
            this.menuItemCircleToday.Index  = 9;
            this.menuItemCircleToday.Text   = "Circle Today";
            this.menuItemCircleToday.Click += new System.EventHandler(this.menuItemCircleToday_Click);
            //
            // menuItemWeekNumbers
            //
            this.menuItemWeekNumbers.Index  = 10;
            this.menuItemWeekNumbers.Text   = "Week Numbers";
            this.menuItemWeekNumbers.Click += new System.EventHandler(this.menuItemWeekNumbers_Click);
            //
            // menuItemTopMost
            //
            this.menuItemTopMost.Index  = 11;
            this.menuItemTopMost.Text   = "Top Most";
            this.menuItemTopMost.Click += new System.EventHandler(this.menuItemTopMost_Click);
            //
            // menuItemShowInTray
            //
            this.menuItemShowInTray.Index  = 12;
            this.menuItemShowInTray.Text   = "Show in Tray";
            this.menuItemShowInTray.Click += new System.EventHandler(this.menuItemShowInTray_Click);
            //
            // menuItem4
            //
            this.menuItem4.Index = 13;
            this.menuItem4.Text  = "-";
            //
            // menuItemBorder
            //
            this.menuItemBorder.Index = 14;
            this.menuItemBorder.MenuItems.AddRange(new System.Windows.Forms.MenuItem[]
            {
                this.menuItemBorderThick,
                this.menuItemBorderThin,
                this.menuItemBorderNone
            });
            this.menuItemBorder.Text = "Border";
            //
            // menuItemBorderThick
            //
            this.menuItemBorderThick.Index  = 0;
            this.menuItemBorderThick.Text   = "Thick";
            this.menuItemBorderThick.Click += new System.EventHandler(this.menuItemBorderThick_Click);
            //
            // menuItemBorderThin
            //
            this.menuItemBorderThin.Index  = 1;
            this.menuItemBorderThin.Text   = "Thin";
            this.menuItemBorderThin.Click += new System.EventHandler(this.menuItemBorderThin_Click);
            //
            // menuItemBorderNone
            //
            this.menuItemBorderNone.Index  = 2;
            this.menuItemBorderNone.Text   = "None";
            this.menuItemBorderNone.Click += new System.EventHandler(this.menuItemBorderNone_Click);
            //
            // menuItemFirstDayOfWeek
            //
            this.menuItemFirstDayOfWeek.Index = 15;
            this.menuItemFirstDayOfWeek.MenuItems.AddRange(new System.Windows.Forms.MenuItem[]
            {
                this.menuItemSunday,
                this.menuItemMonday,
                this.menuItemTuesday,
                this.menuItemWednesday,
                this.menuItemThursday,
                this.menuItemFriday,
                this.menuItemSaturday
            });
            this.menuItemFirstDayOfWeek.Text = "First Day of Week";
            //
            // menuItemSunday
            //
            this.menuItemSunday.Index  = 0;
            this.menuItemSunday.Text   = "Sunday";
            this.menuItemSunday.Click += new System.EventHandler(this.menuItemSunday_Click);
            //
            // menuItemMonday
            //
            this.menuItemMonday.Index  = 1;
            this.menuItemMonday.Text   = "Monday";
            this.menuItemMonday.Click += new System.EventHandler(this.menuItemMonday_Click);
            //
            // menuItemTuesday
            //
            this.menuItemTuesday.Index  = 2;
            this.menuItemTuesday.Text   = "Tuesday";
            this.menuItemTuesday.Click += new System.EventHandler(this.menuItemTuesday_Click);
            //
            // menuItemWednesday
            //
            this.menuItemWednesday.Index  = 3;
            this.menuItemWednesday.Text   = "Wednesday";
            this.menuItemWednesday.Click += new System.EventHandler(this.menuItemWednesday_Click);
            //
            // menuItemThursday
            //
            this.menuItemThursday.Index  = 4;
            this.menuItemThursday.Text   = "Thursday";
            this.menuItemThursday.Click += new System.EventHandler(this.menuItemThursday_Click);
            //
            // menuItemFriday
            //
            this.menuItemFriday.Index  = 5;
            this.menuItemFriday.Text   = "Friday";
            this.menuItemFriday.Click += new System.EventHandler(this.menuItemFriday_Click);
            //
            // menuItemSaturday
            //
            this.menuItemSaturday.Index  = 6;
            this.menuItemSaturday.Text   = "Saturday";
            this.menuItemSaturday.Click += new System.EventHandler(this.menuItemSaturday_Click);
            //
            // menuItem2
            //
            this.menuItem2.Index = 16;
            this.menuItem2.Text  = "-";
            //
            // menuItemExit
            //
            this.menuItemExit.Index  = 17;
            this.menuItemExit.Text   = "Exit";
            this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
            //
            // toolTip
            //
            this.toolTip.ShowAlways = true;
            //
            // welcomeTimer
            //
            this.welcomeTimer.Enabled  = true;
            this.welcomeTimer.Interval = 1000;
            this.welcomeTimer.Tick    += new System.EventHandler(this.welcomeTimer_Tick);
            //
            // notifyIcon
            //
            this.notifyIcon.Icon   = ((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon")));
            this.notifyIcon.Text   = "Calendar";
            this.notifyIcon.Click += new System.EventHandler(this.notifyIcon_Click);
            //
            // timer
            //
            this.timer.Enabled  = true;
            this.timer.Interval = 60000;
            this.timer.Tick    += new System.EventHandler(this.timer_Tick);
            //
            // Calendar
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.BackColor         = System.Drawing.SystemColors.Window;
            this.ClientSize        = new System.Drawing.Size(181, 158);
            this.Controls.Add(this.calendarControl);
            this.Icon             = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name             = "Calendar";
            this.StartPosition    = System.Windows.Forms.FormStartPosition.Manual;
            this.Text             = "Calendar";
            this.SizeChanged     += new System.EventHandler(this.Calendar_SizeChanged);
            this.Closed          += new System.EventHandler(this.Calendar_Closed);
            this.LocationChanged += new System.EventHandler(this.Calendar_LocationChanged);
            this.ResumeLayout(false);
        }