Exemplo n.º 1
0
        internal SettingIoViewModel(
            RootSettingSync rootModel, AutomationSettingSync model, SaveFileManager saveFileManager, IMessageSender sender
            ) : base(sender)
        {
            _rootModel       = rootModel;
            _model           = model;
            _saveFileManager = saveFileManager;

            OpenInstructionUrlCommand       = new ActionCommand(OpenInstructionUrl);
            RequestEnableAutomationCommand  = new ActionCommand(OnEnableAutomationRequested);
            RequestDisableAutomationCommand = new ActionCommand(OnDisableAutomationRequested);
            ApplyPortNumberCommand          = new ActionCommand(ApplyPortNumber);

            ShowSaveModalCommand = new ActionCommand(ShowSaveModal);
            ShowLoadModalCommand = new ActionCommand(ShowLoadModal);

            ExportSettingToFileCommand   = new ActionCommand(SaveSettingToFile);
            ImportSettingFromFileCommand = new ActionCommand(LoadSettingFromFile);

            AutomationPortNumberText = new RProperty <string>(
                _model.AutomationPortNumber.Value.ToString(), v =>
            {
                //フォーマット違反になってないかチェック
                PortNumberIsInvalid.Value = !(int.TryParse(v, out int i) && i >= 0 && i < 65536);
            });

            _model.AutomationPortNumber.PropertyChanged += (_, __) =>
            {
                AutomationPortNumberText.Value = _model.AutomationPortNumber.Value.ToString();
            };
        }
        private SaveLoadDataViewModel(RootSettingSync?rootModel, SaveFileManager model, bool isLoadMode, Action actToClose)
        {
            _rootModel    = rootModel;
            _model        = model;
            _actToClose   = actToClose;
            Items         = new ReadOnlyObservableCollection <SaveLoadFileItemViewModel>(_items);
            CancelCommand = new ActionCommand(CloseDialog);

            //NOTE: SaveモードではUIも出ないし何も使わない値なのでfalseのまま放置しとけばOK、という値
            LoadCharacterWhenSettingLoaded
                = new RProperty <bool>(_rootModel?.LoadCharacterWhenLoadInternalFile?.Value ?? false);
            LoadNonCharacterWhenSettingLoaded
                = new RProperty <bool>(_rootModel?.LoadNonCharacterWhenLoadInternalFile?.Value ?? false);

            IsLoadMode = isLoadMode;
            Refresh();
        }
Exemplo n.º 3
0
        public MainWindowViewModel()
        {
            Model           = new RootSettingSync(MessageSender, MessageIo.Receiver);
            SettingFileIo   = new SettingFileIo(Model, MessageSender);
            SaveFileManager = new SaveFileManager(SettingFileIo, Model, MessageSender);

            WindowSetting          = new WindowSettingViewModel(Model.Window, MessageSender);
            MotionSetting          = new MotionSettingViewModel(Model.Motion, MessageSender, MessageIo.Receiver);
            GamepadSetting         = new GamepadSettingViewModel(Model.Gamepad, MessageSender);
            LayoutSetting          = new LayoutSettingViewModel(Model.Layout, Model.Gamepad, MessageSender, MessageIo.Receiver);
            LightSetting           = new LightSettingViewModel(Model.Light, MessageSender);
            WordToMotionSetting    = new WordToMotionSettingViewModel(Model.WordToMotion, MessageSender, MessageIo.Receiver);
            ExternalTrackerSetting = new ExternalTrackerViewModel(Model.ExternalTracker, Model.Motion, MessageSender, MessageIo.Receiver);
            SettingIo = new SettingIoViewModel(Model, Model.Automation, SaveFileManager, MessageSender);
            //オートメーションの配線: 1つしかないのでザツにやる。OC<T>をいじる関係でUIスレッド必須なことに注意
            Model.Automation.LoadSettingFileRequested += v =>
                                                         Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                                                        () => SaveFileManager.LoadSetting(v.Index, v.LoadCharacter, v.LoadNonCharacter, true))
                                                                                                    );

            _runtimeHelper = new RuntimeHelper(MessageSender, MessageIo.Receiver, Model);

            LoadVrmCommand           = new ActionCommand(LoadVrm);
            LoadVrmByFilePathCommand = new ActionCommand <string>(LoadVrmByFilePath);
            ConnectToVRoidHubCommand = new ActionCommand(ConnectToVRoidHubAsync);

            OpenVRoidHubCommand      = new ActionCommand(() => UrlNavigate.Open("https://hub.vroid.com/"));
            AutoAdjustCommand        = new ActionCommand(() => MessageSender.SendMessage(MessageFactory.Instance.RequestAutoAdjust()));
            OpenSettingWindowCommand = new ActionCommand(() => SettingWindow.OpenOrActivateExistingWindow(this));

            ResetToDefaultCommand  = new ActionCommand(ResetToDefault);
            LoadPrevSettingCommand = new ActionCommand(LoadPrevSetting);

            TakeScreenshotCommand       = new ActionCommand(_runtimeHelper.TakeScreenshot);
            OpenScreenshotFolderCommand = new ActionCommand(_runtimeHelper.OpenScreenshotSavedFolder);

            MessageIo.Receiver.ReceivedCommand      += OnReceiveCommand;
            SaveFileManager.VRoidModelLoadRequested += id => LoadSavedVRoidModel(id, false);
        }
 internal static SaveLoadDataViewModel CreateForLoad(RootSettingSync rootModel, SaveFileManager model, Action actToClose)
 => new SaveLoadDataViewModel(rootModel, model, true, actToClose);
        //NOTE: セーブとロードで必要な素材が微妙に違うのでファクトリで作ります

        internal static SaveLoadDataViewModel CreateForSave(SaveFileManager model, Action actToClose)
        => new SaveLoadDataViewModel(null, model, false, actToClose);