本文整理汇总了C#中Repository.GetElementByID方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.GetElementByID方法的具体用法?C# Repository.GetElementByID怎么用?C# Repository.GetElementByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.GetElementByID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertInterface
// ReSharper disable once UnusedMember.Local
static void InsertInterface(Repository rep, Diagram dia, string text)
{
bool isComponent = false;
Package pkg = rep.GetPackageByID(dia.PackageID);
int pos = 0;
// only one diagram object selected as source
if (dia.SelectedObjects.Count != 1) return;
// save selected object
DiagramObject objSelected = null;
if (!(dia == null && dia.SelectedObjects.Count > 0))
{
objSelected = (DiagramObject) dia.SelectedObjects.GetAt(0);
}
rep.SaveDiagram(dia.DiagramID);
var diaObjSource = (DiagramObject) dia.SelectedObjects.GetAt(0);
var elSource = rep.GetElementByID(diaObjSource.ElementID);
isComponent |= elSource.Type == "Component";
// remember selected object
List<Element> ifList = GetInterfacesFromText(rep, pkg, text);
foreach (Element elTarget in ifList)
{
if (elSource.Locked)
{
MessageBox.Show($"Source '{elSource.Name}' is locked", @"Element locked");
continue;
}
if (isComponent)
{
AddPortToComponent(elSource, elTarget);
}
else
{
AddInterfaceToElement(rep, pos, elSource, elTarget, dia, diaObjSource);
}
pos = pos + 1;
}
// visualize ports
if (isComponent)
{
dia.SelectedObjects.AddNew(diaObjSource.ElementID.ToString(), ObjectType.otElement.ToString());
dia.SelectedObjects.Refresh();
ShowEmbeddedElementsGui(rep);
}
// reload selected object
if (objSelected != null)
{
dia.SelectedObjects.AddNew(elSource.ElementID.ToString(), elSource.ObjectType.ToString());
dia.SelectedObjects.Refresh();
}
rep.ReloadDiagram(dia.DiagramID);
dia.SelectedObjects.AddNew(elSource.ElementID.ToString(), elSource.ObjectType.ToString());
dia.SelectedObjects.Refresh();
}
示例2: GenIDL_DependenciesAlreadyGenerated
/**
* Checks that all the definitions this class depends on are already generated
* This includes the base classes as well as any types that appear as
* attributes and are not marked "@Shared"
*
*/
private static bool GenIDL_DependenciesAlreadyGenerated(Repository repository, Element classElem,
TextOutputInterface output, HashSet<long> completedClasses, bool outputReport)
{
//output.OutputTextLine("// GenIDL_DependenciesAlreadyGenerated Checking: " + classElem.Name);
// Check base classes
if (classElem.BaseClasses.Count > 0)
{
Object obj = classElem.BaseClasses.GetAt(0);
Element elem = (Element)obj;
if (!completedClasses.Contains(elem.ElementID))
{
if (outputReport)
{
output.OutputText(" ( \"" + GenIDL_GetFullPackageName(repository, classElem) + "\" , \"" + classElem.Name + "\" )");
output.OutputText(" depends on ( " + GenIDL_GetFullPackageName(repository, elem) + "\" , \"" + elem.Name + "\" )");
output.OutputTextLine(" dependency: baseclass");
}
return false;
}
}
// Check atributes
foreach (EA.Attribute child in classElem.Attributes)
{
if (child.ClassifierID == 0) /* Primitive type */
{
continue;
}
if (!completedClasses.Contains(child.ClassifierID))
{
// Not generated yet. It is only OK if this is by reference
if ( !IsAttributeReference(child) )
{
if (outputReport)
{
Element childTypeElem = repository.GetElementByID(child.ClassifierID);
output.OutputText(" ( \"" + GenIDL_GetFullPackageName(repository, classElem) + "\" , \"" + classElem.Name + "\" )");
output.OutputText(" depends on ( " + GenIDL_GetFullPackageName(repository, childTypeElem) + "\" , \"" + childTypeElem.Name + "\" )");
output.OutputTextLine(" dependency: attribute \"" + child.Name + "\"");
}
return false;
}
}
}
// Check relationships (Aggregations only)
foreach (EA.Connector conn in classElem.Connectors)
{
ConnectorEnd thisElemEnd;
ConnectorEnd referencedElemEnd;
int referencedElemId;
if (classElem.ElementID == conn.ClientID)
{
thisElemEnd = conn.ClientEnd;
referencedElemEnd = conn.SupplierEnd;
referencedElemId = conn.SupplierID;
}
else
{
thisElemEnd = conn.SupplierEnd;
referencedElemEnd = conn.ClientEnd;
referencedElemId = conn.ClientID;
}
if ( (thisElemEnd.Aggregation == 0)
|| (conn.Type.Equals("Aggregation") == false))
{
continue;
}
if (!referencedElemEnd.IsNavigable)
{
continue;
}
if (!completedClasses.Contains(referencedElemId))
{
if (outputReport)
{
Element referencedElem = repository.GetElementByID(referencedElemId);
output.OutputText(" ( \"" + GenIDL_GetFullPackageName(repository, classElem) + "\" , \"" + classElem.Name + "\" )");
output.OutputText(" depends on ( " + GenIDL_GetFullPackageName(repository, referencedElem) + "\" , \"" + referencedElem.Name + "\" )");
output.OutputTextLine(" dependency: aggregation \"" + conn.Name + "\"");
}
return false;
}
}
return true;
}
示例3: GenIDL_Attributes
/* Generate the IDL for an attribute.
* The attribute can appear by itself, a sequence, or an array.
* The determination of this is based on the settings of LowerBound and UpperBound
*
* UpperBound == 0 ==> Unbounded Sequence
* LowerBound == UpperBound == 1 ==> Single member (no Array/Sequence)
* LowerBound == 0 && UpperBound == 1 ==> Optional single member
*
* LowerBound < UpperBound (other values) ==> Bounded Sequence
* LowerBound == UpperBound (other values) == > Array
*
* returns true if it outputs some attribute; otherwise returns false
*/
private static bool GenIDL_Attributes(Repository repository, Element classElem, TextOutputInterface output, int depth)
{
if (classElem.Attributes.Count == 0)
{
return false;
}
foreach (EA.Attribute child in classElem.Attributes)
{
// This does not get the fully qualified type name. We need that to fully resolve
// the type in the IDL...
String typeName;
/* This code was trying to get the fully-qualified name but it throws an exception
*/
if ( child.ClassifierID == 0 ) {
typeName = IDL_NormalizeMemberTypeNameClassiffiedID0(child.Type);
}
else {
Element attributeType = repository.GetElementByID(child.ClassifierID);
Package attributePackage = repository.GetPackageByID(attributeType.PackageID);
typeName = GenIDL_GetFullPackageName(repository, attributeType)
+ IDL_NormalizeMemberTypeName(attributeType.Name);
}
//DEBUG::
if (typeName.Equals("dateTime") )
{
output.OutputTextLine(depth, "//DEBUG: typeName= " + typeName + " classifiedId= " + child.ClassifierID);
}
int lower = 0;
int upper = 0;
try {
lower = Convert.ToInt32(child.LowerBound);
} catch (Exception) {}
try {
upper = Convert.ToInt32(child.UpperBound);
} catch (Exception) { }
int attributeDepth = depth;
String effectiveTypeName = typeName;
String effectiveMemberName = child.Name;
String extraAnnotation = null;
if (upper == 0) // Unbounded sequence
{
//output.OutputText(attributeDepth, "sequence<" + typeName + "> " + child.Name + ";");
effectiveTypeName = "sequence<" + typeName + ">";
if (idlMappingDetail >= IDLMappingDetail.IDL_DETAILS_FULL)
{
output.OutputTextLine(depth, "// Mapping to unbounded sequence because (upper bound == 0)");
}
}
else if (lower == upper)
{
if (upper != 1) // Array
{
effectiveMemberName = child.Name + "[" + child.UpperBound + "]";
if (idlMappingDetail >= IDLMappingDetail.IDL_DETAILS_FULL)
{
output.OutputTextLine(depth, "// Mapping to array because (lower bound == upper bound)");
}
}
}
else if (lower == 0 && upper == 1)
{
// Handle this the same as an @optional annotation
extraAnnotation = "Optional";
if (idlMappingDetail >= IDLMappingDetail.IDL_DETAILS_FULL)
{
output.OutputTextLine(depth, "// Mapping to optional because (lower bound == 0 && upper bound == 1)");
}
}
else // bounded sequence
{
effectiveTypeName = "sequence<" + typeName + "," + child.UpperBound + ">";
if (idlMappingDetail >= IDLMappingDetail.IDL_DETAILS_FULL)
{
output.OutputTextLine(depth, "// Mapping to bounded sequence because (lower bound < upper bound)");
}
}
GenIDL_AttributeWithAnnotations(child, effectiveTypeName, effectiveMemberName, extraAnnotation, output, depth);
output.OutputTextLine();
//.........这里部分代码省略.........
示例4: handleDiagramCreation
public void handleDiagramCreation(Repository repository, int diagramID)
{
try
{
changed = false;
EA.Diagram diagram = repository.GetDiagramByID(diagramID);
ItemCreation itemCreation = new ItemCreation();
itemCreation.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
itemCreation.itemGUID = diagram.DiagramGUID;
itemCreation.elementType = itemTypes.getDiagramType(diagram.DiagramGUID);
itemCreation.author = diagram.Author;
itemCreation.name = diagram.Name;
itemCreation.parentGUID = "0";
if (diagram.ParentID != 0)
{
EA.Element parent = repository.GetElementByID(diagram.ParentID);
if (parent != null)
{
itemCreation.parentGUID = parent.ElementGUID;
}
}
EA.Package package = repository.GetPackageByID(diagram.PackageID);
if (package != null)
{
itemCreation.packageGUID = package.PackageGUID;
}
changeService.saveChange(itemCreation);
}
catch (Exception ex) { }
}
示例5: handleDiagramObjectDeletion
public void handleDiagramObjectDeletion(Repository repository, int elementID)
{
try
{
changed = false;
EA.Element element = repository.GetElementByID(elementID);
EA.Diagram diagram = repository.GetCurrentDiagram();
PropertyChange modelChange = new PropertyChange();
modelChange.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
modelChange.itemGUID = element.ElementGUID;
modelChange.propertyBody = diagram.DiagramGUID;
modelChange.elementType = 700;
modelChange.elementDeleted = 1;
changeService.saveChange(modelChange);
currentDiagramObjectPositions.Remove(element.ElementID);
}
catch (Exception ex) { }
}
示例6: handleElementDeletion
public void handleElementDeletion(Repository repository, int elementID)
{
try
{
changed = false;
EA.Element element = repository.GetElementByID(elementID);
PropertyChange modelChange = new PropertyChange();
modelChange.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
modelChange.itemGUID = element.ElementGUID;
modelChange.elementType = itemTypes.getElementType(element.ElementGUID); ;
modelChange.elementDeleted = 1;
changeService.saveChange(modelChange);
if (element.Type == "UseCase")
{
currentExtensionPoints.Remove(element.ElementGUID);
}
}
catch (Exception ex) { }
}
示例7: handleConnectorCreation
public void handleConnectorCreation(Repository repository, int connectorID)
{
try
{
currentItem = null;
currentDiagram = null;
changed = false;
EA.Connector connector = repository.GetConnectorByID(connectorID);
currentConnector = connector;
ItemCreation itemCreation = new ItemCreation();
itemCreation.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
itemCreation.itemGUID = connector.ConnectorGUID;
itemCreation.elementType = itemTypes.getConnectorType(connector.ConnectorGUID);
itemCreation.name = connector.Name;
itemCreation.srcGUID = repository.GetElementByID(connector.ClientID).ElementGUID;
itemCreation.targetGUID = repository.GetElementByID(connector.SupplierID).ElementGUID;
changeService.saveChange(itemCreation);
}
catch (Exception ex) { }
}
示例8: InsertDiagramElementAndConnect
/// <summary>insertDiagramElement insert a diagram element and connects it to all selected diagramobject
/// <para>type: type of the node like "Action", Activity", "MergeNode"</para>
/// MergeNode may have the subType "no" to draw a transition with a "no" guard.
/// <para>subTyp: subType of the node:
/// StateNode: 100=ActivityInitial, 101 ActivityFinal
/// </para>guardString of the connector "","yes","no",..
/// if "yes" or "" it will locate the node under the last selected element
/// </summary>
// ReSharper disable once UnusedMember.Global
public static void InsertDiagramElementAndConnect(Repository rep, string type, string subType,
string guardString = "")
{
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return;
if (dia.Type != "Activity") return;
int count = dia.SelectedObjects.Count;
if (count == 0) return;
rep.SaveDiagram(dia.DiagramID);
var oldCollection = new List<DiagramObject>();
// get context element (last selected element)
Element originalSrcEl = Util.GetElementFromContextObject(rep);
if (originalSrcEl == null) return;
int originalSrcId = originalSrcEl.ElementID;
for (int i = count - 1; i > -1; i = i - 1)
{
oldCollection.Add((DiagramObject) dia.SelectedObjects.GetAt((short) i));
// keep last selected element
//if (i > 0) dia.SelectedObjects.DeleteAt((short)i, true);
}
Util.GetDiagramObjectById(rep, dia, originalSrcId);
//EA.DiagramObject originalSrcObj = dia.GetDiagramObjectByID(originalSrcID, "");
DiagramObject trgObj = CreateDiagramObjectFromContext(rep, "", type, subType, 0, 0, guardString,
originalSrcEl);
Element trgtEl = rep.GetElementByID(trgObj.ElementID);
// if connection to more than one element make sure the new element is on the deepest position
int offset = 50;
if (guardString == "yes") offset = 0;
int bottom = 1000;
int diff = trgObj.top - trgObj.bottom;
foreach (DiagramObject diaObj in oldCollection)
{
Element srcEl = rep.GetElementByID(diaObj.ElementID);
// don't connect two times
if (originalSrcId != diaObj.ElementID)
{
var con = (Connector) srcEl.Connectors.AddNew("", "ControlFlow");
con.SupplierID = trgObj.ElementID;
if (type == "MergeNode" && guardString == "no" && srcEl.Type == "Decision")
con.TransitionGuard = "no";
con.Update();
srcEl.Connectors.Refresh();
dia.DiagramLinks.Refresh();
//trgtEl.Connectors.Refresh();
// set line style
string style = "LV";
if ((srcEl.Type == "Action" | srcEl.Type == "Activity") & guardString == "no") style = "LH";
var link = GetDiagramLinkForConnector(dia, con.ConnectorID);
if (link != null) Util.SetLineStyleForDiagramLink(style, link);
}
// set new high/bottom_Position
var srcObj = Util.GetDiagramObjectById(rep, dia, srcEl.ElementID);
//srcObj = dia.GetDiagramObjectByID(srcEl.ElementID, "");
if (srcObj.bottom < bottom) bottom = srcObj.bottom;
}
if (oldCollection.Count > 1)
{
// set bottom/high of target
trgObj.top = bottom + diff - offset;
trgObj.bottom = bottom - offset;
trgObj.Sequence = 1;
trgObj.Update();
// final
if (subType == "101" && trgtEl.ParentID > 0)
{
Element parEl = rep.GetElementByID(trgtEl.ParentID);
if (parEl.Type == "Activity")
{
DiagramObject parObj = Util.GetDiagramObjectById(rep, dia, parEl.ElementID);
//EA.DiagramObject parObj = dia.GetDiagramObjectByID(parEl.ElementID, "");
if (parObj != null)
{
parObj.bottom = trgObj.bottom - 30;
parObj.Update();
}
}
}
}
rep.ReloadDiagram(dia.DiagramID);
dia.SelectedObjects.AddNew(trgtEl.ElementID.ToString(), trgtEl.ObjectType.ToString());
//.........这里部分代码省略.........
示例9: 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());
}
示例10: CreateAttributesFromText
public static void CreateAttributesFromText(Repository rep, string txt)
{
DiagramObject objSelected = null;
Element el = Util.GetElementFromContextObject(rep);
Diagram dia = rep.GetCurrentDiagram();
if (!(dia == null && dia.SelectedObjects.Count > 0))
{
objSelected = (DiagramObject) dia.SelectedObjects.GetAt(0);
}
if (el == null)
{
MessageBox.Show(@"No Element selected, probably nothing or an attribute / operation");
return;
}
if (el.Type.Equals("Class") | el.Type.Equals("Interface")) CreateClassAttributesFromText(rep, el, txt);
if (el.Type.Equals("Enumeration")) CreateEnumerationAttributesFromText(rep, el, txt);
if (objSelected != null)
{
el = rep.GetElementByID(objSelected.ElementID);
dia.SelectedObjects.AddNew(el.ElementID.ToString(), el.ObjectType.ToString());
dia.SelectedObjects.Refresh();
}
}
示例11: UpdateTypeName
private static bool UpdateTypeName(Repository rep, ref int classifierId, ref string parName, ref string parType)
{
// no classifier defined
// check if type is correct
Element el = null;
if (!classifierId.Equals(0))
{
try
{
el = rep.GetElementByID(classifierId);
if (el.Name != parType) el = null;
}
// empty catch, el = null
#pragma warning disable RECS0022
catch //(Exception e)
{
// ignored
}
#pragma warning restore RECS0022
}
if (el == null)
{
// get the type
// find type from type_name
classifierId = Util.GetTypeId(rep, parType);
// type not defined
if (classifierId == 0)
{
if (parType.EndsWith("*", StringComparison.Ordinal))
{
parType = parType.Substring(0, parType.Length - 1);
parName = "*" + parName;
}
if (parType.EndsWith("*", StringComparison.Ordinal))
{
parType = parType.Substring(0, parType.Length - 1);
parName = "*" + parName;
}
classifierId = Util.GetTypeId(rep, parType);
}
if (classifierId != 0)
{
return true;
}
parType = "";
return true;
}
return false;
}
示例12: CreateTypeDefStructFromText
static void CreateTypeDefStructFromText(Repository rep, Diagram dia, Package pkg, Element el, string txt)
{
Element elTypedef = null;
// delete comment
txt = DeleteComment(txt);
bool update = false;
bool isStruct = true;
string elType = "Class";
// find start
string regex = @"[\s]*typedef[\s]+(struct|enum)[\s]*([^{]*){";
Match match = Regex.Match(txt, regex);
if (!match.Success) return;
if (txt.Contains(" enum"))
{
elType = "Enumeration";
isStruct = false;
}
txt = txt.Replace(match.Value, "");
// find name
regex = @"}[\s]*([^;]*);";
match = Regex.Match(txt, regex);
if (!match.Success) return;
string name = match.Groups[1].Value.Trim();
if (name == "") return;
txt = txt.Remove(match.Index, match.Length);
// check if typedef already exists
int targetId = Util.GetTypeId(rep, name);
if (targetId != 0)
{
elTypedef = rep.GetElementByID(targetId);
update = true;
for (int i = elTypedef.Attributes.Count - 1; i > -1; i = i - 1)
{
elTypedef.Attributes.DeleteAt((short) i, true);
}
}
// create typedef
if (update == false)
{
if (el != null)
{
// create class below element
if ("Interface Class Component".Contains(el.Type))
{
elTypedef = (Element) el.Elements.AddNew(name, elType);
el.Elements.Refresh();
}
else
{
MessageBox.Show(@"Can't create element below selected Element");
}
}
else // create class in package
{
elTypedef = (Element) pkg.Elements.AddNew(name, elType);
pkg.Elements.Refresh();
}
}
if (isStruct)
{
elTypedef.Stereotype = @"struct";
EA.TaggedValue tag = TaggedValue.AddTaggedValue(elTypedef, "typedef");
tag.Value = "true";
tag.Update();
}
if (update == false)
{
elTypedef.Name = name;
elTypedef.Update();
}
// add elements
if (isStruct) CreateClassAttributesFromText(rep, elTypedef, txt);
else CreateEnumerationAttributesFromText(rep, elTypedef, txt);
if (update)
{
rep.RefreshModelView(elTypedef.PackageID);
rep.ShowInProjectView(elTypedef);
}
else
{
// put diagram object on diagram
int left = 0;
int right = left + 200;
int top = 0;
int bottom = top + 100;
//int right = diaObj.right + 2 * (diaObj.right - diaObj.left);
rep.SaveDiagram(dia.DiagramID);
string position = "l=" + left + ";r=" + right + ";t=" + top + ";b=" + bottom + ";";
var diaObj = (DiagramObject) dia.DiagramObjects.AddNew(position, "");
dia.DiagramObjects.Refresh();
//.........这里部分代码省略.........
示例13: LocateType
/// <summary>
/// Locate the type for Connector, Method, Attribute, Diagram, Element, Package
/// </summary>
/// <param name="rep"></param>
public static void LocateType(Repository rep)
{
ObjectType oType = rep.GetContextItemType();
Element el;
int id;
string triggerGuid;
// connector
// links to trigger
switch (oType)
{
case ObjectType.otConnector:
var con = (Connector) rep.GetContextObject();
triggerGuid = Util.GetTrigger(rep, con.ConnectorGUID);
if (triggerGuid.StartsWith("{", StringComparison.Ordinal) &&
triggerGuid.EndsWith("}", StringComparison.Ordinal))
{
Element trigger = rep.GetElementByGuid(triggerGuid);
if (trigger != null) rep.ShowInProjectView(trigger);
}
else
{
SelectBehaviorFromConnector(rep, con, DisplayMode.Method);
}
break;
case ObjectType.otMethod:
var m = (Method) rep.GetContextObject();
if (m.ClassifierID != "")
{
id = Convert.ToInt32(m.ClassifierID);
// get type
if (id > 0)
{
el = rep.GetElementByID(id);
rep.ShowInProjectView(el);
}
}
break;
case ObjectType.otAttribute:
var attr = (EA.Attribute) rep.GetContextObject();
id = attr.ClassifierID;
// get type
if (id > 0)
{
el = rep.GetElementByID(attr.ClassifierID);
if (el.Type.Equals("Package"))
{
Package pkg = rep.GetPackageByID(Convert.ToInt32(el.MiscData[0]));
rep.ShowInProjectView(pkg);
}
else
{
rep.ShowInProjectView(el);
}
}
break;
// Locate Diagram (e.g. from Search Window)
case ObjectType.otDiagram:
var d = (Diagram) rep.GetContextObject();
rep.ShowInProjectView(d);
break;
case ObjectType.otElement:
el = (Element) rep.GetContextObject();
if (el.ClassfierID > 0)
{
el = rep.GetElementByID(el.ClassfierID);
rep.ShowInProjectView(el);
}
else
{
//MiscData(0) PDATA1,PDATA2,
// pdata1 Id for parts, UmlElement
// object_id for text with Hyper link to diagram
// locate text or frame
if (LocateTextOrFrame(rep, el)) return;
string guid = el.MiscData[0];
if (guid.EndsWith("}", StringComparison.Ordinal))
{
el = rep.GetElementByGuid(guid);
rep.ShowInProjectView(el);
}
else
{
if (el.Type.Equals("Action"))
{
foreach (CustomProperty custproperty in el.CustomProperties)
{
if (custproperty.Name.Equals("kind") && custproperty.Value.Contains("AcceptEvent"))
//.........这里部分代码省略.........
示例14: 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);
}
}
示例15: 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);
}