public StagedGraphic StageGraphic(string filePath, string id) { var definition = File.ReadAllLines(filePath).Where(l => l.Length > 0) .Where(l => l.ToLower().StartsWith("graphic") && l.Contains($"id={id}")) .FirstOrDefault(); if (definition.Length == 0) { return(new StagedGraphic()); } var work = definition.Split(';'); GraphicType type = GraphicType.None; for (int i = 0; i < work.Length; i++) { var pair = work[i].Split('='); if (pair[0].Trim().ToLower() == "graphic") { type = ParseType(pair[1].Trim().ToLower()); break; } } if (type == GraphicType.None) { return(new StagedGraphic()); } var stagedGraphic = new StagedGraphic(id, filePath, type); return(stagedGraphic); }
public IGraphic2D LoadGraphic(StagedGraphic stagedGraphic) { IGraphic2D graphic = null; switch (stagedGraphic.Type) { case (GraphicType.Image): graphic = ParseImage(stagedGraphic.FilePath, stagedGraphic.Id); break; case (GraphicType.Effect): graphic = ParseEffect(stagedGraphic.FilePath, stagedGraphic.Id); break; case (GraphicType.Sprite): graphic = ParseSprite(stagedGraphic.FilePath, stagedGraphic.Id); break; case (GraphicType.Text): graphic = ParseText(stagedGraphic.FilePath, stagedGraphic.Id); break; } return(graphic); }