Пример #1
0
        private async Task ChangeBuildsSavePath()
        {
            var dialogSettings = new FileSelectorDialogSettings
            {
                DefaultPath       = Options.BuildsSavePath,
                IsFolderPicker    = true,
                ValidationSubPath = SerializationConstants.EncodedDefaultBuildName
            };
            var path = await _dialogCoordinator.ShowFileSelectorAsync(this,
                                                                      L10n.Message("Select build directory"),
                                                                      L10n.Message("Select the directory where builds will be stored.\n" +
                                                                                   "It will be created if it does not yet exist."),
                                                                      dialogSettings);

            if (path == null)
            {
                return;
            }

            var message = L10n.Message("There are unsaved builds. Do you want to save them before changing build directory?\n\n"
                                       + "If you cancel, the build directory will not be changed.");

            if (!await _buildsControlViewModel.HandleUnsavedBuilds(message, true))
            {
                return;
            }
            _persistentData.SaveFolders();

            Options.BuildsSavePath = path;
            await _persistentData.ReloadBuildsAsync();
        }
        /// <summary>
        /// Changes the stat tracking path.
        /// </summary>
        /// <returns></returns>
        private async Task ChangeStatTrackingPath()
        {
            var dialogSettings = new FileSelectorDialogSettings
            {
                DefaultPath       = StatTrackingSavePath,
                IsFolderPicker    = true,
                ValidationSubPath = SerializationConstants.EncodedDefaultBuildName
            };
            var path = await _dialogCoordinator.ShowFileSelectorAsync(this,
                                                                      L10n.Message("Select TrackedStat directory"),
                                                                      L10n.Message("Select the directory where builds will be stored.\n" +
                                                                                   "It will be created if it does not yet exist."),
                                                                      dialogSettings);

            if (path == null)
            {
                return;
            }

            StatTrackingSavePath = path;
        }
Пример #3
0
        public async Task InitializeAsync(IDialogCoordinator dialogCoordinator)
        {
            DialogCoordinator = dialogCoordinator;
            if (PersistentData.Options.BuildsSavePath == null)
            {
                if (AppData.IsPortable)
                {
                    PersistentData.Options.BuildsSavePath = AppData.GetFolder("Builds");
                }
                else
                {
                    // Ask user for path. Default: AppData.GetFolder("Builds")
                    var dialogSettings = new FileSelectorDialogSettings
                    {
                        DefaultPath       = AppData.GetFolder("Builds"),
                        IsFolderPicker    = true,
                        ValidationSubPath = GetLongestRequiredSubpath(),
                        IsCancelable      = false
                    };
                    if (!DeserializesBuildsSavePath)
                    {
                        dialogSettings.AdditionalValidationFunc =
                            path => Directory.Exists(path) && Directory.EnumerateFileSystemEntries(path).Any()
                                ? L10n.Message("Directory must be empty.")
                                : null;
                    }
                    PersistentData.Options.BuildsSavePath = await dialogCoordinator.ShowFileSelectorAsync(PersistentData,
                                                                                                          L10n.Message("Select build directory"),
                                                                                                          L10n.Message("Select the directory where builds will be stored.\n" +
                                                                                                                       "It will be created if it does not yet exist. You can change it in the settings later."),
                                                                                                          dialogSettings);
                }
            }
            Directory.CreateDirectory(PersistentData.Options.BuildsSavePath);
            await DeserializeAdditionalFilesAsync();

            PersistentData.EquipmentData = await DeserializeEquipmentData();

            PersistentData.StashItems.AddRange(await DeserializeStashItemsAsync());
        }
 public async Task InitializeAsync(IDialogCoordinator dialogCoordinator)
 {
     DialogCoordinator = dialogCoordinator;
     if (PersistentData.Options.BuildsSavePath == null)
     {
         if (AppData.IsPortable)
         {
             PersistentData.Options.BuildsSavePath = AppData.GetFolder("Builds");
         }
         else
         {
             // Ask user for path. Default: AppData.GetFolder("Builds")
             var dialogSettings = new FileSelectorDialogSettings
             {
                 DefaultPath = AppData.GetFolder("Builds"),
                 IsFolderPicker = true,
                 ValidationSubPath = GetLongestRequiredSubpath(),
                 IsCancelable = false
             };
             if (!DeserializesBuildsSavePath)
             {
                 dialogSettings.AdditionalValidationFunc =
                     path => Directory.Exists(path) && Directory.EnumerateFileSystemEntries(path).Any()
                         ? L10n.Message("Directory must be empty.")
                         : null;
             }
             PersistentData.Options.BuildsSavePath = await dialogCoordinator.ShowFileSelectorAsync(PersistentData,
                 L10n.Message("Select build directory"),
                 L10n.Message("Select the directory where builds will be stored.\n" +
                              "It will be created if it does not yet exist. You can change it in the settings later."),
                 dialogSettings);
         }
     }
     Directory.CreateDirectory(PersistentData.Options.BuildsSavePath);
     await DeserializeAdditionalFilesAsync();
     PersistentData.EquipmentData = await DeserializeEquipmentData();
     PersistentData.StashItems.AddRange(await DeserializeStashItemsAsync());
 }