using System.Collections.Generic; using System.Drawing; namespace UseCases { public class UseCase : IDrawable { /// /// Generate empty useCase /// public UseCase() { Result = ""; Exceptions = ""; Discription = ""; Assumption = ""; Actors = new List(); Brief = ""; Name = ""; Position = new Point(); } /// /// Create new instance of UseCase with specific data /// /// The name of the UseCase /// Brief summary of UseCase /// Which actors apply to usecase /// What is assumed with the usecase /// What happens /// What may be different /// What is the result /// Postion of UseCase on screen public UseCase(string name, string brief, List actors, string assumption, string discription, string exceptions, string result, Point position) { Result = result; Exceptions = exceptions; Discription = discription; Assumption = assumption; Actors = actors; Brief = brief; Name = name; Position = position; } public void Draw(Graphics g, Font font, Pen pen) { //calculate size var size = g.MeasureString(Name, font); //draw ellipse g.DrawEllipse(pen, new RectangleF(Utils.TranslatePointF(Position, size.Width / -2f - 5f, size.Height / -2f - 5f), Utils.TranslateSizeF(size, 10f, 10f))); //draw text g.DrawString(Name, font, Brushes.Black, Utils.TranslatePointF(Position, size.Width / -2f, size.Height / -2f)); var casePosLine = Utils.TranslatePointF(Position, size.Width / -2 - 5f, 0f); foreach (var act in Actors) { //draw line between usecase and actor, if actor doesn't exist use a fake actor at 0,0 g.DrawLine(pen, casePosLine, act?.Position ?? new Point(0, 0)); } } public string Name { get; set; } public string Brief { get; set; } public List Actors { get; set; } public string Assumption { get; set; } public string Discription { get; set; } public string Exceptions { get; set; } public string Result { get; set; } public Point Position { get; set; } } }