public WordToMotionSettingSync(IMessageSender sender, IMessageReceiver receiver) : base(sender) { var settings = WordToMotionSetting.Default; var factory = MessageFactory.Instance; _motionRequests = MotionRequestCollection.LoadDefault(); _midiNoteToMotionMap = MidiNoteToMotionMap.LoadDefault(); PreviewDataSender = new WordToMotionItemPreviewDataSender(sender); SelectedDeviceType = new RProperty <int>(settings.SelectedDeviceType, i => SendMessage(factory.SetDeviceTypeToStartWordToMotion(i))); ItemsContentString = new RProperty <string>(settings.ItemsContentString, s => SendMessage(factory.ReloadMotionRequests(s))); MidiNoteMapString = new RProperty <string>(settings.MidiNoteMapString, s => SendMessage(factory.LoadMidiNoteToMotionMap(s))); EnablePreview = new RProperty <bool>(false, b => { SendMessage(factory.EnableWordToMotionPreview(b)); if (b) { PreviewDataSender.Start(); } else { PreviewDataSender.End(); } }); MidiNoteReceiver = new MidiNoteReceiver(receiver); //NOTE: このStartは通信とかではないので、すぐ始めちゃってOK MidiNoteReceiver.Start(); //NOTE: この2つの呼び出しにより、必ずデフォルト設定をUnity側に通知する+シリアライズ文字列が空ではなくなる SaveMidiNoteMap(); SaveMotionRequests(); }
public void Load(MidiNoteToMotionMap model) { Model = model; _items.Clear(); foreach (var i in model.Items) { _items.Add(new MidiNoteToMotionItemViewModel() { ItemIndex = i.ItemIndex, NoteNumber = i.NoteNumber, }); } }
public static MidiNoteToMotionMap LoadDefault() { var result = new MidiNoteToMotionMap(); for (int i = 0; i < 9; i++) { result.Items.Add(new MidiNoteToMotionItem() { ItemIndex = i, NoteNumber = InvalidNoteNumber, }); } return(result); }
public MidiNoteToMotionMap CreateCopy() { var result = new MidiNoteToMotionMap(); foreach (var i in Items) { result.Items.Add(new MidiNoteToMotionItem() { ItemIndex = i.ItemIndex, NoteNumber = i.NoteNumber, }); } return(result); }
public MidiNoteToMotionMapViewModel(MidiNoteToMotionMap model) { Items = new ReadOnlyObservableCollection <MidiNoteToMotionItemViewModel>(_items); Model = model; Load(model); }