本文整理汇总了C#中Repository.ReloadDiagram方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.ReloadDiagram方法的具体用法?C# Repository.ReloadDiagram怎么用?C# Repository.ReloadDiagram使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.ReloadDiagram方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
}
示例3: 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());
}
示例4: 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());
}
示例5: CreateTypeDefStructFromText
//.........这里部分代码省略.........
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();
diaObj.ElementID = elTypedef.ElementID;
diaObj.Update();
}
rep.ReloadDiagram(dia.DiagramID);
dia.SelectedObjects.AddNew(elTypedef.ElementID.ToString(), elTypedef.ObjectType.ToString());
dia.SelectedObjects.Refresh();
}
示例6: 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());
//.........这里部分代码省略.........
示例7: 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();
}
示例8: 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);
}
}
示例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: 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();
}
示例11: CreateDiagramObjectFromContext
//.........这里部分代码省略.........
diaObjTarget.Update();
Util.SetSequenceNumber(rep, dia, diaObjTarget, "1");
// position the label:
// LBL=CX=180: length of label
// CY=13: hight of label
// OX=26: x-position of label (relative object)
// CY=13: y-position of label (relative object)
if (basicType == "Decision" & name.Length > 0)
{
if (name.Length > 25) length = 25*widthPerCharacter/10;
else length = name.Length*widthPerCharacter/10;
// string s = "DUID=E2352ABC;LBL=CX=180:CY=13:OX=29:OY=-4:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;;";
string s = "DUID=E2352ABC;LBL=CX=180:CY=13:OX=-" + length +
":OY=-4:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;;";
Util.SetDiagramObjectLabel(rep,
diaObjTarget.ElementID, diaObjTarget.DiagramID, diaObjTarget.InstanceID, s);
}
if (extension == "Comp=no")
{
/* Activity ind diagram */
// place an init
int initLeft = left + ((right - left)/2) - 10;
int initRight = initLeft + 20;
int initTop = top - 25;
int initBottom = initTop - 20;
string initPosition = "l=" + initLeft + ";r=" + initRight + ";t=" + initTop + ";b=" + initBottom + ";";
ActivityPar.CreateInitFinalNode(rep, dia,
elTarget, 100, initPosition);
}
// draw a Control Flow
var con = (Connector) elSource.Connectors.AddNew("", "ControlFlow");
con.SupplierID = elTarget.ElementID;
con.Update();
elSource.Connectors.Refresh();
// set line style LV
foreach (DiagramLink link in dia.DiagramLinks)
{
if (link.ConnectorID == con.ConnectorID)
{
if (guardString != "no")
{
link.Geometry =
"EDGE=3;$LLB=;LLT=;LMT=;LMB=CX=21:CY=13:OX=-20:OY=-19:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LRT=;LRB=;IRHS=;ILHS=;";
}
// in case of switch case line style = LH
string style = "LV";
if ((elSource.Type == "Action" | elSource.Type == "Activity") & guardString == "no") style = "LH";
if (Regex.IsMatch(elSource.Name, @"switch[\s]*\(")) style = "OS";
Util.SetLineStyleForDiagramLink(style, link);
break;
}
}
// set Guard
if (guardString != "")
{
if (guardString == "no" && elSource.Type != "Decision")
{
// mo GUARD
}
else
{
// GUARD
Util.SetConnectorGuard(rep, con.ConnectorID, guardString);
}
}
else if (elSource.Type.Equals("Decision") & !elSource.Name.Trim().Equals(""))
{
if (guardString == "no")
{
Util.SetConnectorGuard(rep, con.ConnectorID, "no");
}
else
{
Util.SetConnectorGuard(rep, con.ConnectorID, "yes");
}
}
// handle subtypes of action
if (type == "CallOperation")
{
Method method = CallOperationAction.GetMethodFromMethodName(rep, extension);
if (method != null)
{
CallOperationAction.CreateCallAction(rep, elTarget, method);
}
}
rep.ReloadDiagram(dia.DiagramID);
// set selected object
dia.SelectedObjects.AddNew(diaObjTarget.ElementID.ToString(), diaObjTarget.ObjectType.ToString());
dia.SelectedObjects.Refresh();
return diaObjTarget;
}