Beispiel #1
0
        // --------------------------------------------------------------------
        #region 補助処理
        // --------------------------------------------------------------------
        /// <summary>
        /// 入力をチェックする
        /// </summary>
        /// <returns>入力正常か</returns>
        private bool CheckInput(out TimerDef outDef)
        {
            outDef = null;

            TimerDef input = new TimerDef();

            input.Memo      = this.txMemo.Text;
            input.Name      = this.txTitle.Text;
            input.AutoStart = false;
            input.Type      = this.ucTimeSet.TimeSetType;
            input.SetCount  = this.ucTimeSet.InputValue;
            input.Soundfile = this.txSoundPath.Text;

            if (input.Type == Cs.TimerType.Timer)
            {
                if (input.SetCount < 1)
                {
                    this.ucTimeSet.Focus();
                    return(false);
                }
            }

            outDef = input;
            return(true);
        }
Beispiel #2
0
        // --------------------------------------------------------------------
        #region 終了処理
        // --------------------------------------------------------------------
        private void buOK_Click(object sender, EventArgs e)
        {
            TimerDef def;

            if (this.CheckInput(out def))
            {
                this.EditTimerDef = def;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
Beispiel #3
0
        /// <summary>
        /// 最初の選択行のタイマーインスタンスを返す
        /// </summary>
        /// <returns>選択行タイマーインスタンス、無い場合はnull</returns>
        private TimerDef GetFirstSelectedTemplate()
        {
            TimerDef     tdef = null;
            ListViewItem item = this.GetFirstSelectdItem();

            if (item != null)
            {
                tdef = (TimerDef)item.Tag;
            }
            return(tdef);
        }
Beispiel #4
0
        /// <summary>
        /// 新規カウントダウンタイマー作成
        /// </summary>
        private void OperateNewTimer()
        {
            FrmTimerSet dialog = new FrmTimerSet();

            dialog.StartPosition = FormStartPosition.CenterParent;
            dialog.Defs          = this.defs;
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                TimerDef      def      = dialog.EditTimerDef;
                TimerInstance instance = this.CreateTimerInstance(def);
                instance.Start();
                this.timerList.Items.Add(this.CreateViewItem(instance));
                this.DoSoreList();
                this.UpdateMenuItemEnabled();
            }
        }
Beispiel #5
0
        /// <summary>
        /// 自動起動設定メニュークリック応答
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miAutoStart_Click(object sender, EventArgs e)
        {
            bool startAuto = !this.miAutoStart.Checked;

            foreach (ListViewItem item in this.lstDefs.SelectedItems)
            {
                TimerDef def = (TimerDef)item.Tag;
                def.AutoStart = startAuto;
                if (startAuto)
                {
                    item.SubItems[1].Text = "自動";
                }
                else
                {
                    item.SubItems[1].Text = "";
                }
            }
            this.miAutoStart.Checked = startAuto;
        }
Beispiel #6
0
        /// <summary>
        /// テンプレート修正釦
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buUpdTemplate_Click(object sender, EventArgs e)
        {
            ListViewItem lvItem = this.GetFirstSelectdItem();

            if (lvItem != null)
            {
                TimerDef tdef = (TimerDef)lvItem.Tag;
                TimerDef inputdef;
                if (this.CheckInput(out inputdef))
                {
                    tdef.Memo      = inputdef.Memo;
                    tdef.Name      = inputdef.Name;
                    tdef.SetCount  = inputdef.SetCount;
                    tdef.Soundfile = inputdef.Soundfile;
                    tdef.Type      = inputdef.Type;
                    lvItem.Text    = tdef.Name;
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// リストビューアイテムを作成する
        /// </summary>
        /// <param name="tdef">タイマー定義</param>
        /// <returns></returns>
        private ListViewItem CreateViewItem(TimerDef tdef)
        {
            ListViewItem item = new ListViewItem();

            // タイマインスタンスは Tag に保持させる
            item.Tag = tdef;

            // 名称
            item.Text = tdef.Name;

            if (tdef.AutoStart)
            {
                item.SubItems.Add("自動");
            }
            else
            {
                item.SubItems.Add("");
            }
            return(item);
        }
Beispiel #8
0
        /// <summary>
        /// テンプレート選択行変化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lstDefs_SelectedIndexChanged(object sender, EventArgs e)
        {
            // 選択テンプレートの内容をタイマー情報各欄に設定
            if (this.lstDefs.SelectedItems.Count == 1)
            {
                TimerDef tdef = this.GetFirstSelectedTemplate();
                this.txTitle.Text = tdef.Name;
                this.txMemo.Text  = tdef.Memo;
                this.ucTimeSet.SetCount(tdef.Type, tdef.SetCount);
                this.txSoundPath.Text = tdef.Soundfile;

                if (this.ucTimeSet.ContainsFocus)
                {
                    this.ucTimeSet.SetFocusCounter();
                }
                else if (this.txTitle.Focused)
                {
                    this.txTitle.SelectAll();
                }
            }

            this.UpdateMenuItemEnabled();
        }
Beispiel #9
0
        /// <summary>
        /// 選択テンプレートを削除する
        /// </summary>
        private void OperateDeleteTemplate()
        {
            if (this.lstDefs.SelectedItems.Count == 0)
            {
                return;
            }

            if (MessageBox.Show("選択テンプレートを削除してよろしいですか?", "削除確認",
                                MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                // メモリにあるテンプレートリストから削除する
                foreach (ListViewItem item in this.lstDefs.SelectedItems)
                {
                    TimerDef tdef = (TimerDef)item.Tag;
                    this.Defs.Remove(tdef);
                }

                // リストビューからも削除する
                while (this.lstDefs.SelectedItems.Count > 0)
                {
                    this.lstDefs.Items.Remove(this.lstDefs.SelectedItems[0]);
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// 定義情報からタイマーのインスタンスを生成する
        /// </summary>
        /// <param name="def"></param>
        /// <returns></returns>
        private TimerInstance CreateTimerInstance(TimerDef def)
        {
            TimerInstance instance = new TimerInstance(def);

            return(instance);
        }