public void SetNextButtonState(UserControl caller, bool enabled) { _wizardControl.SelectedPage.AllowNext = enabled; if (caller is KindOfCollectionControl) { _kindOfCollectionPage.NextPage = _collectionInfo.IsSourceCollection ? _collectionNamePage : _vernacularLanguagePage; if (_collectionInfo.IsSourceCollection) { _collectionInfo.Language1.Iso639Code = "en"; } } if (caller is LanguageIdControl) { var pattern = "{0} Books"; // GetPathForNewSettings uses Path.Combine which can fail with certain characters that are illegal in paths, but not in language names. // The characters we ran into were two pipe characters ("|") at the front of the language name. var tentativeCollectionName = string.Format(pattern, _collectionInfo.Language1.Name); var sanitizedCollectionName = tentativeCollectionName.SanitizePath('.'); _collectionInfo.PathToSettingsFile = CollectionSettings.GetPathForNewSettings(DefaultParentDirectoryForCollections, sanitizedCollectionName); // An earlier version went direct to finish if the proposed name was OK (unless DefaultCollectionPathWouldHaveProblems || (tentativeCollectionName != sanitizedCollectionName)) // but per BL-2649 we now want to always let the user check the name. _languageLocationPage.NextPage = _collectionNamePage; } }
private bool GetNameIsOk() { if (_collectionNameControl.Text.Trim().Length < 1) { return(false); } if (_collectionNameControl.Text.IndexOfAny(Path.GetInvalidFileNameChars()) > -1) { return(false); } _collectionInfo.PathToSettingsFile = CollectionSettings.GetPathForNewSettings(_destinationDirectory, _collectionNameControl.Text); return(!DestinationAlreadyExists && _collectionNameControl.Text.ToLowerInvariant() != "templates"); }