|
@@ -36,18 +36,18 @@ namespace InABox.DynamicGrid
|
|
|
ToolTip = CreateImageToolTip;
|
|
|
}
|
|
|
|
|
|
- private static BitmapImage PreviewImage(CoreRow arg)
|
|
|
+ private static BitmapImage? PreviewImage(CoreRow? arg)
|
|
|
{
|
|
|
- if (arg == null || arg.Get<Guid>(ImageIDProperty) == Guid.Empty)
|
|
|
+ if (arg is null || arg.Get<Guid>(ImageIDProperty) == Guid.Empty)
|
|
|
return null;
|
|
|
return _preview;
|
|
|
}
|
|
|
|
|
|
- protected Bitmap LoadBitmapFromDatabase(Guid imageid)
|
|
|
+ protected Bitmap? LoadBitmapFromDatabase(Guid imageid)
|
|
|
{
|
|
|
if (imageid == Guid.Empty)
|
|
|
return null;
|
|
|
- Bitmap result = null;
|
|
|
+ Bitmap? result = null;
|
|
|
var image = new Client<Document>().Query(
|
|
|
new Filter<Document>(x => x.ID).IsEqualTo(imageid),
|
|
|
new Columns<Document>(x => x.ID, x => x.Data)
|
|
@@ -61,9 +61,11 @@ namespace InABox.DynamicGrid
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private FrameworkElement CreateImageToolTip(DynamicActionColumn column, CoreRow arg)
|
|
|
+ private FrameworkElement? CreateImageToolTip(DynamicActionColumn column, CoreRow? arg)
|
|
|
{
|
|
|
- FrameworkElement result = null;
|
|
|
+ if (arg is null)
|
|
|
+ return null;
|
|
|
+ FrameworkElement? result = null;
|
|
|
var imageid = arg.Get<Guid>(ImageIDProperty);
|
|
|
if (!imageid.Equals(Guid.Empty))
|
|
|
using (new WaitCursor())
|
|
@@ -112,13 +114,13 @@ namespace InABox.DynamicGrid
|
|
|
return item;
|
|
|
}
|
|
|
|
|
|
- private void SaveBitmapToDatabase(CoreRow row, Guid id, string filename, Bitmap bitmap)
|
|
|
+ private void SaveBitmapToDatabase(CoreRow row, Guid id, string filename, Bitmap? bitmap)
|
|
|
{
|
|
|
var docid = id;
|
|
|
|
|
|
if (bitmap != null && docid == Guid.Empty)
|
|
|
{
|
|
|
- byte[] data = null;
|
|
|
+ byte[] data;
|
|
|
using (var ms = new MemoryStream())
|
|
|
{
|
|
|
bitmap.Save(ms, ImageFormat.Png);
|
|
@@ -156,7 +158,7 @@ namespace InABox.DynamicGrid
|
|
|
_parent.UpdateRow(row, _imagefilename, Path.GetFileName(filename));
|
|
|
}
|
|
|
|
|
|
- private ContextMenu CreateImageMenu(CoreRow[] rows)
|
|
|
+ private ContextMenu? CreateImageMenu(CoreRow[]? rows)
|
|
|
{
|
|
|
if (rows == null || rows.Length != 1)
|
|
|
return null;
|
|
@@ -194,7 +196,7 @@ namespace InABox.DynamicGrid
|
|
|
{
|
|
|
var filename = dlg.FileName.ToLower();
|
|
|
|
|
|
- Bitmap bmp = null;
|
|
|
+ Bitmap bmp;
|
|
|
if (Path.GetExtension(filename).ToLower().Equals(".dxf"))
|
|
|
{
|
|
|
DxfUtils.OnProcessError += ((message) =>
|
|
@@ -204,7 +206,7 @@ namespace InABox.DynamicGrid
|
|
|
bmp = DxfUtils.DXFToBitmap(filename);
|
|
|
}
|
|
|
else
|
|
|
- bmp = System.Drawing.Image.FromFile(filename) as Bitmap;
|
|
|
+ bmp = (System.Drawing.Image.FromFile(filename) as Bitmap)!;
|
|
|
|
|
|
SaveBitmapToDatabase(row, Guid.Empty, filename, bmp);
|
|
|
//_parent?.Refresh(false, false);
|
|
@@ -230,7 +232,7 @@ namespace InABox.DynamicGrid
|
|
|
private void CopyImage(CoreRow row)
|
|
|
{
|
|
|
var bmp = LoadBitmapFromDatabase(row.Get<Guid>(ImageIDProperty));
|
|
|
- var data = new Tuple<Guid, string, Bitmap>(
|
|
|
+ var data = new Tuple<Guid, string, Bitmap?>(
|
|
|
row.Get<Guid>(ImageIDProperty),
|
|
|
row.Get<string>(_imagefilename),
|
|
|
bmp
|
|
@@ -247,26 +249,25 @@ namespace InABox.DynamicGrid
|
|
|
|
|
|
var id = Guid.Empty;
|
|
|
var filename = "";
|
|
|
- Bitmap bitmap = null;
|
|
|
+ Bitmap? bitmap = null;
|
|
|
|
|
|
- if (Clipboard.ContainsData("ProductImage"))
|
|
|
+ if (Clipboard.ContainsData("ProductImage") && Clipboard.GetData("ProductImage") is Tuple<Guid, string, Bitmap?> data)
|
|
|
{
|
|
|
- var data = Clipboard.GetData("ProductImage") as Tuple<Guid, string, Bitmap>;
|
|
|
id = data.Item1;
|
|
|
filename = data.Item2;
|
|
|
bitmap = data.Item3;
|
|
|
}
|
|
|
else if (Clipboard.ContainsImage())
|
|
|
{
|
|
|
- var data = Clipboard.GetImage();
|
|
|
- bitmap = data.AsBitmap2();
|
|
|
+ var dataImage = Clipboard.GetImage();
|
|
|
+ bitmap = dataImage.AsBitmap2();
|
|
|
|
|
|
filename = string.Format("clip{0:yyyyMMddhhmmss}.png", DateTime.Now);
|
|
|
if (Clipboard.ContainsFileDropList())
|
|
|
{
|
|
|
var list = Clipboard.GetFileDropList();
|
|
|
if (list.Count > 0)
|
|
|
- filename = Path.ChangeExtension(Path.GetFileName(list[0]), ".png");
|
|
|
+ filename = Path.ChangeExtension(Path.GetFileName(list[0]!), ".png");
|
|
|
}
|
|
|
|
|
|
//filename = String.Format("clip{0:yyyyMMddhhmmss}.png",DateTime.Now);
|
|
@@ -274,7 +275,7 @@ namespace InABox.DynamicGrid
|
|
|
id = Guid.Empty;
|
|
|
}
|
|
|
|
|
|
- if (bitmap == null)
|
|
|
+ if (bitmap is null)
|
|
|
{
|
|
|
MessageBox.Show("Unable to paste data from clipboard");
|
|
|
return;
|