All pastes #1243210 Raw Edit

Mine

public text v1 · immutable
#1243210 ·published 2008-11-02 14:43 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;

namespace MazeCreator
{
    public partial class Form1 : Form
    {
        static int patro = 1;
        static int patroDraw = 1;

        static int side = 40;
        static int sidebuffer = 40;
        static int[,,] mapa = new int[side, side, 10];

        Image canvas;

        int id = 500010;
        int idstairs = 500011;

        int bufferX;
        int bufferY;

        bool save = true;

        string warning = "Pozor, formát dotazu pro ArcEmu byl vytvořen podle ArcEmu wiki, netestováno. Za funkčnost neručím. Schody zatím nejsou podporovány. Přejděte na mangos, je lepší ;-)";

        int imageX;
        int imageY;

        int line = 0;
        int ctverec = 0;

        int positionX = 0;
        int positionY = 0;

        Graphics artist;
        Random rnd = new Random();

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            drawMap();
        }

        public void drawMap()
        {
            int x = 0;
            int y = 0;

            imageX = 0;
            imageY = 0;

                canvas = new Bitmap(side * 10, side * 10);
                artist = Graphics.FromImage(canvas);
                try
                {
                    for (y = 0; y < side; y++)
                    {
                        for (x = 0; x < side; x++)
                        {
                            if (mapa[x, y, patroDraw] == 1)
                            {
                                Image image = Image.FromFile("full.jpg");
                                artist.DrawImage(image, imageX, imageY);
                            }
                            else if (mapa[x, y, patroDraw] == 2)
                            {
                                Image image = Image.FromFile("stairs.jpg");
                                artist.DrawImage(image, imageX, imageY);
                            }
                            else
                            {
                                Image image = Image.FromFile("empty.jpg");
                                artist.DrawImage(image, imageX, imageY);
                            }
                            imageX += 10;

                        }
                        imageX = 0;
                        imageY += 10;
                    }
                }
                catch
                {
                }

            pictureBox1.Image = canvas;
        }

        private void pictureBox1_MouseHover(object sender, MouseEventArgs e)
        {
            positionX = e.X / 10;
            positionY = e.Y / 10;
            label1.Location = new System.Drawing.Point(e.X + 10, e.Y + 10);
            label1.Text = Convert.ToString(positionX + 1) + " : " + Convert.ToString(positionY + 1);
            label1.Visible = true;
        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (ctverec == 0 && mapa[positionX, positionY, patroDraw] == 0)
            {
                textBox15.Text = Convert.ToString(positionX + 1);
                textBox14.Text = Convert.ToString(positionY + 1);
                ctverec++;
            }
            else if (mapa[positionX, positionY, patroDraw] == 0)
            {
                textBox13.Text = Convert.ToString(positionX + 1);
                textBox12.Text = Convert.ToString(positionY + 1);
            }

            if (line == 0 && mapa[positionX, positionY, patroDraw] == 0)
            {
                textBox1.Text = Convert.ToString(positionX + 1);
                textBox2.Text = Convert.ToString(positionY + 1);
                line++;
            }
            else if (mapa[positionX, positionY, patroDraw] == 0)
            {
                textBox3.Text = Convert.ToString(positionX + 1);
                textBox4.Text = Convert.ToString(positionY + 1);
            }

            if (e.Button == MouseButtons.Left)
            {
                mouse_left_click();
                timer1.Enabled = true;
                timer2.Enabled = false;
                save = true;
            }
            else if (e.Button == MouseButtons.Right)
            {
                mouse_right_click();
                timer1.Enabled = false;
                timer2.Enabled = true;
                save = true;
            }
            else if (e.Button == MouseButtons.Middle)
            {
                mouse_middle_click();
                timer1.Enabled = false;
                timer2.Enabled = false;
                save = true;
            }
            //MessageBox.Show(mapa[e.X / 10, e.Y / 10, patroDraw].ToString());
        }

        public void click()
        {
            if (line == 0 && mapa[positionX, positionY, patroDraw] == 0)
            {
                textBox1.Text = Convert.ToString(positionX + 1);
                textBox2.Text = Convert.ToString(positionY + 1);
                line++;
            }
            else if (mapa[positionX, positionY, patroDraw] == 0)
            {
                textBox3.Text = Convert.ToString(positionX + 1);
                textBox4.Text = Convert.ToString(positionY + 1);
            }

            if (mapa[positionX, positionY, patroDraw] == 0)
            {
                mapa[positionX, positionY, patroDraw] = 1;
                Image image = Image.FromFile("full.jpg");
                artist = Graphics.FromImage(canvas);
                artist.DrawImage(image, positionX * 10, positionY * 10);
                pictureBox1.Image = canvas;
            }
            else
            {
                mapa[positionX, positionY, patroDraw] = 0;
                Image image = Image.FromFile("empty.jpg");
                artist = Graphics.FromImage(canvas);
                artist.DrawImage(image, positionX * 10, positionY * 10);
                pictureBox1.Image = canvas;
            }
        }

