コード例 #1
0
        /// <summary>
        /// 日付をリストにするクラス
        /// </summary>
        /// <param name="entity">Entityクラス</param>
        /// <param name="data">Dataクラス</param>
        /// <param name="col">横の位置</param>
        /// <param name="row">縦の位置</param>
        /// <param name="option">Optionクラス</param>
        private void DaysCreate(CalenderCreateEntity entity, CalenderData data, int col, int row, Option option)
        {
            var startPoint = col;

            for (var i = 0; i < data.CalenderLastDay; i++)
            {
                this.calenderDay = new CalenderDay();
                this.DayCreate(this.calenderDay, i, col, row);

                // 曜日の色を変える処理
                this.DateColorChange(col, this.calenderDay);

                // 当日かどうかの判断
                if (option.IsTodayColorChange && int.Parse(this.calenderDay.Day) == DateTime.Now.Day && data.Date.Year == DateTime.Now.Year && data.Date.Month == DateTime.Now.Month)
                {
                    this.calenderDay.IsToday = true;
                }

                entity.CalenderDays.Add(this.calenderDay);
                col++;

                // Gridが6*7の為
                if (col > 6)
                {
                    row++;
                    col = 0;
                }
            }

            // デザイン用にスペースを作る処理 必ず6*7で作る
            // 最上段のデザイン
            for (var x = 0; x < 7; x++)
            {
                this.calenderDay = new CalenderDay()
                {
                    Col = x,
                    Row = 0,
                };
                entity.CalenderDays.Add(this.calenderDay);
            }

            // LastDayのRowから最下段までのデザイン
            for (int y = row; y < 6; y++)
            {
                for (int x = 0; x < 7; x++)
                {
                    this.calenderDay = new CalenderDay()
                    {
                        Col = x,
                        Row = y,
                    };
                    entity.CalenderDays.Add(this.calenderDay);
                }

                col = 0;
            }
        }
コード例 #2
0
        /// <summary>
        /// カレンダーを1つ作成するメソッド
        /// </summary>
        /// <param name="calData">カレンダーデータクラス</param>
        /// <param name="paramOption">オプションクラス</param>
        /// <returns>CalenderEntity カレンダーの情報</returns>
        protected CalenderCreateEntity SetCalender(CalenderData calData, Option paramOption)
        {
            // 日付データの作成
            this.entity         = new CalenderCreateEntity();
            this.sunColorNumber = 0;
            this.satColorNumber = 6;

            calData.LastDay();
            calData.FastDateCreate();
            this.entity.Date        = calData.Date;
            this.entity.StringMonth = calData.Date.Month.ToString();
            this.entity.StringYear  = calData.Date.Year.ToString();
            this.option             = paramOption;

            var col = this.DateSwitch(this.option.IsDatePrintChange, calData.FastDate);

            var row = 0;

            this.DaysCreate(this.entity, calData, col, row, this.option);

            // 曜日の作成
            var dateCol = 0;
            var sun     = new WeekTitleSun()
            {
                Col = dateCol,
            };

            this.entity.CalenderWeekItems.Add(sun);
            dateCol++;

            var mon = new WeekTitleMon()
            {
                Col = dateCol,
            };

            this.entity.CalenderWeekItems.Add(mon);
            dateCol++;

            var tue = new WeekTitleTue()
            {
                Col = dateCol,
            };

            this.entity.CalenderWeekItems.Add(tue);
            dateCol++;

            var wen = new WeekTitleWen()
            {
                Col = dateCol,
            };

            this.entity.CalenderWeekItems.Add(wen);
            dateCol++;

            var thu = new WeekTitleThu()
            {
                Col = dateCol,
            };

            this.entity.CalenderWeekItems.Add(thu);
            dateCol++;

            var fri = new WeekTitleFri()
            {
                Col = dateCol,
            };

            this.entity.CalenderWeekItems.Add(fri);
            dateCol++;

            var sat = new WeekTitleSat()
            {
                Col = dateCol,
            };

            this.entity.CalenderWeekItems.Add(sat);

            return(this.entity);
        }