27 lines
648 B
C#
27 lines
648 B
C#
using System;
|
|
using System.IO;
|
|
using Avalonia.Media;
|
|
using Avalonia.Media.Imaging;
|
|
using Avalonia.Platform.Storage;
|
|
|
|
namespace Photos.Models;
|
|
|
|
public class Photo
|
|
{
|
|
public string DisplayName { get; set; }
|
|
public string FullPath { get; set; }
|
|
public string DisplayPath { get; set; }
|
|
|
|
public IImage Source { get; set; }
|
|
|
|
public Photo(string path, string relativeTo)
|
|
{
|
|
DisplayName = System.IO.Path.GetFileName(path);
|
|
FullPath = path;
|
|
DisplayPath = path.Remove(0, relativeTo.Length + 1);
|
|
using (var stream = File.OpenRead(path))
|
|
{
|
|
Source = new Bitmap(stream);
|
|
}
|
|
}
|
|
} |