Initial Commit

This commit is contained in:
Rick Rongen
2018-02-21 09:40:31 +01:00
commit f203f3c86f
25 changed files with 2539 additions and 0 deletions

324
.gitignore vendored Normal file
View File

@@ -0,0 +1,324 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# TypeScript v1 declaration files
typings/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog

22
UseCases.sln Normal file
View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UseCases", "UseCases\UseCases.csproj", "{7AD26D8A-D2A9-4438-AF3B-5B8DE49F1DD6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7AD26D8A-D2A9-4438-AF3B-5B8DE49F1DD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AD26D8A-D2A9-4438-AF3B-5B8DE49F1DD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AD26D8A-D2A9-4438-AF3B-5B8DE49F1DD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AD26D8A-D2A9-4438-AF3B-5B8DE49F1DD6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

44
UseCases/Actor.cs Normal file
View File

@@ -0,0 +1,44 @@
using System.Drawing;
namespace UseCases
{
public class Actor : IDrawable
{
/// <summary>
/// Create new Actor
/// </summary>
/// <param name="name">Name of Actor</param>
/// <param name="position">Position of actor on screen</param>
public Actor(string name, Point position)
{
Name = name;
Position = position;
}
/// <inheritdoc />
public void Draw(Graphics g, Font font, Pen pen)
{
//calculate size
var size = g.MeasureString(Name, font);
//draw poppet
g.DrawEllipse(pen,
new RectangleF(Utils.TranslatePointF(Position, -10f, -10f - 20f), new SizeF(20f, 20f)));
g.DrawLine(pen, Utils.TranslatePointF(Position, 0f, -10f),
Utils.TranslatePointF(Position, 0f, 10f));
g.DrawLine(pen, Utils.TranslatePointF(Position, -5f, -5f),
Utils.TranslatePointF(Position, 5f, -5f));
g.DrawLine(pen, Utils.TranslatePointF(Position, 0f, 10f),
Utils.TranslatePointF(Position, -5f, 20f));
g.DrawLine(pen, Utils.TranslatePointF(Position, 0f, 10f),
Utils.TranslatePointF(Position, 5f, 20f));
//draw text
g.DrawString(Name, font, Brushes.Black,
Utils.TranslatePointF(Position, size.Width / -2f, size.Height / -2f + 35f));
}
/// <inheritdoc />
public string Name { get; set; }
/// <inheritdoc />
public Point Position { get; set; }
}
}

6
UseCases/App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

78
UseCases/Diagram.cs Normal file
View File

@@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using Newtonsoft.Json;
namespace UseCases
{
public class Diagram
{
/// <summary>
/// Initialize a new diagram with the default values.
/// </summary>
public Diagram()
{
Version = new Version(1,0,0,0);
Actors = new List<Actor>();
UseCases = new List<UseCase>();
Size = new Size(430, 372);
Maximized = false;
}
/// <inheritdoc />
/// <summary>
/// Initialize a new diagram with the default values and a specific size.
/// </summary>
/// <param name="size">The size the diagram should be.</param>
public Diagram(Size size) : this()
{
Size = size;
}
/// <summary>
/// Initialize a new diagram with these values.
/// </summary>
/// <param name="version">The version of the diagram</param>
/// <param name="actors">The actors in the diagram</param>
/// <param name="useCases">The usecases in the diagram</param>
/// <param name="size">The size of the diagram</param>
/// <param name="maximized">Whether or not the window is maximized</param>
public Diagram(Version version, List<Actor> actors, List<UseCase> useCases, Size size, bool maximized)
{
Version = version;
Actors = actors;
UseCases = useCases;
Size = size;
Maximized = maximized;
}
/// <summary>
/// All the drawable objects (Actors and UseCases) concatenated.
/// </summary>
[JsonIgnore]
public IEnumerable<IDrawable> Drawable => Actors.Cast<IDrawable>().Concat(UseCases);
/// <summary>
/// The version of the diagram
/// </summary>
public Version Version { get; set; }
/// <summary>
/// The actors in the diagram
/// </summary>
public List<Actor> Actors { get; set; }
/// <summary>
/// The usecases in the diagram
/// </summary>
public List<UseCase> UseCases { get; set; }
/// <summary>
/// The size of the diagram
/// </summary>
public Size Size { get; set; }
/// <summary>
/// Wheter or not the diagram is maximized.
/// </summary>
public bool Maximized { get; set; }
}
}

88
UseCases/EditActor.Designer.cs generated Normal file
View File

@@ -0,0 +1,88 @@
namespace UseCases
{
partial class EditActor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.lblName = new System.Windows.Forms.Label();
this.btOk = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(53, 14);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(138, 20);
this.textBox1.TabIndex = 0;
//
// lblName
//
this.lblName.AutoSize = true;
this.lblName.Location = new System.Drawing.Point(12, 17);
this.lblName.Name = "lblName";
this.lblName.Size = new System.Drawing.Size(35, 13);
this.lblName.TabIndex = 1;
this.lblName.Text = "Name";
//
// btOk
//
this.btOk.Location = new System.Drawing.Point(197, 12);
this.btOk.Name = "btOk";
this.btOk.Size = new System.Drawing.Size(75, 23);
this.btOk.TabIndex = 2;
this.btOk.Text = "Ok";
this.btOk.UseVisualStyleBackColor = true;
this.btOk.Click += new System.EventHandler(this.btOk_Click);
//
// EditActor
//
this.AcceptButton = this.btOk;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 45);
this.Controls.Add(this.btOk);
this.Controls.Add(this.lblName);
this.Controls.Add(this.textBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "EditActor";
this.Text = "Edit Actor";
this.Load += new System.EventHandler(this.EditActor_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label lblName;
private System.Windows.Forms.Button btOk;
}
}

43
UseCases/EditActor.cs Normal file
View File

@@ -0,0 +1,43 @@
using System;
using System.Windows.Forms;
namespace UseCases
{
public partial class EditActor : Form
{
public EditActor()
{
InitializeComponent();
}
public EditActor(String name)
{
ActorName = name;
InitializeComponent();
textBox1.Text = name;
}
public String ActorName { get; private set; }
private void EditActor_Load(object sender, EventArgs e)
{
}
private void btOk_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
if (
MessageBox.Show("Are you sure you want to remove this actor?", "Are you sure?",
MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;//if the user doesn't want to remove actor cancel
}
}
ActorName = textBox1.Text;
DialogResult = DialogResult.OK;
Close();
}
}
}

