A list of files (pictures) can be searched and shown in listbox
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using Caliburn.Micro;
|
||||
using ImageHandlingLibrary;
|
||||
using ImageHandlingLibrary.Helpers;
|
||||
using ImageHandlingLibrary.InterFaces;
|
||||
using ImageHandlingUI.ViewModels;
|
||||
using System;
|
||||
@ -33,6 +34,7 @@ namespace ImageHandlingUI
|
||||
|
||||
_container
|
||||
.PerRequest<IRegistring, Registring>()
|
||||
.PerRequest<IDialogs, Dialogs>()
|
||||
.PerRequest<IFiling, Filing>();
|
||||
|
||||
GetType().Assembly.GetTypes()
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,8 +103,13 @@
|
||||
Grid.Row="6" Grid.Column="1"
|
||||
Grid.ColumnSpan="2" Margin="3,3,0,3"
|
||||
MinHeight="300" MinWidth="150"
|
||||
HorizontalAlignment="Left" Width="150">
|
||||
|
||||
HorizontalAlignment="Left" Width="150"
|
||||
ItemsSource="{Binding PicList}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding PictureFileName}"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<!--Row 7-->
|
||||
|
||||
Reference in New Issue
Block a user