Exemplo n.º 1
0
        private void ShowPreview(object sender, EventArgs e)
        {
            Program.Settings.InfoText = LayoutRichTextBox.Rtf;

            if (Resolution.IsEmpty)
                _renderForm = new RenderForm();
            else
                _renderForm = new RenderForm(Resolution);
            _renderForm.Show();
            _renderForm.Location = new Point(0, 0);
        }
Exemplo n.º 2
0
        //public static Bitmap CaptureWindow(Form form)
        //{
        //    Bitmap bitmap = new Bitmap(form.Width, form.Height);
        //    Graphics graphics = Graphics.FromImage(bitmap);
        //    bool result = PrintWindow(form.Handle, graphics.GetHdc(), 0);
        //    graphics.ReleaseHdc();
        //    graphics.Flush();
        //    return bitmap;
        //}
        public static void SetWallpaper(RenderForm renderForm)
        {
            string destinationPath = string.Empty;

            switch (Settings.OutputDestination)
            {
                case OutputDestinations.WindowsFolder:
                    destinationPath = "%windir%";
                    break;
                case OutputDestinations.AppDataFolder:
                    destinationPath = @"%userprofile%\Local Settings\Application Data\";
                    break;
                case OutputDestinations.TempFolder:
                    destinationPath = "%temp%";
                    break;
                case OutputDestinations.OtherFolder:
                    destinationPath = Settings.OtherFolder;
                    break;
            }

            destinationPath = Environment.ExpandEnvironmentVariables(Path.Combine(destinationPath, Settings.OutputFileName));

            if (renderForm == null)
                if (ForcedResolution != Size.Empty)
                    renderForm = new RenderForm(ForcedResolution);
                else
                    renderForm = new RenderForm();

            renderForm.RenderLayers();

            // Use the size from the form, which means we don't need to calculate screen sizes etc all over again
            // We might not need this, we should be able to use Output natively since it should be the right size!
            //Size finalRes = renderForm.Resolution;

            //Bitmap b = new Bitmap(renderForm.Output, finalRes.Width, finalRes.Height);
            Bitmap b = renderForm.Output;
            // TODO: Selectable image format (at least BMP/JPG/PNG)
            b.Save(destinationPath, ImageFormat.Bmp);

            renderForm.Close();

            #if !DEBUG
            // I don't want to actually change the wallpaper on my dev box!
            RegistryKey key = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);
            key.SetValue(@"WallpaperStyle", "1");
            key.SetValue(@"TileWallpaper", "0");

            SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, destinationPath, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
            #endif
        }
Exemplo n.º 3
0
        private void SetWallpaper(object sender, EventArgs e)
        {
            Program.Settings.InfoText = LayoutRichTextBox.Rtf;
            _renderForm = new RenderForm();
            _renderForm.Show();
            _renderForm.Location = new Point(0, 0);

            UseWaitCursor = true;
            Program.Settings.InfoText = LayoutRichTextBox.Rtf;
            Program.SetWallpaper(_renderForm);
            UseWaitCursor = false;
        }