コード例 #1
0
ファイル: BundleComponent.cs プロジェクト: waharnum/AsTeRICS
        /// <summary>
        /// Adding the ports to the helper collection (for faster and easier access)
        /// and positioning of the portRectangles on the componentCanvas
        /// </summary>
        /// <param name="id">Id (Name) of the component</param>
        public void InitGraphPorts(String id)
        {
            int counterIn  = 0;
            int counterOut = 0;

            if (this.ports != null)
            {
                foreach (object o in this.ports)
                {
                    if (o is inputPortType)
                    {
                        this.PortsList.Add(((inputPortType)o).id, (inputPortType)o);
                    }
                    else if (o is outputPortType)
                    {
                        this.PortsList.Add(((outputPortType)o).id, (outputPortType)o);
                    }
                }
                foreach (Object o in this.PortsList.Values)
                {
                    if (o is inputPortType)
                    {
                        inputPortType pIn = (inputPortType)o;
                        componentCanvas.Children.Add(pIn.PortRectangle);
                        Canvas.SetLeft(pIn.PortRectangle, ACS.LayoutConstants.INPORTRECTANGLEOFFSETX);
                        Canvas.SetTop(pIn.PortRectangle, ACS.LayoutConstants.INPORTRECTANGLEOFFSETY + counterIn * ACS.LayoutConstants.INPORTDISTANCE);
                        counterIn++;
                        pIn.ComponentId = this.id;
                    }
                    else
                    {
                        outputPortType pOut = (outputPortType)o;
                        componentCanvas.Children.Add(pOut.PortRectangle);
                        Canvas.SetLeft(pOut.PortRectangle, ACS.LayoutConstants.OUTPORTRECTANGLEOFFSETX);
                        Canvas.SetTop(pOut.PortRectangle, ACS.LayoutConstants.OUTPORTRECTANGLEOFFSETY + counterOut * ACS.LayoutConstants.OUTPORTDISTANCE);
                        counterOut++;
                        pOut.ComponentId = this.id;
                    }
                }
            }

            // TODO: make the following dependent on the existance of eventports
            //Event100
            if (true)
            {
                Asterics.ACS.EventListenerPolygon inputEventPolygon = new Asterics.ACS.EventListenerPolygon();
                componentCanvas.Children.Add(inputEventPolygon.InputEventPortCanvas);
                Canvas.SetLeft(inputEventPolygon.InputEventPortCanvas, ACS.LayoutConstants.EVENTINPORTCANVASOFFSETX);
                Canvas.SetTop(inputEventPolygon.InputEventPortCanvas, ACS.LayoutConstants.EVENTINPORTCANVASOFFSETY);
            }
            if (true)
            {
                Asterics.ACS.EventTriggerPolygon outputEventPolygon = new Asterics.ACS.EventTriggerPolygon();
                componentCanvas.Children.Add(outputEventPolygon.OutputEventPortCanvas);
                Canvas.SetLeft(outputEventPolygon.OutputEventPortCanvas, ACS.LayoutConstants.EVENTOUTPORTCANVASOFFSETX);
                Canvas.SetTop(outputEventPolygon.OutputEventPortCanvas, ACS.LayoutConstants.EVENTOUTPORTCANVASOFFSETY);
            }
        }
コード例 #2
0
        /// <summary>
        /// Adding the ports to the helper collection (for faster and easier access)
        /// and positioning of the portRectangles on the componentCanvas
        /// </summary>
        /// <param name="id">Id (Name) of the component</param>
        public void InitGraphPorts(String id)
        {
            int counterIn = 0;
            int counterOut = 0;
            if (this.ports != null) {
                foreach (object o in this.ports) {
                    if (o is inputPortType) {
                        this.PortsList.Add(((inputPortType)o).id, (inputPortType)o);
                    } else if (o is outputPortType) {
                        this.PortsList.Add(((outputPortType)o).id, (outputPortType)o);
                    }
                }
                foreach (Object o in this.PortsList.Values) {
                    if (o is inputPortType) {
                        inputPortType pIn = (inputPortType)o;
                        componentCanvas.Children.Add(pIn.PortRectangle);
                        Canvas.SetLeft(pIn.PortRectangle, ACS.LayoutConstants.INPORTRECTANGLEOFFSETX);
                        Canvas.SetTop(pIn.PortRectangle, ACS.LayoutConstants.INPORTRECTANGLEOFFSETY + counterIn * ACS.LayoutConstants.INPORTDISTANCE);
                        counterIn++;
                        pIn.ComponentId = this.id;
                    } else {
                        outputPortType pOut = (outputPortType)o;
                        componentCanvas.Children.Add(pOut.PortRectangle);
                        Canvas.SetLeft(pOut.PortRectangle, ACS.LayoutConstants.OUTPORTRECTANGLEOFFSETX);
                        Canvas.SetTop(pOut.PortRectangle, ACS.LayoutConstants.OUTPORTRECTANGLEOFFSETY + counterOut * ACS.LayoutConstants.OUTPORTDISTANCE);
                        counterOut++;
                        pOut.ComponentId = this.id;
                    }
                }
            }

            // TODO: make the following dependent on the existance of eventports
            //Event100
            if (true) {
                Asterics.ACS.EventListenerPolygon inputEventPolygon = new Asterics.ACS.EventListenerPolygon();
                componentCanvas.Children.Add(inputEventPolygon.InputEventPortCanvas);
                Canvas.SetLeft(inputEventPolygon.InputEventPortCanvas, ACS.LayoutConstants.EVENTINPORTCANVASOFFSETX);
                Canvas.SetTop(inputEventPolygon.InputEventPortCanvas, ACS.LayoutConstants.EVENTINPORTCANVASOFFSETY);
            }
            if (true) {
                Asterics.ACS.EventTriggerPolygon outputEventPolygon = new Asterics.ACS.EventTriggerPolygon();
                componentCanvas.Children.Add(outputEventPolygon.OutputEventPortCanvas);
                Canvas.SetLeft(outputEventPolygon.OutputEventPortCanvas, ACS.LayoutConstants.EVENTOUTPORTCANVASOFFSETX);
                Canvas.SetTop(outputEventPolygon.OutputEventPortCanvas, ACS.LayoutConstants.EVENTOUTPORTCANVASOFFSETY);
            }
        }