private void ClearButton_Click(object sender, RoutedEventArgs e) { Button cb = sender as Button; string fieldName = cb.Name.Substring(0, cb.Name.Length - 4); BackupImage img = register[fieldName + UI_ELEMENT_SUFFIX] as BackupImage; img.SetSourceAndBackup(null); Label lab = register[fieldName + "_lab"] as Label; lab.Content = "<No file>"; }
private void BrowseButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); Button bb = sender as Button; ofd.DefaultExt = ".png"; ofd.Filter = "Image Files|*.jpeg;*.png;*.jpg;*.gif|JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"; if (ofd.ShowDialog() == true) { XImage xi = new XImage(ofd.FileName, false); string fieldName = bb.Name.Substring(0, bb.Name.Length - 3); BackupImage img = register[fieldName + UI_ELEMENT_SUFFIX] as BackupImage; img.SetSourceAndBackup(xi); Label lab = register[fieldName + "_lab"] as Label; lab.Content = ofd.FileName.Substring(ofd.FileName.LastIndexOf('\\')); } }