Add copy to clipboard command for material
This commit is contained in:
@@ -27,12 +27,23 @@ namespace StructureHelperLogics.NdmCalculations.Analyses
|
||||
|
||||
private static void EncodeVisual(FrameworkElement visual, string fileName, BitmapEncoder encoder)
|
||||
{
|
||||
var bitmap = new RenderTargetBitmap((int)visual.ActualWidth, (int)visual.ActualHeight, 96, 96, PixelFormats.Pbgra32);
|
||||
// Measure and arrange the element to ensure it's fully rendered
|
||||
visual.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
Rect previousBounds = VisualTreeHelper.GetDescendantBounds(visual);
|
||||
visual.Arrange(new Rect(0, 0, visual.ActualWidth, visual.ActualHeight));
|
||||
|
||||
var bitmap = new RenderTargetBitmap(
|
||||
(int)visual.ActualWidth,
|
||||
(int)visual.ActualHeight,
|
||||
96,
|
||||
96,
|
||||
PixelFormats.Pbgra32);
|
||||
|
||||
bitmap.Render(visual);
|
||||
var frame = BitmapFrame.Create(bitmap);
|
||||
encoder.Frames.Add(frame);
|
||||
using (var stream = File.Create(fileName)) encoder.Save(stream);
|
||||
visual.Arrange(previousBounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user