|  | @@ -7,6 +7,7 @@ using System.Linq.Expressions;
 | 
	
		
			
				|  |  |  using System.Windows;
 | 
	
		
			
				|  |  |  using System.Windows.Controls;
 | 
	
		
			
				|  |  |  using System.Windows.Media.Imaging;
 | 
	
		
			
				|  |  | +using System.Windows.Threading;
 | 
	
		
			
				|  |  |  using InABox.Clients;
 | 
	
		
			
				|  |  |  using InABox.Core;
 | 
	
		
			
				|  |  |  using InABox.Dxf;
 | 
	
	
		
			
				|  | @@ -19,13 +20,13 @@ namespace InABox.DynamicGrid
 | 
	
		
			
				|  |  |      public class DynamicImagePreviewColumn<T> : DynamicImageColumn
 | 
	
		
			
				|  |  |          where T : BaseObject
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        private static readonly BitmapImage _preview =Wpf.Resources.doc_png.AsBitmapImage();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        private static readonly BitmapImage _preview = Wpf.Resources.doc_png.AsBitmapImage();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          protected static Expression<Func<T, ImageDocumentLink>> Property { get; private set; }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          protected static string ImageIDProperty => Property != null ? CoreUtils.GetFullPropertyName(Property, ".") + ".ID" : "";
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          public DynamicImagePreviewColumn(Expression<Func<T, ImageDocumentLink>> property) : base(PreviewImage)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              Property = property;
 | 
	
	
		
			
				|  | @@ -34,14 +35,14 @@ namespace InABox.DynamicGrid
 | 
	
		
			
				|  |  |              FilterRecord = DoFilterImages;
 | 
	
		
			
				|  |  |              ToolTip = CreateImageToolTip;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          private static BitmapImage PreviewImage(CoreRow arg)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              if (arg == null || arg.Get<Guid>(ImageIDProperty) == Guid.Empty)
 | 
	
		
			
				|  |  |                  return null;
 | 
	
		
			
				|  |  |              return _preview;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          protected Bitmap LoadBitmapFromDatabase(Guid imageid)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              if (imageid == Guid.Empty)
 | 
	
	
		
			
				|  | @@ -59,7 +60,7 @@ namespace InABox.DynamicGrid
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              return result;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          private FrameworkElement CreateImageToolTip(DynamicActionColumn column, CoreRow arg)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              FrameworkElement result = null;
 | 
	
	
		
			
				|  | @@ -73,7 +74,7 @@ namespace InABox.DynamicGrid
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              return result;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          private bool DoFilterImages(CoreRow row, string[] filter)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              var hasimage = row.Get<Guid>(ImageIDProperty) != Guid.Empty;
 | 
	
	
		
			
				|  | @@ -84,7 +85,7 @@ namespace InABox.DynamicGrid
 | 
	
		
			
				|  |  |              return false;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      public class DynamicImageManagerColumn<T> : DynamicImagePreviewColumn<T>
 | 
	
		
			
				|  |  |          where T : Entity, IRemotable, IPersistent, new()
 | 
	
		
			
				|  |  |      {
 | 
	
	
		
			
				|  | @@ -93,7 +94,7 @@ namespace InABox.DynamicGrid
 | 
	
		
			
				|  |  |          private readonly bool _canupdate;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          private readonly IDynamicGrid _parent;
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          private static string _imagefilename => Property != null ? CoreUtils.GetFullPropertyName(Property, ".") + ".FileName" : "";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          public DynamicImageManagerColumn(IDynamicGrid parent, Expression<Func<T, ImageDocumentLink>> property, bool canupdate) : base(property)
 | 
	
	
		
			
				|  | @@ -102,7 +103,7 @@ namespace InABox.DynamicGrid
 | 
	
		
			
				|  |  |              _canupdate = canupdate;
 | 
	
		
			
				|  |  |              ContextMenu = CreateImageMenu;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          private MenuItem CreateMenu(string caption, RoutedEventHandler click)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              var item = new MenuItem();
 | 
	
	
		
			
				|  | @@ -110,7 +111,7 @@ namespace InABox.DynamicGrid
 | 
	
		
			
				|  |  |              item.Click += click;
 | 
	
		
			
				|  |  |              return item;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          private void SaveBitmapToDatabase(CoreRow row, Guid id, string filename, Bitmap bitmap)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              var docid = id;
 | 
	
	
		
			
				|  | @@ -195,7 +196,13 @@ namespace InABox.DynamicGrid
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      Bitmap bmp = null;
 | 
	
		
			
				|  |  |                      if (Path.GetExtension(filename).ToLower().Equals(".dxf"))
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        DxfUtils.OnProcessError += ((message) =>
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            MessageBox.Show("Error - " + message);
 | 
	
		
			
				|  |  | +                        });
 | 
	
		
			
				|  |  |                          bmp = DxfUtils.DXFToBitmap(filename);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                      else
 | 
	
		
			
				|  |  |                          bmp = System.Drawing.Image.FromFile(filename) as Bitmap;
 | 
	
		
			
				|  |  |  
 |