Пример #1
0
        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);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            labelState.Text = e.Location.X.ToString() + " , " + e.Location.Y.ToString();

            if (isDrawing)
            {
                pictureBox1.Refresh();
                Color newColor = Color.FromArgb(125, Color.Gray);

                Control control = (Control)sender;
                formGraphics = control.CreateGraphics();
                formGraphics.FillRectangle(new SolidBrush(newColor), theRectangle);
                formGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                theRectangle.X             = startpoint.X;
                theRectangle.Y             = startpoint.Y;
                theRectangle.Height        = e.Y - startpoint.Y;
                theRectangle.Width         = e.X - startpoint.X;

                fontSize = 96f;
                SizeF stringSize = formGraphics.MeasureString(DateTime.Now.ToShortTimeString(), new Font(font.Name, fontSize));

                if (theRectangle.Width > 15 && theRectangle.Height > 15)
                {
                    while (stringSize.Width > theRectangle.Width || stringSize.Height > theRectangle.Height)
                    {
                        stringSize = formGraphics.MeasureString(DateTime.Now.ToShortTimeString(), new Font(font.Name, fontSize));
                        fontSize  -= 0.05f;
                    }

                    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);

                    Settings.ChangeSetting(Settings.settings.fontSize, fontSize.ToString());
                    Wallpaper.fontSize = this.fontSize;
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Bakes the current time on the original wallpaper and returns the path of the baked wallpaper.
        /// </summary>
        /// <param name="originalWallpaperPath">The full path of the original wallpaper.</param>
        /// <returns></returns>
        public static string BurnNewWallpaper(string originalWallpaperPath)
        {
            Image    wallpaper      = Image.FromFile(originalWallpaperPath);
            Bitmap   bufferBtmp     = new Bitmap(wallpaper);
            Graphics wallpaperGraph = Graphics.FromImage(bufferBtmp);

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();

            wallpaperGraph.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            wallpaperGraph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
            path.FillMode = System.Drawing.Drawing2D.FillMode.Winding;

            path.AddString(DateTime.Now.ToShortTimeString(), font.FontFamily, (int)font.Style, (float)(fontSize * Convert.ToDouble(wallpaper.Width) / Convert.ToDouble(pictureBoxRectangle.Width)), CalculateTheRelativePoint(), new StringFormat());
            wallpaperGraph.DrawPath(new Pen(HSL.GetComplementaryColor(color), 3f), path);
            wallpaperGraph.FillPath(new SolidBrush(Color.FromArgb(255, color)), path);
            BurntWallpaperPath = Settings.rootDirectory + "\\wallpaper.png";

            bufferBtmp.Save(BurntWallpaperPath);
            bufferBtmp.Dispose();
            wallpaper.Dispose();
            wallpaperGraph.Dispose();

            return(BurntWallpaperPath);
        }