public void Events_EditItem(int index, object element, CollectionBoxViewModel.EditElementOp op) { string elementName = "Events[" + index + "]"; DataEditForm frmData = new DataEditForm(); frmData.Title = DataEditor.GetWindowTitle(ZoneManager.Instance.CurrentMap.AssetName, elementName, element, typeof(SingleCharEvent), new object[0]); DataEditor.LoadClassControls(frmData.ControlPanel, ZoneManager.Instance.CurrentMap.AssetName, elementName, typeof(SingleCharEvent), new object[0], element, true); frmData.SelectedOKEvent += () => { element = DataEditor.SaveClassControls(frmData.ControlPanel, elementName, typeof(SingleCharEvent), new object[0], true); op(index, element); frmData.Close(); }; frmData.SelectedCancelEvent += () => { frmData.Close(); }; DevForm form = (DevForm)DiagManager.Instance.DevEditor; form.MapEditForm.RegisterChild(frmData); frmData.Show(); }
public void TileStates_EditItem(int index, object element, CollectionBoxViewModel.EditElementOp op) { string elementName = "TileStates[" + index + "]"; DataEditForm frmData = new DataEditForm(); frmData.Title = DataEditor.GetWindowTitle("Tile", elementName, element, typeof(TileState), new object[0]); //TODO: make this a member and reference it that way DataEditor.LoadClassControls(frmData.ControlPanel, "Tile", elementName, typeof(TileState), new object[0], element, true); DevForm form = (DevForm)DiagManager.Instance.DevEditor; frmData.SelectedOKEvent += async() => { element = DataEditor.SaveClassControls(frmData.ControlPanel, elementName, typeof(TileState), new object[0], true); bool itemExists = false; List <object> states = (List <object>)TileStates.GetList(typeof(List <object>)); for (int ii = 0; ii < states.Count; ii++) { if (ii != index) { if (states[ii].GetType() == element.GetType()) { itemExists = true; } } } if (itemExists) { await MessageBox.Show(form.MapEditForm, "Cannot add duplicate states.", "Entry already exists.", MessageBox.MessageBoxButtons.Ok); } else { op(index, element); frmData.Close(); } }; frmData.SelectedCancelEvent += () => { frmData.Close(); }; form.MapEditForm.RegisterChild(frmData); frmData.Show(); }
//TODO: move these events into ListEditor; they were generic enough to warrant copy+pasting public void Statuses_EditItem(int index, object element, CollectionBoxViewModel.EditElementOp op) { string elementName = "Statuses[" + index + "]"; DataEditForm frmData = new DataEditForm(); frmData.Title = DataEditor.GetWindowTitle(ZoneManager.Instance.CurrentMap.AssetName, elementName, element, typeof(MapStatus), new object[0]); DataEditor.LoadClassControls(frmData.ControlPanel, ZoneManager.Instance.CurrentMap.AssetName, elementName, typeof(MapStatus), new object[0], element, true); DevForm form = (DevForm)DiagManager.Instance.DevEditor; frmData.SelectedOKEvent += async() => { element = DataEditor.SaveClassControls(frmData.ControlPanel, elementName, typeof(MapStatus), new object[0], true); bool itemExists = false; List <MapStatus> states = (List <MapStatus>)Statuses.GetList(typeof(List <MapStatus>)); for (int ii = 0; ii < states.Count; ii++) { if (ii != index) { if (states[ii].ID == ((MapStatus)element).ID) { itemExists = true; } } } if (itemExists) { await MessageBox.Show(form.MapEditForm, "Cannot add duplicate IDs.", "Entry already exists.", MessageBox.MessageBoxButtons.Ok); } else { op(index, element); frmData.Close(); } }; frmData.SelectedCancelEvent += () => { frmData.Close(); }; form.MapEditForm.RegisterChild(frmData); frmData.Show(); }