private void RenameDialog_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e) { if (Item.IsOfType(StorageItemTypes.File)) { if (Item.Name != Path.GetExtension(Item.Name)) { RenameText.Select(0, Item.Name.Length - Path.GetExtension(Item.Name).Length); } } else { RenameText.SelectAll(); } }
private async void RenameDialog_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e) { DesireNameMap.Clear(); if (RenameItems.Count() > 1) { FileSystemStorageItemBase BaseItem = RenameItems.First(); StorageItemTypes BaseTypes = BaseItem switch { FileSystemStorageFile => StorageItemTypes.File, FileSystemStorageFolder => StorageItemTypes.Folder, _ => StorageItemTypes.None }; HashSet <string> ExceptPath = new HashSet <string>(); List <string> StringArray = new List <string>(); foreach (string Name in RenameItems.Select((Item) => Item.Name)) { string UniquePath = await GenerateUniquePath(BaseItem.Path, BaseTypes, ExceptPath); ExceptPath.Add(UniquePath); StringArray.Add($"{Name}\r⋙⋙ ⋙⋙ ⋙⋙\r{Path.GetFileName(UniquePath)}"); DesireNameMap.Add(Name, Path.GetFileName(UniquePath)); } Preview.Text = string.Join(Environment.NewLine + Environment.NewLine, StringArray); } else { string OriginName = RenameItems.First().Name; DesireNameMap.Add(OriginName, OriginName); Preview.Text = $"{OriginName}\r⋙⋙ ⋙⋙ ⋙⋙\r{OriginName}"; } if (RenameItems.First() is FileSystemStorageFile File) { if (File.Name != Path.GetExtension(File.Name)) { RenameText.Select(0, File.Name.Length - Path.GetExtension(File.Name).Length); } } else { RenameText.SelectAll(); } }