public void ColumnChangedType(ColumnModel model, string typeS) { int index = columns.IndexOf(model); if (index > -1) { ColumnModel newmodel; if (Enum.TryParse <ColumnController.ColumnType>(typeS, out ColumnController.ColumnType type)) { switch (type) { case ColumnController.ColumnType.TEXT: newmodel = new ColumnModelText(); break; case ColumnController.ColumnType.NUMBER: newmodel = new ColumnModelNumber(); break; case ColumnController.ColumnType.CHOICE: newmodel = new ColumnModelChoice(); break; case ColumnController.ColumnType.IMAGE: newmodel = new ColumnModelImage(); break; case ColumnController.ColumnType.DATE: newmodel = new ColumnModelDate(); break; default: newmodel = new ColumnModelText(); break; } } else { newmodel = new ColumnModelText(); } newmodel.Type = model.Type; newmodel.Name = model.Name; newmodel.ColumnId = model.ColumnId; newmodel.Data = model.Data; newmodel.Primary = model.Primary; newmodel.SetTypeChangeListener(this); newmodel.SetReference(database.GetReferenceFromUrl(columnsRef.ToString()).Child(newmodel.ColumnId).Ref.ToString()); columns[index] = newmodel; columnsEditView.RemoveViewAt(index); columnsEditView.AddView(newmodel.GetEditView(this).GetView(), index); } }
public CellModelChoice(ColumnModelChoice parent) : base(parent) { controller = new CellControllerChoice(this); }