Пример #1
0
 public WordToMotionSettingViewModel() : base()
 {
     Items              = new ReadOnlyObservableCollection <WordToMotionItemViewModel>(_items);
     Devices            = WordToMotionDeviceItem.LoadAvailableItems();
     SelectedDevice     = Devices.FirstOrDefault(d => d.Index == DeviceTypeKeyboardWord);
     _previewDataSender = new WordToMotionItemPreviewDataSender(Sender);
 }
Пример #2
0
        internal WordToMotionSettingViewModel(WordToMotionSettingSync model, IMessageSender sender, IMessageReceiver receiver) : base(sender)
        {
            _model = model;
            Items  = new ReadOnlyObservableCollection <WordToMotionItemViewModel>(_items);
            CustomMotionClipNames = new ReadOnlyObservableCollection <string>(_customMotionClipNames);
            Devices = WordToMotionDeviceItem.LoadAvailableItems();

            AddNewItemCommand = new ActionCommand(() => model.AddNewItem());
            OpenKeyAssignmentEditorCommand = new ActionCommand(() => OpenKeyAssignmentEditor());
            ResetByDefaultItemsCommand     = new ActionCommand(
                () => SettingResetUtils.ResetSingleCategoryAsync(LoadDefaultItems)
                );

            _model.SelectedDeviceType.PropertyChanged += (_, __) =>
            {
                SelectedDevice           = Devices.FirstOrDefault(d => d.Index == _model.SelectedDeviceType.Value);
                EnableWordToMotion.Value = _model.SelectedDeviceType.Value != WordToMotionSetting.DeviceTypes.None;
            };
            SelectedDevice = Devices.FirstOrDefault(d => d.Index == _model.SelectedDeviceType.Value);
            //NOTE: シリアライズ文字列はどのみち頻繁に更新せねばならない
            //(並び替えた時とかもUnityにデータ送るために更新がかかる)ので、そのタイミングを使う
            _model.MidiNoteToMotionMapReloaded += (_, __) =>
            {
                if (!_model.IsLoading)
                {
                    LoadMidiSettingItems();
                }
            };
            _model.MotionRequestsReloaded += (_, __) =>
            {
                if (!_model.IsLoading)
                {
                    LoadMotionItems();
                }
            };

            _model.Loaded += (_, __) =>
            {
                LoadMidiSettingItems();
                LoadMotionItems();
            };

            _model.PreviewDataSender.PrepareDataSend +=
                (_, __) => _dialogItem?.WriteToModel(_model.PreviewDataSender.MotionRequest);
            receiver.ReceivedCommand += OnReceiveCommand;

            LoadDefaultItemsIfInitialStart();

            LoadMotionItems();
            LoadMidiSettingItems();
        }
Пример #3
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();
        }