public PlayTimer() { KifuMoveTime = new KifuMoveTime(); Stopwatch = new Stopwatch(); Stopwatch.Stop(); KifuTimeSetting = new KifuTimeSetting(); // デフォルトで何かセットしておかないと起動後の描画でnull参照になってしまう。 }
/// <summary> /// このControl上にあるcontrolとbindする。 /// </summary> public void Bind(KifuTimeSetting player) { var n = new[] { numericUpDown1, numericUpDown2, numericUpDown3, numericUpDown4, numericUpDown5 }; var r = new[] { radioButton1, radioButton2 }; var check = checkBox1; var check_unlimit_time = checkBox2; var group = groupBox1; binder.Bind(player, "Hour", n[0]); binder.Bind(player, "Minute", n[1]); binder.Bind(player, "Second", n[2]); binder.Bind(player, "Byoyomi", n[3]); binder.Bind(player, "IncTime", n[4]); // 秒読みのラジオボタンが選択されていれば、IncTimeのほうの設定はグレーアウト。 binder.Bind(player, "ByoyomiEnable", r[0], (v) => { if (v) { n[3].Enabled = true; n[4].Enabled = false; } }); binder.Bind(player, "IncTimeEnable", r[1], (v) => { if (v) { n[3].Enabled = false; n[4].Enabled = true; } }); binder.Bind(player, "IgnoreTime", check); binder.Bind(player, "TimeLimitless", check_unlimit_time, (v) => { // 時間無制限の時、GroupBox丸ごとDisableに。 // ただし、自分のチェックボックスは除外。この除外は、コンストラクタでGroupから除外している。 group.Enabled = !v && // 後手ならば、個別設定を有効にするのチェックが有効ではない時は、このGroupBoxは無効化されなければならない。 !(ViewModel.Color == SCore.Color.WHITE && !ViewModel.WhiteEnable) ; }); }