Click here to Skip to main content
15,746,302 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have a big wpf canvas (1920*1080) with a small web browser (400*300) in it, i want to copy the browser at full size (1920*1080) and set an image at its place(400*300) instead.

So first i get the previous size of the browser and its position on my screen
then i maximise the browser and set its position to (0,0)
then i copy the screen
then i make the browser disapear and sets a image (400*300 the previous size) to the previous position

I don't want the user to see the user full size , so all is done in the code behind , the problem is that the copy is done on a small browser window

so I tried
with almost no success, it juste moved the browser window but didn't resize it
Updated 14-Aug-13 3:46am
Sergey Alexandrovich Kryukov 14-Aug-13 9:51am    
Canvas itself does not need refresh. How do you do the changes, exactly?

when i load the web browser, i set a 10s timer to launch the function which set to max size, copy and set the image in front

private void webUserControl_Loaded(object sender, RoutedEventArgs e)
double widthBefore = Width;
double heightBefore = Height;
double leftPosBefore = Canvas.GetLeft(this);
double topPosBefore = Canvas.GetTop(this);

Timer webContentTimer = new Timer();
webContentTimer.AutoReset = false;
webContentTimer.Interval = 10000;
webContentTimer.Elapsed += (oo, ee) => {
DispatcherOperation dispatcherOp = Dispatcher.BeginInvoke(
DispatcherPriority.ApplicationIdle, new Action(delegate()
Canvas.SetLeft(this, 0);
Canvas.SetTop(this, 0);
containerWeb.setFreshMeasure(screenWidth_, screenHeight_);
Width = screenWidth_;
Height = screenHeight_;

dispatcherOp.Completed += new EventHandler((ooo,eee) => {

Canvas.SetLeft(this, leftPosBefore);
Canvas.SetTop(this, topPosBefore);
containerWeb.setFreshMeasure(widthBefore, heightBefore);
Width = widthBefore;
Height = heightBefore;

Share this answer
in fact to make it work, there is an ugly one that i'd like to avoid. It is to set 2 events :

the first one happens 10000 millisecond after the loading and maximises the browser

then one waits 40 milliseconds for the second event which copies the screen and sets the small image

it's ugly
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900