119 lines
3.1 KiB
C#
119 lines
3.1 KiB
C#
using Caliburn.Micro;
|
|
using ImageHandlingLibrary.InterFaces;
|
|
using ImageHandlingLibrary.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing.Imaging;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
|
|
namespace ImageHandlingUI.ViewModels
|
|
{
|
|
public class ShellViewModel : Conductor<object>
|
|
{
|
|
private string _rootCatalog;
|
|
private readonly IRegistring _registring;
|
|
private readonly IFiling _filing;
|
|
private readonly IDialogs _dialogs;
|
|
private string initialFileName;
|
|
ImageSource _selectedImage = null;
|
|
private List<FileInfo> fileInfos;
|
|
private bool canChooseFile = true;
|
|
private BindableCollection<LocalPicture> picList = new BindableCollection<LocalPicture>();
|
|
|
|
|
|
public ShellViewModel(IRegistring registring, IFiling filing, IDialogs dialogs)
|
|
{
|
|
|
|
initialFileName = @"D:\CsharpDevelop\PictureHandlingProject\pictures\AgueroVillage.JPG";
|
|
_selectedImage = filing.ConvertFromDrawImage(System.Drawing.Image.FromFile(InitialFileName));
|
|
_registring = registring;
|
|
_filing = filing;
|
|
_dialogs = dialogs;
|
|
}
|
|
|
|
|
|
public ImageSource SelectedImage
|
|
{
|
|
get { return _selectedImage; }
|
|
set
|
|
{
|
|
_selectedImage = value;
|
|
NotifyOfPropertyChange(() => SelectedImage);
|
|
}
|
|
}
|
|
|
|
public string InitialFileName { get => initialFileName; set => initialFileName = value; }
|
|
|
|
|
|
public string RootCatalog
|
|
{
|
|
get
|
|
{
|
|
_rootCatalog = _registring.GetRegistryRootDir();
|
|
return _rootCatalog;
|
|
}
|
|
set
|
|
{
|
|
if (value != _rootCatalog)
|
|
{
|
|
_registring.SetRegistryValues(value);
|
|
}
|
|
_rootCatalog = value;
|
|
}
|
|
}
|
|
|
|
private string _groundPath;
|
|
|
|
public string GroundPath
|
|
{
|
|
get
|
|
{
|
|
_groundPath = _filing.ShowText();
|
|
return _groundPath;
|
|
}
|
|
set { _groundPath = value; }
|
|
}
|
|
|
|
|
|
|
|
public bool CanChooseFile
|
|
{
|
|
get { return canChooseFile; }
|
|
set { canChooseFile = value; }
|
|
}
|
|
|
|
|
|
public void ChooseFile()
|
|
{
|
|
fileInfos = _dialogs.ChooseFiles();
|
|
if (fileInfos.Count > 0)
|
|
{
|
|
//Cursor.Current = Cursors.WaitCursor;
|
|
var localPicList = _filing.CreateListBoxDataSource(fileInfos, _rootCatalog);
|
|
foreach (var lPicture in localPicList)
|
|
{
|
|
picList.Add(lPicture);
|
|
}
|
|
NotifyOfPropertyChange(() => PicList);
|
|
}
|
|
}
|
|
|
|
|
|
public BindableCollection<LocalPicture> PicList
|
|
{
|
|
get { return picList; }
|
|
set { picList = value; }
|
|
}
|
|
|
|
|
|
}
|
|
}
|