120
UseCases/EditActor.resx Normal file
View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

199
UseCases/Form1.Designer.cs generated Normal file
View File

@@ -0,0 +1,199 @@
namespace UseCases
{
partial class FrmMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.btSave = new System.Windows.Forms.ToolStripMenuItem();
this.btSaveImage = new System.Windows.Forms.ToolStripMenuItem();
this.btOpen = new System.Windows.Forms.ToolStripMenuItem();
this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.btExit = new System.Windows.Forms.ToolStripMenuItem();
this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.btAddActor = new System.Windows.Forms.ToolStripMenuItem();
this.btAddUseCase = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.controlsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.addToolStripMenuItem,
this.helpToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(414, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.btSave,
this.btSaveImage,
this.btOpen,
this.clearToolStripMenuItem,
this.btExit});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "File";
//
// btSave
//
this.btSave.Name = "btSave";
this.btSave.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.btSave.Size = new System.Drawing.Size(220, 22);
this.btSave.Text = "Save";
this.btSave.Click += new System.EventHandler(this.btSave_Click);
//
// btSaveImage
//
this.btSaveImage.Name = "btSaveImage";
this.btSaveImage.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.S)));
this.btSaveImage.Size = new System.Drawing.Size(220, 22);
this.btSaveImage.Text = "Save as Image";
this.btSaveImage.Click += new System.EventHandler(this.btSaveImage_Click);
//
// btOpen
//
this.btOpen.Name = "btOpen";
this.btOpen.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.btOpen.Size = new System.Drawing.Size(220, 22);
this.btOpen.Text = "Open";
this.btOpen.Click += new System.EventHandler(this.btOpen_Click);
//
// clearToolStripMenuItem
//
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
this.clearToolStripMenuItem.Size = new System.Drawing.Size(220, 22);
this.clearToolStripMenuItem.Text = "Clear";
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
//
// btExit
//
this.btExit.Name = "btExit";
this.btExit.Size = new System.Drawing.Size(220, 22);
this.btExit.Text = "Exit";
this.btExit.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// addToolStripMenuItem
//
this.addToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.btAddActor,
this.btAddUseCase});
this.addToolStripMenuItem.Name = "addToolStripMenuItem";
this.addToolStripMenuItem.Size = new System.Drawing.Size(41, 20);
this.addToolStripMenuItem.Text = "Add";
//
// btAddActor
//
this.btAddActor.Name = "btAddActor";
this.btAddActor.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
this.btAddActor.Size = new System.Drawing.Size(163, 22);
this.btAddActor.Text = "Actor";
this.btAddActor.Click += new System.EventHandler(this.btAddActor_Click);
//
// btAddUseCase
//
this.btAddUseCase.Name = "btAddUseCase";
this.btAddUseCase.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
this.btAddUseCase.Size = new System.Drawing.Size(163, 22);
this.btAddUseCase.Text = "Use Case";
this.btAddUseCase.Click += new System.EventHandler(this.btAddUseCase_Click);
//
// helpToolStripMenuItem
//
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.controlsToolStripMenuItem,
this.aboutToolStripMenuItem});
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.helpToolStripMenuItem.Text = "Help";
//
// controlsToolStripMenuItem
//
this.controlsToolStripMenuItem.Name = "controlsToolStripMenuItem";
this.controlsToolStripMenuItem.Size = new System.Drawing.Size(119, 22);
this.controlsToolStripMenuItem.Text = "Controls";
this.controlsToolStripMenuItem.Click += new System.EventHandler(this.controlsToolStripMenuItem_Click);
//
// aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(119, 22);
this.aboutToolStripMenuItem.Text = "About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(414, 333);
this.Controls.Add(this.menuStrip1);
this.DoubleBuffered = true;
this.MainMenuStrip = this.menuStrip1;
this.Name = "FrmMain";
this.Text = "UseCase Designer";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing);
this.Click += new System.EventHandler(this.frmMain_Click);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.frmMain_Paint);
this.DoubleClick += new System.EventHandler(this.frmMain_DoubleClick);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.frmMain_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.frmMain_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.frmMain_MouseUp);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem btSave;
private System.Windows.Forms.ToolStripMenuItem btSaveImage;
private System.Windows.Forms.ToolStripMenuItem btExit;
private System.Windows.Forms.ToolStripMenuItem addToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem btAddActor;
private System.Windows.Forms.ToolStripMenuItem btAddUseCase;
private System.Windows.Forms.ToolStripMenuItem btOpen;
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem controlsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
}
}

