コード例 #1
0
        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();
        }
コード例 #2
0
        internal WordToMotionSettingViewModel(IMessageSender sender, IMessageReceiver receiver) : base(sender)
        {
            Items = new ReadOnlyObservableCollection <WordToMotionItemViewModel>(_items);
            CustomMotionClipNames = new ReadOnlyObservableCollection <string>(_customMotionClipNames);

            Devices            = WordToMotionDeviceItem.LoadAvailableItems();
            SelectedDevice     = Devices.FirstOrDefault(d => d.Index == DeviceTypeKeyboardWord);
            _previewDataSender = new WordToMotionItemPreviewDataSender(sender);
            _previewDataSender.PrepareDataSend +=
                (_, __) => _dialogItem?.WriteToModel(_previewDataSender.MotionRequest);

            receiver.ReceivedCommand += OnReceiveCommand;
            MidiNoteReceiver          = new MidiNoteReceiver(receiver);
            MidiNoteReceiver.Start();

            LoadDefaultItemsIfInitialStart();
        }