Hello guys,

I am trying to do some HLSL effects with DirectX library. Basically I
want to freeze the screen and show a radially blurred screen using the
HLSL effects and a MessageBox on top of that which is active. The
whole effect is somewhat similar to Vista User Account Control effect
where the active screen turns gray and the messagebox is active and
shown in bright shades.

Just before I show the messagebox I capture an image of the entire
screen and save it to the directory (during development in Debug
folder).

            int sWidth = (int)
System.Windows.SystemParameters.PrimaryScreenWidth;
            int sHeight = (int)
System.Windows.SystemParameters.PrimaryScreenHeight;

            string path = Environment.CurrentDirectory;
            System.Drawing.Image bit = new Bitmap(sWidth, sHeight);

            Graphics gs = Graphics.FromImage(bit);
            try
            {
                gs.CopyFromScreen(new System.Drawing.Point(0, 0), new
System.Drawing.Point(0, 0), bit.Size);

                gs.Dispose();

                bit.Save(path + @"\tem.jpg",
System.Drawing.Imaging.ImageFormat.Jpeg);

            }
            catch
            {

            }
            finally
            {
                bit.Dispose();
            }


At this point tem.jpg has been created.

I create an instance of a window with WindowState="Maximized" and
WindowStyle=None to occupy the full screen with an Image control.

<Window x:Class="FullScreenTest.Window2"
    Title="Window2" WindowState="Maximized"  WindowStyle="None"
Loaded="Window_Loaded" >
    <Grid>
        <Image Name="winBck" Height="Auto" Width="Auto"/>
    </Grid>
</Window>

At runtime I am trying to set the Image Source to the image I just
saved and then popping the MessageBox on top with the following line
as this.Close() so that when the user says 'OK' or 'Cancel' in the
message box I can close this Window2 and show the active window or
close the application.


            BitmapImage bmp = new BitmapImage();
            bmp.BeginInit();
            bmp.UriSource = new Uri(Environment.CurrentDirectory +
@"\tem.jpg", UriKind.Relative);
            bmp.EndInit();
            wndBack.Source = bmp;

Separately I have tried the radial blur and it works fine.

When the image is an embedded resource it gets displayed. But the
Image has to be updated every time the error occurs so that the exact
screen shot just before the error is captured and used.

I am not sure if this is the best way to implement the UAC display
effects. If there are better ways please do let me know.

If anyone can find/suggest a solution I would greatly appreciate it.

Thank you for your time.

AT

Reply via email to