/// <summary> /// Модификация от 15 января 2015 года /// Заложен от 15 января 2015 года /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FiloOpena_Click(object sender, RoutedEventArgs e) { // Create OpenFileDialog Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.InitialDirectory = @"D:\tempo"; dlg.Filter = "MainoImageType (*.png)|*.png|All files (*.*)|*.*"; dlg.FilterIndex = 1; dlg.RestoreDirectory = true; try { // Display OpenFileDialog by calling ShowDialog method Nullable <bool> result = dlg.ShowDialog(); byte[] kartinka; // Get the selected file name and display in a TextBox if (result == true) { // Open document string filename = dlg.FileName; BinaryReader br = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)); int raz = (int)br.BaseStream.Length; kartinka = br.ReadBytes(raz); br.Close(); winpicture = new mypict(kartinka); Bosso.DataContext = winpicture; } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } }
/// <summary> /// Модификация от 21 января 2015 года /// Заложен 21 января 2015 года /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FromoBuffo_Click(object sender, RoutedEventArgs e) { if (Clipboard.ContainsImage()) { BitmapSource cliba = Clipboard.GetImage(); if (cliba != null) { winpicture = new mypict(cliba); Bosso.DataContext = winpicture; } } }
public PictureNew() { winpicture = new mypict(); InitializeComponent(); }