Example #1
0
        private void 自定义飞行点_Load(object sender, EventArgs e)
        {
            button3.Enabled = false;
            dataGridView1.CellValueChanged       += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged);
            dataGridView1.CellClick              += new DataGridViewCellEventHandler(dataGridView1_CellClick);
            dataGridView1.ReadOnly                = true;
            dataGridView1.AllowUserToAddRows      = false;
            dataGridView1.ContextMenuStrip        = contextMenuStrip1;
            dataGridView1.Rows.CollectionChanged += new CollectionChangeEventHandler(Rows_CollectionChanged);
            dataGridView1.DataError              += new DataGridViewDataErrorEventHandler(dataGridView1_DataError);
            dataGridView1.AutoSizeColumnsMode     = DataGridViewAutoSizeColumnsMode.Fill;
            StreamReader infile     = new StreamReader("Set.ini", Encoding.GetEncoding("gb2312"));
            string       tempstring = infile.ReadLine();

            tempstring = infile.ReadLine();
            tempstring = infile.ReadLine();
            tempstring = infile.ReadLine();
            int nestnum = Convert.ToInt32(tempstring.Substring(tempstring.IndexOf("=") + 1));

            movenestnum = nestnum;
            movenest    = new Nest[nestnum];
            nestitems   = new ToolStripMenuItem[nestnum];

            for (int j = 0; j < nestnum; j++)
            {
                tempstring = infile.ReadLine();
                string nestname = tempstring.Substring(tempstring.IndexOf("=") + 1);
                tempstring = infile.ReadLine();
                int nestmovenum = Convert.ToInt32(tempstring.Substring(tempstring.IndexOf("=") + 1));
                movenest[j] = new Nest(nestname, nestmovenum);
                movenest[j].ReadNest("Locate.txt");
                comboBox1.Items.Add(nestname);
                nestitems[j] = new ToolStripMenuItem(nestname);

                除巢穴ToolStripMenuItem.DropDownItems.Add(nestitems[j]);
                nestitems[j].Click += new EventHandler(自定义飞行点_Click);
            }
            infile.Close();
            dataGridView1.Columns[0].HeaderText = "传送点名称";
            dataGridView1.Columns[1].HeaderText = "X坐标";
            dataGridView1.Columns[0].ValueType  = typeof(string);
            dataGridView1.Columns[1].ValueType  = typeof(short);
            dataGridView1.Columns[2].ValueType  = typeof(short);
            dataGridView1.Columns[2].HeaderText = "Y坐标";
            for (int i = 0; i < movenest[0].movepointnum; i++)
            {
                dataGridView1.Rows.Add();
                dataGridView1.Rows[i].Cells[0].Value = movenest[0].movepointname[i];
                dataGridView1.Rows[i].Cells[1].Value = movenest[0].movex[i];
                dataGridView1.Rows[i].Cells[2].Value = movenest[0].movey[i];
            }
            selectindex             = 0;
            comboBox1.SelectedIndex = 0;
        }
Example #2
0
        public Nest(Nest nst)
        {
            int n = nst.movepointnum;

            nestname      = nst.nestname;
            movepointname = new string[n];
            movex         = new short[n];
            movey         = new short[n];
            for (int i = 0; i < n; i++)
            {
                movex[i]         = nst.movex[i];
                movey[i]         = nst.movey[i];
                movepointname[i] = nst.movepointname[i];
            }
            movepointnum = n;
        }
