public PortPainter FindPort(Guid portGuid) { foreach (CompositionInstance composition in Compositions) { foreach (ComponentInstance compInstance in composition.ComponentInstances) { PortPainter portPainter = compInstance.Ports.FindObject(portGuid); if (portPainter != null) { return(portPainter); } } PortPainter externalPortPainter = composition.Ports.FindObject(portGuid); if (externalPortPainter != null) { return(externalPortPainter); } PortPainter internalPortPainter = composition.InternalPortsInstances.FindObject(portGuid); if (internalPortPainter != null) { return(internalPortPainter); } } return(null); }
public PortPainter CreatePortPainter(PortDefenition portDef, double X, double Y) { String portName = NameUtils.GetInterfaceName(portDef); PortPainter portPainter = new PortPainter(portDef.GUID, X, Y, portName); return(portPainter); }
public void DeletePort(PortPainter portPainter) { if (portPainter == null) { return; } foreach (CompositionInstance composition in Compositions) { List <PortConnection> connectionPainters = composition.Connections.FindConnections(portPainter); if (connectionPainters.Count > 0) { foreach (PortConnection connection in connectionPainters) { composition.Connections.Remove(connection); } } } IElementWithPorts componentPainter = FindComponentInstanceByPortGuid(portPainter.GUID); if (componentPainter != null) { componentPainter.Ports.Remove(portPainter); } }
public void Port_DeleteButton_Click(object sender, RoutedEventArgs e) { int index = portsGrid.SelectedIndex; if ((index < portsGrid.Items.Count) && (index >= 0)) { PortDefenition portDef = portsGrid.Items[index] as PortDefenition; bool delete = MessageUtilities.AskToDelete("Do you want to delete " + portDef.Name + "?"); if (delete == true) { AutosarApplication.GetInstance().DeletePort(composition.GetInternalPortPainter(portDef)); AutosarApplication.GetInstance().DeletePort(composition.GetExternalPortPainter(portDef)); PortPainter internalPort = composition.GetInternalPortPainter(portDef); if (internalPort != null) { composition.InternalPortsInstances.Remove(internalPort); } PortPainter externalPort = composition.GetExternalPortPainter(portDef); if (externalPort != null) { composition.Ports.Remove(externalPort); } composition.PortsDefenitions.Remove(portDef); tree.UpdateAutosarTreeView(tree.SelectedItem); UpdatePortsGrid(); } } }
public void Viewport_MouseDown(MouseButtonEventArgs e, Point sceneCursorPosition) { if (e.LeftButton == MouseButtonState.Pressed) { /* Add Connection Line command started */ if (this.AddConnectionLineActive == true) { Object selectedObject = null; bool clicked; clicked = AutosarApplication.GetInstance().ActiveComposition.GetClickedObject(sceneCursorPosition, out selectedObject); /* if we check in main composition */ if (!clicked) { CompositionInstance mainComposition = AutosarApplication.GetInstance().Compositions.GetMainComposition(); foreach (CompositionInstance composition in AutosarApplication.GetInstance().Compositions) { if (!composition.Equals(mainComposition)) { clicked = composition.IsClicked(sceneCursorPosition, out selectedObject); if (clicked == true) { break; } } } } if (clicked == true) { /* Check that PortPainter has been selected first */ if (selectedObject is PortPainter) { firstPort = selectedObject as PortPainter; connectionPainter = PortConnectionFabric.GetInstance().CreatePortConnection(); connectionPainter.Port1 = firstPort; connectionPainter.SecondPoint = sceneCursorPosition; leftMouseDown = true; return; } else { AddConnectionLineActive = false; } } else { AddConnectionLineActive = false; } } } }
public PortPainter GetOppositePort(PortPainter port) { if (port == Port1) { return(Port2); } else { return(Port1); } }
public bool CouldPortsBeAssigned(PortPainter port1, PortPainter port2) { /* Ports shall be different */ if (port1 == port2) { return(false); } /* ports shall have different parent */ IElementWithPorts component1 = AutosarApplication.GetInstance().FindComponentInstanceByPort(port1); IElementWithPorts component2 = AutosarApplication.GetInstance().FindComponentInstanceByPort(port2); if ((component1 == component2) || (component1 == null) || (component2 == null)) { return(false); } /* Ports shall have the same interfaces */ PortDefenition portDef1 = AutosarApplication.GetInstance().GetPortDefenition(port1.PortDefenitionGuid); PortDefenition portDef2 = AutosarApplication.GetInstance().GetPortDefenition(port2.PortDefenitionGuid); if (!portDef1.InterfaceGUID.Equals(portDef2.InterfaceGUID)) { return(false); } if (!port1.IsDelegatePort && !port2.IsDelegatePort) { /* Another port shall be the correspondent type */ bool check = (portDef1.PortType == PortType.Client) && (portDef2.PortType == PortType.Server); check |= (portDef1.PortType == PortType.Server) && (portDef2.PortType == PortType.Client); check |= (portDef1.PortType == PortType.Receiver) && (portDef2.PortType == PortType.Sender); check |= (portDef1.PortType == PortType.Sender) && (portDef2.PortType == PortType.Receiver); if (!check) { return(false); } } else /* One of the ports is delegate */ { /* Port shall have the same type */ bool check = (portDef1.PortType == portDef2.PortType); if (!check) { return(false); } } return(true); }
public List <PortConnection> FindConnections(PortPainter portPainter) { List <PortConnection> portConnections = new List <PortConnection>(); foreach (PortConnection connectionPainter in this) { if ((connectionPainter.Port1 == portPainter) || (connectionPainter.Port2 == portPainter)) { portConnections.Add(connectionPainter); } } return(portConnections); }
public void UpdatePortsInComponentInstances() { /* Remove unexists port in defenition */ foreach (CompositionInstance composition in Compositions) { foreach (ComponentInstance compInstance in composition.ComponentInstances) { ComponentDefenition compDefenition = compInstance.ComponentDefenition; for (int i = compInstance.Ports.Count - 1; i >= 0; i--) { PortPainter portPainter = compInstance.Ports[i]; PortDefenition portDefenition = compDefenition.Ports.FindObject(portPainter.PortDefenitionGuid); if (portDefenition == null) { DeletePort(portPainter); } } } } /* Add new or missing ports */ foreach (CompositionInstance composition in Compositions) { foreach (ComponentInstance compInstance in composition.ComponentInstances) { ComponentDefenition compDefenition = compInstance.ComponentDefenition; foreach (PortDefenition portDef in compDefenition.Ports) { bool find = false; foreach (PortPainter portPainter in compInstance.Ports) { if (portPainter.PortDefenition.Equals(portDef)) { find = true; break; } } if (!find) { double x = compInstance.Painter.Left - PortPainter.DefaultWidth / 2.0; double y = (compInstance.Painter.Top + compInstance.Painter.Bottom) / 2; PortPainter portPainter = ComponentFabric.GetInstance().CreatePortPainter(portDef, x, y); compInstance.Ports.Add(portPainter); } } } } }
/* Search if this port has been already used in other connection */ bool IsThisPointConnectionExists(IElementWithPorts component, PortPainter port) { foreach (PortConnection connection in this) { if ((connection.Component1 == component) && (connection.Port1 == port)) { return(true); } if ((connection.Component2 == component) && (connection.Port2 == port)) { return(true); } } return(false); }
public PortsConnectionsList GetPortConnections(PortPainter portPainter) { PortsConnectionsList portConnection = new PortsConnectionsList(); foreach (CompositionInstance composition in Compositions) { foreach (PortConnection connection in composition.Connections) { if (connection.PortPainter1Guid.Equals(portPainter.GUID) || connection.PortPainter2Guid.Equals(portPainter.GUID)) { portConnection.Add(connection); } } } return(portConnection); }
public void AddPort(PortDefenition newPortDefenition) { PortsDefenitions.Add(newPortDefenition); PortPainter externalPort = new PortPainter(newPortDefenition.GUID, Painter.Left - PortPainter.DefaultWidth / 2.0, Painter.Top + 25, newPortDefenition.Name); externalPort.IsDelegatePort = false; Ports.Add(externalPort); PortPainter internalPort = new PortPainter(newPortDefenition.GUID, 0, 0, newPortDefenition.Name); internalPort.IsDelegatePort = true; InternalPortsInstances.Add(internalPort); Ports.DoSort(); InternalPortsInstances.DoSort(); }
public void Viewport_MouseLeftButtonUp(Point sceneCoordinates) { /* Add Connection Line command started */ if (this.AddConnectionLineActive == true) { Object newSelectedObject; bool clicked = AutosarApplication.GetInstance().ActiveComposition.GetClickedObject(sceneCoordinates, out newSelectedObject); /* if we check in main composition */ if (!clicked) { CompositionInstance mainComposition = AutosarApplication.GetInstance().Compositions.GetMainComposition(); foreach (CompositionInstance composition in AutosarApplication.GetInstance().Compositions) { if (!composition.Equals(mainComposition)) { clicked = composition.IsClicked(sceneCoordinates, out newSelectedObject); if (clicked) { break; } } } } if (newSelectedObject is PortPainter) { PortPainter startPort = connectionPainter.Port1; PortPainter endPort = newSelectedObject as PortPainter; /* Check that we can assign another port to this */ if (CouldPortsBeAssigned(startPort, endPort)) { connectionPainter.Port2 = endPort; connectionPainter.UpdateLines(); connectionPainter.UpdateName(); CompositionInstance currentComposition = AutosarApplication.GetInstance().ActiveComposition; currentComposition.Connections.AddConnection(connectionPainter); connectionPainter = null; treeView.UpdateAutosarTreeView(null); } } AddConnectionLineActive = false; } leftMouseDown = false; }
public Boolean Viewport_MouseMove(Point sceneCoordinates, MouseEventArgs e) { Boolean needRedraw = false; if (e.LeftButton == MouseButtonState.Pressed) { if (SelectedObject != null) { if (leftMouseDown) { double translateX = (sceneCoordinates.X - previousPosition.X); double translateY = (sceneCoordinates.Y - previousPosition.Y); if (SelectedObject is ResizableRectangleElement) { ResizableRectangleElement componentPainter = (ResizableRectangleElement)SelectedObject; componentPainter.Translate(translateX, translateY); AutosarApplication.GetInstance().ActiveComposition.UpdateConnections(); needRedraw = true; } else if (SelectedObject is AnchorPoint) { AnchorPoint anchor = (AnchorPoint)SelectedObject; anchor.Move(translateX, translateY); AutosarApplication.GetInstance().ActiveComposition.UpdateConnections(); needRedraw = true; } else if (SelectedObject is PortPainter) { PortPainter portPainter = (PortPainter)SelectedObject; TranslatePortPainter(portPainter, sceneCoordinates, translateX, translateY); AutosarApplication.GetInstance().ActiveComposition.UpdateConnections(); needRedraw = true; } } } previousPosition = sceneCoordinates; } return(needRedraw); }
public void GetOppositePortAndComponent(PortPainter portPainter, out ComponentInstance oppositeComponent, out PortPainter oppositePort) { oppositeComponent = null; oppositePort = null; if (portPainter.PortDefenition.InterfaceName == "isrDesiredForce") { } PortsConnectionsList portConnections = GetPortConnections(portPainter); if (portConnections.Count != 0) { oppositePort = portConnections[0].GetOppositePort(portPainter); if (oppositePort != null) { IElementWithPorts elem = FindComponentInstanceByPort(oppositePort); if (elem is ComponentInstance) { /* No problem just return the component*/ oppositeComponent = elem as ComponentInstance; } /* the port belongs to the composition */ else if (elem is CompositionInstance) { CompositionInstance composition = elem as CompositionInstance; PortPainter middlePort; /* Is it composition's external port?*/ int externalPortIndex = composition.Ports.IndexOf(oppositePort); if (externalPortIndex >= 0) { /* get internal index */ middlePort = composition.InternalPortsInstances[externalPortIndex]; } else /* It was internal port */ { /* get external port */ int internalPortIndex = composition.InternalPortsInstances.IndexOf(oppositePort); middlePort = composition.Ports[internalPortIndex]; } /* Get middle port connections */ portConnections = GetPortConnections(middlePort); if (portConnections.Count > 0) { PortConnection connection = portConnections[0]; oppositePort = connection.GetOppositePort(middlePort); Object oppositeObject = FindComponentInstanceByPort(oppositePort); /* Check if another port belongs to composition */ if (oppositeObject is CompositionInstance) { CompositionInstance oppositeComposition = oppositeObject as CompositionInstance; PortPainter middlePort2; int externalPortIndex2 = oppositeComposition.Ports.IndexOf(oppositePort); /* get internal index */ middlePort2 = oppositeComposition.InternalPortsInstances[externalPortIndex2]; /* Get middle port connections */ PortsConnectionsList portConnections2 = GetPortConnections(middlePort2); if (portConnections2.Count > 0) { PortConnection connection3 = portConnections2[0]; oppositePort = connection3.GetOppositePort(middlePort2); oppositeComponent = FindComponentInstanceByPort(oppositePort) as ComponentInstance; } } else { oppositeComponent = oppositeObject as ComponentInstance; } } } } } }
public IElementWithPorts FindComponentInstanceByPort(PortPainter portPainter) { return(FindComponentInstanceByPortGuid(portPainter.GUID)); }
public void EndConnection() { AddConnectionLineActive = false; firstPort = null; leftMouseDown = false; }
void GenerateRteCallPortFieldFunction(StreamWriter writer, ComponentDefenition compDef, PortDefenition port, ClientServerOperation operation) { String returnValue = Properties.Resources.STD_RETURN_TYPE; String RteFuncName = RteFunctionsGenerator.Generate_RteCall_ConnectionGroup_FunctionName(compDef, port, operation); String fieldVariable = RteFunctionsGenerator.GenerateClientServerInterfaceArguments(operation, compDef.MultipleInstantiation); writer.WriteLine(returnValue + RteFuncName + fieldVariable); writer.WriteLine("{"); if (!compDef.MultipleInstantiation) //single instantiation component { ComponentInstancesList components = AutosarApplication.GetInstance().GetComponentInstanceByDefenition(compDef); if (components.Count > 0) { ComponentInstance compInstance = components[0]; PortPainter portPainter = compInstance.Ports.FindPortByItsDefenition(port); ComponentInstance oppositCompInstance; PortPainter oppositePort; AutosarApplication.GetInstance().GetOppositePortAndComponent(portPainter, out oppositCompInstance, out oppositePort); if (oppositCompInstance != null) { String functionName = RteFunctionsGenerator.Generate_RteCall_ConnectionGroup_FunctionName(oppositCompInstance.ComponentDefenition, oppositePort.PortDefenition, operation); String arguments = RteFunctionsGenerator.Generate_ClientServerPort_Arguments(oppositCompInstance, operation, oppositCompInstance.ComponentDefenition.MultipleInstantiation); writer.WriteLine(" return " + functionName + arguments + ";"); } else { writer.WriteLine(" return " + Properties.Resources.RTE_E_UNCONNECTED + ";"); } } } else //multiple instantiation component { ComponentInstancesList components = AutosarApplication.GetInstance().GetComponentInstanceByDefenition(compDef); if (components.Count > 0) { writer.WriteLine(" switch(((" + compDef.Name + "*)" + "instance)->index)"); writer.WriteLine(" {"); for (int i = 0; i < components.Count; i++) { ComponentInstance compInstance = components[i]; PortPainter portPainter = compInstance.Ports.FindPortByItsDefenition(port); ComponentInstance oppositCompInstance; PortPainter oppositePort; AutosarApplication.GetInstance().GetOppositePortAndComponent(portPainter, out oppositCompInstance, out oppositePort); writer.WriteLine(" case " + i.ToString() + ": "); writer.WriteLine(" {"); if (oppositCompInstance != null) { String functionName = RteFunctionsGenerator.Generate_RteCall_ConnectionGroup_FunctionName(oppositCompInstance.ComponentDefenition, oppositePort.PortDefenition, operation); String arguments = RteFunctionsGenerator.Generate_ClientServerPort_Arguments(oppositCompInstance, operation, oppositCompInstance.ComponentDefenition.MultipleInstantiation); writer.WriteLine(" return " + functionName + arguments + ";"); } else { writer.WriteLine(" return " + Properties.Resources.RTE_E_UNCONNECTED + ";"); } writer.WriteLine(" }"); } writer.WriteLine(" }"); } writer.WriteLine(" return " + Properties.Resources.RTE_E_UNCONNECTED + ";"); } writer.WriteLine("}"); writer.WriteLine(""); }
void GenerateRteReadPortFieldFunction(StreamWriter writer, ComponentDefenition compDef, PortDefenition port, SenderReceiverInterfaceField field) { String returnValue = Properties.Resources.STD_RETURN_TYPE; String RteFuncName = RteFunctionsGenerator.GenerateReadWriteConnectionFunctionName(port, field); String fieldVariable = RteFunctionsGenerator.GenerateSenderReceiverInterfaceArguments(field, port.PortType, compDef.MultipleInstantiation); writer.WriteLine(returnValue + RteFuncName + fieldVariable); writer.WriteLine("{"); if (!compDef.MultipleInstantiation) //single instantiation component { ComponentInstancesList components = AutosarApplication.GetInstance().GetComponentInstanceByDefenition(compDef); if (components.Count > 0) { /* At least one component exists at this step */ ComponentInstance compInstance = components[0]; PortPainter portPainter = compInstance.Ports.FindPortByItsDefenition(port); ComponentInstance oppositCompInstance; PortPainter oppositePort; AutosarApplication.GetInstance().GetOppositePortAndComponent(portPainter, out oppositCompInstance, out oppositePort); if (oppositCompInstance != null) { String copyFromField = RteFunctionsGenerator.GenerateRteWriteFieldInComponentDefenitionStruct(oppositePort.PortDefenition, field); String oppositeCompName = RteFunctionsGenerator.GenerateComponentName(oppositCompInstance.Name); writer.WriteLine(" memcpy(" + field.Name + ", " + "&" + oppositeCompName + "." + copyFromField + ", sizeof(" + field.DataTypeName + "));"); writer.WriteLine(" return " + Properties.Resources.RTE_E_OK + ";"); } else { writer.WriteLine(" memset(" + field.Name + ", " + "0, sizeof(" + field.DataTypeName + "));"); writer.WriteLine(" return " + Properties.Resources.RTE_E_UNCONNECTED + ";"); } } } else //multiple instantiation component { ComponentInstancesList components = AutosarApplication.GetInstance().GetComponentInstanceByDefenition(compDef); if (components.Count > 0) { writer.WriteLine(" switch(((" + compDef.Name + "*)" + "instance)->index)"); writer.WriteLine(" {"); for (int i = 0; i < components.Count; i++) { ComponentInstance compInstance = components[i]; PortPainter portPainter = compInstance.Ports.FindPortByItsDefenition(port); ComponentInstance oppositCompInstance; PortPainter oppositePort; AutosarApplication.GetInstance().GetOppositePortAndComponent(portPainter, out oppositCompInstance, out oppositePort); writer.WriteLine(" case " + i.ToString() + ": "); writer.WriteLine(" {"); if (oppositCompInstance != null) { String copyFromField = RteFunctionsGenerator.GenerateRteWriteFieldInComponentDefenitionStruct(oppositePort.PortDefenition, field); String oppositeCompName = RteFunctionsGenerator.GenerateComponentName(oppositCompInstance.Name); writer.WriteLine(" memcpy(" + field.Name + ", " + "&" + oppositeCompName + "." + copyFromField + ", sizeof(" + field.DataTypeName + "));"); writer.WriteLine(" return " + Properties.Resources.RTE_E_OK + ";"); } else { writer.WriteLine(" memset(" + field.Name + ", " + "0, sizeof(" + field.DataTypeName + "));"); writer.WriteLine(" return " + Properties.Resources.RTE_E_UNCONNECTED + ";"); } writer.WriteLine(" }"); } writer.WriteLine(" }"); } writer.WriteLine(" return " + Properties.Resources.RTE_E_UNCONNECTED + ";"); } writer.WriteLine("}"); writer.WriteLine(""); }
void GenerateStaticVariablesForSenderPortsWithoutMultipleInstantiation(StreamWriter writer, PortPainter port, SenderReceiverInterfaceField field) { /* Declare variable and its default value */ IElementWithPorts compInst = AutosarApplication.GetInstance().FindComponentInstanceByPortGuid(port.GUID); String staticVariableName = RteFunctionsGenerator.GenerateRte_Component_SRInterface_Name(compInst.Name, port.Name, field); if (!field.IsPointer) { writer.Write("static " + field.DataTypeName + " " + staticVariableName + " ="); writer.Write(GenerateRteComponentSenderReceiverInterfaceField_DefaultValue(compInst.Name, port.Name, field)); } else { writer.Write("static " + field.DataTypeName + "* " + staticVariableName + " = 0"); } writer.WriteLine(";"); writer.WriteLine(""); }
public PortPainter GetExternalPortPainter(PortDefenition portDef) { PortPainter portPainter = base.GetPort(portDef); return(portPainter); }
public PortDefenition FindPortDefenition(PortPainter portPainter) { return(FindPortDefenition(portPainter.PortDefenitionGuid)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null) { if (value is ComponentInstance) { //var image = "../../Images/icons/tree/Component.png"; var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Component.png"; return(new BitmapImage(new Uri(image))); /* return new BitmapImage(string.Format( * "pack://application:,,,/{0};component/Images/logo.ico", * Path.GetFileNameWithoutExtension(Application.ResourceAssembly.Location)));*/ } else if (value is PortPainter) { PortPainter portPainter = value as PortPainter; if (portPainter.PortType == PortType.Server) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\ports\\ServerPort.png"; return(new BitmapImage(new Uri(image))); } if (portPainter.PortType == PortType.Client) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\ports\\ClientPort.png"; return(new BitmapImage(new Uri(image))); } if (portPainter.PortType == PortType.Receiver) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\ports\\ReceiverPort.png"; return(new BitmapImage(new Uri(image))); } if (portPainter.PortType == PortType.Sender) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\ports\\TransmitterPort.png"; return(new BitmapImage(new Uri(image))); } } else if (value is PortDefenition) { PortDefenition portDefenition = value as PortDefenition; if (portDefenition.PortType == PortType.Server) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\ports\\ServerPort.png"; return(new BitmapImage(new Uri(image))); } if (portDefenition.PortType == PortType.Client) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\ports\\ClientPort.png"; return(new BitmapImage(new Uri(image))); } if (portDefenition.PortType == PortType.Receiver) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\ports\\ReceiverPort.png"; return(new BitmapImage(new Uri(image))); } if (portDefenition.PortType == PortType.Sender) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\ports\\TransmitterPort.png"; return(new BitmapImage(new Uri(image))); } } else if (value is PortConnection) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Connection.png"; return(new BitmapImage(new Uri(image))); } if (value is ComplexDataType) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\composite data types.png"; return(new BitmapImage(new Uri(image))); } if (value is SimpleDataType) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Brick.png"; return(new BitmapImage(new Uri(image))); } if (value is EnumDataType) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Simple data type.png"; return(new BitmapImage(new Uri(image))); } if (value is BaseDataType) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Simple data type.png"; return(new BitmapImage(new Uri(image))); } if (value is CompositionInstance) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\composition.png"; return(new BitmapImage(new Uri(image))); } if (value is ClientServerInterface) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Port.png"; return(new BitmapImage(new Uri(image))); } if (value is ClientServerOperationFieldsList) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Bricks.png"; return(new BitmapImage(new Uri(image))); } if (value is ClientServerOperationField) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Brick.png"; return(new BitmapImage(new Uri(image))); } if (value is SenderReceiverInterface) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\dataflow.png"; return(new BitmapImage(new Uri(image))); } if (value is SenderReceiverInterfaceField) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Brick.png"; return(new BitmapImage(new Uri(image))); } if (value is SenderReceiverInterfaceFieldsList) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Bricks.png"; return(new BitmapImage(new Uri(image))); } if (value is ComponentDefenition) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\ComponentDefenition.png"; return(new BitmapImage(new Uri(image))); } if ((value is PeriodicRunnableInstance) || (value is PeriodicRunnableDefenition)) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\PeriodicRunnable.png"; return(new BitmapImage(new Uri(image))); } if ((value is CDataInstance) || (value is CDataDefenition)) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\CData.png"; return(new BitmapImage(new Uri(image))); } if ((value is PimInstance) || (value is PimDefenition)) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Pim.png"; return(new BitmapImage(new Uri(image))); } if (value is OsTask) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\osTask.jpg"; return(new BitmapImage(new Uri(image))); } if (value is ComplexDataTypeField) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Brick.png"; return(new BitmapImage(new Uri(image))); } if (value is EnumField) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\Brick2.png"; return(new BitmapImage(new Uri(image))); } if (value is ClientServerOperation) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\operation.png"; return(new BitmapImage(new Uri(image))); } if (value is ClientServerOperationList) { var image = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Images\\icons\\tree\\gears.png"; return(new BitmapImage(new Uri(image))); } } return(null); }
public void TranslatePortPainter(PortPainter portPainter, Point worldCordinates, double deltaX, double deltaY) { IElementWithPorts Owner = AutosarApplication.GetInstance().FindComponentInstanceByPortGuid(portPainter.GUID); /* Move port of the component */ if (!AutosarApplication.GetInstance().ActiveComposition.Equals(Owner)) { RectangleSide side; Point closestPoint = MathUtility.getNearestPointInPerimeter( Owner.Painter.Left, Owner.Painter.Top, Owner.Painter.Width, Owner.Painter.Height, worldCordinates.X, worldCordinates.Y, out side ); if (side == portPainter.ConnectionPortLocation) { if ((side == RectangleSide.Left) || (side == RectangleSide.Right)) { if ((worldCordinates.Y >= Owner.Painter.Top) && (worldCordinates.Y <= Owner.Painter.Bottom)) { double newPos = portPainter.Painter.Top + deltaY; if ((newPos >= Owner.Painter.Top) && (newPos <= Owner.Painter.Bottom)) { portPainter.Painter.Top = newPos; } else { portPainter.Painter.Left = closestPoint.X - portPainter.Painter.Width / 2.0f; portPainter.Painter.Top = closestPoint.Y - portPainter.Painter.Height / 2.0f; } } else { portPainter.Painter.Left = closestPoint.X - portPainter.Painter.Width / 2.0f; portPainter.Painter.Top = closestPoint.Y - portPainter.Painter.Height / 2.0f; } } else { if ((worldCordinates.X >= Owner.Painter.Left) && (worldCordinates.X <= Owner.Painter.Right)) { double newPos = portPainter.Painter.Left + deltaX; if ((newPos >= Owner.Painter.Left - portPainter.Painter.Width / 2) && (newPos <= Owner.Painter.Right - portPainter.Painter.Width / 2)) { portPainter.Painter.Left = newPos; } else { portPainter.Painter.Left = closestPoint.X - portPainter.Painter.Width / 2.0f; portPainter.Painter.Top = closestPoint.Y - portPainter.Painter.Height / 2.0f; } } else { portPainter.Painter.Left = closestPoint.X - portPainter.Painter.Width / 2.0f; portPainter.Painter.Top = closestPoint.Y - portPainter.Painter.Height / 2.0f; } } } else { portPainter.Painter.Left = closestPoint.X - portPainter.Painter.Width / 2.0f; portPainter.Painter.Top = closestPoint.Y - portPainter.Painter.Height / 2.0f; portPainter.ConnectionPortLocation = side; } } else /* Move composition's port inside the composition */ { portPainter.Painter.Left += deltaX; portPainter.Painter.Top += deltaY; } }