380
UseCases/Form1.cs Normal file
View File

@@ -0,0 +1,380 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Newtonsoft.Json;
namespace UseCases
{
public partial class FrmMain : Form
{
[DllImport("kernel32")]
static extern bool AllocConsole();
enum AddAction
{
Nothing,
Actor,
UseCase
}
public FrmMain()
{
//get the command line arguments
var args = Environment.GetCommandLineArgs();
InitializeComponent();
//check if there are multiple arguments
if (args.Count() > 1)
{
//check if first arguments is a file
if (File.Exists(args[1]))
{
//try to open the file
OpenFile(args[1]);
}
else
{
Diagram = new Diagram();
//initialise default values
}
}
else
{
//initialise default values
Diagram = new Diagram();
}
}
#region variables
//actors and usecases
public Diagram Diagram { get; private set; }
//drawing variables
private readonly Font _myFont = new Font("Sans Sherif", 20f, FontStyle.Regular);
private readonly Pen _drawingPen = new Pen(Color.Black, 3f);
//adding elements
private AddAction _toAdd = AddAction.Nothing;
private IDrawable _dragged = null;
//edit tracker
private bool _hasEdited = false;
#endregion
#region menustrip
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void btAddActor_Click(object sender, EventArgs e)
{
_toAdd = AddAction.Actor;
}
private void btAddUseCase_Click(object sender, EventArgs e)
{
_toAdd = AddAction.UseCase;
}
//save in json format
private void btSave_Click(object sender, EventArgs e)
{
//show save file dialog and quit if canceled
var saveDiag = new SaveFileDialog {Filter = @"*.ucd|*.ucd"};
if (saveDiag.ShowDialog() != DialogResult.OK) return;
_hasEdited = false;
Diagram.Size = Size;
Diagram.Maximized = WindowState == FormWindowState.Maximized;
//save to file
var serialized = JsonConvert.SerializeObject(Diagram, Utils.SerializerSettings);
File.WriteAllText(saveDiag.FileName, serialized);
}
//save png format
private void btSaveImage_Click(object sender, EventArgs e)
{
//show save file dialog and quit if canceled
var saveDiag = new SaveFileDialog {Filter = @"*.png|*.png"};
if (saveDiag.ShowDialog() != DialogResult.OK) return;
//create bitmap and draw usecases and actors to it
var bmp = new Bitmap(Size.Width, Size.Height);
var g = Graphics.FromImage(bmp);
DrawElements(g);
//save image to file
bmp.Save(saveDiag.FileName);
}
//open json format
private void btOpen_Click(object sender, EventArgs e)
{
//check if anything has been edited
if (_hasEdited)
{
if (
MessageBox.Show(@"Are you sure you want to load a new file?", @"Load new file",
MessageBoxButtons.YesNo) == DialogResult.No)
return;
}
//show open file dialog and quit if canceled
var openDiag = new OpenFileDialog {Filter = @"*.ucd|*ucd"};
if (openDiag.ShowDialog() != DialogResult.OK) return;
//open the file
OpenFile(openDiag.FileName);
Refresh();
}
private void clearToolStripMenuItem_Click(object sender, EventArgs e)
{
//check if user realy wants to clear the diagram else return
if (MessageBox.Show(@"Are you sure you want to clear the diagram?", @"Clear", MessageBoxButtons.YesNo) !=
DialogResult.Yes) return;
//clear lists and refresh screen
Diagram = new Diagram(new Size(430, 372));
// _actors.Clear();
// _useCases.Clear();
WindowState = FormWindowState.Normal;
Size = Diagram.Size;
Refresh();
}
private void controlsToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show(@"Pres Ctrl+A or click Add>Actor to add an Actor
Press Ctrl+U or click File>Use Case to add a Use Case
Click somwhere on screen to add Use Case or Actor at that position
Leave name empty to remove
Click and drag to move usecase or actor
Press Ctrl+S or click File>Save to save the diagram
Press Ctrl+Shift+S or click File>Save as image to save diagram as image
Click File>Clear to clear the diagram
Press Alt+F4 or click the cross or click File>Exit to close the form
Click Help>Controls to view this message
Click Help>About to view information about the application", @"Controls");
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show(@"Use Case Designer by Rick Rongen
Version 1.0
Developed by order of Fontys Hogerescholen ICT Eindhoven", @"About");
}
#endregion
#region functions
/// <summary>
/// Opens an file into form and shows error if it could not be loaded
/// </summary>
/// <param name="filename">full path of ile to load</param>
private void OpenFile(string filename)
{
//try to open file
try
{
Diagram = JsonConvert.DeserializeObject<Diagram>(File.ReadAllText(filename), Utils.SerializerSettings);
WindowState = Diagram.Maximized ? FormWindowState.Maximized : FormWindowState.Normal;
Size = Diagram.Size;
Refresh();
}
catch (JsonException jex)
{
//show the console with the error if the user wan't to see it
if (
MessageBox.Show(
$@"Error while loading {filename}\n
Invallid format or broken data\nGeeks may check console for the exception, pres yes to show console",
@"Error occured, show console?", MessageBoxButtons.YesNo) == DialogResult.Yes) AllocConsole();
Console.WriteLine(jex.ToString());
}
catch (IOException ioex)
{
//show the console with the error if the user wan't to see it
if (
MessageBox.Show(
$@"Error while loading {filename}\nCouldn't open the file or there was an encoding issue.",
@"Error occured, show console?", MessageBoxButtons.YesNo) == DialogResult.Yes) AllocConsole();
Console.WriteLine(ioex.ToString());
}
finally
{
_hasEdited = false;
}
}
/// <summary>
/// Draws all ellements in actors and useCases to the graphics object
/// </summary>
/// <param name="g">graphics object</param>
private void DrawElements(Graphics g)
{
g.SmoothingMode = SmoothingMode.AntiAlias;
foreach (var drawable in Diagram.Drawable)
{
drawable.Draw(g, _myFont, _drawingPen);
}
}
#endregion
#region mouse
//handle creation of components
private void frmMain_Click(object sender, EventArgs e)
{
var pos = PointToClient(MousePosition);
switch (_toAdd)
{
case AddAction.Actor:
//create new actor
var adiag = new EditActor();
if (adiag.ShowDialog() == DialogResult.OK && adiag.ActorName != "")
{
Diagram.Actors.Add(new Actor(adiag.ActorName, pos));
}
Refresh();
break;
case AddAction.UseCase:
//create new useCase
var udiag = new editUseCase(Diagram.Actors) {UseCase = new UseCase(), CasePos = pos};
if (udiag.ShowDialog() == DialogResult.OK && udiag.UseCase.Name != "")
{
Diagram.UseCases.Add(udiag.UseCase);
udiag.UseCase.Actors.ForEach(Console.WriteLine);
}
Refresh();
break;
default:
case AddAction.Nothing:
break;
}
_toAdd = AddAction.Nothing;
if (Diagram.UseCases.Any() || Diagram.Actors.Any()) _hasEdited = true;
}
//handle editing of components
private void frmMain_DoubleClick(object sender, EventArgs e)
{
var mousepos = PointToClient(MousePosition);
var closest = GetClosestDrawable(mousepos);
switch (closest)
{
case null:
return;
case Actor actor:
var edAcDiag = new EditActor(actor.Name);
if (edAcDiag.ShowDialog() == DialogResult.OK)
{
if (edAcDiag.ActorName == "")
{
//remove actor if name is equal to ""
Diagram.Actors.Remove(actor);
foreach (var usecase in Diagram.UseCases)
{
//remove this actor from all refering usecases
usecase.Actors.Remove(actor);
}
}
else
{
//update name
actor.Name = edAcDiag.ActorName;
}
}
break;
case UseCase useCase:
var edUcDiag = new editUseCase(Diagram.Actors)
{
UseCase = useCase,
CasePos = useCase.Position
};
if (edUcDiag.ShowDialog() == DialogResult.OK)
{
if (edUcDiag.UseCase.Name == "")
{
//remove usecase if name is equal to ""
Diagram.UseCases.Remove(useCase);
}
}
break;
}
Refresh();
}
//move usecase or actor
private void frmMain_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && _toAdd == AddAction.Nothing)
{
_dragged = null;
}
}
private void frmMain_MouseDown(object sender, MouseEventArgs e)
{
//quit if not left mousebutton or adding item
if (e.Button != MouseButtons.Left || _toAdd != AddAction.Nothing) return;
//get mouse position in client
var mousepos = PointToClient(MousePosition);
var closest = GetClosestDrawable(mousepos);
if (closest == null)
return;
_dragged = closest;
}
private void frmMain_MouseMove(object sender, MouseEventArgs e)
{
if (_dragged == null) return;
_dragged.Position = PointToClient(MousePosition);
Refresh();
}
private IDrawable GetClosestDrawable(Point position, double maxDistance = 30d)
{
if (!Diagram.UseCases.Any() && !Diagram.Actors.Any())
return null; // No items to check
var comm = Diagram.Drawable.Select(org => new
{
original = org,
distance = Math.Sqrt(Math.Pow(org.Position.X - position.X, 2) +
Math.Pow(org.Position.Y - position.Y, 2))
}).Aggregate((a1, a2) => a1.distance < a2.distance ? a1 : a2);
return comm.distance > maxDistance ? null : comm.original;
}
#endregion
private void frmMain_Paint(object sender, PaintEventArgs e)
{
//draw actors, use cases and lines
DrawElements(e.Graphics);
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (!_hasEdited) return;
if (MessageBox.Show(@"Are you sure you want to exit?", @"exit", MessageBoxButtons.YesNo) !=
DialogResult.Yes)
e.Cancel = true;
}
}
}

