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 SelectPropType(this HistoricalCourseEditorState state, PropType propType) { var newProps = ImmutableDictionary <PropId, EditorProp> .Empty; var newPropOrder = ImmutableList <PropId> .Empty; var newSelectedProp = Maybe.Nothing <PropId>(); for (int i = 0; i < state.PropOrder.Count; i++) { var oldProp = state.Props[state.PropOrder[i]]; var newProp = new EditorProp { Id = PropId.CreateRandomId(), PropType = propType, Transform = oldProp.Transform }; newProps = newProps.Add(newProp.Id, newProp); newPropOrder = newPropOrder.Add(newProp.Id); if (state.SelectedProp.Equals(Maybe.Just(oldProp.Id))) { newSelectedProp = Maybe.Just(newProp.Id); } } return(new HistoricalCourseEditorState(state.Id, propType, newSelectedProp, newProps, newPropOrder, state.IsUndoPossibe, state.IsRedoPossibe)); }
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))); }
private static HistoricalCourseEditorState Update(this HistoricalCourseEditorState state, Maybe <PropId> selectedPropId, IImmutableDictionary <PropId, EditorProp> props, IImmutableList <PropId> propOrder) { return(new HistoricalCourseEditorState(state.Id, state.SelectedPropType, selectedPropId, props, propOrder, state.IsUndoPossibe, state.IsRedoPossibe)); }
public static HistoricalCourseEditorState UpdateUndoRedoAvailability(this HistoricalCourseEditorState state, bool isUndoPossible, bool isRedoPossible) { return(new HistoricalCourseEditorState(state.Id, state.SelectedPropType, state.SelectedProp, state.Props, state.PropOrder, isUndoPossible, isRedoPossible)); }
public CourseEditorState(HistoricalCourseEditorState historicalState, TransientCourseEditorState transientState) { _transientState = transientState; _historicalState = historicalState; }