public void addAssociation(ComponentDiagram d) { //d.Association.Add(new KeyValuePair<ConnectionPoint, ConnectionPoint>(d.SourceConnectionPoint, this)); //this.myComponent.setRelatedComponent(d.SourceConnectionPoint.myComponent); //d.SourceConnectionPoint.myComponent.setRelatedComponent(this.myComponent); //d.IsLocking = false; //d.UpdateConnections(); //d.SourceConnectionPoint = null; //d.isAdding = false; }
public Relation(ConnectionType ct, ComponentDiagram parent, Component source, Component target) { this.connectionType = ct; this.Parent = parent; this.Source = source; this.Target = target; relationDescription = new Label(); this.isSelected = false; this.relationLines = new List <Line>(); if (ct == ConnectionType.Mutex) { drawMutexConnection(); } if (ct == ConnectionType.Requires) { drawRequiresConnection(); } }
private void connectionPoint_MouseDown(object sender, MouseButtonEventArgs e) { foreach (ConnectionPoint c in ((Grid)this.Parent).Children.OfType <ConnectionPoint>()) { if (!c.Equals(this)) { c.connectionPoint.Stroke = new SolidColorBrush(Colors.Black); } else { c.myComponent.setSelectedPoint(this); c.connectionPoint.Stroke = new SolidColorBrush(Colors.Red); } } ComponentDiagram d = ((SelectObject)this.MyComponent).getParentDiagram(); if (!d.IsLocking) { d.SourceConnectionPoint = this; } else { if (d.SourceConnectionPoint != null && d.isAdding == true) { if (this.myComponent is Component && d.SourceConnectionPoint.myComponent is Component) { MessageBox.Show("You can not connect a component in another component"); d.IsLocking = false; d.SourceConnectionPoint = null; ComponentDiagram cd = this.MyComponent.getParentDiagram(); cd.invalidOperation = true; return; } if (this.myComponent is Ball && d.SourceConnectionPoint.myComponent is Ball) { MessageBox.Show("You can not connect a interface in another interface"); d.IsLocking = false; d.SourceConnectionPoint = null; ComponentDiagram cd = this.MyComponent.getParentDiagram(); cd.invalidOperation = true; return; } if (this.MyComponent is Component && (d.SourceConnectionPoint.myComponent as Ball).RelatedComponent != null) { MessageBox.Show("You can not connect two components in one interface or socket"); d.IsLocking = false; d.SourceConnectionPoint = null; ComponentDiagram cd = this.MyComponent.getParentDiagram(); cd.invalidOperation = true; return; } if (this.myComponent is Ball) { if ((this.myComponent as Ball).RelatedComponent != null) { MessageBox.Show("You can not connect two components in one interface or socket"); d.IsLocking = false; d.SourceConnectionPoint = null; ComponentDiagram cd = this.MyComponent.getParentDiagram(); cd.invalidOperation = true; return; } } if (this.MyComponent is Component && d.SourceConnectionPoint.MyComponent is Ball) { (this.myComponent as Component).interfaceList.Add(d.SourceConnectionPoint.myComponent as Ball); } addAssociation(d); } else { d.isRemoving = false; d.SourceConnectionPoint = null; d.isAdding = false; d.invalidOperation = false; } } }