126
UseCases/Form1.resx Normal file
View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>56</value>
</metadata>
</root>

24
UseCases/IDrawable.cs Normal file
View File

@@ -0,0 +1,24 @@
using System.Drawing;
namespace UseCases
{
public interface IDrawable
{
/// <summary>
/// The name of the drawable.
/// </summary>
string Name { get; set; }
/// <summary>
/// The position of the drawable
/// </summary>
Point Position { get; set; }
/// <summary>
/// Draw the drawable
/// </summary>
/// <param name="g">The graphics to draw to</param>
/// <param name="font">The font to draw text with</param>
/// <param name="p">The pen to draw lines with</param>
void Draw(Graphics g, Font font, Pen p);
}
}

57
UseCases/Program.cs Normal file
View File

@@ -0,0 +1,57 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Newtonsoft.Json;
namespace UseCases
{
static class Program
{
[DllImport("kernel32")]
static extern bool AllocConsole();
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var frm = new FrmMain();
try
{
Application.Run(frm);
}
catch (Exception ex)
{
if(MessageBox.Show(
@"Fatal error occured and the application cannot continue
A memmory dump will be generated to minimize lost data
Nerds may check console for the exception, press yes to show console"
, @"Error occured, show console?", MessageBoxButtons.YesNo) ==
DialogResult.Yes) AllocConsole();
Console.Error.WriteLine(ex.ToString());
Console.WriteLine(ex.ToString());
var tosave = JsonConvert.SerializeObject(frm.Diagram, Utils.SerializerSettings);
//dump know data before exiting, may contain errors
// var saveObj = new JObject
// {
// {"version", 2},
// {"actors", JToken.FromObject(frm.actors)},
// {"useCases", JToken.FromObject(frm.useCases)},
// {"size", JToken.FromObject(frm.Size)},
// {"maximized",JToken.FromObject(frm.WindowState==FormWindowState.Maximized)}
// };
//dump to file
File.WriteAllText(Application.StartupPath+"\\DUMP-"+DateTime.Now.ToString().Replace(':','.')+".ucd",tosave);
Console.ReadLine();
throw;
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("UseCases")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UseCases")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0a354ee6-7a89-4536-b1d1-732d2bc54cab")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace UseCases.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UseCases.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

30
UseCases/Properties/Settings.Designer.cs generated Normal file
View File

@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace UseCases.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

75
UseCases/UseCase.cs Normal file
View 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; }
}
}

