public async Task ExecuteSave(int index)
        {
            if (index <= 0 || index > SaveFileManager.FileCount)
            {
                return;
            }

            //上書き保存があり得るので確認を挟む。
            //初セーブの場合は上書きにならないが、「次から上書きになるで」の意味で出しておく
            var indication = MessageIndication.ConfirmSettingFileSave();
            var result     = await MessageBoxWrapper.Instance.ShowAsync(
                indication.Title,
                string.Format(indication.Content, index),
                MessageBoxWrapper.MessageBoxStyle.OKCancel
                );

            if (!result)
            {
                return;
            }

            _model.SaveCurrentSetting(index);

            //ファイルレベルの処理なので流石にスナックバーくらい出しておく(ロードとかインポート/エクスポートも同様)
            SnackbarWrapper.Enqueue(string.Format(
                                        LocalizedString.GetString("SettingFile_SaveCompleted"), index
                                        ));

            //ロードと違い、ダイアログは閉じず、代わりに更新時刻が変わった所を見に行く
            _ = Application.Current.Dispatcher.BeginInvoke(new Action(() => Refresh()));
        }
Esempio n. 2
0
        private void LoadSettingFromFile()
        {
            var dialog = new OpenFileDialog()
            {
                Title       = "Load VMagicMirror Setting",
                Filter      = "VMagicMirror Setting File (*.vmm)|*.vmm",
                Multiselect = false,
            };

            if (dialog.ShowDialog() == true)
            {
                _saveFileManager.SettingFileIo.LoadSetting(dialog.FileName, SettingFileReadWriteModes.Exported);
                SnackbarWrapper.Enqueue(LocalizedString.GetString("SettingFile_LoadCompleted_ExportedFile"));
            }
        }
Esempio n. 3
0
        private void SaveSettingToFile()
        {
            var dialog = new SaveFileDialog()
            {
                Title        = "Save VMagicMirror Setting",
                Filter       = "VMagicMirror Setting File(*.vmm)|*.vmm",
                DefaultExt   = ".vmm",
                AddExtension = true,
            };

            if (dialog.ShowDialog() == true)
            {
                _saveFileManager.SettingFileIo.SaveSetting(dialog.FileName, SettingFileReadWriteModes.Exported);
                SnackbarWrapper.Enqueue(LocalizedString.GetString("SettingFile_SaveCompleted_ExportedFile"));
            }
        }
        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;
            }
        }