示例#1
0
        /// <summary>
        /// リスト項目を選択したときの処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkedListBoxToDoList_SelectedIndexChanged(object sender, EventArgs e)
        {
            // 選択しているToDoを文字列として取得
            int index = this.checkedListBoxToDoList.SelectedIndex;

            if (index < 0)
            {
                index = 0;
            }
            string selectedToDo = this.checkedListBoxToDoList.Items[index].ToString();

            this.exToDo = selectedToDo;

            // 入力欄に反映
            ToDoData td = ToDoData.GetToDoDataSet(selectedToDo);
            // 年月日
            string   dateStr = string.Format("{0,0:D4}/{1,0:D2}/{2,0:D2}", td.GetToDoYear(), td.GetToDoMonth(), td.GetToDoDay());
            DateTime dtDate  = Convert.ToDateTime(dateStr);

            this.dateTimePickerToDoDate.Value = dtDate;
            // 時刻
            string   timeStr = string.Format("{0,0:D2}:{1,0:D2}:00", td.GetToDoHour(), td.GetToDoMinute());
            DateTime dtTime  = Convert.ToDateTime(timeStr);

            this.dateTimePickerToDoTime.Value = dtTime;
            // ToDo詳細
            this.textBoxToDoDetail.Text = td.GetToDoDetail();

            return;
        }
示例#2
0
        /// <summary>
        /// 次のToDoを検索する
        /// </summary>
        public ToDoData SearchNextToDo(DateTime nowDateTime)
        {
            int      maxList = this.todoList.Count;
            ToDoData td;

            for (int i = 0; i < maxList; i++)
            {
                td = ToDoData.GetToDoDataSet(todoList[i]);

                string destDateTimeStr = string.Format("{0}/{1}/{2} {3}:{4}:00",
                                                       td.GetToDoYear(), td.GetToDoMonth(), td.GetToDoDay(), td.GetToDoHour(), td.GetToDoMinute()
                                                       );
                DateTime destDateTime = Convert.ToDateTime(destDateTimeStr);

                if (nowDateTime < destDateTime)
                {
                    // 通知済みなら次のToDoをセットする
                    if (this.isNotified)
                    {
                        this.dtNext      = destDateTime;
                        this.nextTodoStr = td.GetToDoDetail();
                        this.isNotified  = false;
                    }

                    // 次のToDoを返す
                    return(td);
                }
            }

            // 該当ToDoがない時はnullを返す
            return(null);
        }
示例#3
0
        /// <summary>
        /// データファイルの読み込み
        /// </summary>
        private void ReadDataFile()
        {
            string[] temp = ToDoData.ReadFile();

            th.SetToDoData(temp);

            return;
        }
示例#4
0
        /// <summary>
        /// フォームを閉じるときに,データを保存する
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToDoSetPanel_FormClosing(object sender, FormClosingEventArgs e)
        {
            int max = this.checkedListBoxToDoList.Items.Count;

            string[] datas = new string[max];
            this.checkedListBoxToDoList.Items.CopyTo(datas, 0);
            ToDoData.WriteFile(datas);

            ToDoData.ReadFile();

            return;
        }
示例#5
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public ToDoSetPanel()
        {
            InitializeComponent();

            // DateTimePicker にカスタムフォーマットを適用
            this.dateTimePickerToDoDate.Format       = DateTimePickerFormat.Custom;
            this.dateTimePickerToDoDate.CustomFormat = "yyyy年MM月dd日";
            this.dateTimePickerToDoTime.Format       = DateTimePickerFormat.Custom;
            this.dateTimePickerToDoTime.CustomFormat = "HH時mm分";

            // DateTimePicker に現在の日時をセット
            this.SetNowDateTime();

            // ファイルから読み込み
            string[] datas = ToDoData.ReadFile();
            this.checkedListBoxToDoList.Items.AddRange(datas);

            return;
        }
示例#6
0
        /// <summary>
        /// 文字列からToDoクラスに変換する
        /// </summary>
        /// <returns></returns>
        public static ToDoData GetToDoDataSet(string todoStr)
        {
            ToDoData td = new ToDoData();

            // 日時
            MatchCollection matches = Regex.Matches(todoStr, "[0-9]{2,4}");

            td.todoYear   = Convert.ToInt32(matches[0].ToString());
            td.todoMonth  = Convert.ToInt32(matches[1].ToString());
            td.todoDay    = Convert.ToInt32(matches[2].ToString());
            td.todoHour   = Convert.ToInt32(matches[3].ToString());
            td.todoMinute = Convert.ToInt32(matches[4].ToString());
            // ToDo詳細,ID
            string[] tempStr = todoStr.Split(' ');
            td.todoDetail = "";
            for (int i = 2; i < (tempStr.Length - 1); i++)
            {
                td.todoDetail += tempStr[i] + " ";
            }
            td.todoDetail = td.todoDetail.Trim(' ');
            td.todoId     = tempStr[tempStr.Length - 1];

            return(td);
        }