114
UseCases/UseCases.csproj Normal file
View File

@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7AD26D8A-D2A9-4438-AF3B-5B8DE49F1DD6}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UseCases</RootNamespace>
<AssemblyName>UseCases</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Actor.cs" />
<Compile Include="Diagram.cs" />
<Compile Include="EditActor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="EditActor.Designer.cs">
<DependentUpon>EditActor.cs</DependentUpon>
</Compile>
<Compile Include="editUseCase.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="editUseCase.Designer.cs">
<DependentUpon>editUseCase.cs</DependentUpon>
</Compile>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="IDrawable.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UseCase.cs" />
<Compile Include="Utils.cs" />
<EmbeddedResource Include="EditActor.resx">
<DependentUpon>EditActor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="editUseCase.resx">
<DependentUpon>editUseCase.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

41
UseCases/Utils.cs Normal file
View File

@@ -0,0 +1,41 @@
using System.Collections.Generic;
using System.Drawing;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace UseCases
{
internal static class Utils
{
/// <summary>
/// Translate a PointF
/// </summary>
/// <param name="input">Original PointF</param>
/// <param name="offX">Horizontal offset</param>
/// <param name="offY">Vertical offset</param>
/// <returns>Translated point</returns>
public static PointF TranslatePointF(PointF input, float offX, float offY)
{
return new PointF(input.X + offX, input.Y + offY);
}
/// <summary>
/// Translate a SizeF
/// </summary>
/// <param name="input">Original SizeF</param>
/// <param name="offX">Horizontal offset</param>
/// <param name="offY">Vertical offset</param>
/// <returns>Translated point</returns>
public static SizeF TranslateSizeF(SizeF input, float offX, float offY)
{
var returnSize = new SizeF(input);
returnSize.Width += offX;
returnSize.Height += offY;
return returnSize;
}
public static JsonSerializerSettings SerializerSettings =>
new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects, Converters = new List<JsonConverter>{new VersionConverter()}};
}
}

