예제 #1
0
        private void ExecuteNewFolderCommand()
        {
            var items      = SourcePane.Items.Select(item => item.Name).ToList();
            var wkDirs     = DirectoryStructure.WellKnownDirectoriesOf(SourcePane.CurrentFolder.Path);
            var suggestion = wkDirs.Where(d => !items.Contains(d)).Select(d => new InputDialogOptionViewModel
            {
                Value       = d,
                DisplayName = TitleRecognizer.GetTitle(d)
            }).ToList();

            var name = WindowManager.ShowTextInputDialog(Resx.AddNewFolder, Resx.FolderName + Strings.Colon, string.Empty, suggestion);

            if (name == null)
            {
                return;
            }
            name = name.Trim();
            if (name == string.Empty)
            {
                WindowManager.ShowMessage(Resx.AddNewFolder, Resx.CannotCreateFolderWithNoName);
                return;
            }
            //var invalidChars = Path.GetInvalidFileNameChars();
            //if (invalidChars.Any(name.Contains))
            //{
            //    WindowManager.ShowMessage(Resx.AddNewFolder, Resx.CannotCreateFolderWithInvalidCharacters);
            //    return;
            //}
            var path = string.Format("{0}{1}", SourcePane.CurrentFolder.Path, name);

            WorkHandler.Run(() => SourcePane.CreateFolder(path), result => NewFolderSuccess(result, name), NewFolderError);
        }