Initial Commit
This commit is contained in:
75
UseCases/UseCase.cs
Normal file
75
UseCases/UseCase.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace UseCases
|
||||
{
|
||||
public class UseCase : IDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// Generate empty useCase
|
||||
/// </summary>
|
||||
public UseCase()
|
||||
{
|
||||
Result = "";
|
||||
Exceptions = "";
|
||||
Discription = "";
|
||||
Assumption = "";
|
||||
Actors = new List<Actor>();
|
||||
Brief = "";
|
||||
Name = "";
|
||||
Position = new Point();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create new instance of UseCase with specific data
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the UseCase</param>
|
||||
/// <param name="brief">Brief summary of UseCase</param>
|
||||
/// <param name="actors">Which actors apply to usecase</param>
|
||||
/// <param name="assumption">What is assumed with the usecase</param>
|
||||
/// <param name="discription">What happens</param>
|
||||
/// <param name="exceptions">What may be different</param>
|
||||
/// <param name="result">What is the result</param>
|
||||
/// <param name="position">Postion of UseCase on screen</param>
|
||||
public UseCase(string name, string brief, List<Actor> 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<Actor> 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; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user