using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SketchAssistantWPF { public class SketchAction { //Types of possible actions public enum ActionType { Draw, Delete, Start } //Type of this action private ActionType thisAction; //ID of the Line affected private HashSet lineIDs; /// /// Constructor for a new action with multiple lines affected. /// /// The type of action, if it is ActionType.Start the affectedIDs will be ignored. /// The IDs of the lines affected. public SketchAction(ActionType theAction, HashSet affectedIDs) { thisAction = theAction; if (theAction.Equals(ActionType.Start)) { lineIDs = new HashSet(); } else { lineIDs = new HashSet(affectedIDs); } } /// /// Constructor for a new action with one line affected. /// /// The type of action, if it is ActionType.Start the affectedID will be ignored. /// The ID of the affected line. public SketchAction(ActionType theAction, int affectedID) { thisAction = theAction; if (theAction.Equals(ActionType.Start)) { lineIDs = new HashSet(); } else { lineIDs = new HashSet(); lineIDs.Add(affectedID); } } /// /// Fetches the type of this action. /// /// The type of this action. public ActionType GetActionType() { return thisAction; } /// /// Fetches the IDs of the lines affected by this action. /// /// The IDs of the lines affected by this action. An empty set if there is no line affected. public HashSet GetLineIDs() { return lineIDs; } /// /// Get the information about this action. /// /// A String describing what happend at this action. public String GetActionInformation() { String returnString = ""; switch (thisAction) { case ActionType.Start: returnString = "A new canvas was created."; break; case ActionType.Draw: returnString = "Line number " + lineIDs.First().ToString() + " was drawn."; break; case ActionType.Delete: if (lineIDs.Count == 1) { returnString = "Line number " + lineIDs.First().ToString() + " was deleted."; } else { returnString = "Several Lines were deleted."; } break; } return returnString; } } }