示例#1
0
        private void OnOverwriteNamesCommand()
        {
            var dirtyNames = GetDirtyObjects().Where(obj => obj is AffixedPictureName)
                             .Select(obj => (AffixedPictureName)obj)
                             .ToList();

            var allInvalidNames = dirtyNames.Where(name => !name.ToString()
                                                   .IsValidFileNameAndDoesntExist())
                                  .ToList();

            if (allInvalidNames.Count > 0)
            {
                _messageDialogService.ShowMessage("Invalid file names:",
                                                  string.Join("\r\n", allInvalidNames.Select(name =>
                                                                                             name.ToString())));
                return;
            }

            dirtyNames.RemoveAll(editName =>
            {
                if (_pictureRepository.TryChangePictureName(
                        editName.Picture, editName.ToString()).Success.Value)
                {
                    _eventAggregator.GetEvent <PictureNameChangedEvent>()
                    .Publish(new PictureNameChangePayload()
                    {
                        Guid           = editName.Picture.Guid,
                        NewPictureName = editName.ToString()
                    });

                    EditPictureNames.Remove(editName);

                    return(true);
                }
                else
                {
                    return(false);
                }
            });

            if (dirtyNames.Count > 0)
            {
                _messageDialogService.ShowMessage("Unable to change names for these:",
                                                  string.Join("\r\n", dirtyNames.Select(name =>
                                                                                        name.ToString())));
            }
        }
示例#2
0
 private void OnRemovePictureCommand(int index)
 {
     EditPictureNames.RemoveAt(index);
 }