From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。

---
 HotelPms.Share.Windows/Component/Calendar.cs | 1014 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,014 insertions(+), 0 deletions(-)

diff --git a/HotelPms.Share.Windows/Component/Calendar.cs b/HotelPms.Share.Windows/Component/Calendar.cs
new file mode 100644
index 0000000..0084996
--- /dev/null
+++ b/HotelPms.Share.Windows/Component/Calendar.cs
@@ -0,0 +1,1014 @@
+using HotelPms.Share.Windows.Util;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+using System.Windows.Forms.VisualStyles;
+
+namespace HotelPms.Share.Windows.Component
+{
+    /// <summary>
+    /// コピーだけ、全く書いてない
+    /// テスト
+    /// </summary>
+    public class Calendar : System.Windows.Forms.Control
+    {
+        #region  ★★★★★ Declartions ★★★★★
+
+        public enum ShowStyleType : int
+        {
+            TreeMonth = 0,
+            OneMonth,
+        }
+
+        public enum HitType : int
+        {
+            None = 0,
+            YearPrev,
+            MonthPrev,
+            CurrentDay,
+            MonthNext,
+            YearNext,
+            Day,
+        }
+
+        public enum LanguageType : int
+        {
+            Japanese = 0,
+            Chinese,
+            English,
+        }
+
+        public enum DayStyleType : int
+        {
+            Row4 = 0,
+            Row3,
+        }
+
+        public sealed class HitTestInfo
+        {
+            public static readonly HitTestInfo Nowhere;
+
+            internal int y;
+            internal int x;
+            internal string value = string.Empty;
+            internal HitType type;
+
+            static HitTestInfo()
+            {
+                HitTestInfo.Nowhere = new HitTestInfo();
+            }
+
+            internal HitTestInfo()
+            {
+                this.type = HitType.None;
+                this.x = -1;
+                this.y = -1;
+            }
+
+            public string Value { get { return value; } }
+
+            public int X
+            {
+                get { return this.x; }
+            }
+
+            public int Y
+            {
+                get { return this.y; }
+            }
+
+            public HitType Type
+            {
+                get { return this.type; }
+            }
+
+            public override int GetHashCode()
+            {
+                return this.x << 16 | this.y << 8 | (int)this.type;
+            }
+
+            public override bool Equals(object obj)
+            {
+                HitTestInfo hi = obj as HitTestInfo;
+                return (this.type == hi.type && this.x == hi.x && this.x == hi.x);
+            }
+
+            public override string ToString()
+            {
+                return string.Concat(new string[7] { "{ ", this.type.ToString(), ",", this.x.ToString(), ",", this.y.ToString(), "}" });
+            }
+        }
+
+        private static string[] weekShortNamesCn = new string[] { "日", "一", "二", "三", "四", "五", "六" };
+        private static string[] weekShortNamesJp = new string[] { "日", "月", "火", "水", "木", "金", "土" };
+        private static string[] weekShortNamesEn = new string[] { "S", "M", "T", "W", "T", "F", "S" };
+
+        private static string[] ButtonBarText = new string[] { "<<", "<", "〇", ">", ">>" };
+
+        private StringFormat m_StringFormat = new StringFormat(StringFormatFlags.NoWrap);
+        private StringFormat m_StringFormatLeft = new StringFormat(StringFormatFlags.NoWrap);
+        private static int colCount = 35;  //幅35セル単位
+        private static int dayWidth = 5;  //5セル単位(固定)
+        private static int dayHeight = 4;  //4セル単位,3セル単位可能
+        private static int dayLineCount = 6;  //6行
+        private int headerRowCount = 9;    //Topカレンダーの高さ
+        private int changeBarRowCount = 2;   //年月調整バー
+        private int weekRowCount = 2;   //週のタイトル
+        private int rowCount = 0;
+        private float cellHeight = 0;
+        private float cellWidth = 0;
+        private bool m_MouseFocused = false;
+        private bool m_MouseDown = false;
+        private HitType currHitType = HitType.None;
+        private string currHitValue = string.Empty;
+
+        private RectangleF headerCenterRect;
+        private List<RectangleF> buttonRectList = new List<RectangleF>();
+        private SortedList<string, RectangleF> dayRectList = new SortedList<string, RectangleF>();
+        private DateTime showValue = DateTime.Now;
+
+        public event CalendarEventHandler DayCellFormat;
+        public event CalendarEventHandler DateSelect;
+
+        #endregion
+
+        #region  ★★★★★ Property ★★★★★
+
+        #region カレンダー(年月日)
+
+        private Font yearFont = new Font("メイリオ", 14F);
+
+        [Description("年のフォント"), Category("Calendar Action(TopCenter)")]
+        public Font YearFont
+        {
+            get { return yearFont; }
+            set { yearFont = value; Invalidate(); }
+        }
+
+        private Color yearForeColor = Color.Purple;
+
+        [Description("年のフォント色"), Category("Calendar Action(TopCenter)")]
+        public Color YearForeColor
+        {
+            get { return yearForeColor; }
+            set { yearForeColor = value; Invalidate(); }
+        }
+
+        private Font monthFont = new Font("メイリオ", 36F);
+
+        [Description("月のフォント"), Category("Calendar Action(TopCenter)")]
+        public Font MonthFont
+        {
+            get { return monthFont; }
+            set { monthFont = value; Invalidate(); }
+        }
+
+        private Color monthForeColor = Color.Purple;
+
+        [Description("月のフォント色"), Category("Calendar Action(TopCenter)")]
+        public Color MonthForeColor
+        {
+            get { return monthForeColor; }
+            set { monthForeColor = value; Invalidate(); }
+        }
+
+        private Font selectDateFont = new Font("メイリオ", 12F);
+
+        [Description("選択された日のフォント"), Category("Calendar Action(TopCenter)")]
+        public Font SelectDateFont
+        {
+            get { return selectDateFont; }
+            set { selectDateFont = value; Invalidate(); }
+        }
+
+        private Color selectDateForeColor = Color.Navy;
+
+        [Description("選択された日のフォント色"), Category("Calendar Action(TopCenter)")]
+        public Color SelectDateForeColor
+        {
+            get { return selectDateForeColor; }
+            set { selectDateForeColor = value; Invalidate(); }
+        }
+
+        #endregion
+
+        #region カレンダー(ボタン)
+
+        private Font buttonFont = new Font("メイリオ", 12F);
+
+        [Description("ボタンのフォント"), Category("Calendar Action(Button)")]
+        public Font ButtonFont
+        {
+            get { return buttonFont; }
+            set { buttonFont = value; Invalidate(); }
+        }
+
+        private Color buttonForeColor = Color.White;
+
+        [Description("ボタンのフォント色"), Category("Calendar Action(Button)")]
+        public Color ButtonForeColor
+        {
+            get { return buttonForeColor; }
+            set { buttonForeColor = value; Invalidate(); }
+        }
+
+        private Color buttonBackColor = Color.FromArgb(64, 64, 64);
+
+        [Description("ボタンの背景色"), Category("Calendar Action(Button)")]
+        public Color ButtonBackColor
+        {
+            get { return buttonBackColor; }
+            set { buttonBackColor = value; Invalidate(); }
+        }
+
+        private Color buttonOverColor = Color.Gray;
+
+        [Description("ボタンのマウス移動色"), Category("Calendar Action(Button)")]
+        public Color ButtonOverColor
+        {
+            get { return buttonOverColor; }
+            set { buttonOverColor = value; Invalidate(); }
+        }
+
+        private Color buttonDownColor = Color.Black;
+
+        [Description("ボタンのマウス押した色"), Category("Calendar Action(Button)")]
+        public Color ButtonDownColor
+        {
+            get { return buttonDownColor; }
+            set { buttonDownColor = value; Invalidate(); }
+        }
+
+        #endregion
+
+        #region カレンダー(当月)
+
+        private DayStyleType dayStyle = DayStyleType.Row4;
+        [Description("日付セルスタイル"), Category("Calendar Action(Current Month)")]
+        public DayStyleType DayStyle
+        {
+            get { return dayStyle; }
+            set
+            {
+                dayStyle = value;
+                dayHeight = dayStyle == DayStyleType.Row4 ? 4 : 3;
+                Invalidate();
+            }
+        }
+        
+        private Font weekFont = new Font("メイリオ", 10F);
+
+        [Description("曜日表記のフォント"), Category("Calendar Action(Current Month)")]
+        public Font WeekFont
+        {
+            get { return weekFont; }
+            set { weekFont = value; Invalidate(); }
+        }
+
+        private Color weekForeColor = Color.White;
+
+        [Description("曜日のフォント色"), Category("Calendar Action(Current Month)")]
+        public Color WeekForeColor
+        {
+            get { return weekForeColor; }
+            set { weekForeColor = value; Invalidate(); }
+        }
+
+        private Color weekBackColor = Color.FromArgb(0, 192, 0);
+
+        [Description("曜日の背景色"), Category("Calendar Action(Current Month)")]
+        public Color WeekBackColor
+        {
+            get { return weekBackColor; }
+            set { weekBackColor = value; Invalidate(); }
+        }
+
+        private Color selDayBackColor = Color.FromArgb(192, 255, 192);
+
+        [Description("選択された日付セルの背景色"), Category("Calendar Action(Current Month)")]
+        public Color SelDayBackColor
+        {
+            get { return selDayBackColor; }
+            set { selDayBackColor = value; Invalidate(); }
+        }
+
+        private Color dayBackColor = Color.FromArgb(255, 245, 210);
+
+        [Description("日付セルの背景色"), Category("Calendar Action(Current Month)")]
+        public Color DayBackColor
+        {
+            get { return dayBackColor; }
+            set { dayBackColor = value; Invalidate(); }
+        }
+
+        private Color dayOverColor = Color.FromArgb(192, 255, 255);
+
+        [Description("日付セルのマウス移動色"), Category("Calendar Action(Current Month)")]
+        public Color DayOverColor
+        {
+            get { return dayOverColor; }
+            set { dayOverColor = value; Invalidate(); }
+        }
+
+        private Color dayDownColor = Color.FromArgb(0, 192, 0);
+
+        [Description("日付セルのマウス押した色"), Category("Calendar Action(Current Month)")]
+        public Color DayDownColor
+        {
+            get { return dayDownColor; }
+            set { dayDownColor = value; Invalidate(); }
+        }
+
+
+        private Font dayFont = new Font("メイリオ", 14F);
+
+        [Description("日付のフォント"), Category("Calendar Action(Current Month)")]
+        public Font DayFont
+        {
+            get { return dayFont; }
+            set
+            {
+                dayFont = value;
+                Invalidate();
+            }
+        }
+
+        private Color dayForeColor = Color.Black;
+
+        [Description("日付のフォント色"), Category("Calendar Action(Current Month)")]
+        public Color DayForeColor
+        {
+            get { return dayForeColor; }
+            set { dayForeColor = value;Invalidate();}
+        }
+
+
+        private Font rokuyouFont = new Font("メイリオ", 8F);
+
+        [Description("六曜のフォント調整"), Category("Calendar Action(Current Month)")]
+        public Font RokuyouFont
+        {
+            get { return rokuyouFont; }
+            set
+            {
+                rokuyouFont = value;
+                Invalidate();
+            }
+        }
+
+        private bool rokuyouVisible = true;
+        [Description("六曜の表示・非表示"), Category("Calendar Action(Current Month)")]
+        public bool RokuyouVisible
+        {
+            get { return rokuyouVisible; }
+            set { rokuyouVisible = value; Invalidate(); }
+        }
+
+        private Color rokuyouForeColor = Color.FromArgb(0, 64, 0);
+
+        [Description("六曜のフォント色"), Category("Calendar Action(Current Month)")]
+        public Color RokuyouForeColor
+        {
+            get { return rokuyouForeColor; }
+            set { rokuyouForeColor = value; Invalidate(); }
+        }
+
+        private Font holidayFont = new Font("メイリオ", 7F);
+
+        [Description("祝日のフォント調整"), Category("Calendar Action(Current Month)")]
+        public Font HolidayFont
+        {
+            get { return holidayFont; }
+            set
+            {
+                holidayFont = value;
+                Invalidate();
+            }
+        }
+
+        private Color memoForeColor = Color.Black;
+
+        [Description("メモのフォント色"), Category("Calendar Action(Current Month)")]
+        public Color MemoForeColor
+        {
+            get { return memoForeColor; }
+            set { memoForeColor = value; Invalidate(); }
+        }
+
+        private Font memoFont = new Font("メイリオ", 9F);
+
+        [Description("メモのフォント調整"), Category("Calendar Action(Current Month)")]
+        public Font MemoFont
+        {
+            get { return memoFont; }
+            set
+            {
+                memoFont = value;
+                Invalidate();
+            }
+        }
+
+        private Color holidayForeColor = Color.Red;
+
+        [Description("祝日のフォント色"), Category("Calendar Action(Current Month)")]
+        public Color HolidayForeColor
+        {
+            get { return holidayForeColor; }
+            set { holidayForeColor = value; Invalidate(); }
+        }
+
+        #endregion
+
+        #region カレンダー(Small)
+
+        private Font smallYearFont = new Font("メイリオ", 12F);
+
+        [Description("年月のフォント"), Category("Calendar Action(Small)")]
+        public Font SmallYearFont
+        {
+            get { return smallYearFont; }
+            set { smallYearFont = value; Invalidate(); }
+        }
+
+        private Color smallYearForeColor = Color.Black;
+
+        [Description("年月のフォント色"), Category("Calendar Action(Small)")]
+        public Color SmallYearForeColor
+        {
+            get { return smallYearForeColor; }
+            set { smallYearForeColor = value; Invalidate(); }
+        }
+
+        private Font smallFont = new Font("メイリオ", 7F);
+
+        [Description("小さい日付のフォント調整"), Category("Calendar Action(Small)")]
+        public Font SmallFont
+        {
+            get { return smallFont; }
+            set
+            {
+                smallFont = value;
+                Invalidate();
+            }
+        }
+
+        #endregion
+
+        private ShowStyleType showStyle = ShowStyleType.TreeMonth;
+
+        [Description("表示形式"), Category("Calendar Action")]
+        public ShowStyleType ShowStyle
+        {
+            get { return showStyle; }
+            set
+            {
+                showStyle = value;
+                Invalidate();
+            }
+        }
+
+        private LanguageType language = LanguageType.Japanese;
+
+        [Description("言語"), Category("Calendar Action")]
+        public LanguageType Language
+        {
+            get { return language; }
+            set
+            {
+                language = value;
+                Invalidate();
+            }
+        }
+
+        private string format = "yyyy/MM/dd";
+
+        [Description("Format 例:yyyy/MM/dd"), Category("Calendar Action")]
+        public string Format
+        {
+            get { return format; }
+            set
+            {
+                format = value;
+                if (format.Length == 0) { format = "yyyy/MM/dd"; }
+                Invalidate();
+            }
+        }
+
+        private DateTime dateValue = DateTime.Now.Date;
+
+        [Description("選択された日付"), Category("Calendar Action")]
+        public DateTime Value
+        {
+            get { return dateValue; }
+            set
+            {
+                dateValue = value;
+                showValue = dateValue;
+                Invalidate();
+            }
+        }
+
+        public override string Text
+        {
+            get
+            {
+                return Value.ToString(Format);
+            }
+        }
+
+        #endregion
+
+        #region  ★★★★★ Class Event ★★★★★
+
+        public Calendar()
+        {
+            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.Opaque | ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.Selectable | ControlStyles.UserMouse, true);
+            m_StringFormat.Alignment = StringAlignment.Center;
+            m_StringFormat.LineAlignment = StringAlignment.Center;
+            m_StringFormatLeft.Alignment = StringAlignment.Near;
+            m_StringFormatLeft.LineAlignment = StringAlignment.Center;
+        }
+
+        protected override void Dispose(bool disposing)
+        {
+            m_StringFormatLeft.Dispose();
+            m_StringFormat.Dispose();
+            base.Dispose(disposing);
+        }
+
+        #endregion
+
+        #region  ★★★★★ Control Event ★★★★★
+
+        protected override void OnPaint(PaintEventArgs e)
+        {
+            base.OnPaint(e);
+
+            try
+            {
+                if (ShowStyle == ShowStyleType.OneMonth) { headerRowCount = 2; }                
+                rowCount = headerRowCount + changeBarRowCount + weekRowCount + dayHeight * dayLineCount;
+                cellWidth = (ClientRectangle.Width - 1 - Padding.Left - Padding.Right) * 1.0F / colCount;
+                cellHeight = (ClientRectangle.Height - 1 - Padding.Top - Padding.Bottom) * 1.0F / rowCount;
+
+                //印字領域
+                Rectangle rect = new Rectangle(new Point(Padding.Left, Padding.Top), new Size(ClientRectangle.Width - 1 - Padding.Left - Padding.Right, ClientRectangle.Height - 1 - Padding.Top - Padding.Bottom));
+                e.Graphics.Clear(BackColor);
+
+                using (Brush textBrush = new SolidBrush(ForeColor))
+                {
+                    if (ShowStyle == ShowStyleType.TreeMonth)
+                    {
+                        DrawSmall(rect.Left, rect.Top, -1, e.Graphics, textBrush);  //前月
+                        DrawHeaderCenter(rect.Left + cellWidth * 14, rect.Top, e.Graphics, textBrush);
+                        DrawSmall(rect.Left + rect.Width - cellWidth * 14, rect.Top, 1, e.Graphics, textBrush);  //来月
+                    }
+                    else
+                    {
+                        DrawHeaderOneMonth(rect.Left, rect.Top, e.Graphics, textBrush);
+                    }
+                    DrawButtonBar(rect.Left, rect.Top + cellHeight * headerRowCount, e.Graphics, textBrush);  //ボタンバー
+                    DrawNormal(rect.Left, rect.Top + cellHeight * (headerRowCount + changeBarRowCount), e.Graphics, textBrush); //カレンダー
+                }
+            }
+            catch 
+            {
+            }
+        }
+
+        private string GetWeekShortName(int index)
+        {
+            return Language == LanguageType.Japanese ? weekShortNamesJp[index] : Language == LanguageType.Chinese ? weekShortNamesCn[index] : weekShortNamesEn[index];
+        }
+
+        private void DrawHeaderOneMonth(float x, float y, Graphics g, Brush textBrush)
+        {
+            headerCenterRect = new RectangleF(new PointF(x, y), new SizeF(cellWidth * colCount, cellHeight * headerRowCount));
+            g.DrawRectangle(Pens.Black, headerCenterRect.X, headerCenterRect.Y, headerCenterRect.Width, headerCenterRect.Height);
+
+            //表示の年
+            bool isNewColor = YearForeColor.IsSystemColor;
+            Brush brush = isNewColor ? SystemBrushes.FromSystemColor(YearForeColor) : new SolidBrush(YearForeColor);
+            RectangleF rect = new RectangleF(new PointF(x, y), new SizeF(cellWidth * 18, cellHeight * headerRowCount));
+            g.DrawString(showValue.ToString("yyyy年MM月"), YearFont, brush, rect, m_StringFormat);
+            if (isNewColor) { brush.Dispose(); }
+
+            ////表示の月
+            //isNewColor = MonthForeColor.IsSystemColor;
+            //brush = isNewColor ? SystemBrushes.FromSystemColor(MonthForeColor) : new SolidBrush(MonthForeColor);
+            //rect = new RectangleF(new PointF(x + cellWidth * 9, y), new SizeF(cellWidth * 9, cellHeight * headerRowCount));
+            //g.DrawString(showValue.Month.ToString() + "月", MonthFont, brush, rect, m_StringFormat);
+            //if (isNewColor) { brush.Dispose(); }
+
+            //現在の利用日
+            isNewColor = SelectDateForeColor.IsSystemColor;
+            brush = isNewColor ? SystemBrushes.FromSystemColor(SelectDateForeColor) : new SolidBrush(SelectDateForeColor);
+            rect = new RectangleF(new PointF(x + cellWidth * 18, y), new SizeF(cellWidth * 17, cellHeight * headerRowCount));
+            g.DrawString(Text, SelectDateFont, brush, rect, m_StringFormat);
+            if (isNewColor) { brush.Dispose(); }
+        }
+
+        private void DrawHeaderCenter(float x, float y, Graphics g, Brush textBrush)
+        {
+            headerCenterRect = new RectangleF(new PointF(x, y), new SizeF(cellWidth * 7, cellHeight * 9));
+            g.DrawRectangle(Pens.Black, headerCenterRect.X, headerCenterRect.Y, headerCenterRect.Width, headerCenterRect.Height);
+
+            //表示の年
+            bool isNewColor = YearForeColor.IsSystemColor;
+            Brush brush = isNewColor ? SystemBrushes.FromSystemColor(YearForeColor) : new SolidBrush(YearForeColor);
+            RectangleF rect = new RectangleF(new PointF(x, y), new SizeF(cellWidth * 7, cellHeight * 2));
+            g.DrawString(showValue.Year.ToString(), YearFont, brush, rect, m_StringFormat);
+            if(isNewColor) { brush.Dispose(); }
+
+            //表示の月
+            isNewColor = MonthForeColor.IsSystemColor;
+            brush = isNewColor ? SystemBrushes.FromSystemColor(MonthForeColor) : new SolidBrush(MonthForeColor);
+            rect = new RectangleF(new PointF(x, y + cellHeight * 2), new SizeF(cellWidth * 7, cellHeight * 5));
+            g.DrawString(showValue.Month.ToString(), MonthFont, brush, rect, m_StringFormat);
+            if (isNewColor) { brush.Dispose(); }
+
+            //現在の利用日
+            isNewColor = SelectDateForeColor.IsSystemColor;
+            brush = isNewColor ? SystemBrushes.FromSystemColor(SelectDateForeColor) : new SolidBrush(SelectDateForeColor);
+            rect = new RectangleF(new PointF(x, y + cellHeight * 7), new SizeF(cellWidth * 7, cellHeight * 2));
+            g.DrawString(Text, SelectDateFont, brush, rect, m_StringFormat);
+            if (isNewColor) { brush.Dispose(); }
+        }
+
+        //yearPrevRect, yearNextRect, monthPrevRect, monthNextRect, dayRect
+        private void DrawButtonBar(float x, float y, Graphics g, Brush textBrush)
+        {
+            buttonRectList.Clear();
+            RectangleF rect = new RectangleF(new PointF(x, y), new SizeF(cellWidth * 7, cellHeight * 2));
+            buttonRectList.Add(rect);
+            for (int i= 0; i< 5; i++ )
+            {
+                if (i > 0) { rect = new RectangleF(new PointF(rect.Left + rect.Width, y), new SizeF(cellWidth * 7, cellHeight * 2)); buttonRectList.Add(rect); }
+                Color hitColor = m_MouseDown && !ButtonDownColor.IsEmpty ? buttonDownColor : !ButtonOverColor.IsEmpty ? ButtonOverColor : ControlPaint.Light(ButtonBackColor.IsEmpty ? BackColor : ButtonBackColor);
+                using (Brush brush = (HitType)(i + 1) == currHitType ? new SolidBrush(hitColor) : new SolidBrush(ButtonBackColor.IsEmpty ? BackColor : ButtonBackColor))
+                {
+                    g.FillRectangle(brush, rect);
+                }
+                g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);
+                bool isNewColor = ButtonForeColor.IsSystemColor;
+                Brush foreBrush = isNewColor ? SystemBrushes.FromSystemColor(ButtonForeColor) : new SolidBrush(ButtonForeColor);
+                g.DrawString(ButtonBarText[i], ButtonFont, foreBrush, rect, m_StringFormat);
+                if(isNewColor) { foreBrush.Dispose(); }
+            }
+        }
+
+        /// <summary>
+        /// 前月、来月の小さいカレンダーを描く
+        /// </summary>
+        private void DrawSmall(float x, float y, int type, Graphics g, Brush textBrush)
+        {
+            //年-月
+            RectangleF rect = new RectangleF(new PointF(x, y), new SizeF(cellWidth * 14, cellHeight * 2));
+            DateTime firstDate = DateTime.Parse(showValue.AddMonths(type).ToString("yyyy/MM") + "/01");
+            g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);
+            bool isNewColor = SmallYearForeColor.IsSystemColor;
+            Brush foreBrush = isNewColor ? SystemBrushes.FromSystemColor(SmallYearForeColor) : new SolidBrush(SmallYearForeColor);
+            g.DrawString(language == LanguageType.English ? firstDate.ToString("yyyy/MM") : firstDate.ToString("yyyy年MM月"), SmallYearFont, foreBrush, rect, m_StringFormatLeft);
+            if (isNewColor) { foreBrush.Dispose(); }
+
+            //週のタイトル
+            int firstWeek = (int)firstDate.DayOfWeek;
+            float curY = y + rect.Height;
+            rect = new RectangleF(new PointF(x, curY), new SizeF(cellWidth * 2, cellHeight));
+            for (int i = 0; i < 7; i++)
+            {
+                g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);
+                g.DrawString(GetWeekShortName(i), smallFont, i == (int)DayOfWeek.Sunday ? Brushes.Red : i == (int)DayOfWeek.Saturday ? Brushes.Blue : textBrush, rect, m_StringFormat);
+                rect = new RectangleF(new PointF(rect.Left + rect.Width, curY), new SizeF(cellWidth * 2, cellHeight));
+            }
+
+            //日付
+            int dayCount = 0;
+            for (int row = 0; row < dayLineCount; row++)
+            {
+                curY = rect.Top + rect.Height;
+                rect = new RectangleF(new PointF(x, curY), new SizeF(cellWidth * 2, cellHeight));
+                for (int i = 0; i < 7; i++)
+                {
+                    string dayText = string.Empty;
+                    if(row == 0 && i < firstWeek)
+                    {
+                        dayText = string.Empty;
+                    }
+                    else
+                    {
+                        DateTime date = firstDate.AddDays((double)dayCount);
+                        if (date.Month == firstDate.Month) { dayText = date.Day.ToString(); }
+                        dayCount++;
+                    }
+
+                    g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);
+                    g.DrawString(dayText, smallFont, i == (int)DayOfWeek.Sunday ? Brushes.Red : i == (int)DayOfWeek.Saturday ? Brushes.Blue : textBrush, rect, m_StringFormat);
+                    rect = new RectangleF(new PointF(rect.Left + rect.Width, curY), new SizeF(cellWidth * 2, cellHeight));
+                }
+            }
+        }
+
+        private void DrawNormal(float x, float y, Graphics g, Brush textBrush)
+        {
+            dayRectList.Clear();
+            DateTime firstDate = DateTime.Parse(showValue.ToString("yyyy/MM") + "/01");
+
+            //週のタイトル
+            int firstWeek = (int)firstDate.DayOfWeek;
+            float curY = y;
+            RectangleF rect = new RectangleF(new PointF(x, curY), new SizeF(cellWidth * dayWidth, cellHeight * 2));
+            bool isNewColor = WeekForeColor.IsSystemColor;
+            Brush brush = isNewColor ? SystemBrushes.FromSystemColor(WeekForeColor) : new SolidBrush(WeekForeColor);
+            using (Brush backbrush = new SolidBrush(WeekBackColor.IsEmpty ? BackColor : WeekBackColor))
+            {
+                for (int i = 0; i < 7; i++)
+                {
+
+                    g.FillRectangle(backbrush, rect);
+                    g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);
+                    g.DrawString(GetWeekShortName(i), WeekFont, i == (int)DayOfWeek.Sunday ? Brushes.Red : i == (int)DayOfWeek.Saturday ? Brushes.Blue : brush, rect, m_StringFormat);
+                    rect = new RectangleF(new PointF(rect.Left + rect.Width, curY), new SizeF(cellWidth * dayWidth, cellHeight * 2));
+                }
+            }
+            if (isNewColor) { brush.Dispose(); }
+
+            //日付
+            int dayCount = 0;
+            for (int row = 0; row < dayLineCount; row++)
+            {
+                curY = rect.Top + rect.Height;
+                rect = new RectangleF(new PointF(x, curY), new SizeF(cellWidth * dayWidth, cellHeight * dayHeight));
+                for (int i = 0; i < 7; i++)
+                {
+                    DateTime date;
+                    bool isOutOfRange = false;
+                    string dayText = string.Empty;
+                    if (row == 0 && i < firstWeek)
+                    {
+                        date = firstDate.AddDays((double)(i - firstWeek));
+                        dayText = date.Day.ToString();
+                        isOutOfRange = true;
+                    }
+                    else
+                    {
+                        date = firstDate.AddDays((double)dayCount);
+                        if (date.Month != firstDate.Month)
+                        {
+                            isOutOfRange = true;
+                        }
+                        dayText = date.Day.ToString();
+                        dayCount++;
+                    }
+
+                    dayRectList.Add(date.ToString("yyyy/MM/dd"), rect);
+                    RectangleF dayRect = new RectangleF(new PointF(rect.X, rect.Y), new SizeF(cellWidth * 3, cellHeight * 2));
+
+                    //Raise DayCellFormat
+                    CalendarEventArgs args = new CalendarEventArgs()
+                    {
+                        DateValue = date,
+                        DateText = dayText,
+                        Rokuyou = RokuyouVisible ? JapaneseDateTime.ToRokuyou(date) : string.Empty,
+                        Holiday = string.Empty,
+                        MemoText = string.Empty
+                    };
+                    if(DayCellFormat != null) { DayCellFormat(this, args); }
+
+                    Color hitColor = m_MouseDown && !DayDownColor.IsEmpty ? DayDownColor : !DayOverColor.IsEmpty ? DayOverColor : ControlPaint.Light(!SelDayBackColor.IsEmpty && Value.Date.CompareTo(date.Date) == 0 ? SelDayBackColor : DayBackColor.IsEmpty ? BackColor : DayBackColor);
+                    using (Brush backbrush = currHitType == HitType.Day && currHitValue.CompareTo(date.ToString("yyyy/MM/dd")) == 0 ? new SolidBrush(hitColor) : new SolidBrush(!SelDayBackColor.IsEmpty && Value.Date.CompareTo(date.Date) == 0 ? SelDayBackColor : DayBackColor.IsEmpty ? BackColor : DayBackColor))
+                    {
+                        g.FillRectangle(backbrush, rect);
+                    }
+                    g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);
+
+                    //日付
+                    isNewColor = DayForeColor.IsSystemColor;
+                    brush = isNewColor ? SystemBrushes.FromSystemColor(DayForeColor) : new SolidBrush(DayForeColor);
+                    g.DrawString(args.DateText, DayFont, isOutOfRange ? Brushes.Gray : i == (int)DayOfWeek.Sunday ? Brushes.Red : i == (int)DayOfWeek.Saturday ? Brushes.Blue : brush, dayRect, m_StringFormat);
+                    if (isNewColor) { brush.Dispose(); }
+
+                    //六曜
+                    if (RokuyouVisible)
+                    {
+                        RectangleF rokuyouRect;
+                        isNewColor = RokuyouForeColor.IsSystemColor && !isOutOfRange;
+                        brush = isOutOfRange ? Brushes.Gray : isNewColor ? SystemBrushes.FromSystemColor(RokuyouForeColor) : new SolidBrush(RokuyouForeColor);
+                        if (DayStyle == DayStyleType.Row4)
+                        {
+                            rokuyouRect = new RectangleF(new PointF(rect.X, rect.Y + cellHeight * 2), new SizeF(cellWidth * 3, cellHeight));
+                            g.DrawString(args.Rokuyou, rokuyouFont, brush, rokuyouRect, m_StringFormat);
+                        }
+                        else
+                        {
+                            rokuyouRect = new RectangleF(new PointF(rect.X + cellWidth * 3, rect.Y), new SizeF(cellWidth * 2, cellHeight));
+                            g.DrawString(args.Rokuyou, rokuyouFont, brush, rokuyouRect, m_StringFormatLeft);
+                        }
+                        if (isNewColor) { brush.Dispose(); }
+                    }
+
+                    //祝日
+                    if (args.Holiday.Length > 0)
+                    {
+                        RectangleF holidayRect;
+                        isNewColor = HolidayForeColor.IsSystemColor && !isOutOfRange;
+                        brush = isOutOfRange ? Brushes.Gray : isNewColor ? SystemBrushes.FromSystemColor(HolidayForeColor) : new SolidBrush(HolidayForeColor);
+                        if (DayStyle == DayStyleType.Row4)
+                        {
+                            holidayRect = new RectangleF(new PointF(rect.X, rect.Y + cellHeight * 3), new SizeF(cellWidth * dayWidth, cellHeight));
+                            g.DrawString(args.Holiday, holidayFont, brush, holidayRect, m_StringFormat);
+                        }
+                        else
+                        {
+                            holidayRect = new RectangleF(new PointF(rect.X, rect.Y + cellHeight * 2), new SizeF(cellWidth * 3, cellHeight));
+                            g.DrawString(args.Holiday, holidayFont, brush, holidayRect, m_StringFormatLeft);
+                        }
+                        if (isNewColor) { brush.Dispose(); }
+                    }
+
+                    //メモ
+                    if (args.MemoText.Length > 0)
+                    {
+                        RectangleF memoRect;
+                        isNewColor = MemoForeColor.IsSystemColor && !isOutOfRange;
+                        brush = isOutOfRange ? Brushes.Gray : isNewColor ? SystemBrushes.FromSystemColor(MemoForeColor) : new SolidBrush(MemoForeColor);
+                        if (DayStyle == DayStyleType.Row4)
+                        {
+                            memoRect = new RectangleF(new PointF(rect.X + cellWidth * 3, rect.Y), new SizeF(cellWidth * 2, cellHeight * 3));
+                            g.DrawString(args.MemoText, MemoFont, brush, memoRect, m_StringFormat);
+                        }
+                        else
+                        {
+                            memoRect = new RectangleF(new PointF(rect.X + cellWidth * 3, rect.Y + cellHeight * 1), new SizeF(cellWidth * 2, cellHeight * 2));
+                            g.DrawString(args.MemoText, MemoFont, brush, memoRect, m_StringFormat);
+                        }
+                        if (isNewColor) { brush.Dispose(); }
+                    }
+
+                    rect = new RectangleF(new PointF(rect.Left + rect.Width, curY), new SizeF(cellWidth * dayWidth, cellHeight * dayHeight));
+                }
+            }
+        }
+
+
+        protected override void OnMouseWheel(MouseEventArgs e)
+        {
+            //if (e.Delta > 0)
+            //{
+            //    if (m_TabKeyList.Count - m_TopIndex > m_TabCount) { m_TopIndex++; }                
+            //}
+            //else
+            //{
+            //    if (m_TopIndex > 0) { m_TopIndex--; }
+            //}
+            base.OnMouseWheel(e);
+            Invalidate();
+        }
+
+        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
+        {
+            if (keyData == Keys.Tab)
+                return true;
+            if (keyData == (Keys.Tab | Keys.Shift))
+                return true;
+
+            switch (keyData)
+            {
+                case Keys.Left:
+                    return true;
+                case Keys.Right:
+                    return true;
+            }
+
+
+            return base.ProcessCmdKey(ref msg, keyData);
+        }
+
+        protected override void OnMouseClick(MouseEventArgs e)
+        {
+            base.OnMouseClick(e);
+            HitTestInfo item = HitTest(e.X, e.Y);
+            if(currHitType == HitType.CurrentDay) { showValue = Value; }
+            else if (currHitType == HitType.MonthPrev) { showValue = showValue.AddMonths(-1); }
+            else if (currHitType == HitType.MonthNext) { showValue = showValue.AddMonths(1); }
+            else if (currHitType == HitType.YearPrev) { showValue = showValue.AddYears(-1); }
+            else if (currHitType == HitType.YearNext) { showValue = showValue.AddYears(1); }
+            else if (currHitType == HitType.Day)
+            {
+                Value = DateTime.Parse(item.Value); showValue = Value;
+            }
+            Invalidate();
+
+            if (currHitType == HitType.Day && DateSelect != null)
+            {
+                CalendarEventArgs args = new CalendarEventArgs()
+                {
+                    DateValue = Value,
+                    DateText = Text,
+                    Rokuyou = string.Empty,
+                    Holiday = string.Empty,
+                    MemoText = string.Empty
+                };
+                DateSelect(this, args);
+            } 
+        }
+
+        protected override void OnMouseMove(MouseEventArgs e)
+        {
+            HitTestInfo item = HitTest(e.X, e.Y);
+            Invalidate();
+            base.OnMouseMove(e);
+        }
+
+        protected override void OnMouseEnter(System.EventArgs e)
+        {
+            m_MouseFocused = true;
+            Invalidate();
+            base.OnMouseEnter(e);
+        }
+
+        protected override void OnMouseLeave(System.EventArgs e)
+        {
+            m_MouseFocused = false;
+            Invalidate();
+            base.OnMouseLeave(e);
+        }
+
+        protected override void OnMouseDown(MouseEventArgs e)
+        {
+            HitTestInfo item = HitTest(e.X, e.Y);
+            m_MouseDown = true;
+            this.Focus();
+            Invalidate();
+            base.OnMouseDown(e);
+        }
+
+        protected override void OnMouseUp(MouseEventArgs e)
+        {
+            m_MouseDown = false;
+            Invalidate();
+            base.OnMouseUp(e);
+        }
+
+        protected override void OnResize(System.EventArgs e)
+        {
+            Invalidate();
+            base.OnResize(e);
+        }
+
+        #endregion
+
+        #region  ★★★★★ Private Function ★★★★★
+
+
+
+        #endregion
+
+        #region  ★★★★★ Public  Function ★★★★★
+
+        private bool InRectangle(RectangleF r, int x, int y)
+        {
+            return (r.X <= (float)x && (float)x <= (r.X + r.Width)) && (r.Y <= (float)y && (float)y <= (r.Y + r.Height));
+        }
+
+        public HitTestInfo HitTest(int x, int y)
+        {
+            HitTestInfo hit = new HitTestInfo();
+            hit.x = x;
+            hit.y = y;
+            currHitType = HitType.None;
+            currHitValue = string.Empty;
+            for (int i = 0; i < buttonRectList.Count; i++)
+            {
+                if (buttonRectList[i].Contains((float)x, (float)y))
+                {
+                    Cursor = Cursors.Hand;
+                    hit.type = (HitType)(i + 1);
+                    currHitType = hit.Type;
+                    return hit;
+                }
+            }
+
+
+           foreach(KeyValuePair<string, RectangleF> item in dayRectList)
+           {
+               if (item.Value.Contains((float)x, (float)y))
+                {
+                    Cursor = Cursors.Hand;
+                    hit.type = HitType.Day;
+                    hit.value = item.Key;
+                    currHitType = hit.Type;
+                    currHitValue = hit.value;
+                    return hit;
+                }
+            }
+            Cursor = Cursors.Default;
+            return HitTestInfo.Nowhere;
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.10.0