示例#7
0
        /// <summary>
        /// Timer(現在日時の取得と表示制御)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timerGetPresent_Tick(object sender, EventArgs e)
        {
            // 現在の日時を取得
            DateTime dtNow = DateTime.Now;

            // 項目別に分解
            this.presentYear   = dtNow.Year;
            this.presentMonth  = dtNow.Month;
            this.presentDay    = dtNow.Day;
            this.presentHour   = dtNow.Hour;
            this.presentMinute = dtNow.Minute;
            this.presentSecond = dtNow.Second;

            // 月を英字3文字に変換
            string presentMonthStr = this.monthStr[this.presentMonth];

            // formに表示
            this.textBoxPresentYear.Text   = string.Format("{0,0:D4}", presentYear);
            this.textBoxPresentMonth.Text  = presentMonthStr;
            this.textBoxPresentDay.Text    = string.Format("{0,0:D2}", presentDay);
            this.textBoxPresentHour.Text   = string.Format("{0,0:D2}", presentHour);
            this.textBoxPresentMinute.Text = string.Format("{0,0:D2}", presentMinute);
            this.textBoxPresentSecond.Text = string.Format("{0,0:D2}", presentSecond);

            // ":" の点滅
            if (this.isVisibleColon)
            {
                this.labelPresentHM.Visible = true;
                this.labelPresentMS.Visible = true;
            }
            else
            {
                this.labelPresentHM.Visible = false;
                this.labelPresentMS.Visible = false;
            }
            this.isVisibleColon = (this.isVisibleColon) ? false : true;

            // 次のToDoを表示
            ToDoData td = th.SearchNextToDo(dtNow);

            if (td == null)
            {
                // formに表示
                this.textBoxToDoYear.Text   = "----";
                this.textBoxToDoMonth.Text  = "---";
                this.textBoxToDoDay.Text    = "--";
                this.textBoxToDoHour.Text   = "--";
                this.textBoxToDoMinute.Text = "--";
                this.textBoxToDoDetail.Text = "未来のToDoがありません。";
            }
            else
            {
                // formに表示
                this.textBoxToDoYear.Text   = string.Format("{0,0:D4}", td.GetToDoYear());
                this.textBoxToDoMonth.Text  = this.monthStr[td.GetToDoMonth()];
                this.textBoxToDoDay.Text    = string.Format("{0,0:D2}", td.GetToDoDay());
                this.textBoxToDoHour.Text   = string.Format("{0,0:D2}", td.GetToDoHour());
                this.textBoxToDoMinute.Text = string.Format("{0,0:D2}", td.GetToDoMinute());
                this.textBoxToDoDetail.Text = td.GetToDoDetail();
            }

            // 通知済みToDoがあれば表示
            if (notifiedToDo.Length > 0)
            {
                this.isBlinkedNotifiedToDo    = true;
                this.textBoxNotifiedToDo.Text = notifiedToDo;

                notifiedToDo = "";
            }

            // 表示を点滅させる
            if (isBlinkedNotifiedToDo)
            {
                if (this.isVisibleColon)
                {
                    this.textBoxNotifiedToDo.ForeColor = Color.Red;
                    this.textBoxNotifiedToDo.BackColor = Color.Black;
                }
                else
                {
                    this.textBoxNotifiedToDo.ForeColor = Color.Black;
                    this.textBoxNotifiedToDo.BackColor = Color.Red;
                }
            }

            return;
        }
示例#8
0
        /// <summary>
        /// 「登録」ボタン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonSet_Click(object sender, EventArgs e)
        {
            // ToDoID用の現在日時を取得
            DateTime nowDt  = DateTime.Now;
            string   todoId = string.Format("{0,0:D4}{1,0:D2}{2,0:D2}{3,0:D2}{4,0:D2}{5,0:D2}{6,0:D3}",
                                            nowDt.Year, nowDt.Month, nowDt.Day, nowDt.Hour, nowDt.Minute, nowDt.Second, nowDt.Millisecond
                                            );

            // DateTimePicker の値取得
            DateTime setDate = this.dateTimePickerToDoDate.Value;
            DateTime setTime = this.dateTimePickerToDoTime.Value;

            // 過去チェック
            string checkDateTimeStr = string.Format("{0,0:D4}/{1,0:D2}/{2,0:D2} {3,0:D2}:{4,0:D2}:00",
                                                    setDate.Year, setDate.Month, setDate.Day, setTime.Hour, setTime.Minute
                                                    );
            DateTime checkDateTime = Convert.ToDateTime(checkDateTimeStr);

            if (DateTime.Now > checkDateTime)
            {
                DialogResult dlgResult = MessageBox.Show(
                    "過去のToDoを設定すると,タイムスリップが必要になりますがよろしいですか?",
                    "ToDoが過去です",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Exclamation
                    );

                if (dlgResult == DialogResult.No)
                {
                    return;
                }
            }

            // ToDo の取得
            string todoDetail = this.textBoxToDoDetail.Text;

            if (todoDetail.Length == 0)
            {
                todoDetail = "(ToDo詳細未記入)";
            }

            // ToDoクラスに登録
            ToDoData todo = new ToDoData();

            todo.SetToDo(todoId, setDate.Year, setDate.Month, setDate.Day, setTime.Hour, setTime.Minute, todoDetail);
            string todoStr = todo.OutputToDo();

            if (this.exToDo.Length > 0)
            {
                this.checkedListBoxToDoList.Items.Remove(exToDo);
                this.exToDo = "";
            }
            this.checkedListBoxToDoList.Items.Add(todoStr);

            // ソート
            int todoMax = this.checkedListBoxToDoList.Items.Count;

            string[] tempArray = new string[todoMax];
            this.checkedListBoxToDoList.Items.CopyTo(tempArray, 0);
            Array.Sort(tempArray);
            this.checkedListBoxToDoList.Items.Clear();
            this.checkedListBoxToDoList.Items.AddRange(tempArray);


            return;
        }