Ejemplo n.º 1
0
        private async void createRegionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            byte id = 0x00;

            foreach (Region r in regions)
            {
                if (r.ID > id)
                {
                    id = r.ID;
                }
            }

            id++;

            Region reg = new Region(id);

            using (RegionEditor re = new RegionEditor(reg, galaxy))
            {
                if (re.ShowDialog() == DialogResult.OK)
                {
                    await galaxy.UpdateRegion(re.mRegion);

                    regions.Add(reg);
                }
            }
        }
Ejemplo n.º 2
0
        public RegionEditor(Region region, Galaxy galaxy)
        {
            InitializeComponent();

            mRegion     = region;
            this.galaxy = galaxy;
        }
Ejemplo n.º 3
0
        private void pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            selectedUnit   = null;
            selectedRegion = null;

            if (e.Button == MouseButtons.Right)
            {
                updateToolStripMenuItem.Visible       = false;
                deleteToolStripMenuItem.Visible       = false;
                copyToolStripMenuItem.Visible         = false;
                updateRegionToolStripMenuItem.Visible = false;
                deleteRegionToolStripMenuItem.Visible = false;

                Point p = new Point((int)((e.X - cx) / zoom), (int)(-(e.Y - cy) / zoom));

                foreach (mUnit u in mUnits)
                {
                    if (!(u is mPlayerUnit) && Math.Pow(p.X - u.X, 2) + Math.Pow(p.Y - u.Y, 2) <= Math.Pow(u.R, 2))
                    {
                        selectedUnit = u;

                        updateToolStripMenuItem.Visible = true;
                        deleteToolStripMenuItem.Visible = true;
                        copyToolStripMenuItem.Visible   = true;

                        break;
                    }
                }

                foreach (Region r in regions)
                {
                    if (p.X >= r.Left && p.X <= r.Right && p.Y >= r.Bottom && p.Y <= r.Top)
                    {
                        selectedRegion = r;

                        updateRegionToolStripMenuItem.Visible = true;
                        deleteRegionToolStripMenuItem.Visible = true;

                        break;
                    }
                }

                contextMenuStrip.Show(MousePosition);
            }
        }