Here’s an example video of displaying a part image in a dashboard customization. The same idea can be applied to any screen or image type.
And of course the code:
public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
private EpiDataView edvV_PartImage_1View;
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
Erp.Adapters.ImageAdapter imageAdapter;
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
this.edvV_PartImage_1View = ((EpiDataView)(this.oTrans.EpiDataViews["V_PartImage_1View"]));
this.edvV_PartImage_1View.EpiViewNotification += new EpiViewNotification(this.edvV_PartImage_1View_EpiViewNotification);
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
// End Wizard Added Custom Method Calls
imageAdapter = new Erp.Adapters.ImageAdapter(oTrans);
imageAdapter.BOConnect();
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.edvV_PartImage_1View.EpiViewNotification -= new EpiViewNotification(this.edvV_PartImage_1View_EpiViewNotification);
this.edvV_PartImage_1View = null;
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
imageAdapter.Dispose();
imageAdapter = null;
// End Custom Code Disposal
}
private void edvV_PartImage_1View_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
// ** Argument Properties and Uses **
// view.dataView[args.Row]["FieldName"]
// args.Row, args.Column, args.Sender, args.NotifyType
// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
{
if ((args.Row > -1))
{
var imageBytes = imageAdapter.GetOriginalImage(view.dataView[args.Row]["Image_ImageID"].ToString());
System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBytes);
partIb.Image = System.Drawing.Image.FromStream(ms);
}
}
}