/// <summary> /// Attach mouse listeners to the compartments for the shape. /// This is called once per compartment shape. /// The base method creates the compartments for this shape. /// </summary> public override void EnsureCompartments() { base.EnsureCompartments(); foreach (Compartment compartment in NestedChildShapes.OfType <Compartment>()) { compartment.MouseDown += Compartment_MouseDown; compartment.MouseUp += Compartment_MouseUp; compartment.MouseMove += Compartment_MouseMove; } }
/// <summary> /// Attach mouse listeners to the compartments for the shape amd register that they may have tool tips as well /// This is called once per compartment shape. /// The base method creates the compartments for this shape. /// </summary> public override void EnsureCompartments() { base.EnsureCompartments(); foreach (ElementListCompartment compartment in NestedChildShapes.OfType <ElementListCompartment>()) { compartment.HasItemToolTips = true; compartment.MouseDown += Compartment_MouseDown; compartment.MouseUp += Compartment_MouseUp; compartment.MouseMove += Compartment_MouseMove; } }
private void AddElementsToActiveDiagram(List <ModelElement> newElements) { // TODO: Needs sped up int elementCount = newElements.Count; List <ShapeElement> newShapes = new List <ShapeElement>(); using (Transaction t = Store.TransactionManager.BeginTransaction("adding diagram elements")) { for (int index = 0; index < elementCount; index++) { ModelElement newElement = newElements[index]; StatusDisplay.Show($"Adding element {index + 1} of {elementCount}"); ForceAddShape = true; FixUpAllDiagrams.FixUp(this, newElement); newShapes.Add(newElement.GetFirstShapeElement()); ForceAddShape = false; } t.Commit(); } using (Transaction t = Store.TransactionManager.BeginTransaction("adding diagram links")) { for (int index = 0; index < elementCount; index++) { ModelElement newElement = newElements[index]; StatusDisplay.Show($"Linking {index + 1} of {elementCount}"); // find all element links that are attached to our element where the ends are in the diagram but the link isn't already in the diagram List <ElementLink> elementLinks = Store.GetAll <ElementLink>() .Where(link => link.LinkedElements.Contains(newElement) && link.LinkedElements.All(linkedElement => DisplayedElements.Contains(linkedElement)) && !DisplayedElements.Contains(link)) .ToList(); foreach (ElementLink elementLink in elementLinks) { BinaryLinkShape linkShape = CreateChildShape(elementLink) as BinaryLinkShape; newShapes.Add(linkShape); NestedChildShapes.Add(linkShape); switch (elementLink) { case Association a: linkShape.FromShape = a.Source.GetFirstShapeElement() as NodeShape; linkShape.ToShape = a.Target.GetFirstShapeElement() as NodeShape; break; case Generalization g: linkShape.FromShape = g.Subclass.GetFirstShapeElement() as NodeShape; linkShape.ToShape = g.Superclass.GetFirstShapeElement() as NodeShape; break; } } } AutoLayoutShapeElements(newShapes); t.Commit(); } }