269
UseCases/editUseCase.Designer.cs generated Normal file
View File

@@ -0,0 +1,269 @@
namespace UseCases
{
partial class editUseCase
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lbName = new System.Windows.Forms.Label();
this.tbName = new System.Windows.Forms.TextBox();
this.tbBrief = new System.Windows.Forms.TextBox();
this.lbBrief = new System.Windows.Forms.Label();
this.clbActors = new System.Windows.Forms.CheckedListBox();
this.lbActors = new System.Windows.Forms.Label();
this.lbAssumptions = new System.Windows.Forms.Label();
this.tbAssumptions = new System.Windows.Forms.TextBox();
this.tbDescription = new System.Windows.Forms.TextBox();
this.lbDescription = new System.Windows.Forms.Label();
this.tbExceptions = new System.Windows.Forms.TextBox();
this.lbExceptions = new System.Windows.Forms.Label();
this.tbResult = new System.Windows.Forms.TextBox();
this.lbResult = new System.Windows.Forms.Label();
this.btOk = new System.Windows.Forms.Button();
this.btCancel = new System.Windows.Forms.Button();
this.btCopy = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lbName
//
this.lbName.AutoSize = true;
this.lbName.Location = new System.Drawing.Point(12, 13);
this.lbName.Name = "lbName";
this.lbName.Size = new System.Drawing.Size(35, 13);
this.lbName.TabIndex = 0;
this.lbName.Text = "Name";
//
// tbName
//
this.tbName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbName.Location = new System.Drawing.Point(84, 10);
this.tbName.Name = "tbName";
this.tbName.Size = new System.Drawing.Size(366, 20);
this.tbName.TabIndex = 1;
//
// tbBrief
//
this.tbBrief.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbBrief.Location = new System.Drawing.Point(84, 36);
this.tbBrief.Multiline = true;
this.tbBrief.Name = "tbBrief";
this.tbBrief.Size = new System.Drawing.Size(366, 52);
this.tbBrief.TabIndex = 2;
//
// lbBrief
//
this.lbBrief.AutoSize = true;
this.lbBrief.Location = new System.Drawing.Point(12, 39);
this.lbBrief.Name = "lbBrief";
this.lbBrief.Size = new System.Drawing.Size(28, 13);
this.lbBrief.TabIndex = 3;
this.lbBrief.Text = "Brief";
//
// clbActors
//
this.clbActors.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.clbActors.FormattingEnabled = true;
this.clbActors.HorizontalScrollbar = true;
this.clbActors.Location = new System.Drawing.Point(84, 94);
this.clbActors.MultiColumn = true;
this.clbActors.Name = "clbActors";
this.clbActors.Size = new System.Drawing.Size(366, 79);
this.clbActors.TabIndex = 4;
//
// lbActors
//
this.lbActors.AutoSize = true;
this.lbActors.Location = new System.Drawing.Point(12, 96);
this.lbActors.Name = "lbActors";
this.lbActors.Size = new System.Drawing.Size(37, 13);
this.lbActors.TabIndex = 5;
this.lbActors.Text = "Actors";
//
// lbAssumptions
//
this.lbAssumptions.AutoSize = true;
this.lbAssumptions.Location = new System.Drawing.Point(12, 182);
this.lbAssumptions.Name = "lbAssumptions";
this.lbAssumptions.Size = new System.Drawing.Size(66, 13);
this.lbAssumptions.TabIndex = 6;
this.lbAssumptions.Text = "Assumptions";
//
// tbAssumptions
//
this.tbAssumptions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbAssumptions.Location = new System.Drawing.Point(84, 178);
this.tbAssumptions.Multiline = true;
this.tbAssumptions.Name = "tbAssumptions";
this.tbAssumptions.Size = new System.Drawing.Size(366, 52);
this.tbAssumptions.TabIndex = 7;
//
// tbDescription
//
this.tbDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbDescription.Location = new System.Drawing.Point(84, 237);
this.tbDescription.Multiline = true;
this.tbDescription.Name = "tbDescription";
this.tbDescription.Size = new System.Drawing.Size(366, 155);
this.tbDescription.TabIndex = 9;
//
// lbDescription
//
this.lbDescription.AutoSize = true;
this.lbDescription.Location = new System.Drawing.Point(12, 240);
this.lbDescription.Name = "lbDescription";
this.lbDescription.Size = new System.Drawing.Size(60, 13);
this.lbDescription.TabIndex = 8;
this.lbDescription.Text = "Description";
//
// tbExceptions
//
this.tbExceptions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbExceptions.Location = new System.Drawing.Point(84, 398);
this.tbExceptions.Multiline = true;
this.tbExceptions.Name = "tbExceptions";
this.tbExceptions.Size = new System.Drawing.Size(366, 52);
this.tbExceptions.TabIndex = 11;
//
// lbExceptions
//
this.lbExceptions.AutoSize = true;
this.lbExceptions.Location = new System.Drawing.Point(12, 401);
this.lbExceptions.Name = "lbExceptions";
this.lbExceptions.Size = new System.Drawing.Size(59, 13);
this.lbExceptions.TabIndex = 10;
this.lbExceptions.Text = "Exceptions";
//
// tbResult
//
this.tbResult.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbResult.Location = new System.Drawing.Point(84, 456);
this.tbResult.Multiline = true;
this.tbResult.Name = "tbResult";
this.tbResult.Size = new System.Drawing.Size(366, 52);
this.tbResult.TabIndex = 13;
//
// lbResult
//
this.lbResult.AutoSize = true;
this.lbResult.Location = new System.Drawing.Point(12, 459);
this.lbResult.Name = "lbResult";
this.lbResult.Size = new System.Drawing.Size(37, 13);
this.lbResult.TabIndex = 12;
this.lbResult.Text = "Result";
//
// btOk
//
this.btOk.Location = new System.Drawing.Point(375, 514);
this.btOk.Name = "btOk";
this.btOk.Size = new System.Drawing.Size(75, 23);
this.btOk.TabIndex = 14;
this.btOk.Text = "Ok";
this.btOk.UseVisualStyleBackColor = true;
this.btOk.Click += new System.EventHandler(this.btOk_Click);
//
// btCancel
//
this.btCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btCancel.Location = new System.Drawing.Point(294, 514);
this.btCancel.Name = "btCancel";
this.btCancel.Size = new System.Drawing.Size(75, 23);
this.btCancel.TabIndex = 15;
this.btCancel.Text = "Cancel";
this.btCancel.UseVisualStyleBackColor = true;
this.btCancel.Click += new System.EventHandler(this.btCancel_Click);
//
// btCopy
//
this.btCopy.Location = new System.Drawing.Point(12, 514);
this.btCopy.Name = "btCopy";
this.btCopy.Size = new System.Drawing.Size(75, 23);
this.btCopy.TabIndex = 16;
this.btCopy.Text = "Copy";
this.btCopy.UseVisualStyleBackColor = true;
this.btCopy.Click += new System.EventHandler(this.btCopy_Click);
//
// editUseCase
//
this.AcceptButton = this.btOk;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btCancel;
this.ClientSize = new System.Drawing.Size(462, 543);
this.Controls.Add(this.btCopy);
this.Controls.Add(this.btCancel);
this.Controls.Add(this.btOk);
this.Controls.Add(this.tbResult);
this.Controls.Add(this.lbResult);
this.Controls.Add(this.tbExceptions);
this.Controls.Add(this.lbExceptions);
this.Controls.Add(this.tbDescription);
this.Controls.Add(this.lbDescription);
this.Controls.Add(this.tbAssumptions);
this.Controls.Add(this.lbAssumptions);
this.Controls.Add(this.lbActors);
this.Controls.Add(this.clbActors);
this.Controls.Add(this.lbBrief);
this.Controls.Add(this.tbBrief);
this.Controls.Add(this.tbName);
this.Controls.Add(this.lbName);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "editUseCase";
this.Text = "Edit Use Case";
this.Load += new System.EventHandler(this.editUseCase_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lbName;
private System.Windows.Forms.TextBox tbName;
private System.Windows.Forms.TextBox tbBrief;
private System.Windows.Forms.Label lbBrief;
private System.Windows.Forms.CheckedListBox clbActors;
private System.Windows.Forms.Label lbActors;
private System.Windows.Forms.Label lbAssumptions;
private System.Windows.Forms.TextBox tbAssumptions;
private System.Windows.Forms.TextBox tbDescription;
private System.Windows.Forms.Label lbDescription;
private System.Windows.Forms.TextBox tbExceptions;
private System.Windows.Forms.Label lbExceptions;
private System.Windows.Forms.TextBox tbResult;
private System.Windows.Forms.Label lbResult;
private System.Windows.Forms.Button btOk;
private System.Windows.Forms.Button btCancel;
private System.Windows.Forms.Button btCopy;
}
}

