Hi,
We are using NodeXL library latest version for windows(c#) for a year now. It works quite good for us.
But we struck somewhere when we assigned image as node shape. We actually using following code to do this
Next part is to remove this image from node and delete this file from application folder. we are using following code to do this
allowing us to delete from the folder .
We are using NodeXL library latest version for windows(c#) for a year now. It works quite good for us.
But we struck somewhere when we assigned image as node shape. We actually using following code to do this
File.Copy(fileDialog.FileName, strPath, true);
System.Windows.Media.Imaging.BitmapImage myBitmapImage = new System.Windows.Media.Imaging.BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.DecodePixelHeight = 20;
myBitmapImage.DecodePixelWidth = 20;
myBitmapImage.UriSource = new Uri(strPath, UriKind.Absolute);
myBitmapImage.EndInit();
System.Windows.Media.ImageSource imgSource = myBitmapImage;
selectedvertex.SetValue(ReservedMetadataKeys.PerVertexShape, VertexShape.Image);
selectedvertex.SetValue(ReservedMetadataKeys.PerVertexImage, imgSource);
Now what we doing here, Copy the image file to our application folder and then assign it to node. It works quite seamlessly upto here.Next part is to remove this image from node and delete this file from application folder. we are using following code to do this
selectedvertex.RemoveKey(ReservedMetadataKeys.PerVertexImage);
selectedvertex.RemoveKey(ReservedMetadataKeys.PerVertexShape);
selectedvertex.SetValue(ReservedMetadataKeys.PerVertexShape, PerVertexShape.Sphere);
nodeXLControl1.DrawGraph();
File.Delete(strPath); // Here Fails Saying file is used by another process
Even after removing the keys from nodes, why image is still used internally by NodeXL and notallowing us to delete from the folder .