A list of files (pictures) can be searched and shown in listbox

This commit is contained in:
2020-08-02 23:28:42 +02:00
parent 6949a7ba33
commit 4e56dadd25
8 changed files with 236 additions and 10 deletions

View File

@ -1,5 +1,6 @@
using Caliburn.Micro;
using ImageHandlingLibrary.InterFaces;
using ImageHandlingLibrary.Models;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
@ -9,6 +10,7 @@ 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;
@ -19,16 +21,22 @@ namespace ImageHandlingUI.ViewModels
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)
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;
}
@ -47,29 +55,64 @@ namespace ImageHandlingUI.ViewModels
public string RootCatalog
{
get {
get
{
_rootCatalog = _registring.GetRegistryRootDir();
return _rootCatalog;
return _rootCatalog;
}
set
{
if (value != _rootCatalog)
{
_registring.SetRegistryValues(value);
}
_rootCatalog = value; }
}
_rootCatalog = value;
}
}
private string _groundPath;
public string GroundPath
{
get {
get
{
_groundPath = _filing.ShowText();
return _groundPath;
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; }
}
}
}