Пример #1
0
        private static void OpenFile(object @object)
        {
            var viewModel = @object as ImageListViewModel;

            var dialog = new OpenFileDialog
            {
                Filter           = "Image files (*.jpg)|*.jpg|All Files (*.*)|*.*",
                RestoreDirectory = true,
                Multiselect      = true
            };

            if (dialog.ShowDialog() != true)
            {
                return;
            }

            foreach (var file in dialog.FileNames)
            {
                var imageToBeAdded = new ImageViewModel
                {
                    ImageUrl    = new Uri(file),
                    DisplayName = Guid.NewGuid().ToString()
                };

                viewModel?.ImageListCollection.Add(imageToBeAdded);

                ImageRepository.AddBlobImage(imageToBeAdded);
            }
        }