        public void mouse_left_click()
        {
            try
            {
                if (mapa[positionX, positionY, patroDraw] == 0 || mapa[positionX, positionY, patroDraw] == 2)
                {
                    mapa[positionX, positionY, patroDraw] = 1;
                    Image image = Image.FromFile("full.jpg");
                    artist = Graphics.FromImage(canvas);
                    artist.DrawImage(image, positionX * 10, positionY * 10);
                    pictureBox1.Image = canvas;
                }
            }
            catch
            {
            }
        }

        public void mouse_middle_click()
        {
            try
            {
                if (mapa[positionX, positionY, patroDraw] == 0 || mapa[positionX, positionY, patroDraw] == 1)
                {
                    mapa[positionX, positionY, patroDraw] = 2;
                    Image image = Image.FromFile("stairs.jpg");
                    artist = Graphics.FromImage(canvas);
                    artist.DrawImage(image, positionX * 10, positionY * 10);
                    pictureBox1.Image = canvas;
                }
            }
            catch
            {
            }
        }

        public void mouse_right_click()
        {
            try
            {
                mapa[positionX, positionY, patroDraw] = 0;
                Image image = Image.FromFile("empty.jpg");
                artist = Graphics.FromImage(canvas);
                artist.DrawImage(image, positionX * 10, positionY * 10);
                pictureBox1.Image = canvas;
            }
            catch
            {
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            line = 0;
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {

                if (textBox2.Text == textBox4.Text)
                {
                    if (Convert.ToInt32(textBox1.Text) < Convert.ToInt32(textBox3.Text))
                    {
                        for (int x = Convert.ToInt32(textBox1.Text); x < Convert.ToInt32(textBox3.Text); x++)
                        {
                            mapa[x - 1, Convert.ToInt32(textBox2.Text) - 1, patroDraw] = 1;
                            Image image = Image.FromFile("full.jpg");
                            artist = Graphics.FromImage(canvas);
                            artist.DrawImage(image, (x - 1) * 10, (Convert.ToInt32(textBox2.Text) - 1) * 10);
                            pictureBox1.Image = canvas;
                        }
                    }
                    else
                    {
                        for (int x = Convert.ToInt32(textBox3.Text); x < Convert.ToInt32(textBox1.Text); x++)
                        {
                            mapa[x - 1, Convert.ToInt32(textBox2.Text) - 1, patroDraw] = 1;
                            Image image = Image.FromFile("full.jpg");
                            artist = Graphics.FromImage(canvas);
                            artist.DrawImage(image, (x - 1) * 10, (Convert.ToInt32(textBox2.Text) - 1) * 10);
                            pictureBox1.Image = canvas;
                        }
                    }
                    button2.PerformClick();
                }
                else if (textBox1.Text == textBox3.Text)
                {
                    if (Convert.ToInt32(textBox2.Text) < Convert.ToInt32(textBox4.Text))
                    {
                        for (int y = Convert.ToInt32(textBox2.Text); y < Convert.ToInt32(textBox4.Text); y++)
                        {
                            mapa[Convert.ToInt32(textBox1.Text) - 1, y - 1, patroDraw] = 1;
                            Image image = Image.FromFile("full.jpg");
                            artist = Graphics.FromImage(canvas);
                            artist.DrawImage(image, (Convert.ToInt32(textBox1.Text) - 1) * 10, (y - 1) * 10);
                            pictureBox1.Image = canvas;
                        }
                    }
                    else
                    {
                        for (int y = Convert.ToInt32(textBox4.Text); y < Convert.ToInt32(textBox2.Text); y++)
                        {
                            mapa[Convert.ToInt32(textBox1.Text) - 1, y - 1, patroDraw] = 1;
                            Image image = Image.FromFile("full.jpg");
                            artist = Graphics.FromImage(canvas);
                            artist.DrawImage(image, (Convert.ToInt32(textBox1.Text) - 1) * 10, (y - 1) * 10);
                            pictureBox1.Image = canvas;
                        }
                    }
                    button2.PerformClick();
                }
                ctverec = 0;
                textBox15.Text = "";
                textBox12.Text = "";
                textBox13.Text = "";
                textBox14.Text = "";

            }
            catch
            {
                MessageBox.Show("Zadány neplatné hodnoty.");
            }
        }

        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        { 
            timer1.Enabled = false;
            timer2.Enabled = false;
            save = true;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (save == true)
            {
                bufferX = positionX;
                bufferY = positionY;
                save = false;
            }
            else
            {
                if (bufferX != positionX || bufferY != positionY)
                {
                    mouse_left_click();
                    save = true;
                }
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            if (save == true)
            {
                bufferX = positionX;
                bufferY = positionY;
                save = false;
            }
            else
            {
                if (bufferX != positionX || bufferY != positionY)
                {
                    mouse_right_click();
                    save = true;
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                side = Convert.ToInt32(textBox5.Text);
                this.Size = new Size(10 * side + 307, 0);
                tabControl1.Location = new System.Drawing.Point(side * 10, 0);
                mapa = new int[side, side, 10];
                pictureBox1.Size = new Size(side * 10, side * 10);
                drawMap();
            }
            catch
            {
            }

        }

        private void button6_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = side + "!";
            for (int y = 0; y < side; y++)
            {
                for (int x = 0; x < side; x++)
                {
                    if (mapa[x, y, patro] == 1)
                    {
                        richTextBox1.Text += Convert.ToString(x + 1) + "." + Convert.ToString(y + 1) + ";";
                    }
                }
            }
            
        }

        private void button5_Click(object sender, EventArgs e)
        {
            int buffX = 0;
            int buffY = 0;

            string buffer = "";

            for (int x = 0; x < richTextBox2.Text.Length; x++)
            {
                if (richTextBox2.Text[x].ToString() == "!")
                {
                    textBox5.Text = buffer;
                    x++;
                    sidebuffer = Convert.ToInt32(buffer);
                    buffer = "";
                    this.Size = new Size(10 * side + 307, 0);
                    tabControl1.Location = new System.Drawing.Point(side * 10, 0);
                    if (sidebuffer != side)
                    {
                        mapa = new int[side, side, 10];
                        side = sidebuffer;
                    }
                    else
                    {
                        side = sidebuffer;
                    }
                    pictureBox1.Size = new Size(side * 10, side * 10);
                    
                }
                if (richTextBox2.Text[x].ToString() == ".")
                {
                    try
                    {
                        buffX = Convert.ToInt32(buffer) - 1;
                    }
                    catch
                    {
                    }
                    x++;
                    buffer = "";
                }
                if (richTextBox2.Text[x].ToString() == ";")
                {
                    try
                    {
                        buffY = Convert.ToInt32(buffer) - 1;
                    }
                    catch
                    {
                    }
                    x++;
                    buffer = "";
                    mapa[buffX, buffY, patro] = 1;
                }

                try
                {
                    buffer += richTextBox2.Text[x].ToString();
                }
                catch
                {
                }
            }
            drawMap();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {
                richTextBox4.Text = "INSERT INTO `gameobject_template` (`entry`, `type`, `displayId`, `name`, `castBarCaption`, `faction`, `flags`, `size`, `data0`, `data1`, `data2`, `data3`, `data4`, `data5`, `data6`, `data7`, `data8`, `data9`, `data10`, `data11`, `data12`, `data13`, `data14`, `data15`, `data16`, `data17`, `data18`, `data19`, `data20`, `data21`, `data22`, `data23`, `ScriptName`) VALUES (" + id.ToString() + ", 5, 5271, \'Bludiste bedna\', \'\', 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \'\'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (787, -7394.48, 782.512, 131.407, 2.66744, 0, \'mazecreator\');";
                richTextBox3.Text = "DELETE FROM `gameobject` WHERE `id` = " + id.ToString() + "; INSERT INTO `gameobject` (`guid`, `id`, `map`, `spawnMask`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation0`, `rotation1`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`) VALUES";
                bool one = false;
                for (int y = 0; y < side; y++)
                {
                    for (int x = 0; x < side; x++)
                    {
                        if (mapa[x, y, patro] == 1)
                        {
                            if (one == false)
                            {
                                richTextBox3.Text += "\n(NULL, " + id.ToString() + ", 0, 1," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.408 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                one = true;
                            }
                            else
                                richTextBox3.Text += ",\n(NULL, " + id.ToString() + ", 0, 1," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.408 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                        }
                        if (mapa[x, y, patro] == 2)
                        {
                            if (one == false)
                            {
                                richTextBox3.Text += "\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(788.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.600 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                one = true;
                            }
                            else
                            {
                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(788.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.600 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            }
                            richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1," + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(786.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.000 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1," + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(787.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.000 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1," + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(786.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(134.800 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";

                            richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.200 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(790.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.800 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(791.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(132.400 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";

                            richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(787.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(134.800 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(788.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(134.200 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(133.600 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(790.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(133.000 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(791.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(132.400 + ((1.36 * 4) * (patro - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                        }
                    }
                }

            }
            else if (radioButton2.Checked == true)
            {
                richTextBox4.Text = "INSERT INTO `gameobject_names` (`entry`, `Type`, `DisplayID`, `Name`, `spellfocus`, `sound1`, `sound2`, `sound3`, `sound4`, `sound5`, `sound6`, `sound7`, `sound8`, `sound9`, `unknown1`, `unknown2`, `unknown3`, `unknown4`, `unknown5`, `unknown6`, `unknown7`, `unknown8`, `unknown9`, `unknown10`, `unknown11`, `unknown12`, `unknown13`, `unknown14`) VALUES (500010, 5, 5271, 'Bludiste bedna', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);";
                richTextBox3.Text = "DELETE FROM `gameobject_spawns` WHERE `id` = " + id.ToString() + "; INSERT INTO `gameobject_spawns` (`id`, `Entry`, `map`, `position_x`, `position_y`, `position_z`, `Facing`, `orientation1`, `orientation2`, `orientation3`, `orientation4`, `State`, `Flags`, `Faction`, `Scale`, `stateNpcLink`) VALUES";
                bool one = false;
                for (int y = 0; y < side; y++)
                {
                    for (int x = 0; x < side; x++)
                    {
                        if (mapa[x, y, patro] == 1)
                        {
                            if (one == false)
                            {
                                richTextBox3.Text += "\n('', " + id.ToString() + ", 0," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", 131.408, 0, 0, 0, 0, 0, 1, 0, 0, 4, 0)";
                                one = true;
                            }
                            else
                            {
                                richTextBox3.Text += ",\n('', " + id.ToString() + ", 0," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", 131.408, 0, 0, 0, 0, 0, 1, 0, 0, 4, 0)";
                            }
                        }
                    }
                }
            }
        }

        public string replace(string number)
        {
            return number.Replace(Convert.ToChar(','), Convert.ToChar("."));
        }

        private void button17_Click(object sender, EventArgs e)
        {
            try
            {
                id = Convert.ToInt32(textBox11.Text);
            }
            catch
            {
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            tabPage2.Text = "Settings";
            tabPage1.Text = "Drawing";
            tabPage9.Text = "Authors";
            label2.Text = "Line";
            label3.Text = "Beginning:";
            label8.Text = "End:";
            button1.Text = "Draw!";
            button5.Text = "Load data";
            button6.Text = "Export";
            label30.Text = "Ingame use command .tele mazecreator";
            button4.Text = "Export";
            label28.Text = "Authors";
            label29.Text = "The original idea of Maze Creator, as well as first working Maze Creator (PHP), belongs to Bbtrash.\nIt was later rewritten by Axxa into C# (which is quicker)";
            button3.Text = "Set!";
            button17.Text = "Set!";
            label12.Text = "Side:";
            label9.Text = "Field size";
            label27.Text = "Gameobject's ID";
            label31.Text = "Fill field with";
            button18.Text = "Boxes";
            button19.Text = "Grass";
            label32.Text = "Draw recentagle";
            label35.Text = "End:";
            label38.Text = "Beginning:";
            button21.Text = "Draw!";
            button22.Text = "Delete!";
            label39.Text = "Generate boxes randomly";
            label40.Text = "Randomly generate boxes; this might give you an idea while designing new Maze";
            button23.Text = "Surprise me";
            label41.Text = "Reset window size";
            label42.Text = "SQL output format";
            label43.Text = "Coords: x: -7401.79 y:  789.01 z: 131.408 map: 0";
            warning = "Warning, ArcEmu sql format was created using their wiki, untested. If its not working, dont blame me ;). Stairs are unsupported at the moment. You should use mangos, anyway. Its better ;-)";
            button25.Text = "Choose";
            button27.Text = "Choose";
            button29.Text = "Choose";
            label45.Text = "Floor";
            label44.Text = "Floor";
            label46.Text = "Floor";
            label51.Text = "Floor";
            label47.Text = "Warning: Stairs are NOT included in this export/import.";
            label50.Text = "Warning: This export/import is NOT compatible with PHP version.";
            button30.Text = "Export into txt file";
            button31.Text = "Import floor";
            button28.Text = "Set!";
            button26.Text = "Export all";
            button32.Text = "Export all and save as *.sql";


        }

        private void button7_Click(object sender, EventArgs e)
        {
            tabPage2.Text = "Nastavení";
            tabPage1.Text = "Kreslení";
            tabPage9.Text = "Autoři";
            label2.Text = "Přímka";
            label3.Text = "Počátek:";
            label8.Text = "Konec:";
            button1.Text = "Nakresli";
            button5.Text = "Načíst data";
            button6.Text = "Exportovat";
            label30.Text = "Ve hře použíj příkaze .tele mazecreator";
            button4.Text = "Exportovat";
            label28.Text = "Autoři";
            label29.Text = "Myšlenka a první provedení celého projektu bylo Bbtrashovo, a za to mu patří můj nemalý dík. \nDo svižnější C# verze přepsala Axxa.";
            button3.Text = "Nastav!";
            button17.Text = "Nastav!";
            label12.Text = "Strana:";
            label9.Text = "Velikost pole";
            label27.Text = "Id gameobjektu";
            label31.Text = "Naplnit pole";
            button18.Text = "Bednami";
            button19.Text = "Trávou";
            label32.Text = "Nakreslit obdelník";
            label35.Text = "Konec:";
            label38.Text = "Počátek:";
            button21.Text = "Nakresli";
            button22.Text = "Smaž";
            label39.Text = "Vygenerovat bedny náhodně";
            label40.Text = "Náhodně vygeneruje bedny, Toto vám může pomoci při stavbě nového bludiště.";
            button23.Text = "Překvap mě";
            label41.Text = "Resetovat velikost okna";
            label42.Text = "Formát SQL výstupu";
            label43.Text = "Souřadnice: x: -7401.79 y:  789.01 z: 131.408 map: 0";
            warning = "Pozor, formát dotazu pro ArcEmu byl vytvořen podle ArcEmu wiki, netestováno. Za funkčnost neručím. Schody zatím nejsou podporovány. Přejděte na mangos, je lepší ;-)";
            button25.Text = "Zvol";
            button27.Text = "Zvol";
            button29.Text = "Zvol";
            label45.Text = "Patro";
            label44.Text = "Patro";
            label46.Text = "Patro";
            label51.Text = "Patro";
            label47.Text = "Pozor: Tento export/import nezahrnuje schody.";
            label50.Text = "Pozor: Tento export/import není kompatibilní s PHP verzí.";
            button30.Text = "Exportovat do txt";
            button31.Text = "Importovat patro";
            button28.Text = "Nastav!";
            button26.Text = "Exportovat vše";
            button32.Text = "Exportovat vše a uložit jako sql";
        
        }

        private void pictureBox1_MouseLeave(object sender, EventArgs e)
        {
            label1.Visible = false;
        }

        private void button19_Click(object sender, EventArgs e)
        {
            for (int y = 0; y < side; y++)
            {
                for (int x = 0; x < side; x++)
                {
                    mapa[x, y, patroDraw] = 0;
                }
            }
            drawMap();
        }

        private void button18_Click(object sender, EventArgs e)
        {
            for (int y = 0; y < side; y++)
            {
                for (int x = 0; x < side; x++)
                {
                    mapa[x, y, patroDraw] = 1;
                }
            }
            drawMap();
        }

        private void button21_Click(object sender, EventArgs e)
        {
            try
            {
                for (int y = Convert.ToInt32(textBox14.Text) - 1; y < Convert.ToInt32(textBox12.Text); y++)
                {
                    for (int x = Convert.ToInt32(textBox15.Text) - 1; x < Convert.ToInt32(textBox13.Text); x++)
                    {
                        mapa[x, y, patroDraw] = 1;
                        Image image = Image.FromFile("full.jpg");
                        artist = Graphics.FromImage(canvas);
                        artist.DrawImage(image, (x) * 10, (y) * 10);
                        pictureBox1.Image = canvas;
                    }
                }

                for (int y = Convert.ToInt32(textBox12.Text) - 1; y < Convert.ToInt32(textBox14.Text); y++)
                {
                    for (int x = Convert.ToInt32(textBox13.Text) - 1; x < Convert.ToInt32(textBox15.Text); x++)
                    {
                        mapa[x, y, patroDraw] = 1;
                        Image image = Image.FromFile("full.jpg");
                        artist = Graphics.FromImage(canvas);
                        artist.DrawImage(image, (x) * 10, (y) * 10);
                        pictureBox1.Image = canvas;
                    }
                }

                for (int y = Convert.ToInt32(textBox14.Text) - 1; y < Convert.ToInt32(textBox12.Text); y++)
                {
                    for (int x = Convert.ToInt32(textBox13.Text) - 1; x < Convert.ToInt32(textBox15.Text); x++)
                    {
                        mapa[x, y, patroDraw] = 1;
                        Image image = Image.FromFile("full.jpg");
                        artist = Graphics.FromImage(canvas);
                        artist.DrawImage(image, (x) * 10, (y) * 10);
                        pictureBox1.Image = canvas;
                    }
                }

                for (int y = Convert.ToInt32(textBox12.Text) - 1; y < Convert.ToInt32(textBox14.Text); y++)
                {
                    for (int x = Convert.ToInt32(textBox15.Text) - 1; x < Convert.ToInt32(textBox13.Text); x++)
                    {
                        mapa[x, y, patroDraw] = 1;
                        Image image = Image.FromFile("full.jpg");
                        artist = Graphics.FromImage(canvas);
                        artist.DrawImage(image, (x) * 10, (y) * 10);
                        pictureBox1.Image = canvas;
                    }
                }

                ctverec = 0;
                textBox15.Text = "";
                textBox12.Text = "";
                textBox13.Text = "";
                textBox14.Text = "";
                line = 0;
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
            }
            catch
            {
            }
        }

        private void button20_Click(object sender, EventArgs e)
        {
            ctverec = 0;
            textBox15.Text = "";
            textBox12.Text = "";
            textBox13.Text = "";
            textBox14.Text = "";
        }

        private void button22_Click(object sender, EventArgs e)
        {
            try
            {
                for (int y = Convert.ToInt32(textBox14.Text) - 1; y < Convert.ToInt32(textBox12.Text); y++)
                {
                    for (int x = Convert.ToInt32(textBox15.Text) - 1; x < Convert.ToInt32(textBox13.Text); x++)
                    {
                        mapa[x, y, patroDraw] = 0;
                        Image image = Image.FromFile("empty.jpg");
                        artist = Graphics.FromImage(canvas);
                        artist.DrawImage(image, (x) * 10, (y) * 10);
                        pictureBox1.Image = canvas;
                    }
                }

                for (int y = Convert.ToInt32(textBox12.Text) - 1; y < Convert.ToInt32(textBox14.Text); y++)
                {
                    for (int x = Convert.ToInt32(textBox13.Text) - 1; x < Convert.ToInt32(textBox15.Text); x++)
                    {
                        mapa[x, y, patroDraw] = 0;
                        Image image = Image.FromFile("empty.jpg");
                        artist = Graphics.FromImage(canvas);
                        artist.DrawImage(image, (x) * 10, (y) * 10);
                        pictureBox1.Image = canvas;
                    }
                }

                for (int y = Convert.ToInt32(textBox14.Text) - 1; y < Convert.ToInt32(textBox12.Text); y++)
                {
                    for (int x = Convert.ToInt32(textBox13.Text) - 1; x < Convert.ToInt32(textBox15.Text); x++)
                    {
                        mapa[x, y, patroDraw] = 0;
                        Image image = Image.FromFile("empty.jpg");
                        artist = Graphics.FromImage(canvas);
                        artist.DrawImage(image, (x) * 10, (y) * 10);
                        pictureBox1.Image = canvas;
                    }
                }

                for (int y = Convert.ToInt32(textBox12.Text) - 1; y < Convert.ToInt32(textBox14.Text); y++)
                {
                    for (int x = Convert.ToInt32(textBox15.Text) - 1; x < Convert.ToInt32(textBox13.Text); x++)
                    {
                        mapa[x, y, patroDraw] = 0;
                        Image image = Image.FromFile("empty.jpg");
                        artist = Graphics.FromImage(canvas);
                        artist.DrawImage(image, (x) * 10, (y) * 10);
                        pictureBox1.Image = canvas;
                    }
                }

                ctverec = 0;
                textBox15.Text = "";
                textBox12.Text = "";
                textBox13.Text = "";
                textBox14.Text = "";
                line = 0;
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
            }
            catch
            {
            }
        }

        private void button23_Click(object sender, EventArgs e)
        {
            for (int y = 0; y < side; y++)
            {
                for (int x = 0; x < side; x++)
                {
                    switch (rnd.Next(1, 11))
                    { 
                        case 2:
                            goto case 5;
                        case 3:
                            goto case 5;
                        case 4:
                            goto case 5;
                        case 5:
                            mapa[x, y, patroDraw] = 1;
                            mapa[x, y, patroDraw] = 1;
                            Image image = Image.FromFile("full.jpg");
                            artist = Graphics.FromImage(canvas);
                            artist.DrawImage(image, (x) * 10, (y) * 10);
                            pictureBox1.Image = canvas;
                            break;
                    }
                      
                    
                }
            }
        }

        private void button24_Click(object sender, EventArgs e)
        {
            this.Size = new Size(0,0);
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton2.Checked == true)
            {
                MessageBox.Show(warning);
                label30.Visible = false;
                label43.Visible = true;
            }
            else
            {
                label30.Visible = true;
                label43.Visible = false;
            }
        }

        private void numericUpDown3_ValueChanged(object sender, EventArgs e)
        {
            patro = Convert.ToInt32(numericUpDown3.Value);
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            patro = Convert.ToInt32(numericUpDown1.Value);
        }

        private void button25_Click(object sender, EventArgs e)
        {
            patroDraw = Convert.ToInt32(numericUpDown2.Value);
            drawMap();
        }

        private void button26_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {
                bool one = false;
                richTextBox4.Text = "INSERT INTO `gameobject_template` (`entry`, `type`, `displayId`, `name`, `castBarCaption`, `faction`, `flags`, `size`, `data0`, `data1`, `data2`, `data3`, `data4`, `data5`, `data6`, `data7`, `data8`, `data9`, `data10`, `data11`, `data12`, `data13`, `data14`, `data15`, `data16`, `data17`, `data18`, `data19`, `data20`, `data21`, `data22`, `data23`, `ScriptName`) VALUES (" + id.ToString() + ", 5, 5271, \'Bludiste bedna\', \'\', 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \'\'); \nINSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (787, -7394.48, 782.512, 131.407, 2.66744, 0, \'mazecreator\');";
                richTextBox4.Text += "\nINSERT INTO `gameobject_template` (`entry`, `type`, `displayId`, `name`, `castBarCaption`, `faction`, `flags`, `size`, `data0`, `data1`, `data2`, `data3`, `data4`, `data5`, `data6`, `data7`, `data8`, `data9`, `data10`, `data11`, `data12`, `data13`, `data14`, `data15`, `data16`, `data17`, `data18`, `data19`, `data20`, `data21`, `data22`, `data23`, `ScriptName`) VALUES (" + idstairs.ToString() + ", 5, 5271, 'Bludiste bedna', '', 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '');";
                richTextBox3.Text = "DELETE FROM `gameobject` WHERE `id` = " + id.ToString() + "; \nDELETE FROM `gameobject` WHERE `id` = " + idstairs.ToString() + "; \nINSERT INTO `gameobject` (`guid`, `id`, `map`, `spawnMask`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation0`, `rotation1`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`) VALUES";
                    
                for (int z = 0; z < 10; z++)
                {
                    for (int y = 0; y < side; y++)
                    {
                        for (int x = 0; x < side; x++)
                        {
                            if (mapa[x, y, z] == 1)
                            {
                                if (one == false)
                                {
                                    richTextBox3.Text += "\n(NULL, " + id.ToString() + ", 0, 1," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.408 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                    one = true;
                                }
                                else
                                    richTextBox3.Text += ",\n(NULL, " + id.ToString() + ", 0, 1," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.408 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            }
                            if (mapa[x, y, z] == 2)
                            {
                                if (one == false)
                                {
                                    richTextBox3.Text += "\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(788.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.600 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                    one = true;
                                }
                                else
                                {
                                    richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(788.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.600 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                }
                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1," + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(786.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.000 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1," + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(787.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.000 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1," + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(786.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(134.800 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";

                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.200 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(790.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.800 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(791.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(132.400 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";

                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(787.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(134.800 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(788.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(134.200 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(133.600 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(790.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(133.000 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                richTextBox3.Text += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(791.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(132.400 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            }
                        }
                    }
                }

            }
            else if (radioButton2.Checked == true)
            {
                richTextBox4.Text = "INSERT INTO `gameobject_names` (`entry`, `Type`, `DisplayID`, `Name`, `spellfocus`, `sound1`, `sound2`, `sound3`, `sound4`, `sound5`, `sound6`, `sound7`, `sound8`, `sound9`, `unknown1`, `unknown2`, `unknown3`, `unknown4`, `unknown5`, `unknown6`, `unknown7`, `unknown8`, `unknown9`, `unknown10`, `unknown11`, `unknown12`, `unknown13`, `unknown14`) VALUES (500010, 5, 5271, 'Bludiste bedna', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);";
                richTextBox3.Text = "DELETE FROM `gameobject_spawns` WHERE `id` = " + id.ToString() + "; INSERT INTO `gameobject_spawns` (`id`, `Entry`, `map`, `position_x`, `position_y`, `position_z`, `Facing`, `orientation1`, `orientation2`, `orientation3`, `orientation4`, `State`, `Flags`, `Faction`, `Scale`, `stateNpcLink`) VALUES";
                bool one = false;

                for (int z = 0; z < 10; z++)
                {
                    for (int y = 0; y < side; y++)
                    {
                        for (int x = 0; x < side; x++)
                        {
                            if (mapa[x, y, z] == 1)
                            {
                                if (one == false)
                                {
                                    richTextBox3.Text += "\n('', " + id.ToString() + ", 0," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", 131.408, 0, 0, 0, 0, 0, 1, 0, 0, 4, 0)";
                                    one = true;
                                }
                                else
                                {
                                    richTextBox3.Text += ",\n('', " + id.ToString() + ", 0," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", 131.408, 0, 0, 0, 0, 0, 1, 0, 0, 4, 0)";
                                }
                            }
                        }
                    }
                }
            }
        }

        private void button27_Click(object sender, EventArgs e)
        {
            patro = Convert.ToInt32(numericUpDown1.Value);
        }

        private void button28_Click(object sender, EventArgs e)
        {
            try
            {
                idstairs = Convert.ToInt32(textBox16.Text);
            }
            catch
            {
            }
        }

        private void button30_Click(object sender, EventArgs e)
        {
            try
            {
                string buffer = "";

                saveFileDialog1.ShowDialog();

                StreamWriter write = new StreamWriter(saveFileDialog1.OpenFile());

                buffer = side.ToString() + ";\n";
                    for (int y = 0; y < side; y++)
                    {
                        for (int x = 0; x < side; x++)
                        {
                            buffer += mapa[x, y, patro].ToString();
                        }
                        write.WriteLine(buffer);
                        buffer = "";
                    }
                write.Close();
            }
            catch
            { }
        }

        private void button31_Click(object sender, EventArgs e)
        {
            try
            {
                openFileDialog1.ShowDialog();
                bool one = false;

                string buffer = "";
                string line = "";

                int sideBuffer = 0;
                int lineCount = 0;

                StreamReader read = new StreamReader(openFileDialog1.OpenFile());

                while ((line = read.ReadLine()) != null)
                {
                    for (int x = 0; x < line.Length; x++)
                    {
                        if (one == false && line[x] == ';')
                        {
                            one = true;
                            sideBuffer = Convert.ToInt32(buffer);
                            buffer = "";
                            if (sideBuffer != side)
                            {
                                side = sideBuffer;
                                this.Size = new Size(10 * side + 307, 0);
                                tabControl1.Location = new System.Drawing.Point(side * 10, 0);
                                mapa = new int[side, side, 10];
                                pictureBox1.Size = new Size(side * 10, side * 10);
                            }
                            lineCount--;
                        }

                        if (one == false)
                        {
                            buffer += line[x].ToString();
                        }


                        if (one == true && x < side)
                        {
                            if (line[x] == '0')
                            {
                                mapa[x, lineCount, patro] = 0;
                            }
                            if (line[x] == '1')
                            {
                                mapa[x, lineCount, patro] = 1;
                            }
                            if (line[x] == '2')
                            {
                                mapa[x, lineCount, patro] = 2;
                            }
                        }

                    }
                    lineCount++;
                }

                read.Close();
                patroDraw = patro;
                drawMap();
            }
            catch
            {
            }
        }

        private void numericUpDown4_ValueChanged(object sender, EventArgs e)
        {
            patro = Convert.ToInt32(numericUpDown4.Value);
        }

        private void button32_Click(object sender, EventArgs e)
        {
            string buffer = "";
            if (radioButton1.Checked == true)
            {
                bool one = false;
                buffer = "INSERT INTO `gameobject_template` (`entry`, `type`, `displayId`, `name`, `castBarCaption`, `faction`, `flags`, `size`, `data0`, `data1`, `data2`, `data3`, `data4`, `data5`, `data6`, `data7`, `data8`, `data9`, `data10`, `data11`, `data12`, `data13`, `data14`, `data15`, `data16`, `data17`, `data18`, `data19`, `data20`, `data21`, `data22`, `data23`, `ScriptName`) VALUES (" + id.ToString() + ", 5, 5271, \'Bludiste bedna\', \'\', 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \'\'); \nINSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (787, -7394.48, 782.512, 131.407, 2.66744, 0, \'mazecreator\');";
                buffer += "\nINSERT INTO `gameobject_template` (`entry`, `type`, `displayId`, `name`, `castBarCaption`, `faction`, `flags`, `size`, `data0`, `data1`, `data2`, `data3`, `data4`, `data5`, `data6`, `data7`, `data8`, `data9`, `data10`, `data11`, `data12`, `data13`, `data14`, `data15`, `data16`, `data17`, `data18`, `data19`, `data20`, `data21`, `data22`, `data23`, `ScriptName`) VALUES (" + idstairs.ToString() + ", 5, 5271, 'Bludiste bedna', '', 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '');";
                buffer += "\nDELETE FROM `gameobject` WHERE `id` = " + id.ToString() + "; \nDELETE FROM `gameobject` WHERE `id` = " + idstairs.ToString() + "; \nINSERT INTO `gameobject` (`guid`, `id`, `map`, `spawnMask`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation0`, `rotation1`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`) VALUES";

                for (int z = 0; z < 10; z++)
                {
                    for (int y = 0; y < side; y++)
                    {
                        for (int x = 0; x < side; x++)
                        {
                            if (mapa[x, y, z] == 1)
                            {
                                if (one == false)
                                {
                                    buffer += "\n(NULL, " + id.ToString() + ", 0, 1," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.408 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                    one = true;
                                }
                                else
                                    buffer += ",\n(NULL, " + id.ToString() + ", 0, 1," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.408 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            }
                            if (mapa[x, y, z] == 2)
                            {
                                if (one == false)
                                {
                                    buffer += "\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(788.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.600 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                    one = true;
                                }
                                else
                                {
                                    buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(788.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.600 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                }
                                buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1," + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(786.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.000 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1," + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(787.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(130.000 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1," + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(786.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(134.800 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";

                                buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.200 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(790.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(131.800 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7402.50 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(791.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(132.400 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";

                                buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(787.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(134.800 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(788.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(134.200 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(133.600 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(790.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(133.000 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                                buffer += ",\n(NULL, " + idstairs.ToString() + ", 0, 1, " + replace(Convert.ToString((-7404.20 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(791.80 + ((1.70 * 4) * y))) + ", " + replace(Convert.ToString(132.400 + ((1.36 * 4) * (z - 1)))) + ", 0, 0, 0, 0, 0, 25, 0, 1)";
                            }
                        }
                    }
                }

            }
            else if (radioButton2.Checked == true)
            {
                buffer = "INSERT INTO `gameobject_names` (`entry`, `Type`, `DisplayID`, `Name`, `spellfocus`, `sound1`, `sound2`, `sound3`, `sound4`, `sound5`, `sound6`, `sound7`, `sound8`, `sound9`, `unknown1`, `unknown2`, `unknown3`, `unknown4`, `unknown5`, `unknown6`, `unknown7`, `unknown8`, `unknown9`, `unknown10`, `unknown11`, `unknown12`, `unknown13`, `unknown14`) VALUES (500010, 5, 5271, 'Bludiste bedna', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);";
                buffer += "\nDELETE FROM `gameobject_spawns` WHERE `id` = " + id.ToString() + "; INSERT INTO `gameobject_spawns` (`id`, `Entry`, `map`, `position_x`, `position_y`, `position_z`, `Facing`, `orientation1`, `orientation2`, `orientation3`, `orientation4`, `State`, `Flags`, `Faction`, `Scale`, `stateNpcLink`) VALUES";
                bool one = false;

                for (int z = 0; z < 10; z++)
                {
                    for (int y = 0; y < side; y++)
                    {
                        for (int x = 0; x < side; x++)
                        {
                            if (mapa[x, y, z] == 1)
                            {
                                if (one == false)
                                {
                                    buffer += "\n('', " + id.ToString() + ", 0," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", 131.408, 0, 0, 0, 0, 0, 1, 0, 0, 4, 0)";
                                    one = true;
                                }
                                else
                                {
                                    buffer += ",\n('', " + id.ToString() + ", 0," + replace(Convert.ToString((-7401.79 - ((1.70 * 4) * x)))) + ", " + replace(Convert.ToString(789.01 + ((1.70 * 4) * y))) + ", 131.408, 0, 0, 0, 0, 0, 1, 0, 0, 4, 0)";
                                }
                            }
                        }
                    }
                }
            }
            try
            {
                saveFileDialog2.ShowDialog();
                StreamWriter writer = new StreamWriter(saveFileDialog2.OpenFile());
                writer.Write(buffer);
                writer.Close();
            }
            catch
            {
            }
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start("http://wow.zdechov.net/maze/");
        }

    }
}