public static HistoricalCourseEditorState UpdateProp(this HistoricalCourseEditorState state, EditorProp prop) { if (state.Props.ContainsKey(prop.Id)) { return(state.Update(state.SelectedProp, state.Props.SetItem(prop.Id, prop), state.PropOrder)); } else { return(state); } }
public static HistoricalCourseEditorState AddProp(this HistoricalCourseEditorState state, ImmutableTransform transform) { var propId = PropId.CreateRandomId(); var newProp = new EditorProp { Id = propId, PropType = state.SelectedPropType, Transform = transform }; // Immediately select the newly created prop var selectedProp = Maybe.Just(propId); return(state.Update(selectedProp, state.Props.Add(newProp.Id, newProp), state.PropOrder.Add(propId))); }
public static HistoricalCourseEditorState UpdatePropOrder(this HistoricalCourseEditorState state, IImmutableList <PropId> newPropOrder) { return(state.Update(state.SelectedProp, state.Props, newPropOrder)); }
public static HistoricalCourseEditorState SelectProp(this HistoricalCourseEditorState state, Maybe <PropId> selectedPropId) { return(state.Update(selectedPropId, state.Props, state.PropOrder)); }
public static HistoricalCourseEditorState DeleteProp(this HistoricalCourseEditorState state, PropId id) { var selectedProp = state.SelectedProp.Equals(Maybe.Just(id)) ? Maybe.Nothing <PropId>() : state.SelectedProp; return(state.Update(selectedProp, state.Props.Remove(id), state.PropOrder.Remove(id))); }