144
UseCases/editUseCase.cs Normal file
View File

@@ -0,0 +1,144 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
namespace UseCases
{
public partial class editUseCase : Form
{
public editUseCase(List<Actor> actors)
{
InitializeComponent();
Actors = actors;
clbActors.Items.AddRange(actors.Select(actor => actor.Name).ToArray());
}
public UseCase UseCase { get; set; }
public Point CasePos { get; set; }
private List<Actor> Actors;
private void btOk_Click(object sender, EventArgs e)
{
if (tbName.Text == "")
{
if (
MessageBox.Show("Are you sure you want to remove this use case?", "Are you sure?",
MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return; //if the user doesn't want to remove usecase cancel
}
}
//edit usecase data
UseCase.Name = tbName.Text;
UseCase.Brief = tbBrief.Text;
UseCase.Actors = new List<Actor>();
foreach (var item in clbActors.CheckedItems)
{
UseCase.Actors.Add(Actors.Find(a=>a.Name == item.ToString()));
}
UseCase.Assumption = tbAssumptions.Text;
UseCase.Discription = tbDescription.Text;
UseCase.Exceptions = tbExceptions.Text;
UseCase.Result = tbResult.Text;
UseCase.Position = CasePos;
//ok close dialog
DialogResult = DialogResult.OK;
Close();
}
private void btCancel_Click(object sender, EventArgs e)
{
//cancel result and close dialog
DialogResult = DialogResult.Cancel;
Close();
}
private void editUseCase_Load(object sender, EventArgs e)
{
//UseCase.Name = tbName.Text;
//UseCase.Brief = tbBrief.Text;
//UseCase.Actors = new List<String>();
//foreach (var item in clbActors.CheckedItems)
//{
// UseCase.Actors.Add(item.ToString());
//}
//UseCase.Assumption = tbAssumptions.Text;
//UseCase.Discription = tbDescription.Text;
//UseCase.Exceptions = tbExceptions.Text;
//UseCase.Result = tbResult.Text;
//UseCase.Position = CasePos;
tbName.Text = UseCase.Name;
tbBrief.Text = UseCase.Brief;
foreach (var actor in UseCase.Actors)
{
clbActors.SetItemChecked(Actors.FindIndex(act => act == actor), true);
}
tbAssumptions.Text = UseCase.Assumption;
tbDescription.Text = UseCase.Discription;
tbExceptions.Text = UseCase.Exceptions;
tbResult.Text = UseCase.Result;
}
private void btCopy_Click(object sender, EventArgs e)
{
var rtf = $@"{{\rtf1\ansi\deff0
\trowd
\cellx{2000}
\cellx{8000}
\intbl Name\cell
\intbl {ReplaceNewlineRtf(UseCase.Name)}\cell
\row
\trowd
\cellx{2000}
\cellx{8000}
\intbl Brief\cell
\intbl {ReplaceNewlineRtf(UseCase.Brief)}\cell
\row
\trowd
\cellx{2000}
\cellx{8000}
\intbl Actors\cell
\intbl {string.Join(", ", UseCase.Actors)}\cell
\row
\trowd
\cellx{2000}
\cellx{8000}
\intbl Assumptions\cell
\intbl {ReplaceNewlineRtf(UseCase.Assumption)}\cell
\row
\trowd
\cellx{2000}
\cellx{8000}
\intbl Description\cell
\intbl {ReplaceNewlineRtf(UseCase.Discription)}\cell
\row
\trowd
\cellx{2000}
\cellx{8000}
\intbl Exceptions\cell
\intbl {ReplaceNewlineRtf(UseCase.Exceptions)}\cell
\row
\trowd
\cellx{2000}
\cellx{8000}
\intbl Result\cell
\intbl {ReplaceNewlineRtf(UseCase.Result)}\cell
\row
}}";
Clipboard.SetText(rtf, TextDataFormat.Rtf);
}
private static string ReplaceNewlineRtf(string input)
{
return input.Replace("\n", "\\line ");
}
}
}

120
UseCases/editUseCase.resx Normal file
View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

4
UseCases/packages.config Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
</packages>