Here are a few snippets of relevant source code from the demo:public partial class Window1 : Window { private ImageCollection _foundImages = null; private string[] _exifProperties = new string[] { "System.Photo.CameraManufacturer", "System.Photo.CameraModel", "System.Photo.FNumber", "System.Photo.ExposureTime", "System.Photo.FocalLength", "System.Photo.ExposureBias", "System.Photo.MeteringMode", "System.Photo.ColorSpace"};
private string[] _generalProperties = new string[] { "System.Author", "System.Keywords", "System.File.Description"};
private void OnSearch(object sender, RoutedEventArgs e) { string indexerConnString = "provider=Search.CollatorDSO.1;EXTENDED PROPERTIES=\"Application=Windows\""; using (OleDbConnection conn = new OleDbConnection(indexerConnString)) { conn.Open(); string keywordValue = SearchBox.Text;
_foundImages.Clear(); GetImageFileResults(keywordValue, conn); ImageListBox.DataContext = _foundImages; } }
private void GetImageFileResults(string keywordValue, OleDbConnection conn) {
try { System.Collections.Hashtable checkNames = new System.Collections.Hashtable();
string sqlString = "Select \"System.Title\", " + "\"System.DisplayFolder\", \"System.DisplayName\" " + "FROM systemindex..scope() " + "WHERE FREETEXT(\"System.CanonicalType\", 'JPG') "/* + "AND CONTAINS(\"System.Path\", 'file:')"*/; if (!string.IsNullOrEmpty(keywordValue)) { sqlString += " AND (\"System.Keywords\" = SOME ARRAY ['" + keywordValue + "'])"; }
OleDbCommand cmd = new OleDbCommand(sqlString, conn);
using (OleDbDataReader reader = cmd.ExecuteReader()) {
while (reader.Read()) { ImageInfo imageInfo = new ImageInfo(); imageInfo.Title = reader.GetString(0); string folder = reader.GetString(1); string name = reader.GetString(2); // workaround to ignore non-files if (folder.Length < 2 || folder[1] != ':') continue; imageInfo.ImagePath = System.IO.Path.Combine( folder, name); // Workaround to ignore peculiar files on non-existent // volumes that build 5365 seems to return. if (!System.IO.File.Exists(imageInfo.ImagePath)) continue; if (imageInfo.ImagePath.Contains("Temporary Internet Files")) continue; if (checkNames.ContainsKey(imageInfo.Title)) { int index = (int)checkNames[(string)imageInfo.Title];
if (_foundImages[index] != null) { if (_foundImages[index].Variations == null) { ImageCollection variationCollection = new ImageCollection(); variationCollection.Add(imageInfo); _foundImages[index].Variations = variationCollection; } else { _foundImages[index].Variations.Add(imageInfo); } }
} else { imageInfo.Variations = new ImageCollection(); imageInfo.Variations.Add(imageInfo); int currentIndex = _foundImages.Count; checkNames.Add(imageInfo.Title, currentIndex); _foundImages.Add(imageInfo);
} }
} } catch (OleDbException) { // Not finding any results is ok. }
footballism wrote:Good to see Ian's awesome screencast, but where can I get the source code of demo app shown in the video?Sheva
btw, how to extract/change metadata from files in Vista? EDIT: nevermind