Exemplo n.º 1
0
        public selectsys_returnObj selectSystemPromptdlg(Galaxy galaxy)
        {
            SystemObj selectedSystem = null;
            Dictionary<string, SystemObj> systemdict = new Dictionary<string, SystemObj>(galaxy.systems_dictionary());
            galaxy.listupdate_sectors(1);
            List<SystemObj> syslist = new List<SystemObj>(galaxy.systems_list());
            //selectedSystem = syslist[0];
            InitializeComponent();

            dataGridView_systems.DataSource = syslist;

            dataGridView_systems.RowHeadersVisible = false;
            dataGridView_systems.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

            dataGridView_systems.Columns["name"].HeaderText = "Name";
            dataGridView_systems.Columns["name"].DisplayIndex = 0;
            dataGridView_systems.Columns["location"].HeaderText = "Coordinates";
            dataGridView_systems.Columns["location"].DisplayIndex = 1;
            dataGridView_systems.Columns["sector"].HeaderText = "Sector";
            dataGridView_systems.Columns["notes"].HeaderText = "Notes";
            dataGridView_systems.Columns["maploc"].Visible = false;
            dataGridView_systems.Refresh();
            this.ShowDialog();

            //button_ok.Click += (sender, e) => { this.Close(); };
            //string key = dataGridView_systems.SelectedRows[0].Cells[1].Value.ToString();
            int keycolumnindex = dataGridView_systems.Columns["location"].Index;

            int keyrowindex = dataGridView_systems.Rows.IndexOf(dataGridView_systems.SelectedRows[0]);
            DataGridViewCell cell = dataGridView_systems[keycolumnindex, keyrowindex];
            string key = cell.Value.ToString();
            selectedSystem = systemdict[key];
            selectsys_returnObj returnobj = new selectsys_returnObj(selectedSystem, (int)numericUpDown_depth.Value, checkBox_resetloc.Checked);
            return returnobj;
        }