protected override async void OnClosing(CancelEventArgs e) { if (DataContext is ChangeBindPhoneNumberWindowViewModel vm && vm.CurrentStepIsNew && !vm.IsComplete) { // 进入第二步时,如果关闭窗口,则需二次确认 e.Cancel = true; var r = await MessageBoxCompat.ShowAsync(AppResources.UnsavedEditingWillBeDiscarded, AppResources.Warning, MessageBoxButtonCompat.OKCancel); if (r == MessageBoxResultCompat.OK) { vm.IsComplete = true; Close(); } } base.OnClosing(e); }
protected override async void OnClosing(CancelEventArgs e) { if (DataContext is UserProfileWindowViewModel vm && vm.IsModify && !vm.IsComplete) { // 有修改时,如果关闭窗口,则需二次确认 e.Cancel = true; var r = await MessageBoxCompat.ShowAsync(AppResources.UnsavedEditingWillBeDiscarded, AppResources.Warning, MessageBoxButtonCompat.OKCancel); if (r == MessageBoxResultCompat.OK) { vm.IsComplete = true; Close(); } } base.OnClosing(e); }
/// <summary> /// 启动时检测从 V1 版本 迁移配置文件等信息 /// </summary> public static void OnStartFromV1() { return; // 当 2.0 Ready 时取消此行 Task.Run(async() => { try { var s = IStorage.Instance; var examined = await s.GetAsync <bool>(EXAMINED_MIGRATE_FROM_V1); if (!examined) { (var needMigrate, var delete) = CheckV1(); if (needMigrate) { var r = await MessageBoxCompat.ShowAsync( "检测到 V1 版本配置文件," + "如果包含令牌数据,请先手动迁移令牌," + "如果不存在令牌数据则可直接删除,是否直接删除?", "警告", MessageBoxButtonCompat.OKCancel, MessageBoxImageCompat.Warning); if (r == MessageBoxResultCompat.OK) { delete(); // 执行迁移成功后,在AppData下写入文件或写入键值对中的一个标记 // 下次启动检查标记,跳过迁移 await s.SetAsync(EXAMINED_MIGRATE_FROM_V1, true); } } } } catch (Exception e) { Log.Error(nameof(Migrations), e, nameof(OnStartFromV1)); } }); }