8. April 2010 08:50
private void img_Drop(object sender, DragEventArgs e)
{
//Einstiegspunkt für Datenübergabe
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] filename;
filename = (string[])e.Data.GetData(DataFormats.FileDrop);
BitmapImage bi2 = new BitmapImage();
//MessageBox.Show(filename[0]);
bi2.BeginInit();
bi2.StreamSource = File.OpenRead(filename[0]);
bi2.EndInit();
img.Source = bi2;
}
}
public object Value
{
get
{
return this._myPicturebox.GetImage();
}
set
{
if (value is byte[])
{
byte[] data = (byte[])value;
/// Specifies that the data loads only once so that data cannot load while the the user is drawing.
if (data != null && !this._loaded)
{
this._myPicturebox.SetImage(data);
this._loaded = true;
}
}
}
}
8. April 2010 19:27
9. April 2010 11:52
public interface IControlAddInSite
{
void SaveValues();
}
12. April 2010 08:38
13. April 2010 10:15
public class PictureViewer : WinFormsControlAddInBase, IObjectControlAddInDefinition, IControlAddInSite
public void SaveValue()
{
MyPictureBox _picture = new MyPictureBox();
Value = _picture.GetImage();
/*
BitmapImage bi3 = new BitmapImage();
//MessageBox.Show(filename[0]);
bi3.BeginInit();
bi3.StreamSource = File.OpenRead("C:\\meinBild.bmp");
bi3.EndInit();
Value = bi3;
MessageBox.Show("Erfolgreich hochgeladen");
*/
}
private void img_Drop(object sender, DragEventArgs e)
{
//Einstiegspunkt für Datenübergabe
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] filename;
filename = (string[])e.Data.GetData(DataFormats.FileDrop);
bi2.BeginInit();
bi2.StreamSource = File.OpenRead(filename[0]);
bi2.EndInit();
img.Source = bi2;
//pv.Value = bi2;
pv.SaveValue();
//PictureViewer.IControlAddInSite.SaveValues();
}
}
public BitmapImage GetImage()
{
return bi2;
}
13. April 2010 14:09
13. April 2010 14:54
13. April 2010 19:39
14. April 2010 13:50
public object Value
{
get
{
//return Value;
throw new NotImplementedException();
}
set
{
if (value is byte[])
{
byte[] data = (byte[])value;
/// Specifies that the data loads only once so that data cannot load while the the user is drawing.
if (data != null && !this._loaded)
{
this._myPicturebox.SetImage(data);
this._loaded = true;
}
}
//BitmapImage bmpresult = new BitmapImage();
//bmpresult = this._myPicturebox.GetImage();
//byte[] pictureresult = new byte[bmpresult.PixelWidth * bmpresult.PixelHeight * 4];
//bmpresult.CopyPixels(pictureresult, ((bmpresult.PixelWidth * bmpresult.Format.BitsPerPixel) + 7) / 8, 0);
//Value = pictureresult;
//Value = value;
}
}
public override string Value
{
get
{
return base.Value;
}
set
{
base.Value = value;
if (this.control != null)
{
this.control.Text = value;
if (File.Exists(Value))
{
control.Image = Image.FromFile(Value);
control.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
control.MinimumSize = new Size(control.Image.Width, control.Image.Height);
control.MaximumSize = new Size(control.Image.Width, control.Image.Height);
ImageState = ImageState + 1;
}
}
}
}
16. April 2010 08:37
28. April 2010 15:53
8. Mai 2010 11:17