July 2008
Intermediate to advanced
480 pages
11h 50m
English
To support the user interface, you need a set of simple business classes representing the photographs and the items the user can purchase based on each photo. These are collected in the StoreItems.cs file, shown in Example 4-2.
Example 4-2. StoreItems.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Media.Imaging;
using System.Collections.Specialized;
using System.Windows.Controls;
namespace PhotoCooperative
{
public class ImageFile
{
public String Path { get; set; }
public Uri TheUri { get; set; }
public BitmapFrame Image { get; set; }
public ImageFile(string path)
{
Path = path;
TheUri = new Uri(Path);
Image = BitmapFrame.Create(TheUri);
}
public override string ToString()
{
return Path;
}
}
public class PhotoList : ObservableCollection<Image File> { DirectoryInfo theDirectoryInfo; public PhotoList() { } public PhotoList(string path) : this(new DirectoryInfo(path)) { } public PhotoList(DirectoryInfo directory) { theDirectoryInfo = directory; Update(); } public string Path { set { theDirectoryInfo = new DirectoryInfo(value); Update(); } get { return theDirectoryInfo.FullName; } } public DirectoryInfo Directory { set { theDirectoryInfo = value; Update(); } get { return theDirectoryInfo; } } private void Update() { foreach (FileInfo f in theDirectoryInfo.GetFiles("*.gif")) { Add(new ImageFile(f.FullName)); } } } public class PrintType { public ...Read now
Unlock full access