Exemplo n.º 1
0
        private void EditModelAt(int idx)
        {
            if (idx > Model.Count || idx < 0)
            {
                return;
            }

            Location model = Model[idx].Clone() as Location;

            using (LocationEditForm form = new LocationEditForm {
                Model = model
            })
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    Model[idx] = form.Model;
                    Model.Sort(new LocationComparer());
                    UpdateView();
                }
            }
        }
Exemplo n.º 2
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (Model == null)
            {
                return;
            }
            Location newLoc = new Location {
                Id = GeneralHelper.GetNewId(Model)
            };

            using (LocationEditForm form = new LocationEditForm {
                Model = newLoc
            })
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    Model.Add(form.Model);
                    Model.Sort(new LocationComparer());
                    UpdateView();
                }
            }
        }