Advertisement
alien_fx_fiend

Simple Drawing App *FINAL RELEASE !*

Oct 22nd, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 126.23 KB | Source Code | 0 0
  1. ==++Resources Additional Files++==
  2. Graph.jpg == https://www.dropbox.com/scl/fi/tua1061dob9ppjafam19h/graph.jpg?rlkey=pmk287josspq6v3sxuk8pygtc&dl=0
  3. intelcpu_hardware_7155.ico == https://www.dropbox.com/scl/fi/svfby9h7xwkylat8ijjhm/intelcpu_hardware_7155.ico?rlkey=o461swa5tyzyct273z7b55hk7&dl=0
  4.  
  5. ==++"Form1.cs" File Source Code::++==
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. using System.IO;
  16. using System.Runtime.InteropServices;
  17.  
  18. namespace Simple_Drawing_Application
  19. {
  20.     public partial class Form1 : Form
  21.     {
  22.         private Dictionary<string, object> brushSettings = new Dictionary<string, object>();
  23.         private const string ColorKey = "Color";
  24.         private const string WidthKey = "Width";
  25.         private int storedEraserSize; // Add this line at the class level
  26.         //private Dictionary<string, object> brushSettings = new Dictionary<string, object>();
  27.         //Bards Fixes: (not drawing properly (fixed by ChatGPT) but Form1_Load relocated code + Load Image works normally now Clear still doesn't work but oh well
  28.         private Bitmap drawingLayer;
  29.         private Stack<Bitmap> undoStack = new Stack<Bitmap>();
  30.         private Stack<Bitmap> redoStack = new Stack<Bitmap>();
  31.         //private List<Bitmap> undoList = new List<Bitmap>();
  32.         //private List<Bitmap> redoList = new List<Bitmap>();
  33.         public Point end = new Point();
  34.         public Point start = new Point();
  35.         public Pen p;
  36.         bool draw = false;
  37.         string color;
  38.         Graphics graphics;
  39.         Bitmap bmp;
  40.         bool isEraserActive = false; //(start bard #2 line)
  41.         private SolidBrush brush; // Declare the brush variable //(start bard test #12 line)
  42.         // Add a new variable to store the eraser size
  43.         int eraserSize = 26; //50        
  44.         //Image backgroundImage3;
  45.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  46. Start #1 Silhouette
  47. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  48.         private Bitmap brushSilhouette;
  49.         private Bitmap eraserSilhouette;
  50.         private bool canvasDirty = false;
  51.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  52.         End #1 Silhouette
  53.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  54.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  55. Start #25 Silhouette adding persistent values (disabling Silhouette and persistent code)
  56. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  57.         //private string storedPenColor;
  58.         //private float storedPenWidth;
  59.         //private int storedEraserSize;
  60.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  61.         End #25 Silhouette adding persistent values
  62.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  63.  
  64.         public Form1()
  65.         {
  66.             InitializeComponent();
  67.             GenerateVariables();
  68.         }
  69.  
  70.         private void Form1_Load(object sender, EventArgs e)
  71.         {
  72.             Image backgroundImage3 = Houdini.Properties.Resources.graph;
  73.             //drawingLayer = new Bitmap(pb_canvas.Width, pb_canvas.Height); //from generatevariables func 4pm 11th Jan 24 temporary
  74.             //Graphics.FromImage(drawingLayer).Clear(Color.Transparent); //from generatevariables func 4pm 11th Jan 24 temporary
  75.             pb_canvas.BackgroundImage = backgroundImage3; // Set as background image
  76.             pb_canvas.BackgroundImageLayout = ImageLayout.Tile;
  77.             // Create the drawing layer only once here
  78.             drawingLayer = new Bitmap(pb_canvas.Width, pb_canvas.Height);
  79.             if (backgroundImage3 != null)
  80.             {
  81.                 int tileWidth = backgroundImage3.Width;
  82.                 int tileHeight = backgroundImage3.Height;
  83.                 for (int x = 0; x < pb_canvas.Width; x += tileWidth)
  84.                 {
  85.                     for (int y = 0; y < pb_canvas.Height; y += tileHeight)
  86.                     {
  87.                         pb_canvas.CreateGraphics().DrawImage(backgroundImage3, new Point(x, y));
  88.                     }
  89.                 }
  90.             }
  91.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  92. Start #12 Silhouette (disabling Silhouette and persistent code)
  93. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  94.             brushSilhouette = null;
  95.             eraserSilhouette = null;
  96.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  97.             End #12 Silhouette
  98.             .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  99.             GenerateVariables();
  100.         }
  101.  
  102.         private void Form1_Resize(object sender, EventArgs e)
  103.         {
  104.             // Ensure the form doesn't cover the entire screen
  105.             int maxFormWidth = Screen.PrimaryScreen.WorkingArea.Width;
  106.             int maxFormHeight = Screen.PrimaryScreen.WorkingArea.Height;
  107.             this.MaximumSize = new Size(maxFormWidth, maxFormHeight);
  108.  
  109.             // Adjust the size of the canvas
  110.             pb_canvas.Size = new Size(this.ClientSize.Width, this.ClientSize.Height - menuStrip1.Height);
  111.             //crash fix gpt says to disable below:
  112.             //drawingLayer = new Bitmap(pb_canvas.Width, pb_canvas.Height);
  113.  
  114.             //delete if unnecessary
  115.             //original scripts below vv last change to fix Always to Top glitch
  116.             // Adjust the size of pb_canvas to fill the form's client area Formsize= 1362,767
  117.             //pb_canvas.Size = new Size(this.ClientSize.Width, this.ClientSize.Height - menuStrip1.Height);
  118.  
  119.             // Check if drawingLayer is already created
  120.             if (drawingLayer != null)
  121.             {
  122.                 try
  123.                 {
  124.                     Bitmap newDrawingLayer = new Bitmap(pb_canvas.Width, pb_canvas.Height);
  125.                     using (Graphics g = Graphics.FromImage(newDrawingLayer))
  126.                     {
  127.                         g.DrawImage(drawingLayer, Point.Empty);
  128.                     }
  129.  
  130.                     drawingLayer = newDrawingLayer;
  131.                 }
  132.                 catch (ArgumentException ex)
  133.                 {
  134.                     // Handle the exception (optional)
  135.                     Console.WriteLine($"Error during resize: {ex.Message}");
  136.                 }
  137.             }
  138.         }
  139.  
  140.         void GenerateVariables()
  141.         {
  142.             // Enable double buffering
  143.             this.DoubleBuffered = true;
  144.  
  145.             //drawingLayer = new Bitmap(pb_canvas.Width, pb_canvas.Height); disabled temporarily for Bard 4pm 11th Jan 24
  146.             //backgroundLayer = new Bitmap(pb_canvas.Width, pb_canvas.Height); // Initialize background layer //(start bard #7 line)
  147.             //Graphics.FromImage(drawingLayer).Clear(Color.Transparent); disabled temporarily for Bard 4pm 11th Jan 24
  148.  
  149.             //start file-path based#1
  150.             //string imagePath = "D:\\Download\\cpp-projekt\\Simple Drawing App\\graph.jpg";
  151.             // Check if the file exists
  152.             //if (File.Exists(imagePath))
  153.             //{
  154.             // Load the image
  155.             //Image backgroundImage2 = Image.FromFile(imagePath);
  156.             //end file-path based#1
  157.  
  158.             //start embedded-path based#1
  159.             //string imagePath2 = "graph";
  160.             // Check if the file exists "Simple_Drawing_Application.Images.graph.jpg";
  161.             //if (File.Exists(imagePath2))
  162.             //{
  163.             // Load the image from embedded resource
  164.             //Stream imageStream = GetType().Assembly.GetManifestResourceStream(imagePath2);
  165.             //Image backgroundImage3 = Image.FromStream(imageStream);
  166.             //end embedded-path based#1
  167.  
  168.             //Image backgroundImage3 = Houdini.Properties.Resources.graph; disabled temporarily for Bard 4pm 11th Jan 24
  169.  
  170.             // Set the background image and enable tiling
  171.             //pb_canvas.BackgroundImage = backgroundImage3; disabled temporarily for Bard 4pm 11th Jan 24
  172.             //pb_canvas.BackgroundImageLayout = ImageLayout.Tile; disabled temporarily for Bard 4pm 11th Jan 24
  173.             //}
  174.             //else
  175.             //{
  176.             //MessageBox.Show("Image file not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  177.             //}
  178.  
  179.  
  180.             // Load the tiled background image
  181.             //Stream imageStream = GetType().Assembly.GetManifestResourceStream("pb_canvas.BackgroundImage");
  182.             //Image backgroundImage = Image.FromStream(imageStream);
  183.  
  184.             // Set the background image to be tiled
  185.             //pb_canvas.BackgroundImage = backgroundImage;
  186.             // Get the friendly name for the color if available, otherwise use the hex value
  187.  
  188.             string friendlyColorName = Color.FromName(pb_canvas.BackColor.Name).IsKnownColor
  189.                 ? pb_canvas.BackColor.Name
  190.                 : $"#{pb_canvas.BackColor.R:X2}{pb_canvas.BackColor.G:X2}{pb_canvas.BackColor.B:X2}";
  191.             //graphics = pb_canvas.CreateGraphics(); //bard disabled temporarily from func 4pm 11th Jan 24 temp
  192.             // Initialize the pen with a default size
  193.             // You can adjust the color and size as needed
  194.             p = new Pen(Color.Red, 14);
  195.             p.StartCap = p.EndCap = System.Drawing.Drawing2D.LineCap.Round; // Set line cap to round
  196.             p.LineJoin = System.Drawing.Drawing2D.LineJoin.Round; // Set line join to round
  197.             comboBox1.Text = "12";
  198.             color = "#FF8040"; //#FF0000 (Red replaced /w pale Orange)
  199.             //txt_color.Text = color;
  200.             // Set the initial background color and display hex color
  201.             // Set your default background color
  202.             //pb_canvas.BackColor = Color.Black; //bard disabled temporarily from func 4pm 11th Jan 24 temp
  203.             selectBGToolStripMenuItem.Text = $"Select Background ({friendlyColorName})";
  204.             //selectBGToolStripMenuItem.Text = $"Select BG ({ColorToHex(Color.Black)})";
  205.             // Set the tiled background
  206.             //SetTiledBackground();
  207.             // Update the pen color and size dynamically based on the initial values
  208.             UpdatePen();
  209.             // Update font color dynamically
  210.             UpdateFontColor();
  211.  
  212.             // Attach the Resize event handler
  213.             this.Resize += new EventHandler(Form1_Resize);
  214.             pb_canvas.Paint += new PaintEventHandler(pb_canvas_Paint); //bard disabled temporarily from func 4pm 11th Jan 24 temp
  215.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  216. Start #2 Silhouette
  217. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  218.             pb_canvas.MouseDown += new MouseEventHandler(pb_canvas_MouseDown); // Added event handler
  219.             pb_canvas.MouseMove += new MouseEventHandler(pb_canvas_MouseMove); // Added event handler
  220.             pb_canvas.MouseUp += new MouseEventHandler(pb_canvas_MouseUp); // Added event handler
  221.             pb_canvas.MouseLeave += new EventHandler(pb_canvas_MouseLeave); // Added event handler
  222.             //pb_canvas.Cursor = Cursors.Cross; // Set cursor to crosshair
  223.             pb_canvas.MouseEnter += new EventHandler(pb_canvas_MouseEnter);
  224.             // Add these lines where you initialize your menu items
  225.             undoToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.Z)));
  226.             redoToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.Y)));
  227.             loadImageToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.O)));
  228.             saveImageToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.S)));
  229.  
  230.             // Add these lines where you handle other menu items
  231.             undoToolStripMenuItem.Click += new EventHandler(undoToolStripMenuItem_Click);
  232.             redoToolStripMenuItem.Click += new EventHandler(redoToolStripMenuItem_Click);
  233.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  234.             End #2 Silhouette
  235.             .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  236.             // Initialize the canvas size
  237.             Form1_Resize(this, EventArgs.Empty);
  238.             // Initialize the Set Font Size menu item text
  239.             setFontSizeToolStripMenuItem.Text = $"Set Font Size ({p.Width})";
  240.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  241. Start #3 Silhouette (disabled)
  242. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  243.             // Generate brush silhouette
  244.             //brushSilhouette = GenerateBrushSilhouette(p.Width, color);
  245.  
  246.             // Generate eraser silhouette
  247.             //eraserSilhouette = GenerateEraserSilhouette(eraserSize);
  248.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  249.             End #3 Silhouette (disabled)
  250.             .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  251.             //CreateCanvas();
  252.         }
  253.  
  254.         private void pb_canvas_Paint(object sender, PaintEventArgs e)
  255.         {
  256.             e.Graphics.DrawImage(drawingLayer, Point.Empty);
  257.  
  258.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  259. Start #11 Silhouette
  260. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  261.             if (brushSilhouette != null && eraserSilhouette != null)
  262.             {
  263.                 // Create a temporary bitmap to draw the silhouette on.
  264.                 using (Bitmap tempLayer = new Bitmap(drawingLayer.Width, drawingLayer.Height))
  265.                 {
  266.                     using (Graphics g = Graphics.FromImage(tempLayer))
  267.                     {
  268.                         Point cursorPosition = pb_canvas.PointToClient(Cursor.Position);
  269.  
  270.                         // Draw the brush or eraser silhouette on the temporary layer.
  271.                         if (isEraserActive)
  272.                         {
  273.                             g.DrawImage(eraserSilhouette, cursorPosition.X - eraserSize / 2, cursorPosition.Y - eraserSize / 2);
  274.                         }
  275.                         else
  276.                         {
  277.                             g.DrawImage(brushSilhouette, cursorPosition.X - (int)p.Width / 2, cursorPosition.Y - (int)p.Width / 2);
  278.                         }
  279.                     }
  280.  
  281.                     // Draw the temporary layer on top of the existing drawing layer.
  282.                     e.Graphics.DrawImage(tempLayer, Point.Empty);
  283.                 }
  284.             }
  285.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  286.             End #11 Silhouette
  287.             .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  288.  
  289.  
  290.  
  291.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  292. Start #5 Silhouette (disabled)
  293. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  294.             /*// Draw brush silhouette
  295.             if (!isEraserActive)
  296.             {
  297.                 Point cursorPosition = pb_canvas.PointToClient(Cursor.Position);
  298.                 e.Graphics.DrawImage(brushSilhouette, cursorPosition.X - (int)p.Width / 2, cursorPosition.Y - (int)p.Width / 2);
  299.             }
  300.  
  301.             // Draw eraser silhouette
  302.             if (isEraserActive)
  303.             {
  304.                 Point cursorPosition = pb_canvas.PointToClient(Cursor.Position);
  305.                 e.Graphics.DrawImage(eraserSilhouette, cursorPosition.X - eraserSize / 2, cursorPosition.Y - eraserSize / 2);
  306.             }*/
  307.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  308.             End #5 Silhouette (disabled)
  309.             .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  310.  
  311.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  312. Start #6 Silhouette (disabled)
  313. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  314.             //e.Graphics.DrawImage(drawingLayer, Point.Empty); // Draw the contents of drawingLayer onto the canvas
  315.             /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  316.             End #6 Silhouette (disabled)
  317.             .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  318.  
  319.             /*if (pb_canvas.BackgroundImage != null)
  320.             {
  321.                 e.Graphics.DrawImage(pb_canvas.BackgroundImage, 0, 0, pb_canvas.Width, pb_canvas.Height);
  322.             }*/
  323.             /*if (pb_canvas.BackgroundImage != null)
  324.             {
  325.                 e.Graphics.DrawImage(pb_canvas.BackgroundImage, 0, 0, pb_canvas.Width, pb_canvas.Height);  // Scale background image to fit canvas
  326.             }
  327.             e.Graphics.DrawImage(drawingLayer, 0, 0);*/
  328.             // Draw the background image if it is set
  329.             /*if (pb_canvas.BackgroundImage != null)
  330.             {
  331.                 e.Graphics.DrawImage(pb_canvas.BackgroundImage, Point.Empty);
  332.             }*/
  333.             //(start bard test #8)
  334.             /*e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // Enable anti-aliasing
  335.             // Draw the drawing layer on top
  336.             e.Graphics.DrawImage(drawingLayer, Point.Empty);*/
  337.             //(end bard test #8)
  338.         }
  339.  
  340.         //uncomment if fail
  341.         /*void CreateCanvas()
  342.         {
  343.             bmp = new Bitmap(pb_canvas.Width, pb_canvas.Height);
  344.  
  345.             using (Graphics g = Graphics.FromImage(bmp))
  346.             {
  347.                 // Draw the background image if it is set
  348.                 if (pb_canvas.BackgroundImage != null)
  349.                 {
  350.                     g.DrawImage(pb_canvas.BackgroundImage, Point.Empty);
  351.                 }
  352.             }
  353.  
  354.             pb_canvas.BackgroundImage = bmp;
  355.             pb_canvas.BackgroundImageLayout = ImageLayout.Tile;
  356.         }*/
  357.  
  358.         //old orig function test4new
  359.         /*void CreateCanvas() {
  360.             bmp = new Bitmap(pb_canvas.Width, pb_canvas.Height);
  361.             graphics = Graphics.FromImage(bmp);
  362.             pb_canvas.BackgroundImage = bmp;
  363.             pb_canvas.BackgroundImageLayout = ImageLayout.None;
  364.         }*/
  365.  
  366.         private void pb_canvas_MouseDown(object sender, MouseEventArgs e)
  367.         {
  368.             draw = true;
  369.             start = e.Location;
  370.             /*draw = true;
  371.  
  372.             start = e.Location;
  373.  
  374.             int size;
  375.  
  376.             if (comboBox1.Text == "")
  377.             {
  378.                 size = 8;
  379.             }
  380.             else
  381.             {
  382.                 size = Convert.ToInt32(comboBox1.Text);
  383.             }
  384.  
  385.             Color newColor = ColorTranslator.FromHtml(color);
  386.  
  387.             // Update the pen size here
  388.             p = new Pen(newColor, p.Width);
  389.  
  390.             p.SetLineCap(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.DashCap.Round);
  391.         }*/
  392.         }
  393.  
  394.         private void pb_canvas_MouseMove(object sender, MouseEventArgs e)
  395.         {
  396.             if (draw && e.Button == MouseButtons.Left)
  397.             {
  398.                 end = e.Location;
  399.                 using (Graphics g = Graphics.FromImage(drawingLayer))
  400.                 {
  401.                     g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  402.                     if (isEraserActive)
  403.                     {
  404.                         int radius = eraserSize / 2;
  405.                         RectangleF eraseRect = new RectangleF(end.X - radius, end.Y - radius, 2 * radius, 2 * radius);
  406.                         using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  407.                         {
  408.                             path.AddEllipse(eraseRect);
  409.                             g.SetClip(path);
  410.                             g.Clear(Color.Transparent);
  411.                             g.ResetClip();
  412.                         }
  413.                     }
  414.                     else
  415.                     {
  416.                         using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  417.                         {
  418.                             path.AddLine(start, end);
  419.                             g.DrawPath(p, path);
  420.                         }
  421.                     }
  422.                 }
  423.                 start = end;
  424.                 UpdateCanvas();
  425.                 canvasDirty = true; // Set the canvas dirty flag
  426.             }
  427.             else
  428.             {
  429.                 pb_canvas.Invalidate();
  430.             }
  431.         }
  432.  
  433.         /*if (draw && e.Button == MouseButtons.Left)
  434.         {
  435.             end = e.Location;
  436.             using (Graphics g = Graphics.FromImage(drawingLayer))
  437.             {
  438.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  439.                 if (isEraserActive)
  440.                 {
  441.                     int radius = eraserSize / 2;
  442.                     RectangleF eraseRect = new RectangleF(end.X - radius, end.Y - radius, 2 * radius, 2 * radius);
  443.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  444.                     {
  445.                         path.AddEllipse(eraseRect);
  446.                         g.SetClip(path);
  447.                         g.Clear(Color.Transparent);
  448.                         g.ResetClip();
  449.                     }
  450.                 }
  451.                 else
  452.                 {
  453.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  454.                     {
  455.                         path.AddLine(start, end);
  456.                         g.DrawPath(p, path);
  457.                     }
  458.                 }
  459.             }
  460.             start = end;
  461.             UpdateCanvas();
  462.             canvasDirty = true; // Set the canvas dirty flag
  463.         }
  464.         else
  465.         {
  466.             pb_canvas.Invalidate();
  467.         }
  468.     }*/
  469.  
  470.         /*if (draw && e.Button == MouseButtons.Left)
  471.     {
  472.         end = e.Location;
  473.  
  474.         using (Graphics g = Graphics.FromImage(drawingLayer))
  475.         {
  476.             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  477.  
  478.             if (isEraserActive)
  479.             {
  480.                 int radius = eraserSize / 2;
  481.                 RectangleF eraseRect = new RectangleF(end.X - radius, end.Y - radius, 2 * radius, 2 * radius);
  482.                 using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  483.                 {
  484.                     path.AddEllipse(eraseRect);
  485.                     g.SetClip(path);
  486.                     g.Clear(Color.Transparent);
  487.                     g.ResetClip();
  488.                 }
  489.             }
  490.             else
  491.             {
  492.                 using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  493.                 {
  494.                     path.AddLine(start, end);
  495.                     g.DrawPath(p, path);
  496.                 }
  497.             }
  498.         }
  499.  
  500.         start = end;
  501.         UpdateCanvas();
  502.     }
  503.     else
  504.     {
  505.         pb_canvas.Invalidate();
  506.     }
  507. }*/
  508.         /*if (draw && e.Button == MouseButtons.Left)
  509.         {
  510.             end = e.Location;
  511.  
  512.             using (Graphics g = Graphics.FromImage(drawingLayer))
  513.             {
  514.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  515.  
  516.                 if (isEraserActive)
  517.                 {
  518.                     int radius = eraserSize / 2;
  519.                     RectangleF eraseRect = new RectangleF(end.X - radius, end.Y - radius, 2 * radius, 2 * radius);
  520.  
  521.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  522.                     {
  523.                         path.AddEllipse(eraseRect);
  524.                         g.SetClip(path);
  525.                         g.Clear(Color.Transparent);
  526.                         g.ResetClip();
  527.                     }
  528.                 }
  529.                 else
  530.                 {
  531.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  532.                     {
  533.                         path.AddLine(start, end);
  534.                         g.DrawPath(p, path);
  535.                     }
  536.                 }
  537.             }
  538.  
  539.             start = end;
  540.             UpdateCanvas();
  541.         }
  542.         else
  543.         {
  544.             pb_canvas.Invalidate();
  545.         }
  546.     }*/
  547.         /*if (draw && e.Button == MouseButtons.Left)
  548.         {
  549.             end = e.Location;
  550.             using (Graphics g = Graphics.FromImage(drawingLayer))
  551.             {
  552.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  553.                 if (isEraserActive)
  554.                 {
  555.                     Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  556.                     int radius = eraserSize / 2;
  557.                     RectangleF eraseRect = new RectangleF(end.X - radius, end.Y - radius, 2 * radius, 2 * radius);
  558.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  559.                     {
  560.                         path.AddEllipse(eraseRect);
  561.                         g.SetClip(path);
  562.                         g.Clear(Color.Transparent);
  563.                         g.ResetClip();
  564.                     }
  565.                 }
  566.                 else
  567.                 {
  568.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  569.                     {
  570.                         path.AddLine(start, end);
  571.                         g.DrawPath(p, path);
  572.                     }
  573.                 }
  574.             }
  575.             start = end;
  576.             pb_canvas.Invalidate();
  577.         }
  578.         else
  579.         {
  580.             pb_canvas.Invalidate();
  581.         }
  582.     }*/
  583.  
  584.  
  585.  
  586.  
  587.  
  588.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  589. Start #15 Silhouette (disabled) starting anew
  590. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  591.         /*if (draw && e.Button == MouseButtons.Left)
  592.         //if (draw)
  593.         {
  594.             end = e.Location;
  595.             using (Graphics g = Graphics.FromImage(drawingLayer))
  596.             {
  597.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  598.                 if (isEraserActive)
  599.                 {
  600.                     Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  601.                     int radius = eraserSize / 2;
  602.                     RectangleF eraseRect = new RectangleF(start.X - radius, start.Y - radius, 2 * radius, 2 * radius);
  603.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  604.                     {
  605.                         path.AddEllipse(eraseRect);
  606.                         g.SetClip(path);
  607.                         g.Clear(Color.Transparent);
  608.                         g.ResetClip();
  609.                     }
  610.                 }
  611.                 else
  612.                 {
  613.                     using (SolidBrush brush = new SolidBrush(ColorTranslator.FromHtml(color))) // Update this line
  614.                     {
  615.                         g.FillEllipse(brush, end.X - (int)p.Width / 2, end.Y - (int)p.Width / 2, p.Width, p.Width);
  616.                     }*/
  617.         //g.DrawLine(p, start, end);
  618.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  619.         End #15 Silhouette (disabled) starting anew
  620.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  621.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  622. Start #7 Silhouette
  623. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  624.  
  625.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  626. Start #10 Silhouette (disabled)
  627. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  628.         /*Graphics g = pb_canvas.CreateGraphics();
  629.         try
  630.         {
  631.             if (!isEraserActive)
  632.             {
  633.                 Point cursorPosition = pb_canvas.PointToClient(Cursor.Position);
  634.                 g.DrawImage(brushSilhouette, cursorPosition.X - (int)p.Width / 2, cursorPosition.Y - (int)p.Width / 2);
  635.             }
  636.             else
  637.             {
  638.                 Point cursorPosition = pb_canvas.PointToClient(Cursor.Position);
  639.                 g.DrawImage(eraserSilhouette, cursorPosition.X - eraserSize / 2, cursorPosition.Y - eraserSize / 2);
  640.             }
  641.         }
  642.         finally
  643.         {
  644.             g.Dispose();
  645.         }*/
  646.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  647.         End #10 Silhouette (disabled)
  648.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  649.  
  650.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  651. //Start #18 Silhouette (disabled)
  652. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  653.         /*}
  654.     }
  655.     start = end;
  656.     pb_canvas.Invalidate();
  657. }
  658. else
  659. {
  660.     pb_canvas.Invalidate();  // Add this line to refresh the canvas when not drawing
  661. }
  662. }*/
  663.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  664.         End #18 Silhouette (disabled)
  665.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  666.  
  667.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  668.         End #7 Silhouette
  669.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  670.  
  671.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  672. Start #8 Silhouette (disabled)
  673. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  674.         /*if (draw)
  675.         {
  676.             end = e.Location;
  677.             using (Graphics g = Graphics.FromImage(drawingLayer))  // Modify the drawingLayer, not the loaded image
  678.             {
  679.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  680.                 if (isEraserActive)
  681.                 {
  682.                     Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  683.                     int radius = 50;
  684.                     RectangleF eraseRect = new RectangleF(start.X - radius, start.Y - radius, 2 * radius, 2 * radius);
  685.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  686.                     {
  687.                         path.AddEllipse(eraseRect);
  688.                         g.SetClip(path);
  689.                         g.Clear(Color.Transparent);
  690.                         g.ResetClip();
  691.                     }
  692.                 }
  693.                 else
  694.                 {
  695.                     g.DrawLine(p, start, end);
  696.                 }
  697.             }
  698.             start = end;
  699.             pb_canvas.Invalidate();
  700.         }
  701.     }*/
  702.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  703.         End #8 Silhouette (disabled)
  704.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.         //start Genius Mode FINAL FINAL FINAL fixes #22 RESAVE()            
  716.         /*if (draw)
  717.         {
  718.             end = e.Location;
  719.             using (Graphics g = Graphics.FromImage(pb_canvas.Image ?? drawingLayer))
  720.             {
  721.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  722.                 if (isEraserActive)
  723.                 {
  724.                     Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  725.                     int radius = 50;
  726.                     RectangleF eraseRect = new RectangleF(start.X - radius, start.Y - radius, 2 * radius, 2 * radius);
  727.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  728.                     {
  729.                         path.AddEllipse(eraseRect);
  730.                         g.SetClip(path);
  731.                         g.Clear(Color.Transparent);
  732.                         g.ResetClip();
  733.                     }
  734.                 }
  735.                 else
  736.                 {
  737.                     g.DrawLine(p, start, end);
  738.                 }
  739.             }
  740.             start = end;
  741.             pb_canvas.Invalidate();
  742.         }
  743.     }*/
  744.         //end Genius Mode FINAL FINAL FINAL fixes #22 RESAVE()
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.         //start Genius Mode FINAL FINAL fixes #8 clear()
  758.         /*if (draw)
  759.         {
  760.             end = e.Location;
  761.             using (Graphics g = Graphics.FromImage(drawingLayer))
  762.             {
  763.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  764.                 if (isEraserActive)
  765.                 {
  766.                     Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  767.                     RectangleF eraseRect = new RectangleF(start.X - eraserSize, start.Y - eraserSize, 2 * eraserSize, 2 * eraserSize);
  768.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  769.                     {
  770.                         path.AddEllipse(eraseRect);
  771.                         g.SetClip(path);
  772.                         g.Clear(Color.Transparent);
  773.                         g.ResetClip();
  774.                     }
  775.                 }
  776.                 else
  777.                 {
  778.                     g.DrawLine(p, start, end);
  779.                 }
  780.             }
  781.             start = end;
  782.             pb_canvas.Invalidate();
  783.         }
  784.     }*/
  785.         //end Genius Mode FINAL FINAL fixes #8 clear()
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.         //start Genius Mode fixes #1
  805.         //ChatGPTs finishing touches
  806.         /*if (draw)
  807.         {
  808.             end = e.Location;
  809.             using (Graphics g = Graphics.FromImage(drawingLayer))
  810.             {
  811.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  812.                 if (isEraserActive)
  813.                 {
  814.                     Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  815.                     int radius = 50;
  816.                     RectangleF eraseRect = new RectangleF(start.X - radius, start.Y - radius, 2 * radius, 2 * radius);
  817.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  818.                     {
  819.                         path.AddEllipse(eraseRect);
  820.                         g.SetClip(path);
  821.                         g.Clear(Color.Transparent);
  822.                         g.ResetClip();
  823.                     }
  824.                 }
  825.                 else
  826.                 {
  827.                     g.DrawLine(p, start, end);
  828.                 }
  829.             }
  830.             start = end;
  831.             pb_canvas.Invalidate();
  832.         }
  833.     }*/
  834.         //end Genius Mode fixes #1
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.         //Bards fixes
  853.         /*if (draw)
  854.         {
  855.             end = e.Location;
  856.             using (Graphics g = pb_canvas.CreateGraphics()) // Create Graphics from the canvas
  857.             //using (Graphics g = Graphics.FromImage(drawingLayer)) disabled temporarily for Bard 4pm 11th Jan 24
  858.             {
  859.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  860.                 if (isEraserActive)
  861.                 {
  862.                     // Erase only within the drawing layer's bounds
  863.                     Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  864.                     int radius = 50; // Set the radius of your circular clip here
  865.                     RectangleF eraseRect = new RectangleF(start.X - radius, start.Y - radius, 2 * radius, 2 * radius);
  866.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  867.                     {
  868.                         path.AddEllipse(eraseRect);
  869.                         g.SetClip(path);
  870.                         g.Clear(Color.Transparent); // Clear the drawing layer
  871.                         g.ResetClip();
  872.                     }
  873.                 }*/
  874.         //===================================================================//(start BingAI test FINAL4 #24) Fallback code!
  875.         /*if (draw)
  876.         {
  877.             end = e.Location;
  878.             using (Graphics g = Graphics.FromImage(drawingLayer))
  879.             {
  880.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  881.                 if (isEraserActive)
  882.                 {
  883.                     // Erase only within the drawing layer's bounds
  884.                     Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  885.                     int radius = 50; // Set the radius of your circular clip here
  886.                     RectangleF eraseRect = new RectangleF(start.X - radius, start.Y - radius, 2 * radius, 2 * radius);
  887.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  888.                     {
  889.                         path.AddEllipse(eraseRect);
  890.                         g.SetClip(path);
  891.                         g.Clear(Color.Transparent); // Clear the drawing layer
  892.                         g.ResetClip();
  893.                     }
  894.                 }
  895.                 else
  896.                 {
  897.                     g.DrawLine(p, start, end);
  898.                 }
  899.             }
  900.             start = end;
  901.             pb_canvas.Invalidate();
  902.         }*/
  903.         //===================================================================//(end BingAI test FINAL4 #23) Fallback code!
  904.  
  905.         //===================================================================//(start BingAI test #21)
  906.         /*if (draw)
  907.             {
  908.                 end = e.Location;
  909.                 using (Graphics g = Graphics.FromImage(drawingLayer))
  910.                 {
  911.                     g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  912.                     if (isEraserActive)
  913.                     {
  914.                         // Erase only within the drawing layer's bounds
  915.                         Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  916.                         int radius = 50; // Set the radius of your circular clip here
  917.                         RectangleF eraseRect = new RectangleF(start.X - radius, start.Y - radius, 2 * radius, 2 * radius);
  918.                         using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  919.                         {
  920.                             path.AddEllipse(eraseRect);
  921.                             g.SetClip(path);
  922.                             g.Clear(Color.Transparent); // Clear the drawing layer
  923.                             g.DrawImage(pb_canvas.BackgroundImage, eraseRect, eraseRect, GraphicsUnit.Pixel); // Draw the background image within the clip region
  924.                             g.ResetClip();
  925.                         }
  926.                     }*/
  927.         //===================================================================//(end BingAI test #21)
  928.  
  929.         //===================================================================(start bard test #19)
  930.         //fully working BingAI Solution!
  931.         /*if (draw)
  932. {
  933. end = e.Location;
  934. using (Graphics g = Graphics.FromImage(drawingLayer))
  935. {
  936.     g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  937.     if (isEraserActive)
  938.     {
  939.         // Erase only within the drawing layer's bounds
  940.         Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  941.         int radius = 50; // Set the radius of your circular clip here
  942.         RectangleF eraseRect = new RectangleF(start.X - radius, start.Y - radius, 2 * radius, 2 * radius);
  943.         using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  944.         {
  945.             path.AddEllipse(eraseRect);
  946.             g.SetClip(path);
  947.             g.Clear(Color.Transparent); // Clear the drawing layer
  948.             g.DrawImage(pb_canvas.BackgroundImage, eraseRect, eraseRect, GraphicsUnit.Pixel); // Draw the background image within the clip region
  949.             g.ResetClip();
  950.         }
  951.     }*/
  952.         //===================================================================(end bard test #19)
  953.         //BingAI without Entire Tiled Region Bug
  954.         /*if (draw)
  955.         {
  956.             end = e.Location;
  957.             using (Graphics g = Graphics.FromImage(drawingLayer))
  958.             {
  959.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  960.                 if (isEraserActive)
  961.                 {
  962.                     // Erase only within the drawing layer's bounds
  963.                     Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  964.                     int radius = 50; // Set the radius of your circular clip here
  965.                     RectangleF eraseRect = new RectangleF(start.X - radius, start.Y - radius, 2 * radius, 2 * radius);
  966.                     using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
  967.                     {
  968.                         path.AddEllipse(eraseRect);
  969.                         g.SetClip(path);
  970.                         g.DrawImage(pb_canvas.BackgroundImage, eraseRect, eraseRect, GraphicsUnit.Pixel);
  971.                         g.ResetClip();
  972.                     }
  973.                 }*/
  974.  
  975.         //===================================================================//(start bard test FINAL #17)
  976.         /*if (draw)
  977.         {
  978.             end = e.Location;
  979.             using (Graphics g = Graphics.FromImage(drawingLayer))
  980.             {
  981.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  982.                 if (isEraserActive)
  983.                 {
  984.                     // Calculate clipping rectangle to prevent drawing outside bounds
  985.                     Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  986.                     Rectangle eraseRect = new Rectangle(start, new Size(Math.Abs(end.X - start.X) * 3, Math.Abs(end.Y - start.Y) * 3)); // Double the width and height
  987.                     //Rectangle eraseRect = new Rectangle(start, new Size(Math.Abs(end.X - start.X), Math.Abs(end.Y - start.Y)));
  988.                     Rectangle clipRect = Rectangle.Intersect(drawingBounds, eraseRect);
  989.  
  990.                     // Set clipping region before clearing
  991.                     g.SetClip(clipRect);
  992.                     g.Clear(Color.Transparent); // Clear within the clipping region
  993.                     g.ResetClip(); // Remove clipping region for subsequent operations
  994.                     // Erase within the clipping rectangle with transparent color //(start bard test #11 line)
  995.                     //g.Clear(Color.Transparent, clipRect);
  996.                 }*/
  997.         //===================================================================//(end bard test FINAL #17)
  998.         //start google bard broken deleteme code
  999.         /*if (draw)
  1000.         {
  1001.             end = e.Location;
  1002.             using (Graphics g = Graphics.FromImage(drawingLayer))
  1003.             {
  1004.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1005.                 if (isEraserActive)
  1006.                 {
  1007.                     // Calculate clipping rectangle considering both axes
  1008.                     Rectangle eraseRect = new Rectangle(start, new Size(Math.Abs(end.X - start.X), Math.Abs(end.Y - start.Y)));
  1009.  
  1010.                     // Tile the background image within the erase rectangle
  1011.                     for (int x = eraseRect.Left; x < eraseRect.Right; x += pb_canvas.BackgroundImage.Width)
  1012.                     {
  1013.                         for (int y = eraseRect.Top; y < eraseRect.Bottom; y += pb_canvas.BackgroundImage.Height)
  1014.                         {
  1015.                             g.DrawImage(pb_canvas.BackgroundImage, x, y);
  1016.                         }
  1017.                     }
  1018.                 }*/
  1019.         //end google bard broken deleteme code
  1020.  
  1021.         //(start bard test #10)
  1022.         /*if (draw)
  1023.         {
  1024.             end = e.Location;
  1025.             using (Graphics g = Graphics.FromImage(drawingLayer))
  1026.             {
  1027.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1028.                 if (isEraserActive)
  1029.                 {
  1030.                     // Calculate clipping rectangle to ensure erasing within bounds
  1031.                     Rectangle drawingBounds = new Rectangle(0, 0, drawingLayer.Width, drawingLayer.Height);
  1032.                     Rectangle eraseRect = new Rectangle(start, new Size(Math.Abs(end.X - start.X), Math.Abs(end.Y - start.Y)));
  1033.                     Rectangle clipRect = Rectangle.Intersect(drawingBounds, eraseRect);
  1034.                     // Only erase if the clipping rectangle has non-zero dimensions
  1035.                     if (clipRect.Width > 0 && clipRect.Height > 0)
  1036.                     {
  1037.                         g.DrawImage(pb_canvas.BackgroundImage, clipRect, clipRect, GraphicsUnit.Pixel);
  1038.                     }
  1039.                 }*/
  1040.         //(end bard test #10)
  1041.         //(start bard test #9)
  1042.         /*g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1043.         if (isEraserActive)
  1044.         {
  1045.             // Erase by copying pixels from the background image
  1046.             if (pb_canvas.BackgroundImage != null)
  1047.             {
  1048.                 g.DrawImage(pb_canvas.BackgroundImage, start.X, start.Y, end.X - start.X, end.Y - start.Y);
  1049.             }
  1050.         }                    
  1051.         else
  1052.         {
  1053.             g.DrawLine(p, start, end);
  1054.         }
  1055.     }
  1056.     start = end;
  1057.     pb_canvas.Invalidate();
  1058. }
  1059. }*/
  1060.         //(end bard test #9)
  1061.         //(start bard #6)
  1062.         /*//if (e.Button == MouseButtons.Left)
  1063.         //{
  1064.         end = e.Location;
  1065.         // Use CreateGraphics to draw on the PictureBox
  1066.         // Instead of creating a new Graphics object, use the one provided in the PaintEventArgs
  1067.         using (Graphics g = Graphics.FromImage(drawingLayer))
  1068.         //using (Graphics g = pb_canvas.CreateGraphics())
  1069.         {
  1070.             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // Enable anti-aliasing for drawing layer
  1071.             g.DrawLine(p, start, end);
  1072.             }
  1073.             //graphics.DrawLine(p, start, end);
  1074.             start = end;
  1075.             pb_canvas.Invalidate();
  1076.     }//*(end bard #6)
  1077.  
  1078. }
  1079. //}
  1080.  
  1081. /*private void SetTiledBackground()
  1082. {
  1083.     try
  1084.     {
  1085.         //string filePath = @"D:\Download\cpp-projekt\Simple Drawing App\bin\Debug\graph9.gif";
  1086.         string resourceName = "Simple_Drawing_Application.graph9.gif";
  1087.         // Replace "YourNamespace" with the actual namespace where the GIF is stored
  1088.         //if (File.Exists(filePath))
  1089.         using (Stream stream = this.GetType().Assembly.GetManifestResourceStream(resourceName))
  1090.  
  1091.         {
  1092.             if (stream != null)
  1093.             {
  1094.                 // Load the GIF from the stream
  1095.                 Image tiledBackground = Image.FromStream(stream);
  1096.  
  1097.                 // Set the BackgroundImage property of pb_canvas
  1098.                 pb_canvas.BackgroundImage = tiledBackground;
  1099.  
  1100.                 // Set the BackgroundImageLayout property to Tile to tile the image
  1101.                 pb_canvas.BackgroundImageLayout = ImageLayout.Tile;
  1102.             }
  1103.             else
  1104.             {
  1105.                 MessageBox.Show("Failed to get the resource stream.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  1106.             }
  1107.         }
  1108.     }
  1109.     catch (Exception ex)
  1110.     {
  1111.         MessageBox.Show($"Error setting tiled background: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  1112.     }
  1113. }*/
  1114.         /*{
  1115.             // Load the GIF from the file
  1116.             Image tiledBackground = Image.FromFile(filePath);
  1117.  
  1118.             // Set the BackgroundImage property of pb_canvas
  1119.             pb_canvas.BackgroundImage = tiledBackground;
  1120.  
  1121.             // Set the BackgroundImageLayout property to Tile to tile the image
  1122.             pb_canvas.BackgroundImageLayout = ImageLayout.Tile;
  1123.         }
  1124.         else
  1125.         {
  1126.             MessageBox.Show("The specified file does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  1127.         }
  1128.     }
  1129.     catch (Exception ex)
  1130.     {
  1131.         MessageBox.Show($"Error setting tiled background: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  1132.     }
  1133. }*/
  1134.         /*{
  1135.           if (stream != null)
  1136.           {
  1137.               // Load the GIF from the stream
  1138.               Image tiledBackground = Image.FromStream(stream);
  1139.  
  1140.               // Set the BackgroundImage property of pb_canvas
  1141.               pb_canvas.BackgroundImage = tiledBackground;
  1142.  
  1143.               // Set the BackgroundImageLayout property to Tile to tile the image
  1144.               pb_canvas.BackgroundImageLayout = ImageLayout.Tile;
  1145.           }
  1146.           else
  1147.           {
  1148.               MessageBox.Show("Failed to get the resource stream.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  1149.           }
  1150.       }
  1151.   }
  1152.   catch (Exception ex)
  1153.   {
  1154.       MessageBox.Show($"Error setting tiled background: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  1155.   }
  1156. }*/
  1157.  
  1158.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1159. Start #4 Silhouette
  1160. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1161.  
  1162.         private Bitmap GenerateBrushSilhouette(float width, string color)
  1163.         {
  1164.             Bitmap brushSilhouette = new Bitmap((int)width, (int)width);
  1165.             using (Graphics g = Graphics.FromImage(brushSilhouette))
  1166.             {
  1167.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1168.  
  1169.                 Color fillColor = ColorTranslator.FromHtml(color);
  1170.                 using (Brush brush = new SolidBrush(fillColor))
  1171.                 {
  1172.                     g.FillEllipse(brush, 0, 0, width, width);
  1173.                 }
  1174.  
  1175.                 // Ensure the bitmap has an alpha channel for transparency
  1176.                 brushSilhouette.MakeTransparent();
  1177.             }
  1178.  
  1179.             return brushSilhouette;
  1180.         }
  1181.  
  1182.         /*Bitmap brushSilhouette = new Bitmap((int)width, (int)width);
  1183.         using (Graphics g = Graphics.FromImage(brushSilhouette))
  1184.         {
  1185.             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1186.             using (Brush brush = new SolidBrush(ColorTranslator.FromHtml(color)))
  1187.             {
  1188.                 g.FillEllipse(brush, 0, 0, width, width);
  1189.             }
  1190.         }
  1191.         return brushSilhouette;
  1192.     }*/
  1193.  
  1194.  
  1195.         /*Bitmap brushSilhouette = new Bitmap((int)width, (int)width, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
  1196.         using (Graphics g = Graphics.FromImage(brushSilhouette))
  1197.         {
  1198.             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1199.             using (Brush brush = new SolidBrush(ColorTranslator.FromHtml(color)))
  1200.             {
  1201.                 g.FillEllipse(brush, 0, 0, width, width);
  1202.             }
  1203.         }
  1204.         return brushSilhouette;
  1205.     }*/
  1206.  
  1207.  
  1208.  
  1209.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1210. Start #39 Silhouette adding persistent values
  1211. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1212.         /*Bitmap brushSilhouette = new Bitmap((int)width, (int)width);
  1213.         using (Graphics g = Graphics.FromImage(brushSilhouette))
  1214.         {
  1215.             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1216.             using (Brush brush = new SolidBrush(ColorTranslator.FromHtml(color)))
  1217.             {
  1218.                 g.FillEllipse(brush, 0, 0, width, width);
  1219.             }
  1220.         }
  1221.         return brushSilhouette;
  1222.     }*/
  1223.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1224.         End #39 Silhouette adding persistent values
  1225.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1226.  
  1227.  
  1228.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1229. Start #37 Silhouette adding persistent values
  1230. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1231.         /*int silhouetteSize = (int)width;
  1232.         if (silhouetteSize <= 0)
  1233.         {
  1234.             return null; // Avoid creating invalid bitmaps
  1235.         }
  1236.  
  1237.         Bitmap brushSilhouette = new Bitmap(silhouetteSize, silhouetteSize);
  1238.         using (Graphics g = Graphics.FromImage(brushSilhouette))
  1239.         {
  1240.             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1241.             using (Brush brush = new SolidBrush(ColorTranslator.FromHtml(color)))
  1242.             {
  1243.                 g.FillEllipse(brush, 0, 0, silhouetteSize, silhouetteSize);
  1244.             }
  1245.         }
  1246.         return brushSilhouette;
  1247.     }*/
  1248.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1249.         End #37 Silhouette adding persistent values
  1250.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1251.  
  1252.  
  1253.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1254. Start #27 Silhouette adding persistent values
  1255. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1256.         /*Bitmap brushSilhouette = new Bitmap((int)width, (int)width);
  1257.         using (Graphics g = Graphics.FromImage(brushSilhouette))
  1258.         {
  1259.             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1260.             using (Brush brush = new SolidBrush(ColorTranslator.FromHtml(color)))
  1261.             {
  1262.                 g.FillEllipse(brush, 0, 0, width, width);
  1263.             }
  1264.         }
  1265.         return brushSilhouette;
  1266.     }*/
  1267.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1268.         End #27 Silhouette adding persistent values
  1269.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1270.  
  1271.  
  1272.         private Bitmap GenerateEraserSilhouette(int size)
  1273.         {
  1274.             Bitmap eraserSilhouette = new Bitmap(size, size);
  1275.             using (Graphics g = Graphics.FromImage(eraserSilhouette))
  1276.             {
  1277.                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1278.                 using (Brush brush = new SolidBrush(Color.Black))
  1279.                 {
  1280.                     g.FillEllipse(brush, 0, 0, size, size);
  1281.                 }
  1282.             }
  1283.             return eraserSilhouette;
  1284.         }
  1285.  
  1286.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1287. Start #38 Silhouette adding persistent values
  1288. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1289.         /*int silhouetteSize = size;
  1290.         if (silhouetteSize <= 0)
  1291.         {
  1292.             return null; // Avoid creating invalid bitmaps
  1293.         }
  1294.  
  1295.         Bitmap eraserSilhouette = new Bitmap(silhouetteSize, silhouetteSize);
  1296.         using (Graphics g = Graphics.FromImage(eraserSilhouette))
  1297.         {
  1298.             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1299.             using (Brush brush = new SolidBrush(Color.Black))
  1300.             {
  1301.                 g.FillEllipse(brush, 0, 0, silhouetteSize, silhouetteSize);
  1302.             }
  1303.             using (Pen pen = new Pen(Color.Black, 2))
  1304.             {
  1305.                 g.DrawEllipse(pen, 0, 0, silhouetteSize, silhouetteSize);
  1306.             }
  1307.         }
  1308.         return eraserSilhouette;
  1309.     }*/
  1310.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1311.         End #38 Silhouette adding persistent values
  1312.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1313.  
  1314.  
  1315.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1316. Start #27 Silhouette adding persistent values
  1317. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1318.         /*Bitmap eraserSilhouette = new Bitmap(size, size);
  1319.         using (Graphics g = Graphics.FromImage(eraserSilhouette))
  1320.         {
  1321.             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1322.             using (Brush brush = new SolidBrush(Color.Black))
  1323.             {
  1324.                 g.FillEllipse(brush, 0, 0, size, size);
  1325.             }
  1326.             using (Pen pen = new Pen(Color.Black, 2))
  1327.             {
  1328.                 g.DrawEllipse(pen, 0, 0, size, size);
  1329.             }
  1330.         }
  1331.         return eraserSilhouette;
  1332.     }*/
  1333.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1334.         End #27 Silhouette adding persistent values
  1335.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1336.  
  1337.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1338.         End #4 Silhouette
  1339.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1340.  
  1341.         void UpdatePen()
  1342.         {
  1343.             // Update the pen color and size based on the current values
  1344.             p.Color = ColorTranslator.FromHtml(color);
  1345.             //p.Width = Convert.ToInt32(comboBox1.Text);
  1346.             GenerateSilhouettes();
  1347.             // Update the Set Font Size menu item text
  1348.             setFontSizeToolStripMenuItem.Text = $"Set Font Size ({p.Width})";
  1349.         }
  1350.  
  1351.         private void pb_canvas_MouseUp(object sender, MouseEventArgs e)
  1352.         {
  1353.             draw = false;
  1354.             PushToUndoStackIfNeeded();
  1355.         }
  1356.  
  1357.         private void PushToUndoStack()
  1358.         {
  1359.             undoStack.Push(new Bitmap(drawingLayer));
  1360.             redoStack.Clear();
  1361.         }
  1362.  
  1363.         private void PushToUndoStackIfNeeded()
  1364.         {
  1365.             if (canvasDirty)
  1366.             {
  1367.                 undoStack.Push(new Bitmap(drawingLayer));
  1368.                 redoStack.Clear();
  1369.                 canvasDirty = false; // Reset the canvas dirty flag
  1370.             }
  1371.         }
  1372.  
  1373.         private void Undo()
  1374.         {
  1375.             if (undoStack.Count > 0)
  1376.             {
  1377.                 redoStack.Push(new Bitmap(drawingLayer));
  1378.                 drawingLayer.Dispose();
  1379.                 drawingLayer = new Bitmap(undoStack.Pop());
  1380.                 UpdateCanvas();
  1381.             }
  1382.         }
  1383.  
  1384.         private void Redo()
  1385.         {
  1386.             if (redoStack.Count > 0)
  1387.             {
  1388.                 undoStack.Push(new Bitmap(drawingLayer));
  1389.                 drawingLayer.Dispose();
  1390.                 drawingLayer = new Bitmap(redoStack.Pop());
  1391.                 UpdateCanvas();
  1392.             }
  1393.             else if (undoStack.Count > 0)
  1394.             {
  1395.                 redoStack.Push(new Bitmap(drawingLayer));
  1396.                 drawingLayer.Dispose();
  1397.                 drawingLayer = new Bitmap(undoStack.Pop());
  1398.                 UpdateCanvas();
  1399.             }
  1400.         }
  1401.  
  1402.         //this is in perfect working condition (undo()) but gpt has a fix for redo that requires changing this
  1403.         /*private void Undo()
  1404.         {
  1405.             PushToUndoStackIfNeeded();
  1406.  
  1407.             if (undoStack.Count > 0)
  1408.             {
  1409.                 drawingLayer.Dispose();
  1410.                 drawingLayer = new Bitmap(undoStack.Pop());
  1411.                 UpdateCanvas();
  1412.             }
  1413.             else if (redoStack.Count > 0)
  1414.             {
  1415.                 drawingLayer.Dispose();
  1416.                 drawingLayer = new Bitmap(redoStack.Pop());
  1417.                 UpdateCanvas();
  1418.             }
  1419.         }
  1420.  
  1421.         private void Redo()
  1422.         {
  1423.             if (redoStack.Count > 0)
  1424.             {
  1425.                 undoStack.Push(new Bitmap(drawingLayer));
  1426.                 drawingLayer.Dispose();
  1427.                 drawingLayer = new Bitmap(redoStack.Pop());
  1428.                 UpdateCanvas();
  1429.             }
  1430.             else
  1431.             {
  1432.                 // If redoStack is empty, check if undoStack has items
  1433.                 if (undoStack.Count > 0)
  1434.                 {
  1435.                     redoStack.Push(new Bitmap(drawingLayer));
  1436.                     drawingLayer.Dispose();
  1437.                     drawingLayer = new Bitmap(undoStack.Pop());
  1438.                     UpdateCanvas();
  1439.                 }
  1440.             }
  1441.         }*/
  1442.  
  1443.         //bards broken fix
  1444.         /*private void Redo()
  1445.         {
  1446.             if (redoStack.Count > 0)
  1447.             {
  1448.                 // **Ensure consistent state for Redo**
  1449.                 drawingLayer.Dispose();  // Dispose of current drawing layer before loading a new one
  1450.  
  1451.                 drawingLayer = new Bitmap(redoStack.Pop());
  1452.                 undoStack.Push(new Bitmap(drawingLayer));  // Add the reverted state to undoStack
  1453.                 UpdateCanvas();
  1454.             }
  1455.         }*/
  1456.  
  1457.         //redo broken this is original below, undo working
  1458.         /*private void Redo()
  1459.         {
  1460.             if (redoStack.Count > 0)
  1461.             {
  1462.                 undoStack.Push(new Bitmap(drawingLayer));
  1463.                 drawingLayer.Dispose();
  1464.                 drawingLayer = new Bitmap(redoStack.Pop());
  1465.                 redoStack.Clear();  // Clear the redo stack after redoing an action
  1466.                 UpdateCanvas();
  1467.             }
  1468.         }*/
  1469.  
  1470.         /*private void Redo()
  1471.         {
  1472.             if (redoStack.Count > 0)
  1473.             {
  1474.                 undoStack.Push(new Bitmap(drawingLayer));
  1475.                 drawingLayer.Dispose();
  1476.                 drawingLayer = new Bitmap(redoStack.Pop());
  1477.                 UpdateCanvas();
  1478.             }
  1479.         }*/
  1480.  
  1481.         /*private void Redo()
  1482.         {
  1483.             if (redoStack.Count > 0)
  1484.             {
  1485.                 undoStack.Push(new Bitmap(drawingLayer));
  1486.                 drawingLayer.Dispose();
  1487.                 drawingLayer = new Bitmap(redoStack.Pop());
  1488.                 UpdateCanvas();
  1489.             }
  1490.             else if (undoStack.Count > 0)
  1491.             {
  1492.                 redoStack.Push(new Bitmap(drawingLayer));
  1493.                 drawingLayer.Dispose();
  1494.                 drawingLayer = new Bitmap(undoStack.Pop());
  1495.                 UpdateCanvas();
  1496.             }
  1497.         }*/
  1498.  
  1499.         /*private void Redo()
  1500.         {
  1501.             PushToUndoStackIfNeeded();
  1502.  
  1503.             if (redoStack.Count > 0)
  1504.             {
  1505.                 drawingLayer.Dispose();
  1506.                 drawingLayer = new Bitmap(redoStack.Pop());
  1507.                 UpdateCanvas();
  1508.             }
  1509.             else if (undoStack.Count > 0)
  1510.             {
  1511.                 drawingLayer.Dispose();
  1512.                 drawingLayer = new Bitmap(undoStack.Pop());
  1513.                 UpdateCanvas();
  1514.             }
  1515.         }*/
  1516.  
  1517.         /*private void Undo()
  1518.         {
  1519.             if (canvasDirty)
  1520.             {
  1521.                 undoStack.Push(new Bitmap(drawingLayer));
  1522.                 redoStack.Clear();
  1523.                 canvasDirty = false; // Reset the canvas dirty flag
  1524.             }
  1525.  
  1526.             if (undoStack.Count > 0)
  1527.             {
  1528.                 drawingLayer.Dispose();
  1529.                 drawingLayer = new Bitmap(undoStack.Pop());
  1530.                 UpdateCanvas();
  1531.             }
  1532.             else if (redoStack.Count > 0)
  1533.             {
  1534.                 drawingLayer.Dispose();
  1535.                 drawingLayer = new Bitmap(redoStack.Pop());
  1536.                 UpdateCanvas();
  1537.             }
  1538.         }
  1539.  
  1540.         private void Redo()
  1541.         {
  1542.             if (canvasDirty)
  1543.             {
  1544.                 undoStack.Push(new Bitmap(drawingLayer));
  1545.                 redoStack.Clear();
  1546.                 canvasDirty = false; // Reset the canvas dirty flag
  1547.             }
  1548.  
  1549.             if (redoStack.Count > 0)
  1550.             {
  1551.                 drawingLayer.Dispose();
  1552.                 drawingLayer = new Bitmap(redoStack.Pop());
  1553.                 UpdateCanvas();
  1554.             }
  1555.             else if (undoStack.Count > 0)
  1556.             {
  1557.                 drawingLayer.Dispose();
  1558.                 drawingLayer = new Bitmap(undoStack.Pop());
  1559.                 UpdateCanvas();
  1560.             }
  1561.         }*/
  1562.  
  1563.         /*private void Undo()
  1564.         {
  1565.             if (undoStack.Count > 0)
  1566.             {
  1567.                 redoStack.Push(new Bitmap(drawingLayer));
  1568.                 drawingLayer.Dispose();
  1569.                 drawingLayer = new Bitmap(undoStack.Pop());
  1570.                 UpdateCanvas();
  1571.             }
  1572.             else if (redoStack.Count > 0)
  1573.             {
  1574.                 drawingLayer.Dispose();
  1575.                 drawingLayer = new Bitmap(redoStack.Pop());
  1576.                 UpdateCanvas();
  1577.             }
  1578.         }
  1579.  
  1580.         private void Redo()
  1581.         {
  1582.             if (redoStack.Count > 0)
  1583.             {
  1584.                 undoStack.Push(new Bitmap(drawingLayer));
  1585.                 drawingLayer.Dispose();
  1586.                 drawingLayer = new Bitmap(redoStack.Pop());
  1587.                 UpdateCanvas();
  1588.             }
  1589.             else if (undoStack.Count > 0)
  1590.             {
  1591.                 redoStack.Push(new Bitmap(drawingLayer));
  1592.                 drawingLayer.Dispose();
  1593.                 drawingLayer = new Bitmap(undoStack.Pop());
  1594.                 UpdateCanvas();
  1595.             }
  1596.         }*/
  1597.  
  1598.         private void UpdateCanvas()
  1599.         {
  1600.             pb_canvas.Invalidate();
  1601.         }
  1602.  
  1603.         private void undoToolStripMenuItem_Click(object sender, EventArgs e)
  1604.         {
  1605.             Undo();
  1606.         }
  1607.  
  1608.         private void redoToolStripMenuItem_Click(object sender, EventArgs e)
  1609.         {
  1610.             Redo();
  1611.         }
  1612.  
  1613.         private void Form1_KeyDown(object sender, KeyEventArgs e)
  1614.         {
  1615.             if (e.KeyCode == Keys.P)
  1616.             {
  1617.                 ActivatePaintbrush();
  1618.             }
  1619.             else if (e.KeyCode == Keys.E)
  1620.             {
  1621.                 ActivateEraser();
  1622.             }
  1623.             else if (e.KeyCode == Keys.C)
  1624.             {
  1625.                 ClearCanvas();
  1626.             }
  1627.             // Check if the user pressed the '+' or '-' key
  1628.             else if (e.KeyCode == Keys.Oemplus || e.KeyCode == Keys.Add)
  1629.             {
  1630.                 // Increase the paintbrush size by 1
  1631.                 IncreasePaintbrushSize();
  1632.             }
  1633.             else if (e.KeyCode == Keys.OemMinus || e.KeyCode == Keys.Subtract)
  1634.             {
  1635.                 // Decrease the paintbrush size by 1
  1636.                 DecreasePaintbrushSize();
  1637.             }
  1638.         }
  1639.  
  1640.         private void clearToolStripMenuItem_Click(object sender, EventArgs e)
  1641.         {
  1642.             ClearCanvas();
  1643.         }
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.  
  1658.         //This is GPTs final attempt (fail)
  1659.         /*DialogResult result = MessageBox.Show("Are you sure you want to clear the drawing window?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  1660.         if (result == DialogResult.Yes)
  1661.         {
  1662.             drawingLayer = new Bitmap(pb_canvas.Width, pb_canvas.Height);
  1663.             Graphics.FromImage(drawingLayer).Clear(Color.Transparent);
  1664.             pb_canvas.BackgroundImage = null; // Clear background image
  1665.             pb_canvas.Invalidate();
  1666.         }
  1667.     }*/
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.         //ChatGPTs Final Attempt (Bing below Failed don't use below)
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.         /*// Display a confirmation dialog
  1680.         DialogResult result = MessageBox.Show("Are you sure you want to clear the drawing window?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  1681.  
  1682.         // Check the user's response
  1683.         if (result == DialogResult.Yes)
  1684.         {
  1685.             // Clear the drawing layer    
  1686.             Graphics.FromImage(drawingLayer).Clear(Color.Transparent);
  1687.  
  1688.             // Clear the PictureBox's Image
  1689.             pb_canvas.Image = null;
  1690.  
  1691.             // Refresh the PictureBox to reflect the changes
  1692.             pb_canvas.Invalidate();
  1693.         }
  1694.         // If the user clicks "No" or closes the dialog, do nothing
  1695.  
  1696.     }*/
  1697.  
  1698.         //Bings Final Attempt (below is not original)
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.         /*// Display a confirmation dialog
  1705.         DialogResult result = MessageBox.Show("Are you sure you want to clear the drawing window?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  1706.  
  1707.         // Check the user's response
  1708.         if (result == DialogResult.Yes)
  1709.         {
  1710.             // Clear the drawing layer    
  1711.             Graphics.FromImage(drawingLayer).Clear(Color.Transparent);
  1712.  
  1713.             // Clear the PictureBox's Image
  1714.             //pb_canvas.Image = null;
  1715.  
  1716.             // Refresh the PictureBox to reflect the changes
  1717.             pb_canvas.Invalidate();
  1718.         }
  1719.         // If the user clicks "No" or closes the dialog, do nothing
  1720.     }*/
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.         //start Genius Mode FINAL FINAL FINAL fixes #21 RESAVE()            
  1729.         /*DialogResult result = MessageBox.Show("Are you sure you want to clear the drawing window?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  1730.         if (result == DialogResult.Yes)
  1731.         {
  1732.             Graphics.FromImage(drawingLayer).Clear(Color.Transparent);
  1733.             pb_canvas.Image = null;  // Clear the Image property instead of the BackgroundImage
  1734.             pb_canvas.Invalidate();
  1735.         }
  1736.     }*/
  1737.         //end Genius Mode FINAL FINAL FINAL fixes #21 RESAVE()
  1738.  
  1739.         //start Genius Mode FINAL fixes #6 clear()
  1740.         /*//BingAI Final Test for Load Clear
  1741.         // Display a confirmation dialog
  1742.         DialogResult result = MessageBox.Show("Are you sure you want to clear the drawing window?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  1743.             if (result == DialogResult.Yes)
  1744.             {
  1745.                 Graphics.FromImage(drawingLayer).Clear(Color.Transparent);
  1746.                 pb_canvas.BackgroundImage = null;  // Clear the background image as well
  1747.                 pb_canvas.Invalidate();
  1748.             }
  1749.             // If the user clicks "No" or closes the dialog, do nothing
  1750.         }*/
  1751.         //end Genius Mode FINAL fixes #6 clear()
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.         //===================================================================//(start BingAI test FINAL4 #23) Fallback code!
  1763.         /*// Display a confirmation dialog
  1764.         DialogResult result = MessageBox.Show("Are you sure you want to clear the drawing window?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  1765.  
  1766.         // Check the user's response
  1767.         if (result == DialogResult.Yes)
  1768.         {
  1769.             // Clear the drawing layer    
  1770.             Graphics.FromImage(drawingLayer).Clear(Color.Transparent);
  1771.  
  1772.             // Refresh the PictureBox to reflect the changes
  1773.             pb_canvas.Invalidate();
  1774.         }
  1775.         // If the user clicks "No" or closes the dialog, do nothing
  1776.     }*/
  1777.         //===================================================================//(start BingAI test FINAL4 #23) Fallback code!
  1778.  
  1779.         //===================================================================//(start BingAI test FINAL3 #21)
  1780.         /*// Display a confirmation dialog
  1781.         DialogResult result = MessageBox.Show("Are you sure you want to clear the drawing window?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  1782.  
  1783.         // Check the user's response
  1784.         if (result == DialogResult.Yes)
  1785.         {
  1786.             // Clear the drawing layer    
  1787.             Graphics.FromImage(drawingLayer).Clear(Color.Transparent);
  1788.  
  1789.             // Clear the PictureBox background image
  1790.             pb_canvas.Image = null;
  1791.  
  1792.             pb_canvas.Invalidate();
  1793.  
  1794.             //pb_canvas.BackgroundImage = new Bitmap(pb_canvas.Width, pb_canvas.Height);
  1795.             // Clear the drawing window
  1796.             //pb_canvas.Invalidate();
  1797.             //CreateCanvas();
  1798.         }
  1799.         // If the user clicks "No" or closes the dialog, do nothing
  1800.     }*/
  1801.         //===================================================================//(end BingAI test FINAL3 #21)
  1802.  
  1803.         private void ClearCanvas()
  1804.         {
  1805.             DialogResult result = MessageBox.Show("Are you sure you want to clear the drawing window?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  1806.             if (result == DialogResult.Yes)
  1807.             {
  1808.                 drawingLayer = new Bitmap(pb_canvas.Width, pb_canvas.Height);  // Create a new drawingLayer with the same size as the PictureBox
  1809.                 pb_canvas.Image = null;  // Clear the Image property
  1810.                 pb_canvas.Invalidate();
  1811.             }
  1812.         }
  1813.  
  1814.  
  1815.         private void UpdateFontColor()
  1816.         {
  1817.             // (for English colornames)
  1818.             selectColorToolStripMenuItem.Text = $"Select Color ({GetFriendlyColorName(color)})";
  1819.             // Update the font color text dynamically in the menu bar (orig)
  1820.             //selectColorToolStripMenuItem.Text = $"Select Color ({GetFriendlyColorName(color)})";
  1821.         }
  1822.  
  1823.         private void SetBackgroundColor()
  1824.         {
  1825.             // Display the ColorDialog to let the user choose a background color
  1826.             ColorDialog colorDialog = new ColorDialog();
  1827.  
  1828.             if (colorDialog.ShowDialog() == DialogResult.OK)
  1829.             {
  1830.                 // Set the background color of pb_canvas
  1831.                 pb_canvas.BackColor = colorDialog.Color;
  1832.  
  1833.                 //delete this if fail (not hex)
  1834.                 // Get the friendly name for the color if available, otherwise use the hex value
  1835.                 string friendlyColorName = Color.FromName(pb_canvas.BackColor.Name).IsKnownColor
  1836.                     ? pb_canvas.BackColor.Name
  1837.                     : $"#{pb_canvas.BackColor.R:X2}{pb_canvas.BackColor.G:X2}{pb_canvas.BackColor.B:X2}";
  1838.  
  1839.                 //delete this if fail (not hex)
  1840.                 selectBGToolStripMenuItem.Text = $"Select Background ({friendlyColorName})";
  1841.                 // Display the hex color in the menu item dynamically (orig)
  1842.                 //selectBGToolStripMenuItem.Text = $"Select BG ({ColorToHex(colorDialog.Color)})";
  1843.             }
  1844.         }
  1845.  
  1846.         // Helper method to convert Color to hex string
  1847.         private string ColorToHex(Color color)
  1848.         {
  1849.             return $"#{color.R:X2}{color.G:X2}{color.B:X2}";
  1850.         }
  1851.  
  1852.         private void IncreasePaintbrushSize()
  1853.         {
  1854.             if (isEraserActive)
  1855.             {
  1856.                 eraserSize += 1;
  1857.                 setFontSizeToolStripMenuItem.Text = $"Set Size ({eraserSize})";
  1858.                 GenerateSilhouettes(); //added 15 minutes ago ++--
  1859.             }
  1860.             else
  1861.             {
  1862.                 float newSize = p.Width + 1;
  1863.                 p.Width = newSize;
  1864.                 setFontSizeToolStripMenuItem.Text = $"Set Size ({newSize})";
  1865.                 GenerateSilhouettes(); //added 15 minutes ago ++--
  1866.             }
  1867.         }
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.         //start Genius Mode fixes #3 increasepaintsize()
  1878.         /*// Increase the paintbrush size by 1
  1879.         float newSize = p.Width + 1;
  1880.  
  1881.         // Update the pen size
  1882.         p.Width = newSize;
  1883.  
  1884.         // Update the menu item text with the new size
  1885.         setFontSizeToolStripMenuItem.Text = $"Set Font Size ({newSize})";
  1886.     }*/
  1887.         //end Genius Mode fixes #3 increasepaintsize()
  1888.  
  1889.         private void DecreasePaintbrushSize()
  1890.         {
  1891.             if (isEraserActive)
  1892.             {
  1893.                 if (eraserSize > 1)
  1894.                 {
  1895.                     eraserSize -= 1;
  1896.                     setFontSizeToolStripMenuItem.Text = $"Set Size ({eraserSize})";
  1897.                     GenerateSilhouettes(); //added 15 minutes ago ++--
  1898.                 }
  1899.             }
  1900.             else
  1901.             {
  1902.                 if (p.Width > 1)
  1903.                 {
  1904.                     float newSize = p.Width - 1;
  1905.                     p.Width = newSize;
  1906.                     setFontSizeToolStripMenuItem.Text = $"Set Size ({newSize})";
  1907.                     GenerateSilhouettes(); //added 15 minutes ago ++--
  1908.                 }
  1909.             }
  1910.         }
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.         //start Genius Mode fixes #4 decreasepaintsize()
  1923.         /*// Ensure the size does not go below 1
  1924.         if (p.Width > 1)
  1925.         {
  1926.             // Decrease the paintbrush size by 1
  1927.             float newSize = p.Width - 1;
  1928.  
  1929.             // Update the pen size
  1930.             p.Width = newSize;
  1931.  
  1932.             // Update the menu item text with the new size
  1933.             setFontSizeToolStripMenuItem.Text = $"Set Font Size ({newSize})";
  1934.         }
  1935.     }*/
  1936.         //end Genius Mode fixes #4 decreasepaintsize()
  1937.  
  1938.         private void quitToolStripMenuItem_Click(object sender, EventArgs e)
  1939.         {
  1940.             Application.Exit();
  1941.         }
  1942.  
  1943.         private void paintbrushToolStripMenuItem_Click(object sender, EventArgs e)
  1944.         {
  1945.             ActivatePaintbrush();
  1946.         }
  1947.  
  1948.         private void ActivatePaintbrush()
  1949.         {
  1950.             brushSettings.Clear();
  1951.             isEraserActive = false;
  1952.             //color = "#FF0000";
  1953.             ///p.Width = 14; //12
  1954.             UpdatePenColor();
  1955.             string friendlyColorName = Color.FromName(pb_canvas.BackColor.Name).IsKnownColor
  1956.                 ? pb_canvas.BackColor.Name
  1957.                 : $"#{pb_canvas.BackColor.R:X2}{pb_canvas.BackColor.G:X2}{pb_canvas.BackColor.B:X2}";
  1958.             setFontSizeToolStripMenuItem.Text = $"Set Font Size ({p.Width})";
  1959.             selectBGToolStripMenuItem.Text = $"Select Background ({friendlyColorName})";
  1960.             selectColorToolStripMenuItem.Text = $"Select Color ({GetFriendlyColorName(color)})";
  1961.         }
  1962.  
  1963.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1964. Start #40 Silhouette adding persistent values
  1965. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1966.         /*StoreCurrentToolSettings(); //(disabling Silhouette and persistent code)
  1967.         isEraserActive = false;
  1968.         color = "#FF0000";
  1969.         p.Width = 12;
  1970.         UpdatePenColor();
  1971.         string friendlyColorName = Color.FromName(pb_canvas.BackColor.Name).IsKnownColor
  1972.         ? pb_canvas.BackColor.Name
  1973.         : $"#{pb_canvas.BackColor.R:X2}{pb_canvas.BackColor.G:X2}{pb_canvas.BackColor.B:X2}";
  1974.         setFontSizeToolStripMenuItem.Text = $"Set Font Size ({p.Width})";
  1975.         selectBGToolStripMenuItem.Text = $"Select Background ({friendlyColorName})";
  1976.         selectColorToolStripMenuItem.Text = $"Select Color ({GetFriendlyColorName(color)})";
  1977.     }*/
  1978.  
  1979.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1980.         End #40 Silhouette adding persistent values
  1981.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1982.  
  1983.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1984. Start #22 Silhouette (adding persistent settings)
  1985. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  1986.         /*isEraserActive = false;
  1987.             color = "#FF0000";
  1988.             p.Width = 12;
  1989.             UpdatePenColor();
  1990.             string friendlyColorName = Color.FromName(pb_canvas.BackColor.Name).IsKnownColor
  1991.                 ? pb_canvas.BackColor.Name
  1992.                 : $"#{pb_canvas.BackColor.R:X2}{pb_canvas.BackColor.G:X2}{pb_canvas.BackColor.B:X2}";
  1993.             setFontSizeToolStripMenuItem.Text = $"Set Font Size ({p.Width})";
  1994.             selectBGToolStripMenuItem.Text = $"Select Background ({friendlyColorName})";
  1995.             selectColorToolStripMenuItem.Text = $"Select Color ({GetFriendlyColorName(color)})";
  1996.         }*/
  1997.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  1998.         End #22 Silhouette (adding persistent settings)
  1999.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2000.  
  2001.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2002. Start #16 Silhouette (disabled) starting anew
  2003. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2004.         /*isEraserActive = false; // Allow switching back to Paintbrush
  2005.             color = "#FF0000";
  2006.             p.Width = 12;
  2007.             UpdatePen();
  2008.         GenerateSilhouettes(); //added 15 minutes ago
  2009.                                //comboBox1.Text = "12";
  2010.                                //txt_color.Text = color;
  2011.                                // Get the friendly name for the color if available, otherwise use the hex value
  2012.                                //string friendlyColorName = GetFriendlyColorName(pb_canvas.BackColor);
  2013.                                // Get the friendly name for the color if available, otherwise use the hex value
  2014.         string friendlyColorName = Color.FromName(pb_canvas.BackColor.Name).IsKnownColor
  2015.             ? pb_canvas.BackColor.Name
  2016.             : $"#{pb_canvas.BackColor.R:X2}{pb_canvas.BackColor.G:X2}{pb_canvas.BackColor.B:X2}";
  2017.  
  2018.         // Update other menu items dynamically
  2019.         setFontSizeToolStripMenuItem.Text = $"Set Font Size ({p.Width})";
  2020.             selectBGToolStripMenuItem.Text = $"Select Background ({friendlyColorName})";
  2021.             selectColorToolStripMenuItem.Text = $"Select Color ({GetFriendlyColorName(color)})";
  2022.             //selectColorToolStripMenuItem.Text = $"Select Color ({GetFriendlyColorName(ColorTranslator.FromHtml(color))})";
  2023.         }*/
  2024.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2025.         End #16 Silhouette (disabled) starting anew
  2026.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2027.  
  2028.  
  2029.         private void eraserToolStripMenuItem_Click(object sender, EventArgs e)
  2030.         {
  2031.             ActivateEraser();
  2032.         }
  2033.  
  2034.         private void ActivateEraser()
  2035.         {
  2036.             brushSettings.Clear();
  2037.             isEraserActive = true;
  2038.             brush = new SolidBrush(Color.Transparent);
  2039.             UpdatePenColor();
  2040.             GenerateSilhouettes();
  2041.             string friendlyColorName = Color.FromName(pb_canvas.BackColor.Name).IsKnownColor
  2042.                 ? pb_canvas.BackColor.Name
  2043.                 : $"#{pb_canvas.BackColor.R:X2}{pb_canvas.BackColor.G:X2}{pb_canvas.BackColor.B:X2}";
  2044.             setFontSizeToolStripMenuItem.Text = $"Set Font Size ({eraserSize})";
  2045.             selectBGToolStripMenuItem.Text = $"Select Background ({friendlyColorName})";
  2046.             selectColorToolStripMenuItem.Text = $"Select Color ({GetFriendlyColorName(color)})";
  2047.         }
  2048.  
  2049.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2050. Start #41 Silhouette adding persistent values
  2051. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2052.         /*StoreCurrentToolSettings(); //(disabling Silhouette and persistent code)
  2053.         isEraserActive = true;
  2054.         brush = new SolidBrush(Color.Transparent);
  2055.         UpdatePenColor();
  2056.         GenerateSilhouettes(); //added 15 minutes ago ++--
  2057.         string friendlyColorName = Color.FromName(pb_canvas.BackColor.Name).IsKnownColor
  2058.             ? pb_canvas.BackColor.Name
  2059.             : $"#{pb_canvas.BackColor.R:X2}{pb_canvas.BackColor.G:X2}{pb_canvas.BackColor.B:X2}";
  2060.         setFontSizeToolStripMenuItem.Text = $"Set Font Size ({eraserSize})";
  2061.         selectBGToolStripMenuItem.Text = $"Select Background ({friendlyColorName})";
  2062.         selectColorToolStripMenuItem.Text = $"Select Color ({GetFriendlyColorName(color)})";
  2063.     }*/
  2064.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2065.         End #41 Silhouette adding persistent values
  2066.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2067.  
  2068.  
  2069.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2070.         Start #23 Silhouette (adding persistent settings)
  2071.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2072.         /*isEraserActive = true; //(start bard #3 line)
  2073.             //color = "#00FFFFFF"; //(start bard #4 line) "#000000"
  2074.             brush = new SolidBrush(Color.Transparent); // Use SolidBrush with Transparent color //(start bard test #13 line)
  2075.             //p.Width = 60;
  2076.             UpdatePen();
  2077.             GenerateSilhouettes(); //added 15 minutes ago
  2078.             //comboBox1.Text = "17";
  2079.             //txt_color.Text = color;
  2080.             // Get the friendly name for the color if available, otherwise use the hex value
  2081.             //string friendlyColorName = GetFriendlyColorName(pb_canvas.BackColor);
  2082.             // Get the friendly name for the color if available, otherwise use the hex value
  2083.             string friendlyColorName = Color.FromName(pb_canvas.BackColor.Name).IsKnownColor
  2084.                 ? pb_canvas.BackColor.Name
  2085.                 : $"#{pb_canvas.BackColor.R:X2}{pb_canvas.BackColor.G:X2}{pb_canvas.BackColor.B:X2}";
  2086.  
  2087.             // Update other menu items dynamically orig: $"Set Font Size ({p.Width})";
  2088.             setFontSizeToolStripMenuItem.Text = $"Set Font Size ({eraserSize})";
  2089.             selectBGToolStripMenuItem.Text = $"Select Background ({friendlyColorName})";
  2090.             selectColorToolStripMenuItem.Text = $"Select Color ({GetFriendlyColorName(color)})";
  2091.             //selectColorToolStripMenuItem.Text = $"Select Color ({GetFriendlyColorName(ColorTranslator.FromHtml(color))})";
  2092.         }*/
  2093.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2094.         End #23 Silhouette adding persistent settings
  2095.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2096.  
  2097.         //private Dictionary<string, object> brushSettings = new Dictionary<string, object>();
  2098.  
  2099.         private void StoreCurrentToolSettings()
  2100.         {
  2101.             //brushSettings["Color"] = isEraserActive ? Color.Transparent : color;
  2102.             brushSettings["Color"] = isEraserActive ? (object)Color.Transparent : (object)color;
  2103.             brushSettings["Width"] = isEraserActive ? (object)eraserSize : (object)p.Width;
  2104.         }
  2105.  
  2106.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2107. Start #39 Silhouette adding persistent values
  2108. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2109.         /*if (!isEraserActive)
  2110.         {
  2111.             storedPenColor = color;
  2112.             storedPenWidth = p.Width;
  2113.         }
  2114.         else
  2115.         {
  2116.             storedEraserSize = eraserSize;
  2117.         }
  2118.     }*/
  2119.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2120.         End #39 Silhouette adding persistent values
  2121.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2122.  
  2123.  
  2124.         private void RestorePreviousToolSettings()
  2125.         {
  2126.             color = brushSettings.ContainsKey("Color") ? (string)brushSettings["Color"] : "#FF0000";
  2127.             p.Width = brushSettings.ContainsKey("Width") ? (float)brushSettings["Width"] : 12f;
  2128.         }
  2129.  
  2130.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2131. Start #40 Silhouette adding persistent values
  2132. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2133.         /*if (!isEraserActive)
  2134.         {
  2135.             color = storedPenColor;
  2136.             p.Width = storedPenWidth;
  2137.         }
  2138.         else
  2139.         {
  2140.             eraserSize = storedEraserSize;
  2141.         }
  2142.     }*/
  2143.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2144.         End #40 Silhouette adding persistent values
  2145.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2146.  
  2147.  
  2148.  
  2149.         private void loadImageToolStripMenuItem_Click(object sender, EventArgs e)
  2150.         {
  2151.             OpenFileDialog openFileDialog = new OpenFileDialog();
  2152.             openFileDialog.Filter = "Png files|*.png|jpeg files|*.jpg|bitmaps|*.bmp";
  2153.             if (openFileDialog.ShowDialog() == DialogResult.OK)
  2154.             {
  2155.                 string filePath = openFileDialog.FileName;
  2156.                 try
  2157.                 {
  2158.                     Image loadedImage = Image.FromFile(filePath);
  2159.                     pb_canvas.Image = new Bitmap(loadedImage, pb_canvas.Size);  // Resize the loaded image to match the PictureBox size
  2160.                     drawingLayer = new Bitmap(pb_canvas.Image.Width, pb_canvas.Image.Height);  // Create a new drawingLayer with the same size as the PictureBox
  2161.                     using (Graphics g = Graphics.FromImage(drawingLayer))
  2162.                     {
  2163.                         g.DrawImage(loadedImage, Point.Empty);  // Draw the loaded image onto the drawingLayer
  2164.                     }
  2165.                     pb_canvas.Invalidate();
  2166.                 }
  2167.                 catch (Exception ex)
  2168.                 {
  2169.                     MessageBox.Show($"Error loading image: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2170.                 }
  2171.             }
  2172.         }
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.         //start Genius Mode FINAL FINAL FINAL fixes #20 RESAVE()
  2183.         /*OpenFileDialog openFileDialog = new OpenFileDialog();
  2184.         openFileDialog.Filter = "Png files|*.png|jpeg files|*.jpg|bitmaps|*.bmp";
  2185.         if (openFileDialog.ShowDialog() == DialogResult.OK)
  2186.         {
  2187.             string filePath = openFileDialog.FileName;
  2188.             try
  2189.             {
  2190.                 pb_canvas.Image = Image.FromFile(filePath);  // Load the image onto the PictureBox's Image property
  2191.                 drawingLayer = new Bitmap(pb_canvas.Image);  // Update the drawingLayer to match the loaded image
  2192.                 pb_canvas.Invalidate();
  2193.             }
  2194.             catch (Exception ex)
  2195.             {
  2196.                 MessageBox.Show($"Error loading image: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2197.             }
  2198.         }
  2199.     }*/
  2200.         //end Genius Mode FINAL FINAL FINAL fixes #20 RESAVE()
  2201.  
  2202.         /*//This is GPTs final attempt (fail)
  2203.         OpenFileDialog openFileDialog = new OpenFileDialog();
  2204.         openFileDialog.Filter = "Png files|*.png|jpeg files|*.jpg|bitmaps|*.bmp";
  2205.         if (openFileDialog.ShowDialog() == DialogResult.OK)
  2206.         {
  2207.             string filePath = openFileDialog.FileName;
  2208.             try
  2209.             {
  2210.                 drawingLayer = new Bitmap(pb_canvas.Width, pb_canvas.Height); // Reset drawing layer
  2211.                 Graphics.FromImage(drawingLayer).Clear(Color.Transparent);
  2212.  
  2213.                 pb_canvas.BackgroundImage = Image.FromFile(filePath);
  2214.                 pb_canvas.BackgroundImageLayout = ImageLayout.Stretch; // Adjust background image layout
  2215.  
  2216.                 pb_canvas.Image = null;
  2217.                 pb_canvas.Invalidate();
  2218.             }
  2219.             catch (Exception ex)
  2220.             {
  2221.                 MessageBox.Show($"Error loading image: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2222.             }
  2223.         }
  2224.     }*/
  2225.  
  2226.  
  2227.  
  2228.         //ChatGPTs Final Attempt (Bing below Failed don't use below)
  2229.  
  2230.  
  2231.  
  2232.  
  2233.         /*OpenFileDialog openFileDialog = new OpenFileDialog();
  2234.         openFileDialog.Filter = "Png files|*.png|jpeg files|*.jpg|bitmaps|*.bmp";
  2235.  
  2236.         if (openFileDialog.ShowDialog() == DialogResult.OK)
  2237.         {
  2238.             string filePath = openFileDialog.FileName;
  2239.  
  2240.             try
  2241.             {
  2242.                 // Clear the drawing layer
  2243.                 Graphics.FromImage(drawingLayer).Clear(Color.Transparent);
  2244.                 pb_canvas.Invalidate();
  2245.  
  2246.                 // Load the selected image into the PictureBox's Image
  2247.                 pb_canvas.Image = Image.FromFile(filePath);
  2248.  
  2249.                 // Set the PictureBox's BackgroundImageLayout to Zoom
  2250.                 pb_canvas.BackgroundImageLayout = ImageLayout.Zoom;
  2251.             }
  2252.             catch (Exception ex)
  2253.             {
  2254.                 MessageBox.Show($"Error loading image: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2255.             }
  2256.         }
  2257.     }*/
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.         //Bings Final Attempt (below is not original)
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.         //start Genius Mode FINAL FINAL fixes #9 load()
  2274.         /*OpenFileDialog openFileDialog = new OpenFileDialog();
  2275.         openFileDialog.Filter = "Png files|*.png|jpeg files|*.jpg|bitmaps|*.bmp";
  2276.         if (openFileDialog.ShowDialog() == DialogResult.OK)
  2277.         {
  2278.             string filePath = openFileDialog.FileName;
  2279.             try
  2280.             {
  2281.                 pb_canvas.Image = Image.FromFile(filePath);  // Load the image onto the PictureBox's Image property
  2282.                 Graphics.FromImage(drawingLayer).Clear(Color.Transparent);  // Clear the drawingLayer
  2283.                 pb_canvas.Invalidate();
  2284.             }
  2285.             catch (Exception ex)
  2286.             {
  2287.                 MessageBox.Show($"Error loading image: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2288.             }
  2289.         }
  2290.     }*/
  2291.         //end Genius Mode FINAL FINAL fixes #9 load()
  2292.  
  2293.         //start Genius Mode FINAL fixes #7 loadimage()
  2294.         /*OpenFileDialog openFileDialog = new OpenFileDialog();
  2295.         openFileDialog.Filter = "Png files|*.png|jpeg files|*.jpg|bitmaps|*.bmp";
  2296.         if (openFileDialog.ShowDialog() == DialogResult.OK)
  2297.         {
  2298.             string filePath = openFileDialog.FileName;
  2299.             try
  2300.             {
  2301.                 pb_canvas.Image = Image.FromFile(filePath);
  2302.                 Graphics.FromImage(drawingLayer).Clear(Color.Transparent);
  2303.                 pb_canvas.BackgroundImage = null; // Clear previous background if any
  2304.                 pb_canvas.Invalidate();
  2305.             }
  2306.             catch (Exception ex)
  2307.             {
  2308.                 MessageBox.Show($"Error loading image: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2309.             }
  2310.         }
  2311.     }*/
  2312.         //end Genius Mode FINAL fixes #7 loadimage()
  2313.  
  2314.  
  2315.  
  2316.  
  2317.         //===================================================================//(start BingAI test FINAL #18)
  2318.         /*OpenFileDialog openFileDialog = new OpenFileDialog();
  2319.         openFileDialog.Filter = "Png files|*.png|jpeg files|*.jpg|bitmaps|*.bmp";
  2320.  
  2321.         if (openFileDialog.ShowDialog() == DialogResult.OK)
  2322.         {
  2323.             string filePath = openFileDialog.FileName;
  2324.  
  2325.             try
  2326.             {
  2327.                 // Clear the drawing layer
  2328.                 Graphics.FromImage(drawingLayer).Clear(Color.Transparent);
  2329.                 pb_canvas.Invalidate();
  2330.                 // Load the selected image into the PictureBox
  2331.                 pb_canvas.Image = Image.FromFile(filePath);
  2332.             }
  2333.             catch (Exception ex)
  2334.             {
  2335.                 MessageBox.Show($"Error loading image: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2336.             }
  2337.         }
  2338.     }*/
  2339.         //===================================================================//(end BingAI test FINAL #18)
  2340.  
  2341.         private void saveImageToolStripMenuItem_Click(object sender, EventArgs e)
  2342.  
  2343.         {
  2344.             SaveFileDialog s = new SaveFileDialog();
  2345.             s.Filter = "Png files|*.png|jpeg files|*.jpg|bitmaps|*.bmp";
  2346.             if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  2347.             {
  2348.                 try
  2349.                 {
  2350.                     Bitmap mergedImage = new Bitmap(pb_canvas.Width, pb_canvas.Height);
  2351.                     using (Graphics g = Graphics.FromImage(mergedImage))
  2352.                     {
  2353.                         if (pb_canvas.Image != null)
  2354.                         {
  2355.                             g.DrawImage(pb_canvas.Image, Point.Empty);  // Draw the loaded image (if any)
  2356.                         }
  2357.                         g.DrawImage(drawingLayer, Point.Empty);  // Draw the drawingLayer
  2358.                     }
  2359.                     if (s.FileName.Contains(".jpg"))
  2360.                     {
  2361.                         mergedImage.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
  2362.                     }
  2363.                     else if (s.FileName.Contains(".png"))
  2364.                     {
  2365.                         mergedImage.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Png);
  2366.                     }
  2367.                     else if (s.FileName.Contains(".bmp"))
  2368.                     {
  2369.                         mergedImage.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
  2370.                     }
  2371.                 }
  2372.                 catch (Exception ex)
  2373.                 {
  2374.                     MessageBox.Show($"Error saving image: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2375.                 }
  2376.             }
  2377.         }
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.  
  2385.  
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391.  
  2392.         //start Genius Mode FINAL FINAL FINAL fixes #23 RESAVE()            
  2393.         /*SaveFileDialog s = new SaveFileDialog();
  2394.         s.Filter = "Png files|*.png|jpeg files|*.jpg|bitmaps|*.bmp";
  2395.         if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  2396.         {
  2397.             try
  2398.             {
  2399.                 Bitmap mergedImage = new Bitmap(pb_canvas.Width, pb_canvas.Height);
  2400.                 using (Graphics g = Graphics.FromImage(mergedImage))
  2401.                 {
  2402.                     g.DrawImage(pb_canvas.Image ?? drawingLayer, Point.Empty);
  2403.                 }
  2404.                 if (s.FileName.Contains(".jpg"))
  2405.                 {
  2406.                     mergedImage.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
  2407.                 }
  2408.                 else if (s.FileName.Contains(".png"))
  2409.                 {
  2410.                     mergedImage.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Png);
  2411.                 }
  2412.                 else if (s.FileName.Contains(".bmp"))
  2413.                 {
  2414.                     mergedImage.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
  2415.                 }
  2416.             }
  2417.             catch (Exception ex)
  2418.             {
  2419.                 MessageBox.Show($"Error saving image: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2420.             }
  2421.         }
  2422.     }*/
  2423.         //end Genius Mode FINAL FINAL FINAL fixes #23 RESAVE()
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.         //start Genius Mode FINAL FINAL fixes #10 save()
  2432.         /*SaveFileDialog s = new SaveFileDialog();
  2433.         s.Filter = "Png files|*.png|jpeg files|*.jpg|bitmaps|*.bmp";
  2434.  
  2435.         if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  2436.         {
  2437.             try
  2438.             {
  2439.                 // Create a new bitmap to hold the merged image
  2440.                 Bitmap mergedImage = new Bitmap(pb_canvas.Width, pb_canvas.Height);
  2441.  
  2442.                 // Create a graphics object from the merged image
  2443.                 using (Graphics g = Graphics.FromImage(mergedImage))
  2444.                 {
  2445.                     // Draw the background image repeatedly to fill the canvas
  2446.                     for (int x = 0; x < pb_canvas.Width; x += pb_canvas.BackgroundImage.Width)
  2447.                     {
  2448.                         for (int y = 0; y < pb_canvas.Height; y += pb_canvas.BackgroundImage.Height)
  2449.                         {
  2450.                             g.DrawImage(pb_canvas.BackgroundImage, new Point(x, y));
  2451.                         }
  2452.                     }
  2453.  
  2454.                     // Draw the drawing layer
  2455.                     g.DrawImage(drawingLayer, Point.Empty);
  2456.                 }
  2457.  
  2458.                 // Save the merged image
  2459.                 if (s.FileName.Contains(".jpg"))
  2460.                 {
  2461.                     mergedImage.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
  2462.                 }
  2463.                 else if (s.FileName.Contains(".png"))
  2464.                 {
  2465.                     mergedImage.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Png);
  2466.                 }
  2467.                 else if (s.FileName.Contains(".bmp"))
  2468.                 {
  2469.                     mergedImage.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
  2470.                 }
  2471.             }
  2472.             catch (Exception ex)
  2473.             {
  2474.                 MessageBox.Show($"Error saving image: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2475.             }
  2476.         }
  2477.     }*/
  2478.         //end Genius Mode FINAL FINAL fixes #10 save()
  2479.  
  2480.         //old fallbackcode return if unsatisfied
  2481.         /*{
  2482.             SaveFileDialog s = new SaveFileDialog();
  2483.             s.Filter = "Png files| *.png|jpeg files| *.jpg|bitmaps | *.bmp";
  2484.             if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  2485.             {
  2486.                 if (File.Exists(s.FileName))
  2487.                 {
  2488.                     File.Delete(s.FileName);
  2489.                 }
  2490.                 if (s.FileName.Contains(".jpg"))
  2491.                 {
  2492.                     bmp.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
  2493.                 }
  2494.                 else if (s.FileName.Contains(".png"))
  2495.                 {
  2496.                     bmp.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Png);
  2497.                 }
  2498.                 else if (s.FileName.Contains(".bmp"))
  2499.                 {
  2500.                     bmp.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
  2501.                 }
  2502.             }
  2503.         }*/
  2504.  
  2505.         private void selectColorToolStripMenuItem_Click(object sender, EventArgs e)
  2506.         {
  2507.             ColorDialog cd = new ColorDialog();
  2508.             if (cd.ShowDialog() == DialogResult.OK)
  2509.             {
  2510.                 color = "#" + (cd.Color.ToArgb() & 0x00FFFFFF).ToString("X6");
  2511.                 UpdatePenColor();
  2512.             }
  2513.         }
  2514.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2515. Start #15 Silhouette (disabled) starting anew
  2516. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2517.         /*ColorDialog cd = new ColorDialog();
  2518.         if (cd.ShowDialog() == DialogResult.OK)
  2519.         {
  2520.             color = "#" + (cd.Color.ToArgb() & 0x00FFFFFF).ToString("X6");
  2521.             //txt_color.Text = color;
  2522.  
  2523.             // Update font color dynamically
  2524.             UpdateFontColor();
  2525.         }          
  2526.     }*/
  2527.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2528.          End #15 Silhouette (disabled) starting anew
  2529.           .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2530.  
  2531.         private void UpdatePenColor()
  2532.         {
  2533.             p.Color = ColorTranslator.FromHtml(color);
  2534.             UpdateFontColor();
  2535.             GenerateSilhouettes(); //(disabling Silhouette and persistent code) ++--
  2536.         }
  2537.  
  2538.         private void setFontSizeToolStripMenuItem_Click(object sender, EventArgs e)
  2539.         {
  2540.             if (p == null)
  2541.             {
  2542.                 p = new Pen(Color.Black, 1);
  2543.             }
  2544.             using (Form inputForm = new Form())
  2545.             {
  2546.                 inputForm.Text = "Set Size";
  2547.                 Label promptLabel = new Label();
  2548.                 promptLabel.Text = isEraserActive ? "Enter new eraser size:" : "Enter new font size:";
  2549.                 promptLabel.Location = new Point(10, 10);
  2550.                 inputForm.Controls.Add(promptLabel);
  2551.                 TextBox inputBox = new TextBox();
  2552.                 inputBox.Location = new Point(10, 30);
  2553.                 inputForm.Controls.Add(inputBox);
  2554.                 Button okButton = new Button();
  2555.                 okButton.Text = "OK";
  2556.                 okButton.DialogResult = DialogResult.OK;
  2557.                 okButton.Location = new Point(10, 60);
  2558.                 inputForm.Controls.Add(okButton);
  2559.                 if (inputForm.ShowDialog() == DialogResult.OK)
  2560.                 {
  2561.                     if (int.TryParse(inputBox.Text, out int newSize))
  2562.                     {
  2563.                         if (isEraserActive)
  2564.                         {
  2565.                             eraserSize = newSize;
  2566.                         }
  2567.                         else
  2568.                         {
  2569.                             p.Width = newSize;
  2570.                         }
  2571.                         GenerateSilhouettes(); //added 15 minutes ago ++--
  2572.                         setFontSizeToolStripMenuItem.Text = $"Set Size ({newSize})";
  2573.                     }
  2574.                     else
  2575.                     {
  2576.                         MessageBox.Show("Invalid input. Please enter a valid number.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2577.                     }
  2578.                 }
  2579.             }
  2580.         }
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.         //start Genius Mode fixes #2
  2596.         /*if (p == null)
  2597.         {
  2598.             // Initialize the pen with default values if not already initialized
  2599.             p = new Pen(Color.Black, 1); // You can adjust the color and size as needed
  2600.         }
  2601.  
  2602.         // Display the current pen size in the menu dynamically
  2603.         setFontSizeToolStripMenuItem.Text = $"Set Font Size ({p.Width})";
  2604.  
  2605.         // Create a form with a TextBox for user input
  2606.         using (Form inputForm = new Form())
  2607.         {
  2608.             inputForm.Text = "Set Font Size";
  2609.  
  2610.             Label promptLabel = new Label();
  2611.             promptLabel.Text = "Enter new font size:";
  2612.             promptLabel.Location = new Point(10, 10);
  2613.             inputForm.Controls.Add(promptLabel);
  2614.  
  2615.             TextBox inputBox = new TextBox();
  2616.             inputBox.Location = new Point(10, 30);
  2617.             inputForm.Controls.Add(inputBox);
  2618.  
  2619.             Button okButton = new Button();
  2620.             okButton.Text = "OK";
  2621.             okButton.DialogResult = DialogResult.OK;
  2622.             okButton.Location = new Point(10, 60);
  2623.             inputForm.Controls.Add(okButton);
  2624.  
  2625.             // Show the form and get user input
  2626.             if (inputForm.ShowDialog() == DialogResult.OK)
  2627.             {
  2628.                 // Check if the user entered a valid number
  2629.                 if (float.TryParse(inputBox.Text, out float newSize))
  2630.                 {
  2631.                     // Update the pen size
  2632.                     p.Width = newSize;
  2633.  
  2634.                     // Update the menu item text with the new size
  2635.                     setFontSizeToolStripMenuItem.Text = $"Set Font Size ({newSize})";
  2636.                 }
  2637.                 else
  2638.                 {
  2639.                     // Display an error message if the input is not a valid number
  2640.                     MessageBox.Show("Invalid input. Please enter a valid number.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  2641.                 }
  2642.             }
  2643.         }
  2644.     }*/
  2645.         //end Genius Mode fixes #2
  2646.  
  2647.         private void selectBGToolStripMenuItem_Click(object sender, EventArgs e)
  2648.         {
  2649.             // Call the method to change the background color
  2650.             SetBackgroundColor();
  2651.         }
  2652.  
  2653.         private string GetFriendlyColorName(string hexColor)
  2654.         {
  2655.             Color color = ColorTranslator.FromHtml(hexColor);
  2656.  
  2657.             // Check if the color is one of the known colors
  2658.             foreach (KnownColor knownColor in Enum.GetValues(typeof(KnownColor)))
  2659.             {
  2660.                 Color knownColorObj = Color.FromKnownColor(knownColor);
  2661.  
  2662.                 if (knownColorObj.ToArgb() == color.ToArgb())
  2663.                 {
  2664.                     return knownColorObj.Name;
  2665.                 }
  2666.             }
  2667.  
  2668.             // If not a known color, return the original hex color
  2669.             return hexColor;
  2670.         }
  2671.  
  2672.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2673. Start #9 Silhouette
  2674. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2675.         private void pb_canvas_MouseLeave(object sender, EventArgs e)
  2676.         {
  2677.             pb_canvas.Invalidate();
  2678.             Cursor.Show();
  2679.             // Reset the cursor to default when leaving the drawing area
  2680.             pb_canvas.Cursor = Cursors.Default;
  2681.         }
  2682.  
  2683.         // Moved silhouette generation to a separate method for clarity
  2684.         private void GenerateSilhouettes()
  2685.         {
  2686.             brushSilhouette = GenerateBrushSilhouette(p.Width, color);
  2687.             eraserSilhouette = GenerateEraserSilhouette(eraserSize);
  2688.         }
  2689.  
  2690.         private void pb_canvas_MouseEnter(object sender, EventArgs e)
  2691.         {
  2692.             //RestorePreviousToolSettings();
  2693.             GenerateSilhouettes(); //++--
  2694.  
  2695.             Cursor.Hide();
  2696.             //hiding this block to test for Silhouette bugs
  2697.             /*if (!isEraserActive && brushSilhouette != null)
  2698.             {
  2699.                 int xHotSpot = brushSilhouette.Width / 2;
  2700.                 int yHotSpot = brushSilhouette.Height / 2;
  2701.                 pb_canvas.Cursor = CreateCursor(brushSilhouette, xHotSpot, yHotSpot);
  2702.             }
  2703.             else if (isEraserActive && eraserSilhouette != null)
  2704.             {
  2705.                 int xHotSpot = eraserSilhouette.Width / 2;
  2706.                 int yHotSpot = eraserSilhouette.Height / 2;
  2707.                 pb_canvas.Cursor = CreateCursor(eraserSilhouette, xHotSpot, yHotSpot);
  2708.             }*/
  2709.         }
  2710.  
  2711.         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  2712.         {
  2713.             // Display a confirmation message box
  2714.             DialogResult result = MessageBox.Show("Are you sure you want to exit?", "Confirm Exit", MessageBoxButtons.YesNo);
  2715.  
  2716.             // If the user chooses No, cancel the closing process
  2717.             if (result == DialogResult.No)
  2718.             {
  2719.                 e.Cancel = true;
  2720.             }
  2721.         }
  2722.  
  2723.  
  2724.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2725. Start #35 Silhouette adding persistent values
  2726. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2727.         /*RestorePreviousToolSettings();
  2728.         GenerateSilhouettes();
  2729.  
  2730.         Cursor.Hide();
  2731.         if (!isEraserActive && brushSilhouette != null)
  2732.         {
  2733.             int xHotSpot = brushSilhouette.Width / 2;
  2734.             int yHotSpot = brushSilhouette.Height / 2;
  2735.             pb_canvas.Cursor = CreateCursor(brushSilhouette, xHotSpot, yHotSpot);
  2736.         }
  2737.         else if (isEraserActive && eraserSilhouette != null)
  2738.         {
  2739.             int xHotSpot = eraserSilhouette.Width / 2;
  2740.             int yHotSpot = eraserSilhouette.Height / 2;
  2741.             pb_canvas.Cursor = CreateCursor(eraserSilhouette, xHotSpot, yHotSpot);
  2742.         }
  2743.     }*/
  2744.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2745.         End #35 Silhouette adding persistent values
  2746.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2747.  
  2748.  
  2749.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2750. Start #31 Silhouette adding persistent values
  2751. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2752.         /*RestorePreviousToolSettings();
  2753.         GenerateSilhouettes();
  2754.  
  2755.         Cursor.Hide();
  2756.         if (!isEraserActive && brushSilhouette != null)
  2757.         {
  2758.             pb_canvas.Cursor = CreateCursor(brushSilhouette, brushSilhouette.Width / 2, brushSilhouette.Height / 2);
  2759.         }
  2760.         else if (isEraserActive && eraserSilhouette != null)
  2761.         {
  2762.             pb_canvas.Cursor = CreateCursor(eraserSilhouette, eraserSilhouette.Width / 2, eraserSilhouette.Height / 2);
  2763.         }
  2764.     }*/
  2765.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2766.         End #31 Silhouette adding persistent values
  2767.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2768.  
  2769.  
  2770.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2771. Start #29 Silhouette adding persistent values
  2772. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2773.         /*RestorePreviousToolSettings();
  2774.         GenerateSilhouettes();
  2775.         Cursor.Hide();
  2776.         if (!isEraserActive)
  2777.         {
  2778.             pb_canvas.Cursor = CreateCursor(brushSilhouette, (int)p.Width / 2, (int)p.Width / 2);
  2779.         }
  2780.         else
  2781.         {
  2782.             pb_canvas.Cursor = CreateCursor(eraserSilhouette, eraserSize / 2, eraserSize / 2);
  2783.         }
  2784.     }*/
  2785.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2786.         End #29 Silhouette adding persistent values
  2787.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2788.  
  2789.  
  2790.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2791. Start #24 Silhouette adding persistent values
  2792. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2793.         /*GenerateSilhouettes();
  2794.         Cursor.Hide();
  2795.         //delete these "if else" if unnecessary
  2796.         // Set the cursor to the brush silhouette when not using the eraser
  2797.         if (!isEraserActive)
  2798.         {
  2799.             pb_canvas.Cursor = CreateCursor(brushSilhouette, (int)p.Width / 2, (int)p.Width / 2);
  2800.         }
  2801.         // Set the cursor to the eraser silhouette when using the eraser
  2802.         else
  2803.         {
  2804.             pb_canvas.Cursor = CreateCursor(eraserSilhouette, eraserSize / 2, eraserSize / 2);
  2805.         }
  2806.         //below was in original working condition, relocated for better updates
  2807.         // Generate brush silhouette
  2808.         //brushSilhouette = GenerateBrushSilhouette(p.Width, color);
  2809.  
  2810.         // Generate eraser silhouette
  2811.         //eraserSilhouette = GenerateEraserSilhouette(eraserSize);
  2812.     }*/
  2813.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2814.         End #24 Silhouette adding persistent values
  2815.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2816.  
  2817.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2818. End #9 Silhouette
  2819. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2820.  
  2821.         //delete if unnecessary
  2822.         /*private Cursor CreateCursor(Bitmap bitmap, int xHotSpot, int yHotSpot)
  2823.         {
  2824.             IntPtr iconHandle = bitmap.GetHicon();
  2825.             Icon customIcon = Icon.FromHandle(iconHandle);
  2826.             Cursor customCursor = new Cursor(customIcon.Handle);
  2827.             DestroyIcon(iconHandle); // Cleanup icon handle to avoid resource leaks
  2828.             return customCursor;
  2829.         }
  2830.  
  2831.         [DllImport("user32.dll")]
  2832.         private static extern bool DestroyIcon(IntPtr handle);*/
  2833.  
  2834.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2835. Start #33 Silhouette adding persistent values
  2836. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2837.         /*IntPtr cursorHandle = bitmap.GetHicon();
  2838.         Cursor cursor = new Cursor(cursorHandle);
  2839.         cursor.HotSpot = new Point(xHotSpot, yHotSpot);
  2840.         return cursor;            
  2841.     }*/
  2842.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2843.             End #33 Silhouette adding persistent values
  2844.             .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2845.  
  2846.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2847. Start #30 Silhouette adding persistent values
  2848. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2849.         /*IntPtr cursorHandle = bitmap.GetHicon();
  2850.         return new Cursor(cursorHandle);            
  2851.     }*/
  2852.         /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2853.         End #30 Silhouette adding persistent values
  2854.         .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2855.  
  2856.         /*protected override void OnPaintBackground(PaintEventArgs e)
  2857.         {
  2858.             // Override the OnPaintBackground method to prevent default background painting.
  2859.             // This helps in avoiding the runtime exception when minimizing using Windows key + D.
  2860.             // Do nothing here to prevent the default behavior.
  2861.         }*/
  2862.     }
  2863. }
  2864. /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2865. Start #1 Silhouette
  2866. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2867.  
  2868. /*.o0o0o0o0o0o0o0o0o0o0o0o0o0o.
  2869. End #1 Silhouette
  2870. .o0o0o0o0o0o0o0o0o0o0o0o0o0o.*/
  2871.  
  2872. ==++"Form1.Designer.cs" File SourceCode::++==
  2873. namespace Simple_Drawing_Application
  2874. {
  2875.     partial class Form1
  2876.     {
  2877.         /// <summary>
  2878.         /// Required designer variable.
  2879.         /// </summary>
  2880.         private System.ComponentModel.IContainer components = null;
  2881.  
  2882.         /// <summary>
  2883.         /// Clean up any resources being used.
  2884.         /// </summary>
  2885.         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  2886.         protected override void Dispose(bool disposing)
  2887.         {
  2888.             if (disposing && (components != null))
  2889.             {
  2890.                 components.Dispose();
  2891.             }
  2892.             base.Dispose(disposing);
  2893.         }
  2894.  
  2895.         #region Windows Form Designer generated code
  2896.  
  2897.         /// <summary>
  2898.         /// Required method for Designer support - do not modify
  2899.         /// the contents of this method with the code editor.
  2900.         /// </summary>
  2901.         private void InitializeComponent()
  2902.         {
  2903.             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
  2904.             this.label1 = new System.Windows.Forms.Label();
  2905.             this.comboBox1 = new System.Windows.Forms.ComboBox();
  2906.             this.menuStrip1 = new System.Windows.Forms.MenuStrip();
  2907.             this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2908.             this.loadImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2909.             this.saveImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2910.             this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2911.             this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2912.             this.selectColorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2913.             this.setFontSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2914.             this.selectBGToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2915.             this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2916.             this.paintbrushToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2917.             this.eraserToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2918.             this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2919.             this.redoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  2920.             this.button1 = new System.Windows.Forms.Button();
  2921.             this.txt_color = new System.Windows.Forms.TextBox();
  2922.             this.button2 = new System.Windows.Forms.Button();
  2923.             this.button3 = new System.Windows.Forms.Button();
  2924.             this.pb_canvas = new System.Windows.Forms.PictureBox();
  2925.             this.menuStrip1.SuspendLayout();
  2926.             ((System.ComponentModel.ISupportInitialize)(this.pb_canvas)).BeginInit();
  2927.             this.SuspendLayout();
  2928.             //
  2929.             // label1
  2930.             //
  2931.             this.label1.AutoSize = true;
  2932.             this.label1.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  2933.             this.label1.Location = new System.Drawing.Point(1245, 39);
  2934.             this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
  2935.             this.label1.Name = "label1";
  2936.             this.label1.Size = new System.Drawing.Size(39, 18);
  2937.             this.label1.TabIndex = 1;
  2938.             this.label1.Text = "Size";
  2939.             this.label1.Visible = false;
  2940.             //
  2941.             // comboBox1
  2942.             //
  2943.             this.comboBox1.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  2944.             this.comboBox1.FormattingEnabled = true;
  2945.             this.comboBox1.Items.AddRange(new object[] {
  2946.             "8",
  2947.             "9",
  2948.             "10",
  2949.             "11",
  2950.             "12",
  2951.             "14",
  2952.             "16",
  2953.             "18",
  2954.             "20",
  2955.             "22",
  2956.             "24",
  2957.             "26",
  2958.             "28",
  2959.             "36",
  2960.             "48",
  2961.             "72"});
  2962.             this.comboBox1.Location = new System.Drawing.Point(1295, 38);
  2963.             this.comboBox1.Margin = new System.Windows.Forms.Padding(2);
  2964.             this.comboBox1.Name = "comboBox1";
  2965.             this.comboBox1.Size = new System.Drawing.Size(53, 23);
  2966.             this.comboBox1.TabIndex = 2;
  2967.             this.comboBox1.Visible = false;
  2968.             //
  2969.             // menuStrip1
  2970.             //
  2971.             this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
  2972.             this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
  2973.             this.exitToolStripMenuItem,
  2974.             this.editToolStripMenuItem,
  2975.             this.paintbrushToolStripMenuItem,
  2976.             this.eraserToolStripMenuItem,
  2977.             this.undoToolStripMenuItem,
  2978.             this.redoToolStripMenuItem});
  2979.             this.menuStrip1.Location = new System.Drawing.Point(0, 0);
  2980.             this.menuStrip1.Name = "menuStrip1";
  2981.             this.menuStrip1.Padding = new System.Windows.Forms.Padding(4, 1, 0, 1);
  2982.             this.menuStrip1.Size = new System.Drawing.Size(1352, 24);
  2983.             this.menuStrip1.TabIndex = 3;
  2984.             this.menuStrip1.Text = "menuStrip1";
  2985.             //
  2986.             // exitToolStripMenuItem
  2987.             //
  2988.             this.exitToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
  2989.             this.loadImageToolStripMenuItem,
  2990.             this.saveImageToolStripMenuItem,
  2991.             this.quitToolStripMenuItem});
  2992.             this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
  2993.             this.exitToolStripMenuItem.Size = new System.Drawing.Size(43, 22);
  2994.             this.exitToolStripMenuItem.Text = "File";
  2995.             //
  2996.             // loadImageToolStripMenuItem
  2997.             //
  2998.             this.loadImageToolStripMenuItem.Name = "loadImageToolStripMenuItem";
  2999.             this.loadImageToolStripMenuItem.Size = new System.Drawing.Size(151, 22);
  3000.             this.loadImageToolStripMenuItem.Text = "Load Image";
  3001.             this.loadImageToolStripMenuItem.Click += new System.EventHandler(this.loadImageToolStripMenuItem_Click);
  3002.             //
  3003.             // saveImageToolStripMenuItem
  3004.             //
  3005.             this.saveImageToolStripMenuItem.Name = "saveImageToolStripMenuItem";
  3006.             this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(151, 22);
  3007.             this.saveImageToolStripMenuItem.Text = "Save Image";
  3008.             this.saveImageToolStripMenuItem.Click += new System.EventHandler(this.saveImageToolStripMenuItem_Click);
  3009.             //
  3010.             // quitToolStripMenuItem
  3011.             //
  3012.             this.quitToolStripMenuItem.Name = "quitToolStripMenuItem";
  3013.             this.quitToolStripMenuItem.Size = new System.Drawing.Size(151, 22);
  3014.             this.quitToolStripMenuItem.Text = "Quit";
  3015.             this.quitToolStripMenuItem.Click += new System.EventHandler(this.quitToolStripMenuItem_Click);
  3016.             //
  3017.             // editToolStripMenuItem
  3018.             //
  3019.             this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
  3020.             this.selectColorToolStripMenuItem,
  3021.             this.setFontSizeToolStripMenuItem,
  3022.             this.selectBGToolStripMenuItem,
  3023.             this.clearToolStripMenuItem});
  3024.             this.editToolStripMenuItem.Name = "editToolStripMenuItem";
  3025.             this.editToolStripMenuItem.Size = new System.Drawing.Size(44, 22);
  3026.             this.editToolStripMenuItem.Text = "Edit";
  3027.             //
  3028.             // selectColorToolStripMenuItem
  3029.             //
  3030.             this.selectColorToolStripMenuItem.Name = "selectColorToolStripMenuItem";
  3031.             this.selectColorToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
  3032.             this.selectColorToolStripMenuItem.Text = "Select Color";
  3033.             this.selectColorToolStripMenuItem.Click += new System.EventHandler(this.selectColorToolStripMenuItem_Click);
  3034.             //
  3035.             // setFontSizeToolStripMenuItem
  3036.             //
  3037.             this.setFontSizeToolStripMenuItem.Name = "setFontSizeToolStripMenuItem";
  3038.             this.setFontSizeToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
  3039.             this.setFontSizeToolStripMenuItem.Text = "Set Font Size";
  3040.             this.setFontSizeToolStripMenuItem.Click += new System.EventHandler(this.setFontSizeToolStripMenuItem_Click);
  3041.             //
  3042.             // selectBGToolStripMenuItem
  3043.             //
  3044.             this.selectBGToolStripMenuItem.Name = "selectBGToolStripMenuItem";
  3045.             this.selectBGToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
  3046.             this.selectBGToolStripMenuItem.Text = "Select BG";
  3047.             this.selectBGToolStripMenuItem.Click += new System.EventHandler(this.selectBGToolStripMenuItem_Click);
  3048.             //
  3049.             // clearToolStripMenuItem
  3050.             //
  3051.             this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
  3052.             this.clearToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
  3053.             this.clearToolStripMenuItem.Text = "Clear";
  3054.             this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
  3055.             //
  3056.             // paintbrushToolStripMenuItem
  3057.             //
  3058.             this.paintbrushToolStripMenuItem.Name = "paintbrushToolStripMenuItem";
  3059.             this.paintbrushToolStripMenuItem.Size = new System.Drawing.Size(90, 22);
  3060.             this.paintbrushToolStripMenuItem.Text = "Paintbrush";
  3061.             this.paintbrushToolStripMenuItem.Click += new System.EventHandler(this.paintbrushToolStripMenuItem_Click);
  3062.             //
  3063.             // eraserToolStripMenuItem
  3064.             //
  3065.             this.eraserToolStripMenuItem.Name = "eraserToolStripMenuItem";
  3066.             this.eraserToolStripMenuItem.Size = new System.Drawing.Size(61, 22);
  3067.             this.eraserToolStripMenuItem.Text = "Eraser";
  3068.             this.eraserToolStripMenuItem.Click += new System.EventHandler(this.eraserToolStripMenuItem_Click);
  3069.             //
  3070.             // undoToolStripMenuItem
  3071.             //
  3072.             this.undoToolStripMenuItem.Name = "undoToolStripMenuItem";
  3073.             this.undoToolStripMenuItem.Size = new System.Drawing.Size(52, 22);
  3074.             this.undoToolStripMenuItem.Text = "Undo";
  3075.             //
  3076.             // redoToolStripMenuItem
  3077.             //
  3078.             this.redoToolStripMenuItem.Name = "redoToolStripMenuItem";
  3079.             this.redoToolStripMenuItem.Size = new System.Drawing.Size(52, 22);
  3080.             this.redoToolStripMenuItem.Text = "Redo";
  3081.             //
  3082.             // button1
  3083.             //
  3084.             this.button1.Font = new System.Drawing.Font("Kdam Thmor Pro", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  3085.             this.button1.Location = new System.Drawing.Point(1286, 225);
  3086.             this.button1.Margin = new System.Windows.Forms.Padding(2);
  3087.             this.button1.Name = "button1";
  3088.             this.button1.Size = new System.Drawing.Size(64, 85);
  3089.             this.button1.TabIndex = 4;
  3090.             this.button1.Text = "Color";
  3091.             this.button1.UseVisualStyleBackColor = true;
  3092.             this.button1.Visible = false;
  3093.             //
  3094.             // txt_color
  3095.             //
  3096.             this.txt_color.Font = new System.Drawing.Font("Kdam Thmor Pro", 8.999999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  3097.             this.txt_color.Location = new System.Drawing.Point(1286, 314);
  3098.             this.txt_color.Margin = new System.Windows.Forms.Padding(2);
  3099.             this.txt_color.Name = "txt_color";
  3100.             this.txt_color.ReadOnly = true;
  3101.             this.txt_color.Size = new System.Drawing.Size(65, 26);
  3102.             this.txt_color.TabIndex = 5;
  3103.             this.txt_color.Visible = false;
  3104.             //
  3105.             // button2
  3106.             //
  3107.             this.button2.Font = new System.Drawing.Font("Kdam Thmor Pro", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  3108.             this.button2.Location = new System.Drawing.Point(1286, 119);
  3109.             this.button2.Margin = new System.Windows.Forms.Padding(2);
  3110.             this.button2.Name = "button2";
  3111.             this.button2.Size = new System.Drawing.Size(62, 43);
  3112.             this.button2.TabIndex = 6;
  3113.             this.button2.Text = "Save";
  3114.             this.button2.UseVisualStyleBackColor = true;
  3115.             this.button2.Visible = false;
  3116.             //
  3117.             // button3
  3118.             //
  3119.             this.button3.Font = new System.Drawing.Font("Kdam Thmor Pro", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  3120.             this.button3.Location = new System.Drawing.Point(1286, 367);
  3121.             this.button3.Margin = new System.Windows.Forms.Padding(2);
  3122.             this.button3.Name = "button3";
  3123.             this.button3.Size = new System.Drawing.Size(62, 43);
  3124.             this.button3.TabIndex = 7;
  3125.             this.button3.Text = "Clear";
  3126.             this.button3.UseVisualStyleBackColor = true;
  3127.             this.button3.Visible = false;
  3128.             //
  3129.             // pb_canvas
  3130.             //
  3131.             this.pb_canvas.BackColor = System.Drawing.Color.Transparent;
  3132.             this.pb_canvas.Cursor = System.Windows.Forms.Cursors.Default;
  3133.             this.pb_canvas.Dock = System.Windows.Forms.DockStyle.Fill;
  3134.             this.pb_canvas.Location = new System.Drawing.Point(0, 24);
  3135.             this.pb_canvas.Margin = new System.Windows.Forms.Padding(2);
  3136.             this.pb_canvas.Name = "pb_canvas";
  3137.             this.pb_canvas.Size = new System.Drawing.Size(1352, 703);
  3138.             this.pb_canvas.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
  3139.             this.pb_canvas.TabIndex = 0;
  3140.             this.pb_canvas.TabStop = false;
  3141.             this.pb_canvas.WaitOnLoad = true;
  3142.             this.pb_canvas.Paint += new System.Windows.Forms.PaintEventHandler(this.pb_canvas_Paint);
  3143.             this.pb_canvas.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pb_canvas_MouseDown);
  3144.             this.pb_canvas.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pb_canvas_MouseMove);
  3145.             this.pb_canvas.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pb_canvas_MouseUp);
  3146.             //
  3147.             // Form1
  3148.             //
  3149.             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  3150.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  3151.             this.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  3152.             this.ClientSize = new System.Drawing.Size(1352, 727);
  3153.             this.Controls.Add(this.button3);
  3154.             this.Controls.Add(this.button2);
  3155.             this.Controls.Add(this.txt_color);
  3156.             this.Controls.Add(this.button1);
  3157.             this.Controls.Add(this.comboBox1);
  3158.             this.Controls.Add(this.label1);
  3159.             this.Controls.Add(this.pb_canvas);
  3160.             this.Controls.Add(this.menuStrip1);
  3161.             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
  3162.             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  3163.             this.MainMenuStrip = this.menuStrip1;
  3164.             this.Margin = new System.Windows.Forms.Padding(2);
  3165.             this.Name = "Form1";
  3166.             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  3167.             this.Text = "Absence of Euphoria (Default Size = 12 14 23 Eraser = 50 26 Color = #FF0000 #FF80" +
  3168.     "40)";
  3169.             this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
  3170.             this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
  3171.             this.Load += new System.EventHandler(this.Form1_Load);
  3172.             this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
  3173.             this.Resize += new System.EventHandler(this.Form1_Resize);
  3174.             this.menuStrip1.ResumeLayout(false);
  3175.             this.menuStrip1.PerformLayout();
  3176.             ((System.ComponentModel.ISupportInitialize)(this.pb_canvas)).EndInit();
  3177.             this.ResumeLayout(false);
  3178.             this.PerformLayout();
  3179.  
  3180.         }
  3181.  
  3182.         #endregion
  3183.  
  3184.         private System.Windows.Forms.PictureBox pb_canvas;
  3185.         private System.Windows.Forms.Label label1;
  3186.         private System.Windows.Forms.ComboBox comboBox1;
  3187.         private System.Windows.Forms.MenuStrip menuStrip1;
  3188.         private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
  3189.         private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
  3190.         private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem;
  3191.         private System.Windows.Forms.ToolStripMenuItem quitToolStripMenuItem;
  3192.         private System.Windows.Forms.Button button1;
  3193.         private System.Windows.Forms.TextBox txt_color;
  3194.         private System.Windows.Forms.Button button2;
  3195.         private System.Windows.Forms.Button button3;
  3196.         private System.Windows.Forms.ToolStripMenuItem paintbrushToolStripMenuItem;
  3197.         private System.Windows.Forms.ToolStripMenuItem eraserToolStripMenuItem;
  3198.         private System.Windows.Forms.ToolStripMenuItem loadImageToolStripMenuItem;
  3199.         private System.Windows.Forms.ToolStripMenuItem saveImageToolStripMenuItem;
  3200.         private System.Windows.Forms.ToolStripMenuItem selectColorToolStripMenuItem;
  3201.         private System.Windows.Forms.ToolStripMenuItem setFontSizeToolStripMenuItem;
  3202.         private System.Windows.Forms.ToolStripMenuItem selectBGToolStripMenuItem;
  3203.         private System.Windows.Forms.ToolStripMenuItem undoToolStripMenuItem;
  3204.         private System.Windows.Forms.ToolStripMenuItem redoToolStripMenuItem;
  3205.     }
  3206. }
  3207.  
  3208.  
Tags: #multifile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement