Пример #1
0
        private void RenameTab()
        {
            Func <string, string> validateFileName = newName => {
                if (string.IsNullOrEmpty(newName))
                {
                    return("Name cannot be left blank.");
                }
                if (newName.Length > 30)
                {
                    return("Name cannot be longer than 30 characters.");
                }

                var notAllowedChars     = Path.GetInvalidFileNameChars();
                var currentInvalidChars = newName.Where(x => notAllowedChars.Contains(x)).Distinct().ToArray();
                if (currentInvalidChars.Length > 0)
                {
                    return($"Name cannot contain {string.Join(" ", currentInvalidChars)}");
                }

                return("");
            };

            RenameViewModel renameVm = null;

            WindowGenerator.CreateAndShowModal(x => renameVm = new RenameViewModel(validateFileName, DocumentVM.FileName.Value, x), false, 100, 350, "#EEEEEE");
            if (string.IsNullOrEmpty(renameVm.ValidationError.Value) && (renameVm.DialogResult ?? false))
            {
                DocumentVM.FileName.Value = renameVm.Name.Value;
            }
        }
Пример #2
0
        private void RenameTab()
        {
            Func<string, string> validateFileName = newName => {
                if (string.IsNullOrEmpty(newName)) return "Name cannot be left blank.";
                if (newName.Length > 30) return "Name cannot be longer than 30 characters.";

                var notAllowedChars = Path.GetInvalidFileNameChars();
                var currentInvalidChars = newName.Where(x => notAllowedChars.Contains(x)).Distinct().ToArray();
                if (currentInvalidChars.Length > 0) return $"Name cannot contain {string.Join(" ", currentInvalidChars)}";

                return "";
            };

            RenameViewModel renameVm = null;
            WindowGenerator.CreateAndShowModal(x => renameVm = new RenameViewModel(validateFileName, DocumentVM.FileName.Value, x), false, 100, 350, "#EEEEEE");
            if(string.IsNullOrEmpty(renameVm.ValidationError.Value) && (renameVm.DialogResult ?? false)) {
                DocumentVM.FileName.Value = renameVm.Name.Value;
            }
        }