private void SetSubscribes() { FilePath.Subscribe(path => IsFileSpecified.Value = !string.IsNullOrEmpty(path)); Interval.Subscribe(interval => { if (ignoreChange) { return; } Model.IntervalCalculator.Interval = interval; ignoreChange = true; BPM.Value = Model.IntervalCalculator.BPM; ignoreChange = false; }); BPM.Subscribe(bpm => { if (ignoreChange) { return; } Model.IntervalCalculator.BPM = bpm; ignoreChange = true; Interval.Value = Model.IntervalCalculator.Interval; ignoreChange = false; }); Action <bool> UpdateLoopParam = isInterval => { if (isInterval) { BPM.Value = Model.IntervalCalculator.BPM; } else { Interval.Value = Model.IntervalCalculator.Interval; } }; Frequency.Subscribe(freq => Model.DuplicationCounter.Frequency = freq); Beat.Subscribe(beat => Model.DuplicationCounter.Beat = beat); LoopNum.Subscribe(lnum => Model.DuplicationCounter.LoopCount = lnum); EnableDecrement.Subscribe(dec => Model.DuplicationCounter.Decrement = dec); Action <int> UpdateElemNum = _ => { ElementNum.Value = Model.DuplicationCounter.ElementCount; IsDuplicationCountVaild.Value = ElementNum.Value > 0; }; Frequency.Subscribe(UpdateElemNum); Beat.Subscribe(UpdateElemNum); LoopNum.Subscribe(UpdateElemNum); EnableDecrement.Subscribe(_ => UpdateElemNum(0)); OpenFile.Subscribe(_ => { var ofd = new OpenFileDialog() { Filter = "VMDファイル(*.vmd)|*.vmd", AddExtension = true, CheckFileExists = true, CheckPathExists = true, Multiselect = false, }; if (ofd.ShowDialog() ?? false) { string fileName = ofd.FileName; ReadFile(fileName); } }); ExecuteGeneration.Subscribe(_ => { try { var filePath = FilePath.Value ?? ""; var sourceVMD = Model.ReadFile(filePath); var savePath = Path.Combine(Path.GetDirectoryName(filePath) ?? "", Path.GetFileNameWithoutExtension(filePath) + "_loop.vmd"); var loopMotion = Model.CreateLoopMotion(sourceVMD); loopMotion.Write(savePath); AppendLog($"出力が完了しました。"); AppendLog($"フレーム数 : {sourceVMD.Frames.Count()} → {loopMotion.Frames.Count()}"); AppendLog($"保存先 : {savePath}"); AppendLog(Environment.NewLine); } catch (FileNotFoundException) { AppendLog("ファイルが見つかりませんでした。"); FilePath.Value = null; } catch (InvalidDataException) { AppendLog("非VMDファイルが指定されました。"); FilePath.Value = null; } catch (Exception ex) { AppendLog($"エラーが発生しました。{ex.Message}"); } }); FilePath.Subscribe(path => Properties.Settings.Default.FilePath = path); Interval.Subscribe(iv => Properties.Settings.Default.Interval = iv ?? 1); BPM.Subscribe(bpm => Properties.Settings.Default.BPM = bpm ?? 1); Frequency.Subscribe(freq => Properties.Settings.Default.Frequency = freq); Beat.Subscribe(beat => Properties.Settings.Default.Beat = beat); LoopNum.Subscribe(l => Properties.Settings.Default.LoopNum = l); EnableDecrement.Subscribe(d => Properties.Settings.Default.Decrement = d); }