private void cancelBtn_Click(object sender, EventArgs e) { // clear images from pictureboxes BackgroundManager.CleanWallpapers(this.wall); this.HideControls(); }
/// <summary> /// Set Background image for all displays. /// </summary> /// <param name="panel"></param> /// <param name="checkBox"></param> public static void SetBackground(Panel panel, CheckBox checkBox) { // get file names string fileName1 = panel.Controls[0].Tag != null ? panel.Controls[0].Tag.ToString() : string.Empty; string fileName2 = panel.Controls[1].Tag != null ? panel.Controls[1].Tag.ToString() : string.Empty; if (!string.IsNullOrEmpty(fileName1) && !string.IsNullOrEmpty(fileName2) || checkBox.Checked) { // merge images in bitmap // Note: there is no need to save bitmap and images cos it is stored as register key // without saving, setting background speed increases. var img1 = Image.FromFile(fileName1); Image img2 = !string.IsNullOrEmpty(fileName2) ? Image.FromFile(fileName2) : null; List <Image> images = new List <Image>() { img1, img2 }; Bitmap bm; if (checkBox.Checked) { bm = BackgroundManager.StretchBackground(img1, Screen.AllScreens); BackgroundManager.SaveBackground(bm, "0", "1"); } else { bm = BackgroundManager.MergePictures(images, Screen.AllScreens, DefaultLayout); BackgroundManager.SaveBackground(bm, "0", "1"); } } }
// Merge images and store them in the windows registry. private void applyBtn_Click(object sender, EventArgs e) { BackgroundManager.SetBackground(this.wall, this.mergeBtn); this.HideControls(); }