public async Task ExecuteLoad(int index) { if (index < 0 || index > SaveFileManager.FileCount || !_model.CheckFileExist(index)) { return; } //NOTE: オートセーブのデータに関しても、ここを通るケースではスロットのファイルと同格に扱う事に注意 var indication = MessageIndication.ConfirmSettingFileLoad(); var result = await MessageBoxWrapper.Instance.ShowAsync( indication.Title, string.Format(indication.Content, index), MessageBoxWrapper.MessageBoxStyle.OKCancel ); if (!result) { return; } //NOTE: コケる事も考えられるんだけど判別がムズいんですよね… SnackbarWrapper.Enqueue(string.Format( LocalizedString.GetString("SettingFile_LoadCompleted"), index )); //NOTE: ロードが先だとVRoidのロード時にダイアログがうまく閉じないため、先に閉じる _actToClose(); _model.LoadSetting( index, LoadCharacterWhenSettingLoaded.Value, LoadNonCharacterWhenSettingLoaded.Value, false ); //NOTE: Loadでは必ず非nullのはず。ここで設定を覚えることで、次回以降もロード設定のチェックが残る if (_rootModel != null) { _rootModel.LoadCharacterWhenLoadInternalFile.Value = LoadCharacterWhenSettingLoaded.Value; _rootModel.LoadNonCharacterWhenLoadInternalFile.Value = LoadNonCharacterWhenSettingLoaded.Value; } }
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); }