144 lines
3.9 KiB
C#
144 lines
3.9 KiB
C#
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 ");
|
|
}
|
|
}
|
|
} |