using System;
using Views;
using System.IO;
class PhotoAlbum {
///
/// Photo Album program Bishop and Horspool Jan 2003
/// ===================
/// Displays jpg images from a disk
/// Image names have form A:\001.jpg
/// or they can be read off file dialogues.
/// Illustrates dialogue and PutImage()
///
string spec = @"
";
void Go() {
Views.Form f = new Views.Form(spec);
int n = 1;
string filename = null;
for (;;) {
string c = f.GetControl();
if (c == null) break;
switch (c) {
case "next" :
string photo = String.Format("{0:D3}",n);
filename = "A:\\"+photo+".jpg";
if (!File.Exists(filename)) break;
f.PutImage("photo",filename);
n++;
break;
case "Select a photo" :
filename = f.GetText("Select a photo");
f.PutImage("photo",filename);
break;
case "Save as":
string savename = f.GetText("Save as");
OpenAndSave(filename,savename);
break;
}
}
f.CloseGUI();
}
void OpenAndSave(string source, string target) {
File.Copy(source,target,true);
}
static void Main() {
new PhotoAlbum().Go();
}
}