本文整理汇总了C#中Repository.GetCurrentDiagram方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.GetCurrentDiagram方法的具体用法?C# Repository.GetCurrentDiagram怎么用?C# Repository.GetCurrentDiagram使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.GetCurrentDiagram方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SplitAllDiagramObjectsToLastSelected
// ReSharper disable once UnusedMember.Global
// dynamical usage as configurable service by reflection
public static void SplitAllDiagramObjectsToLastSelected(Repository rep)
{
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return;
int count = dia.SelectedObjects.Count;
if (count == 0) return;
rep.SaveDiagram(dia.DiagramID);
// target object/element
ObjectType objType = rep.GetContextItemType();
if (!(objType.Equals(ObjectType.otElement))) return;
var trgEl = (Element) rep.GetContextObject();
foreach (DiagramObject srcObj in dia.DiagramObjects)
{
var srcEl = rep.GetElementByID(srcObj.ElementID);
if (srcEl.ElementID == trgEl.ElementID) continue;
SplitElementsByConnectorType(srcEl, trgEl);
}
rep.ReloadDiagram(dia.DiagramID);
dia.SelectedObjects.AddNew(trgEl.ElementID.ToString(), trgEl.ObjectType.ToString());
}
示例2: MakeNested
// ReSharper disable once UnusedMember.Local
private static void MakeNested(Repository rep)
{
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return;
int count = dia.SelectedObjects.Count;
if (count < 2) return;
rep.SaveDiagram(dia.DiagramID);
// target object/element
ObjectType objType = rep.GetContextItemType();
if (!(objType.Equals(ObjectType.otElement))) return;
var trgEl = (Element) rep.GetContextObject();
if (!(trgEl.Type.Equals("Activity")))
{
MessageBox.Show($"Target '{trgEl.Name}:{trgEl.Type}' isn't an Activity",
@" Only move below Activity is allowed");
return;
}
for (int i = 0; i < count; i = i + 1)
{
var srcObj = (DiagramObject) dia.SelectedObjects.GetAt((short) i);
var srcEl = rep.GetElementByID(srcObj.ElementID);
if (srcEl.ElementID == trgEl.ElementID) continue;
srcEl.ParentID = trgEl.ElementID;
srcEl.Update();
}
}
示例3: macroDiagramSelectedElements_IDS
/// <summary>
/// Replace macro #DiagramElements_IDS# by a comma separated list of all Element IDs in diagram.
/// <para/>
/// If no Element is in the diagram it return '0' for an empty list (not existing ID).
/// </summary>
/// <param name="rep"></param>
/// <param name="sql">The sql string to replace the macro by the found list of Diagram Element IDs</param>
/// <returns>sql string with replaced macro</returns>
static string macroDiagramSelectedElements_IDS(Repository rep, string sql)
{
// get template
string template = GetTemplateText(SqlTemplateId.DiagramSelectedElementsIds);
// template is used
if (sql.Contains(template))
{
// get the diagram
Diagram dia = rep.GetContextItemType() == ObjectType.otDiagram ? rep.GetContextObject() : rep.GetCurrentDiagram();
// Diagram selected?
if (dia == null)
{
MessageBox.Show(sql, $"No Diagram for '{template}' selected!");
sql = "";
}
else
{
// make a list of comma separated IDs
string listId = "0";
foreach (var el in dia.SelectedObjects)
{
int id = ((EA.DiagramObject)el).ElementID;
listId = $"{listId},{id}";
}
// replace by list of IDs
sql = sql.Replace(template, $"{listId}");
}
}
return sql;
}
示例4: JoinDiagramObjectsToLastSelected
// ReSharper disable once UnusedMember.Global
// dynamical usage as configurable service by reflection
public static void JoinDiagramObjectsToLastSelected(Repository rep)
{
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return;
int count = dia.SelectedObjects.Count;
if (count < 2) return;
rep.SaveDiagram(dia.DiagramID);
// target object/element
var trgEl = (Element) rep.GetContextObject();
for (int i = 0; i < count; i = i + 1)
{
var srcObj = (DiagramObject) dia.SelectedObjects.GetAt((short) i);
var srcEl = rep.GetElementByID(srcObj.ElementID);
if (srcEl.ElementID == trgEl.ElementID) continue;
Connectors.Connector connector = GetConnectionDefault();
var con = (Connector) srcEl.Connectors.AddNew("", connector.Type);
con.SupplierID = trgEl.ElementID;
con.Stereotype = connector.Stereotype;
con.Update();
srcEl.Connectors.Refresh();
trgEl.Connectors.Refresh();
dia.DiagramLinks.Refresh();
// set line style
DiagramLink link = GetDiagramLinkForConnector(dia, con.ConnectorID);
if (link != null) Util.SetLineStyleForDiagramLink("LV", link);
}
rep.ReloadDiagram(dia.DiagramID);
dia.SelectedObjects.AddNew(trgEl.ElementID.ToString(), trgEl.ObjectType.ToString());
}
示例5: ShowEmbeddedElementsGui
public static void ShowEmbeddedElementsGui(
Repository rep,
string embeddedElementType = "Port Pin Parameter",
bool isOptimizePortLayout = false)
{
var dia = rep.GetCurrentDiagram();
if (dia == null) return;
rep.SaveDiagram(dia.DiagramID);
var sqlUtil = new UtilSql(rep);
// over all selected elements
foreach (DiagramObject diaObj in dia.SelectedObjects)
{
var elSource = rep.GetElementByID(diaObj.ElementID);
if (!"Class Component Activity".Contains(elSource.Type)) continue;
// find object on Diagram
var diaObjSource = Util.GetDiagramObjectById(rep, dia, elSource.ElementID);
//diaObjSource = dia.GetDiagramObjectByID(elSource.ElementID, "");
if (diaObjSource == null) return;
string[] portTypes = {"left", "right"};
foreach (string portBoundTo in portTypes)
{
// arrange sequence of ports
if (isOptimizePortLayout == false && portBoundTo == "left") continue;
int pos = 0;
List<int> lPorts;
if (isOptimizePortLayout == false)
{
lPorts = sqlUtil.GetAndSortEmbeddedElements(elSource, "", "", "");
}
else
{
if (portBoundTo == "left")
lPorts = sqlUtil.GetAndSortEmbeddedElements(elSource, "Port", "'Server', 'Receiver' ",
"DESC");
else lPorts = sqlUtil.GetAndSortEmbeddedElements(elSource, "Port", "'Client', 'Sender' ", "");
}
// over all sorted ports
string oldStereotype = "";
foreach (int i in lPorts)
{
Element portEmbedded = rep.GetElementByID(i);
if (embeddedElementType == "" | embeddedElementType.Contains(portEmbedded.Type))
{
// only ports / parameters (port has no further embedded elements
if (portEmbedded.Type == "ActivityParameter" | portEmbedded.EmbeddedElements.Count == 0)
{
if (isOptimizePortLayout)
{
if (portBoundTo == "left")
{
if ("Sender Client".Contains(portEmbedded.Stereotype)) continue;
}
else
{
if ("Receiver Server".Contains(portEmbedded.Stereotype)) continue;
}
}
// Make a gap between different stereotypes
if (pos == 0 && "Sender Receiver".Contains(portEmbedded.Stereotype))
oldStereotype = portEmbedded.Stereotype;
if (pos > 0 && "Sender Receiver".Contains(oldStereotype) &&
oldStereotype != portEmbedded.Stereotype)
{
pos = pos + 1; // make a gap
oldStereotype = portEmbedded.Stereotype;
}
Util.VisualizePortForDiagramobject(pos, dia, diaObjSource, portEmbedded, null,
portBoundTo);
pos = pos + 1;
}
else
{
// Port: Visualize Port + Interface
foreach (Element interf in portEmbedded.EmbeddedElements)
{
Util.VisualizePortForDiagramobject(pos, dia, diaObjSource, portEmbedded, interf);
pos = pos + 1;
}
}
}
}
}
}
rep.ReloadDiagram(dia.DiagramID);
}
示例6: AddDiagramNote
public static void AddDiagramNote(Repository rep)
{
ObjectType oType = rep.GetContextItemType();
if (oType.Equals(ObjectType.otDiagram))
{
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return;
Package pkg = rep.GetPackageByID(dia.PackageID);
if (pkg.IsProtected || dia.IsLocked) return;
// save diagram
rep.SaveDiagram(dia.DiagramID);
Element elNote;
try
{
elNote = (Element) pkg.Elements.AddNew("", "Note");
elNote.Update();
pkg.Update();
}
catch
{
return;
}
// add element to diagram
// "l=200;r=400;t=200;b=600;"
// get the position of the Element
int left = (dia.cx/2) - 100;
int right = left + 200;
int top = dia.cy - 150;
int bottom = top + 120;
//int right = diaObj.right + 2 * (diaObj.right - diaObj.left);
string position = "l=" + left + ";r=" + right + ";t=" + top + ";b=" + bottom + ";";
var diaObject = (DiagramObject) dia.DiagramObjects.AddNew(position, "");
dia.Update();
diaObject.ElementID = elNote.ElementID;
diaObject.Update();
pkg.Elements.Refresh();
Util.SetDiagramHasAttchaedLink(rep, elNote);
rep.ReloadDiagram(dia.DiagramID);
}
}
示例7: CopyGuidSqlToClipboard
public static void CopyGuidSqlToClipboard(Repository rep)
{
string str = @"";
string str1;
ObjectType oType = rep.GetContextItemType();
Diagram diaCurrent = rep.GetCurrentDiagram();
Connector conCurrent = null;
if (diaCurrent != null)
{
conCurrent = diaCurrent.SelectedConnector;
}
if (conCurrent != null)
{
// Connector
Connector con = conCurrent;
str = con.ConnectorGUID + " " + con.Name + ' ' + con.Type + "\r\n" +
"\r\n Connector: Select ea_guid As CLASSGUID, connector_type As CLASSTYPE,* from t_connector con where ea_guid = '" +
con.ConnectorGUID + "'" +
"\r\n\r\nSelect o.ea_guid As CLASSGUID, o.object_type As CLASSTYPE,o.name As Name, o.object_type AS ObjectType, o.PDATA1, o.Stereotype, " +
"\r\n con.Name, con.connector_type, con.Stereotype, con.ea_guid As ConnectorGUID, dia.Name As DiagrammName, dia.ea_GUID As DiagramGUID," +
"\r\n o.ea_guid, o.Classifier_GUID,o.Classifier " +
"\r\nfrom (((t_connector con INNER JOIN t_object o on con.start_object_id = o.object_id) " +
"\r\nINNER JOIN t_diagramlinks diaLink on con.connector_id = diaLink.connectorid ) " +
"\r\nINNER JOIN t_diagram dia on diaLink.DiagramId = dia.Diagram_ID) " +
"\r\nINNER JOIN t_diagramobjects diaObj on diaObj.diagram_ID = dia.Diagram_ID and o.object_id = diaObj.object_id " +
"\r\nwhere con.ea_guid = '" + con.ConnectorGUID + "' " +
"\r\nAND dialink.Hidden = 0 ";
Clipboard.SetText(str);
return;
}
if (oType.Equals(ObjectType.otElement))
{
// Element
var el = (Element) rep.GetContextObject();
string pdata1 = el.MiscData[0];
string pdata1String;
if (pdata1.EndsWith("}", StringComparison.Ordinal))
{
pdata1String = "/" + pdata1;
}
else
{
pdata1 = "";
pdata1String = "";
}
string classifier = Util.GetClassifierGuid(rep, el.ElementGUID);
str = el.ElementGUID + ":" + classifier + pdata1String + " " + el.Name + ' ' + el.Type + "\r\n" +
"\r\nSelect ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" +
el.ElementGUID + "'";
if (classifier != "")
{
if (el.Type.Equals("ActionPin"))
{
str = str +
"\r\n Type:\r\nSelect ea_guid As CLASSGUID, 'Parameter' As CLASSTYPE,* from t_operationparams op where ea_guid = '" +
classifier + "'";
}
else
{
str = str +
"\r\n Type:\r\nSelect ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" +
classifier + "'";
}
}
if (pdata1 != "")
{
str = str +
"\r\n PDATA1: Select ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" +
pdata1 + "'";
}
// Look for diagram object
Diagram curDia = rep.GetCurrentDiagram();
if (curDia != null)
{
foreach (DiagramObject diaObj in curDia.DiagramObjects)
{
if (diaObj.ElementID == el.ElementID)
{
str = str + "\r\n\r\n" +
"select * from t_diagramobjects where object_id = " + diaObj.ElementID;
break;
}
}
}
}
if (oType.Equals(ObjectType.otDiagram))
{
// Element
var dia = (Diagram) rep.GetContextObject();
str = dia.DiagramGUID + " " + dia.Name + ' ' + dia.Type + "\r\n" +
"\r\nSelect ea_guid As CLASSGUID, diagram_type As CLASSTYPE,* from t_diagram dia where ea_guid = '" +
dia.DiagramGUID + "'";
}
if (oType.Equals(ObjectType.otPackage))
{
// Element
//.........这里部分代码省略.........
示例8: GenerateComponentPorts
static void GenerateComponentPorts(Repository rep)
{
int pos = 0;
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return;
if (!rep.GetContextItemType().Equals(ObjectType.otElement)) return;
var elSource = (Element) rep.GetContextObject();
if (elSource.Type != "Component") return;
Util.GetDiagramObjectById(rep, dia, elSource.ElementID);
//diaObjSource = dia.GetDiagramObjectByID(elSource.ElementID, "");
rep.SaveDiagram(dia.DiagramID);
foreach (DiagramObject obj in dia.DiagramObjects)
{
var elTarget = rep.GetElementByID(obj.ElementID);
if (!("Class Interface".Contains(elTarget.Type))) continue;
if (!(elTarget.Name.EndsWith("_i", StringComparison.Ordinal)))
{
AddPortToComponent(elSource, elTarget);
pos = pos + 1;
}
if ("Interface Class".Contains(elTarget.Type))
{
List<Element> lEl = GetIncludedHeaderFiles(rep, elTarget);
foreach (Element el in lEl)
{
if (el == null) continue;
if (!(el.Name.EndsWith("_i", StringComparison.Ordinal)))
{
AddPortToComponent(elSource, el);
pos = pos + 1;
}
}
}
}
ShowEmbeddedElementsGui(rep);
}
示例9: AddElementNote
/// <summary>
/// Add Element note for diagram Object from:<para/>
/// Element, Attribute, Operation, Package
///
/// </summary>
/// <param name="rep"></param>
/// <param name="diaObj"></param>
public static void AddElementNote(Repository rep, DiagramObject diaObj)
{
Element el = rep.GetElementByID(diaObj.ElementID);
if (el != null)
{
Diagram dia = rep.GetCurrentDiagram();
Package pkg = rep.GetPackageByID(el.PackageID);
if (pkg.IsProtected || dia.IsLocked || el.Locked) return;
// save diagram;//
rep.SaveDiagram(dia.DiagramID);
Element elNote;
try
{
elNote = (Element) pkg.Elements.AddNew("", "Note");
elNote.Update();
pkg.Update();
}
catch
{
return;
}
// add element to diagram
// "l=200;r=400;t=200;b=600;"
int left = diaObj.right + 50;
int right = left + 100;
int top = diaObj.top;
int bottom = top - 100;
string position = "l=" + left + ";r=" + right + ";t=" + top + ";b=" + bottom + ";";
var diaObject = (DiagramObject) dia.DiagramObjects.AddNew(position, "");
dia.Update();
diaObject.ElementID = elNote.ElementID;
diaObject.Sequence = 1; // put element to top
diaObject.Update();
pkg.Elements.Refresh();
// make a connector
var con = (Connector) el.Connectors.AddNew("test", "NoteLink");
con.SupplierID = elNote.ElementID;
con.Update();
el.Connectors.Refresh();
Util.SetElementHasAttchaedLink(rep, el, elNote);
rep.ReloadDiagram(dia.DiagramID);
}
}
示例10: UpdateActivityParameter
public static void UpdateActivityParameter(Repository rep)
{
ObjectType oType = rep.GetContextItemType();
if (oType.Equals(ObjectType.otElement))
{
var el = (Element) rep.GetContextObject();
if (el.Type.Equals("Activity"))
{
// get the associated operation
Method m = Util.GetOperationFromBrehavior(rep, el);
if (el.Locked) return;
if (m == null) return;
ActivityPar.UpdateParameterFromOperation(rep, el, m); // get parameters from Operation for Activity
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return;
DiagramObject diaObj = Util.GetDiagramObjectById(rep, dia, el.ElementID);
//EA.DiagramObject diaObj = dia.GetDiagramObjectByID(el.ElementID,"");
if (diaObj == null) return;
int pos = 0;
rep.SaveDiagram(dia.DiagramID);
foreach (Element actPar in el.EmbeddedElements)
{
if (!actPar.Type.Equals("ActivityParameter")) continue;
Util.VisualizePortForDiagramobject(pos, dia, diaObj, actPar, null);
pos = pos + 1;
}
rep.ReloadDiagram(dia.DiagramID);
}
if (el.Type.Equals("Class") | el.Type.Equals("Interface"))
{
UpdateActivityParameterForElement(rep, el);
}
}
if (oType.Equals(ObjectType.otMethod))
{
var m = (Method) rep.GetContextObject();
Element act = Appl.GetBehaviorForOperation(rep, m);
if (act == null) return;
if (act.Locked) return;
ActivityPar.UpdateParameterFromOperation(rep, act, m); // get parameters from Operation for Activity
}
if (oType.Equals(ObjectType.otPackage))
{
var pkg = (Package) rep.GetContextObject();
UpdateActivityParameterForPackage(rep, pkg);
}
}
示例11: AddNote
/// <summary>
/// Add Element- or Diagram -Note to Element or Diagram and link Note to Notes Property.
/// </summary>
/// <param name="rep"></param>
public static void AddNote(Repository rep)
{
// handle multiple selected elements
Diagram diaCurrent = rep.GetCurrentDiagram();
EA.Collection objCol = null;
if (diaCurrent != null)
{
objCol = diaCurrent.SelectedObjects;
}
ObjectType oType = rep.GetContextItemType();
switch (oType)
{
case ObjectType.otConnector:
break;
case ObjectType.otPackage:
case ObjectType.otElement:
if (objCol?.Count > 0)
{
foreach (EA.DiagramObject obj in objCol)
{
AddElementNote(rep, obj);
}
}
break;
case ObjectType.otDiagram:
AddDiagramNote(rep);
break;
}
}
示例12: InsertInActivtyDiagram
// ReSharper disable once UnusedMember.Global
public static void InsertInActivtyDiagram(Repository rep, string text)
{
// remember selected object
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return;
if (dia.Type != "Activity") return;
Element elSource = Util.GetElementFromContextObject(rep);
if (elSource == null) return;
DiagramObject objSource = null;
bool isSwitchCase = false;
if (Regex.IsMatch(elSource.Name, @"switch[\s]*\("))
{
isSwitchCase = true;
objSource = Util.GetDiagramObjectById(rep, dia, elSource.ElementID);
//objSource = dia.GetDiagramObjectByID(elSource.ElementID, "");
}
int offsetHorizontal = 0;
int offsetVertical = 0;
// delete comments /* to */
string s0 = DeleteComment(text);
// delete casts
Match match = Regex.Match(s0, @"(\([A-Za-z0-9_*& ]*\))[*&_A-Za-z]+", RegexOptions.Multiline);
while (match.Success)
{
s0 = s0.Replace(match.Groups[1].Value, "");
match = match.NextMatch();
}
// concatenate lines =..;
match = Regex.Match(s0, @"[^=]*(=[^;{}]*)", RegexOptions.Singleline);
while (match.Success)
{
string old = match.Groups[1].Value;
if (!(match.Value.Contains("#")))
{
//if (Regex.IsMatch(old, @"#[\s]*(if|elseif|else)", RegexOptions.Singleline)) continue;
s0 = s0.Replace(match.Groups[1].Value, Regex.Replace(old, "\r\n", ""));
}
match = match.NextMatch();
}
// concatenate lines nnnn(..);
match = Regex.Match(s0, @"[A-Za-z0-9_]+[\s]*\([^;}{]*\)", RegexOptions.Singleline);
while (match.Success)
{
if (!(match.Value.Contains("#")))
{
//if (Regex.IsMatch(old, @"#[\s]*(if|elseif|else)", RegexOptions.Singleline)) continue;
//s0 = s0.Replace(match.Groups[1].Value, Regex.Replace(old, "\r\n", ""));
// check if this is no if(..)
if (match.Value.StartsWith("if", StringComparison.CurrentCulture))
{
}
else s0 = s0.Replace(match.Value, Regex.Replace(match.Value, "\r\n", ""));
}
match = match.NextMatch();
}
// remove empty lines
s0 = Regex.Replace(s0, @"\r\n\s*\r\n", "\r\n");
string[] lines = Regex.Split(s0, "\r\n");
// first line start with an "else"
bool skipFirstLine = false;
// case nnnnn:
string guardString = "";
if (lines.Length > 0)
{
string line0 = lines[0].Trim();
if (line0.StartsWith("else", StringComparison.Ordinal) |
Regex.IsMatch(lines[0], "#[ ]*else"))
{
offsetHorizontal = 300;
guardString = "no";
Match matchElseIf = Regex.Match(line0, @"^else[\s]*if");
if (matchElseIf.Success)
{
offsetHorizontal = 0;
//lines[0] = lines[0].Replace(matchElseIf.Value, "");
}
else
{
skipFirstLine = true;
}
}
}
int lineNumber = -1;
foreach (string s in lines)
{
lineNumber += 1;
var s1 = s.Trim();
// case: of switch case
if (isSwitchCase &
//.........这里部分代码省略.........
示例13: CreateDiagramObjectFromContext
//----------------------------------------------------------------------------------------
// type: "Action", "Activity","Decision", "MergeNode","StateNode"
// extension: "CallOperation" ,"101"=StateNode, Final, "no"= else/no Merge
// comp=yes: Activity with composite Diagram
//----------------------------------------------------------------------------------------
private static DiagramObject CreateDiagramObjectFromContext(Repository rep, string name, string type,
string extension, int offsetHorizental = 0, int offsetVertical = 0, string guardString = "",
Element srcEl = null)
{
int widthPerCharacter = 60;
// filter out linefeed, tab
name = Regex.Replace(name, @"(\n|\r|\t)", "", RegexOptions.Singleline);
if (name.Length > 255)
{
MessageBox.Show($"{type}: '{name}' has more than 255 characters.", @"Name is to long");
return null;
}
Element elSource;
Element elParent = null;
Element elTarget;
string basicType = type;
if (type == "CallOperation") basicType = "Action";
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return null;
rep.SaveDiagram(dia.DiagramID);
// only one diagram object selected as source
if (srcEl == null) elSource = Util.GetElementFromContextObject(rep);
else elSource = srcEl;
if (elSource == null) return null;
var diaObjSource = Util.GetDiagramObjectById(rep, dia, elSource.ElementID);
//diaObjSource = dia.GetDiagramObjectByID(elSource.ElementID, "");
string noValifTypes = "Note, Constraint, Boundary, Text, UMLDiagram, DiagramFrame";
if (noValifTypes.Contains(elSource.Type)) return null;
if (elSource.ParentID != 0)
{
Util.GetDiagramObjectById(rep, dia, elSource.ParentID);
//diaObjParent = dia.GetDiagramObjectByID(elSource.ParentID, "");
}
try
{
if (elSource.ParentID > 0)
{
elParent = rep.GetElementByID(elSource.ParentID);
elTarget = (Element) elParent.Elements.AddNew(name, basicType);
if (basicType == "StateNode") elTarget.Subtype = Convert.ToInt32(extension);
elParent.Elements.Refresh();
}
else
{
var pkg = rep.GetPackageByID(elSource.PackageID);
elTarget = (Element) pkg.Elements.AddNew(name, basicType);
if (basicType == "StateNode") elTarget.Subtype = Convert.ToInt32(extension);
pkg.Elements.Refresh();
}
elTarget.ParentID = elSource.ParentID;
elTarget.Update();
if (basicType == "Activity" & extension.ToLower() == "comp=yes")
{
Diagram actDia = ActivityPar.CreateActivityCompositeDiagram(rep, elTarget);
Util.SetActivityCompositeDiagram(rep, elTarget, actDia.DiagramID.ToString());
//elTarget.
}
}
catch
{
return null;
}
int left = diaObjSource.left + offsetHorizental;
int right = diaObjSource.right + offsetHorizental;
int top = diaObjSource.top + offsetVertical;
int bottom = diaObjSource.bottom + offsetVertical;
int length;
if (basicType == "StateNode")
{
left = left - 10 + (right - left)/2;
right = left + 20;
top = bottom - 20;
bottom = top - 20;
}
if ((basicType == "Decision") | (basicType == "MergeNode"))
{
if (guardString == "no")
{
if (elSource.Type == "Decision") left = left + (right - left) + 200;
else left = left + (right - left) + 50;
bottom = bottom - 5;
}
left = left - 15 + (right - left)/2;
right = left + 30;
//.........这里部分代码省略.........
示例14: DeleteInvisibleUseRealizationDependencies
// ReSharper disable once UnusedMember.Local
static void DeleteInvisibleUseRealizationDependencies(Repository rep)
{
Connector con;
var dia = rep.GetCurrentDiagram();
if (dia == null) return;
if (!rep.GetContextItemType().Equals(ObjectType.otElement)) return;
// only one diagram object selected as source
if (dia.SelectedObjects.Count != 1) return;
rep.SaveDiagram(dia.DiagramID);
var diaObjSource = (DiagramObject) dia.SelectedObjects.GetAt(0);
var elSource = rep.GetElementByID(diaObjSource.ElementID);
var elSourceId = elSource.ElementID;
if (!("Interface Class".Contains(elSource.Type))) return;
// list of all connectorIDs
var lInternalId = new List<int>();
foreach (DiagramLink link in dia.DiagramLinks)
{
con = rep.GetConnectorByID(link.ConnectorID);
if (con.ClientID != elSourceId) continue;
if (!("Usage Realisation".Contains(con.Type))) continue;
lInternalId.Add(con.ConnectorID);
}
for (int i = elSource.Connectors.Count - 1; i >= 0; i = i - 1)
{
con = (Connector) elSource.Connectors.GetAt((short) i);
var conType = con.Type;
if ("Usage Realisation".Contains(conType))
{
// check if target is..
var elTarget = rep.GetElementByID(con.SupplierID);
if (elTarget.Type == "Interface")
{
if (lInternalId.BinarySearch(con.ConnectorID) < 0)
{
elSource.Connectors.DeleteAt((short) i, true);
}
}
}
}
}
示例15: CreateOperationsFromText
private static void CreateOperationsFromText(Repository rep, string txt)
{
Diagram dia = rep.GetCurrentDiagram();
Element el = Util.GetElementFromContextObject(rep);
if (el == null) return;
if (dia != null && dia.SelectedObjects.Count != 1)
{
dia = null;
}
if (dia != null) rep.SaveDiagram(dia.DiagramID);
// delete comment
txt = DeleteComment(txt);
txt = DeleteCurleyBrackets(txt);
txt = txt.Replace(";", " ");
// delete macros
txt = Regex.Replace(txt, @"^[\s]*#[^\n]*\n", "", RegexOptions.Multiline);
string[] lTxt = Regex.Split(txt, @"\)[\s]*\r\n");
for (int i = 0; i < lTxt.Length; i++)
{
txt = lTxt[i].Trim();
if (!txt.Equals(""))
{
if (!txt.EndsWith(")", StringComparison.Ordinal)) txt = txt + ")";
CreateOperationFromText(rep, el, txt);
}
}
if (dia != null) rep.ReloadDiagram(dia.DiagramID);
dia.SelectedObjects.AddNew(el.ElementID.ToString(), el.ObjectType.ToString());
dia.SelectedObjects.Refresh();
}