Esempio n. 1
0
        private void btnAddResource_Click(object sender, EventArgs e)
        {
            NewResourceForm addForm = new NewResourceForm();

            addForm.ShowDialog();

            if (addForm.DialogResult == DialogResult.OK)
            {
                Resource res  = addForm.GetResource();
                string   date = res.Discovered.ToString(MainForm.dateFormat);

                if (res.ApproxDiscovered != null)
                {
                    date = res.ApproxDiscovered.ToString();
                }

                MainForm.resources.Add(res.ID, res);
                MainForm.addedResources.Add(res.ID);
                dgwResources.Rows.Add(new object[] { res.ID, res.Name, date,
                                                     res.Cost.ToString("C"), res.Important, res.Renewable,
                                                     Resource.FrequencyToString(res.Frequency), Resource.UnitToString(res.Unit) });
                dgwResources.Rows[dgwResources.Rows.Count - 1].Tag = res;
                dgwResources.CurrentCell = dgwResources.Rows[dgwResources.Rows.Count - 1].Cells[0];
                dgwResources_SelectionChanged(dgwResources, EventArgs.Empty);
            }
        }
Esempio n. 2
0
        private void urediToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewResourceForm erf = new NewResourceForm(MainForm.resources[((Resource)Tag).ID]);

            erf.ShowDialog();

            if (erf.DialogResult == DialogResult.OK)
            {
                Resource res = erf.GetResource();
                MainForm.resources[res.ID] = res;
                UpdateControl();
            }
        }
Esempio n. 3
0
        private void btnAddResource_Click(object sender, EventArgs e)
        {
            NewResourceForm addForm = new NewResourceForm();

            addForm.ShowDialog();

            if (addForm.DialogResult == DialogResult.OK)
            {
                Resource res = addForm.GetResource();
                resources.Add(res);
                dgwResources.Rows.Add(new object[] { res.Id, res.Name, res.Discovered.ToString(dateFormat), res.Cost.ToString("C"), res.Important, res.Renewable });
                dgwResources.Rows[dgwResources.Rows.Count - 1].Tag = res;
                dgwResources.CurrentCell = dgwResources.Rows[0].Cells[0];
                dgwResources_SelectionChanged(dgwResources, EventArgs.Empty);
            }
        }
Esempio n. 4
0
        private void ResourceIcon_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (MainForm.tutorialMode)
            {
                return;
            }

            NewResourceForm erf = new NewResourceForm(MainForm.resources[((Resource)Tag).ID]);

            erf.ShowDialog();

            if (erf.DialogResult == DialogResult.OK)
            {
                Resource res = erf.GetResource();
                MainForm.resources[res.ID] = res;
                UpdateControl();
            }
        }
Esempio n. 5
0
        private void btnEditResource_Click(object sender, EventArgs e)
        {
            if (dgwResources.SelectedRows.Count > 0)
            {
                NewResourceForm erf = new NewResourceForm((Resource)dgwResources.SelectedRows[0].Tag);
                erf.ShowDialog();

                if (erf.DialogResult == DialogResult.OK)
                {
                    foreach (DataGridViewRow row in dgwResources.SelectedRows)
                    {
                        if (row.Selected)
                        {
                            Resource res  = erf.GetResource();
                            String   date = res.Discovered.ToString(MainForm.dateFormat);

                            if (res.ApproxDiscovered != null)
                            {
                                date = res.ApproxDiscovered.ToString();
                            }

                            int index = dgwResources.Rows.IndexOf(row);
                            dgwResources.Rows.RemoveAt(index);
                            dgwResources.Rows.Insert(index, new object[] { res.ID, res.Name, date,
                                                                           res.Cost.ToString("C"), res.Important, res.Renewable,
                                                                           Resource.FrequencyToString(res.Frequency), Resource.UnitToString(res.Unit) });
                            dgwResources.Rows[index].Tag = res;
                            dgwResources.CurrentCell     = dgwResources.Rows[index].Cells[0];
                            MainForm.resources.Remove(res.ID);
                            MainForm.resources.Add(res.ID, res);
                            break;
                        }
                    }
                    dgwResources_SelectionChanged(dgwResources, EventArgs.Empty);
                }
            }
        }