private void buttonSelectFolder_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { Wallpaper.selectedFolderPath = folderBrowserDialog1.SelectedPath; string[] fileInfoJPG = Directory.GetFiles(Wallpaper.selectedFolderPath, "*.jpg", SearchOption.AllDirectories); string[] fileInfoPNG = Directory.GetFiles(Wallpaper.selectedFolderPath, "*.png", SearchOption.AllDirectories); if (fileInfoJPG.Length == 0 && fileInfoPNG.Length == 0) { MessageBox.Show("Please select a folder with PNG or JPG image(s) in it.", "ERROR", MessageBoxButtons.OK); Wallpaper.selectedFolderPath = null; return; } else { Settings.ChangeSetting(Settings.settings.wallpaperFolderDirectory, Wallpaper.selectedFolderPath); Wallpaper.fileInfoJPG = Directory.GetFiles(Wallpaper.selectedFolderPath, "*.jpg", SearchOption.AllDirectories); Wallpaper.fileInfoPNG = Directory.GetFiles(Wallpaper.selectedFolderPath, "*.png", SearchOption.AllDirectories); string path = Wallpaper.GetNewWallpaper(isShuffle.Checked); pictureBox1.Image = Image.FromFile(Wallpaper.wallpaperFile.FullName); pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; if (path != null) { pictureBox1.LoadAsync(path); SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, Wallpaper.BurnNewWallpaper(Wallpaper.wallpaperFile.FullName), SPIF_UPDATEINIFILE); } } } }
private void timer1_Tick(object sender, EventArgs e) //Every minute. { timerCounter++; if (!String.IsNullOrEmpty(Settings.ReadSetting(Settings.settings.wallpaperFolderDirectory)) && !String.IsNullOrWhiteSpace(Settings.ReadSetting(Settings.settings.wallpaperFolderDirectory))) //Is wallpaperFolderDirectory selected && that selected directory is NullORWhiteSpace { SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, Wallpaper.BurnNewWallpaper(Wallpaper.wallpaperFile.FullName), SPIF_UPDATEINIFILE); pictureBox1.LoadAsync(Wallpaper.wallpaperFile.FullName); if (timerCounter == Convert.ToInt32(numericWallpaperTime.Value)) //If it's time to get a new wallpaper. { timerCounter = 0; string path = Wallpaper.GetNewWallpaper(isShuffle.Checked); if (path != null) { pictureBox1.Image = Image.FromFile(Wallpaper.wallpaperFile.FullName); pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; pictureBox1.LoadAsync(path); SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, Wallpaper.BurnNewWallpaper(Wallpaper.wallpaperFile.FullName), SPIF_UPDATEINIFILE); } } else if (timerCounter > Convert.ToInt32(numericWallpaperTime.Value)) //Stop timerCounter going over the max minutes. { timerCounter = 0; } } }
private void buttonChooseFont_Click(object sender, EventArgs e) { if (fontDialog1.ShowDialog() == DialogResult.OK) { font = new Font(fontDialog1.Font.Name, 96); buttonSelectFont.Font = new Font(fontDialog1.Font.Name, buttonSelectFont.Font.Size); Settings.ChangeSetting(Settings.settings.font, buttonSelectFont.Font.Name); Wallpaper.font = this.font; SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, Wallpaper.BurnNewWallpaper(Wallpaper.wallpaperFile.FullName), SPIF_UPDATEINIFILE); } }
private void buttonSelectColor_Click(object sender, EventArgs e) { if (colorDialog1.ShowDialog() == DialogResult.OK) { color = colorDialog1.Color; buttonSelectColor.BackColor = color; buttonSelectColor.ForeColor = HSL.GetComplementaryColor(color); Wallpaper.color = this.color; Settings.ChangeSetting(Settings.settings.color, color.ToArgb().ToString()); SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, Wallpaper.BurnNewWallpaper(Wallpaper.wallpaperFile.FullName), SPIF_UPDATEINIFILE); } }
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { isDrawing = false; pictureBox1.Refresh(); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddString(DateTime.Now.ToShortTimeString(), font.FontFamily, (int)font.Style, fontSize, theRectangle, new StringFormat()); formGraphics.DrawPath(new Pen(HSL.GetComplementaryColor(color), 3f), path); formGraphics.FillPath(new SolidBrush(Color.FromArgb(255, color)), path); labelState.Text = e.Location.X.ToString() + " , " + e.Location.Y.ToString(); SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, Wallpaper.BurnNewWallpaper(Wallpaper.wallpaperFile.FullName), SPIF_UPDATEINIFILE); }
public MainForm() { Settings.CreateDirectory(); Settings.CreateSettings(); startpoint.X = Convert.ToInt32(Settings.ReadSetting(Settings.settings.startPointX)); startpoint.Y = Convert.ToInt32(Settings.ReadSetting(Settings.settings.startPointY)); InitializeComponent(); pictureBox1.Width = Convert.ToInt32(Convert.ToDouble(pictureBox1.Height) / ratio); pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; color = Color.FromArgb(Convert.ToInt32(Settings.ReadSetting(Settings.settings.color))); buttonSelectColor.BackColor = color; numericWallpaperTime.Value = Convert.ToInt32(Settings.ReadSetting(Settings.settings.minuteOfChangeWallpaper)); font = new Font(Settings.ReadSetting(Settings.settings.font), fontSize); buttonSelectFont.Font = new Font(font.Name, 8f); Wallpaper.font = font; Wallpaper.color = color; Wallpaper.startpoint = startpoint; Wallpaper.pictureBoxRectangle.Height = pictureBox1.Height; Wallpaper.pictureBoxRectangle.Width = pictureBox1.Width; if (!String.IsNullOrEmpty(Settings.ReadSetting(Settings.settings.wallpaperFolderDirectory)) && !String.IsNullOrWhiteSpace(Settings.ReadSetting(Settings.settings.wallpaperFolderDirectory))) //If wallpaper folder selected from before. { SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, Wallpaper.BurnNewWallpaper(Wallpaper.wallpaperFile.FullName), SPIF_UPDATEINIFILE); pictureBox1.LoadAsync(Wallpaper.wallpaperFile.FullName); fileSystemWatcher1.Path = Wallpaper.selectedFolderPath; } checkBoxStartup.Checked = Settings.IsStartupCreated(); isShuffle.Checked = Convert.ToBoolean(Settings.ReadSetting(Settings.settings.shuffle)); checkBoxMinimized.Checked = Convert.ToBoolean(Settings.ReadSetting(Settings.settings.startMinimized)); }