Hi, I have created one Confirmation box using silverlight, it's having two buttons(OK, Cancel). I have written screen capture code for "OK" button click whenever i clicked.I got the dll file from that solution(Confirmation box) and paste into it(.dll) in different silverlight projects for screen capturing(like PrtScn). But my problem is, By using that .dll I can't capture my silverlight whole web page in full screen during Confirmation box appeared on the page.It Captures only My Confirmation box,i need to capture whole page by using that .dll file..
please suggest any idea
Thank You!
<Button x:Name="PrtScn"
Content="Capture"
Click="Capture_Click"
VerticalAlignment="Center"
Height="25"
Grid.Row="1"
Grid.Column="1"
HorizontalAlignment="Left"
Width="50"
Margin="7,5,0,9"
BorderThickness="2" TabIndex="1" />
private void Capture_Click(object sender, RoutedEventArgs e)
{
double i = Application.Current.Host.Content.ActualWidth;
var image = PrintScreen(this);
}
public static System.Windows.Controls.Image PrintScreen(UIElement element)
{
int Width = Convert.ToInt32(HtmlPage.Window.Eval("screen.width").ToString());
int Height = Convert.ToInt32(HtmlPage.Window.Eval("screen.height").ToString());
WriteableBitmap writeableBitmap = new WriteableBitmap((UIElement)element, null);
writeableBitmap.Invalidate();
System.Windows.Controls.Image img = new System.Windows.Controls.Image();
img.Source = writeableBitmap;
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "JPEG Files (*.jpeg)|*.jpeg";
dialog.DefaultExt = ".jpeg";
if ((bool)dialog.ShowDialog())
{
using (Stream fs = dialog.OpenFile())
{
SaveToFile(writeableBitmap, fs);
MessageBox.Show("Screenshot Saved");
}
}
return img;
}
private static void SaveToFile(WriteableBitmap bitmap, Stream fs)
{
{
int width = bitmap.PixelWidth;
int height = bitmap.PixelHeight;
int bands = 3;
byte[][,] raster = new byte[bands][,];
for (int i = 0; i < bands; i++)
{
raster[i] = new byte[width, height];
}
for (int row = 0; row < height; row++)
{
for (int column = 0; column < width; column++)
{
int pixel = bitmap.Pixels[width * row + column];
raster[0][column, row] = (byte)(pixel >> 16);
raster[1][column, row] = (byte)(pixel >> 8);
raster[2][column, row] = (byte)pixel;
}
}
ColorModel model = new ColorModel { colorspace = ColorSpace.RGB };
FluxJpeg.Core.Image img = new FluxJpeg.Core.Image(model, raster);
MemoryStream stream = new MemoryStream();
FluxJpeg.Core.Encoder.JpegEncoder encoder = new FluxJpeg.Core.Encoder.JpegEncoder(img, 100, stream);
encoder.Encode();
stream.Seek(0, SeekOrigin.Begin);
byte[] binaryData = new Byte[stream.Length];
long bytesRead;
bytesRead = stream.Read(binaryData, 0, (int)stream.Length);
fs.Write(binaryData, 0, binaryData.Length);
}
}