diff --git a/ImageHandlingUI/ImageHandlingWPFUI.csproj b/ImageHandlingUI/ImageHandlingWPFUI.csproj index 30e69a6..adc12a9 100644 --- a/ImageHandlingUI/ImageHandlingWPFUI.csproj +++ b/ImageHandlingUI/ImageHandlingWPFUI.csproj @@ -46,6 +46,7 @@ + ..\packages\Caliburn.Micro.3.2.0\lib\net45\System.Windows.Interactivity.dll diff --git a/ImageHandlingUI/ViewModels/ShellViewModel.cs b/ImageHandlingUI/ViewModels/ShellViewModel.cs index 3c4710e..b74ece7 100644 --- a/ImageHandlingUI/ViewModels/ShellViewModel.cs +++ b/ImageHandlingUI/ViewModels/ShellViewModel.cs @@ -1,14 +1,71 @@ using Caliburn.Micro; using System; using System.Collections.Generic; +using System.Drawing.Imaging; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Imaging; namespace ImageHandlingUI.ViewModels { public class ShellViewModel : Conductor { - + public ShellViewModel() + { + //using (var ms = new MemoryStream()) + //{ + // System.Drawing.Image.FromFile(@"D:\CsharpDevelop\PictureHandlingProject\pictures\AgueroVillage.JPG").Save(ms, ImageFormat.Bmp); + // ms.Seek(0, SeekOrigin.Begin); + + // var bitmapImage = new BitmapImage(); + // bitmapImage.BeginInit(); + // bitmapImage.CacheOption = BitmapCacheOption.OnLoad; + // bitmapImage.StreamSource = ms; + // bitmapImage.EndInit(); + + // _selectedImage = bitmapImage; + //} + + //_selectedImage = System.Drawing.Image.FromFile(@"D:\CsharpDevelop\PictureHandlingProject\pictures\AgueroVillage.JPG"); + + initialFileName = @"D:\CsharpDevelop\PictureHandlingProject\pictures\AgueroVillage.JPG"; + _selectedImage = ConvertFromDrawImage(System.Drawing.Image.FromFile(InitialFileName)); + } + ImageSource _selectedImage = null; + private string initialFileName; + + public ImageSource SelectedImage + { + get { return _selectedImage; } + set + { + _selectedImage = value; + NotifyOfPropertyChange(() => SelectedImage); + } + } + + public string InitialFileName { get => initialFileName; set => initialFileName = value; } + + private static BitmapImage ConvertFromDrawImage(System.Drawing.Image _image) + { + using (var ms = new MemoryStream()) + { + //System.Drawing.Image.FromFile(@"D:\CsharpDevelop\PictureHandlingProject\pictures\AgueroVillage.JPG").Save(ms, ImageFormat.Bmp); + _image.Save(ms, ImageFormat.Bmp); + ms.Seek(0, SeekOrigin.Begin); + + var bitmapImage = new BitmapImage(); + bitmapImage.BeginInit(); + bitmapImage.CacheOption = BitmapCacheOption.OnLoad; + bitmapImage.StreamSource = ms; + bitmapImage.EndInit(); + + return bitmapImage; + } + } } } diff --git a/ImageHandlingUI/Views/ShellView.xaml b/ImageHandlingUI/Views/ShellView.xaml index 3935b6c..23fcbda 100644 --- a/ImageHandlingUI/Views/ShellView.xaml +++ b/ImageHandlingUI/Views/ShellView.xaml @@ -4,9 +4,124 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:ImageHandlingUI.Views" FontSize="12" - mc:Ignorable="d" WindowStartupLocation="CenterScreen" - Title="ShellView" Height="450" Width="800"> + mc:Ignorable="d" WindowStartupLocation="CenterScreen" + Title="ShellView" Height="650" Width="800" Background="Beige"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Picture handling + + + + + Filnamn + + + + + + Path + + + + Skapad + + + + + + GrundPath + + + + Slutpath + + + + + + + + + + + + + + + + + + + + + + + Ny Rotkatalog + + + diff --git a/pictures/AgueroVillage.JPG b/pictures/AgueroVillage.JPG new file mode 100644 index 0000000..0c53043 Binary files /dev/null and b/pictures/AgueroVillage.JPG differ