private void DoubleClick(object sender, MouseButtonEventArgs e) { System.Windows.Controls.Button sp = sender as System.Windows.Controls.Button; Picture pic = sp.DataContext as Picture; ExtraWindow window = new ExtraWindow(pic, PluginsManager.Instance._plugins); window.Show(); }
private void OpenImageEvent(object sender, RoutedEventArgs e) { Stream myStream = null; System.Windows.Forms.OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Image files (*.gif;*.jpg; *.png)|*.gif;*.jpg;*.png | All files (*.*) | *.*"; openFileDialog1.Title = "Open an image file"; openFileDialog1.ShowDialog(); try { string ext = System.IO.Path.GetExtension(openFileDialog1.FileName); if (ext != ".jpg" && ext != ".gif" && ext != ".png") { System.Windows.MessageBox.Show("Error: Could not open file."); return; } if ((myStream = openFileDialog1.OpenFile()) != null) { BitmapImage bitmap = new BitmapImage(new Uri(openFileDialog1.FileName)); Picture picture = new Picture { image = bitmap, name = openFileDialog1.SafeFileName, creationDate = File.GetCreationTime(openFileDialog1.FileName).ToString(), height = bitmap.PixelHeight, width = bitmap.PixelWidth }; ExtraWindow window = new ExtraWindow(picture, PluginsManager.Instance._plugins); window.Show(); } } catch (Exception ex) { System.Windows.MessageBox.Show("Error: Could not read file. Original error: " + ex.Message); } }