Exemplo n.º 1
0
        private void ChangePixelSize(object sender, EventArgs e)
        {
            String value = Properties.Settings.Default.PixelSize.ToString();

            if (InputBox("PixelPaint | " + GetLang("Pixel_Size_Menu_Item"), GetLang("Image_Reset_Warning"), ref value).Equals(DialogResult.OK))
            {
                if (int.Parse(value) < 5)
                {
                    MessageBox.Show(GetLang("Min_Pixel_Size_Error"), GetLang("Error"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                Properties.Settings.Default.PixelSize = int.Parse(value);
                Properties.Settings.Default.Save();

                this.s = int.Parse(value);

                Thread thread = new Thread(() =>
                {
                    this.Invoke(new System.Action(() => { this.Text = MainForm.GetLang("Unnamed_Title"); }));
                    ImagePanel.Invoke(new System.Action(() => { ImagePanel.Controls.Clear(); }));
                    px    = 0;
                    int x = 0;
                    int y = 0;
                    int s = this.s;
                    while (y + s <= ImagePanel.Height)
                    {
                        while (x + s <= ImagePanel.Width)
                        {
                            PictureBox box  = new PictureBox();
                            box.Name        = "Box" + px;
                            box.Click      += new EventHandler(Paint);
                            box.Size        = new Size(s, s);
                            box.BackColor   = Color.White;
                            box.BorderStyle = BorderStyle.FixedSingle;
                            box.Location    = new Point(x, y);
                            ImagePanel.Invoke(new System.Action(() => { ImagePanel.Controls.Add((Control)box); }));

                            x  += s;
                            px += 1;
                            PixelSizeLabel.Invoke(new System.Action(() => { PixelSizeLabel.Text = px.ToString(); }));
                        }
                        x  = 0;
                        y += s;
                    }
                });
                this.threads.Add(thread);
                MainForm.threads.Add(thread);
                thread.Start();

                this.fileName = "";
            }
        }
Exemplo n.º 2
0
        private void ResetPixels(object sender, EventArgs e)
        {
            if (MessageBox.Show(GetLang("Image_Reset_Warning"), "PixelPaint | " + GetLang("Reset_Confirmation"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning).Equals(DialogResult.OK))
            {
                Thread thread = new Thread(() =>
                {
                    this.Invoke(new System.Action(() => { this.Text = MainForm.GetLang("Unnamed_Title"); }));
                    ImagePanel.Invoke(new System.Action(() => { ImagePanel.Controls.Clear(); }));
                    px    = 0;
                    int x = 0;
                    int y = 0;
                    int s = this.s;
                    while (y + s <= ImagePanel.Height)
                    {
                        while (x + s <= ImagePanel.Width)
                        {
                            PictureBox box  = new PictureBox();
                            box.Name        = "Box" + px;
                            box.Click      += new EventHandler(Paint);
                            box.Size        = new Size(s, s);
                            box.BackColor   = Color.White;
                            box.BorderStyle = BorderStyle.FixedSingle;
                            box.Location    = new Point(x, y);
                            ImagePanel.Invoke(new System.Action(() => { ImagePanel.Controls.Add((Control)box); }));

                            x  += s;
                            px += 1;
                            PixelSizeLabel.Invoke(new System.Action(() => { PixelSizeLabel.Text = px.ToString(); }));
                        }
                        x  = 0;
                        y += s;
                    }
                });
                this.threads.Add(thread);
                MainForm.threads.Add(thread);
                thread.Start();
                this.fileName = "";
            }
        }
Exemplo n.º 3
0
        public void NewProjekt()
        {
            Thread thread = new Thread(() =>
            {
                this.Invoke(new System.Action(() => { this.Text = MainForm.GetLang("Unnamed_Title"); }));
                ImagePanel.Invoke(new System.Action(() => { ImagePanel.Controls.Clear(); }));
                px    = 0;
                int x = 0;
                int y = 0;
                int s = this.s;
                while (y + s <= ImagePanel.Height)
                {
                    while (x + s <= ImagePanel.Width)
                    {
                        PictureBox box  = new PictureBox();
                        box.Name        = "Box" + px;
                        box.Click      += new EventHandler(Paint);
                        box.Size        = new Size(s, s);
                        box.BackColor   = Color.White;
                        box.BorderStyle = BorderStyle.FixedSingle;
                        box.Location    = new Point(x, y);
                        ImagePanel.Invoke(new System.Action(() => { ImagePanel.Controls.Add(box); }));

                        x  += s;
                        px += 1;
                        PixelSizeLabel.Invoke(new System.Action(() => { PixelSizeLabel.Text = px.ToString(); }));
                    }
                    x  = 0;
                    y += s;
                }
            });

            this.threads.Add(thread);
            MainForm.threads.Add(thread);
            thread.Start();
        }
Exemplo n.º 4
0
        public void Open(String fileName)
        {
            Thread thread = new Thread(() =>
            {
                if (File.Exists(fileName))
                {
                    this.Invoke(new System.Action(() => { this.Text = fileName.Substring(fileName.LastIndexOf("\\") + 1).Replace(".pxp", ""); }));
                    StreamReader reader = new StreamReader(File.OpenRead(fileName));
                    String content      = reader.ReadToEnd();
                    string[] result     = content.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                    Properties.Settings.Default.PixelSize = int.Parse(result[0].Split('=')[1]);
                    Properties.Settings.Default.Save();
                    this.Invoke(new System.Action(() => { this.Text = fileName; }));
                    ImagePanel.Invoke(new System.Action(() => { ImagePanel.Controls.Clear(); }));
                    px    = 0;
                    int x = 0;
                    int y = 0;
                    int s = int.Parse(result[0].Split('=')[1]);
                    while (y + s <= ImagePanel.Height)
                    {
                        while (x + s <= ImagePanel.Width)
                        {
                            PictureBox box  = new PictureBox();
                            box.Name        = "Box" + px;
                            box.Click      += new EventHandler(Paint);
                            box.Size        = new Size(s, s);
                            box.BackColor   = Color.White;
                            box.BorderStyle = BorderStyle.FixedSingle;
                            box.Location    = new Point(x, y);
                            ImagePanel.Invoke(new System.Action(() => { ImagePanel.Controls.Add((Control)box); }));

                            x  += s;
                            px += 1;
                            PixelSizeLabel.Invoke(new System.Action(() => { PixelSizeLabel.Text = px.ToString(); }));
                        }
                        x  = 0;
                        y += s;
                    }

                    this.fileName = fileName;
                    this.name     = fileName.Substring(fileName.LastIndexOf("\\") + 1).Replace(".pxp", "");
                    result        = result.Where(val => val != result[0]).ToArray();
                    int i         = 0;
                    while (i < result.Length)
                    {
                        PictureBox box = (PictureBox)ImagePanel.Controls[i];
                        string[] vs    = result[i].Split('|');
                        Color color    = Color.FromArgb(int.Parse(vs[0]), int.Parse(vs[1]), int.Parse(vs[2]));
                        this.Invoke(new System.Action(() => { box.BackColor = color; }));
                        i++;
                    }
                }
                else
                {
                    MessageBox.Show(GetLang("Path_Not_Exists"), GetLang("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            });

            this.threads.Add(thread);
            MainForm.threads.Add(thread);
            thread.Start();
        }