Example #3
0
        void 自定义飞行点_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < movenestnum; i++)
            {
                if (sender.ToString() == movenest[i].nestname)
                {
                    if (MessageBox.Show("是否删除副本" + movenest[i].nestname, "注意", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;
                    }
                    int    k       = 0;
                    Nest[] tmpnest = new Nest[movenestnum];
                    for (int l = 0; l < movenestnum; l++)
                    {
                        tmpnest[l] = new Nest(movenest[l]);
                    }
                    movenest = null;
                    movenestnum--;
                    movenest = new Nest[movenestnum];
                    k        = 0;
                    for (int l = 0; l < movenestnum; l++)
                    {
                        if (k == i)
                        {
                            k++;
                        }
                        movenest[l] = new Nest(tmpnest[k]);
                        k++;
                    }
                    break;
                }
            }
            comboBox1.Items.Clear();
            除巢穴ToolStripMenuItem.DropDownItems.Clear();
            nestitems = null;
            nestitems = new ToolStripMenuItem[movenestnum];
            for (int i = 0; i < movenestnum; i++)
            {
                comboBox1.Items.Add(movenest[i].nestname);
                nestitems[i] = new ToolStripMenuItem(movenest[i].nestname);

                除巢穴ToolStripMenuItem.DropDownItems.Add(nestitems[i]);
                nestitems[i].Click += new EventHandler(自定义飞行点_Click);
            }
            comboBox1.SelectedIndex = movenestnum - 1;
            dataGridView1.Rows.Clear();
            save            = 0;
            isinit          = 1;
            button3.Enabled = false;
            string[] set = new string[3];

            StreamReader sr = new StreamReader("Set.ini");

            for (int i = 0; i < 3; i++)
            {
                set[i] = sr.ReadLine();
            }
            sr.Close();
            FileStream   thefile = new FileStream("Set.ini", FileMode.Create);
            StreamWriter sw      = new StreamWriter(thefile, Encoding.GetEncoding("gb2312"));

            for (int i = 0; i < 3; i++)
            {
                sw.WriteLine(set[i]);
            }
            sw.WriteLine("副本个数=" + movenestnum);
            for (int i = 0; i < movenestnum; i++)
            {
                sw.WriteLine("副本" + (i + 1) + "名称=" + movenest[i].nestname);
                sw.WriteLine("副本" + (i + 1) + "传送点个数=" + movenest[i].movepointnum);
            }
            sw.Close();
            thefile = null;
            thefile = new FileStream("Locate.txt", FileMode.Create);
            sw      = new StreamWriter(thefile, Encoding.GetEncoding("gb2312"));
            for (int i = 0; i < movenestnum; i++)
            {
                sw.WriteLine("#" + movenest[i].nestname);
                for (int j = 0; j < movenest[i].movepointnum; j++)
                {
                    sw.WriteLine(movenest[i].movepointname[j]);
                    sw.WriteLine("movx =" + movenest[i].movex[j]);
                    sw.WriteLine("movy =" + movenest[i].movey[j]);
                }
            }
            sw.Close();
        }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            Input inputbox = new Input();

            inputbox.ShowDialog();
            string name = "";

            if (inputbox.DialogResult == DialogResult.OK)
            {
                name = inputbox.name;
                if (name == "")
                {
                    MessageBox.Show("未创建副本(名字为空)");
                    return;
                }
                for (int i = 0; i < movenestnum; i++)
                {
                    if (name == comboBox1.Items[i].ToString())
                    {
                        MessageBox.Show("该副本已存在");
                        comboBox1.SelectedIndex = i;
                        selectindex             = i;
                        dataGridView1.Rows.Clear();
                        for (int j = 0; j < movenest[selectindex].movepointnum; j++)
                        {
                            dataGridView1.Rows.Add();
                            dataGridView1.Rows[j].Cells[0].Value = movenest[selectindex].movepointname[j];
                            dataGridView1.Rows[j].Cells[1].Value = movenest[selectindex].movex[j];
                            dataGridView1.Rows[j].Cells[2].Value = movenest[selectindex].movey[j];
                        }
                        button3.Enabled        = false;
                        dataGridView1.ReadOnly = true;
                        return;
                    }
                }
                Nest[] tmpnest = new Nest[movenestnum];
                for (int i = 0; i < movenestnum; i++)
                {
                    tmpnest[i] = new Nest(movenest[i]);
                }
                movenest = null;
                movenestnum++;
                movenest = new Nest[movenestnum];

                for (int j = 0; j < movenestnum - 1; j++)
                {
                    movenest [j] = new Nest(tmpnest[j]);
                }
                movenest[movenestnum - 1] = new Nest(name, 0);
                comboBox1.Items.Clear();

                除巢穴ToolStripMenuItem.DropDownItems.Clear();
                nestitems = null;
                nestitems = new ToolStripMenuItem[movenestnum];


                for (int i = 0; i < movenestnum; i++)
                {
                    comboBox1.Items.Add(movenest[i].nestname);
                    nestitems[i] = new ToolStripMenuItem(movenest[i].nestname);

                    除巢穴ToolStripMenuItem.DropDownItems.Add(nestitems[i]);
                    nestitems[i].Click += new EventHandler(自定义飞行点_Click);
                }
                comboBox1.SelectedIndex = movenestnum - 1;
                dataGridView1.Rows.Clear();
                save            = 0;
                isinit          = 1;
                button3.Enabled = false;
            }
        }