//Adds a process shape and line and returns a process
        private SubChart AddSubChartImplementation(string key, Shape parent, Port port)
        {
            SubChart     subChart = new SubChart();
            PointF       location = new PointF();
            Group        group    = Runtime.CreateGroup();
            SolidElement start    = (port == null) ? (SolidElement)parent : (SolidElement)port;

            //Set the location
            if (Orientation == FlowchartOrientation.Vertical)
            {
                location = new PointF(start.Location.X, start.Location.Y + Spacing.Height);
                if (port == null)
                {
                    location.Y += parent.Rectangle.Height;
                }
            }
            else
            {
                location = new PointF(start.Location.X + start.Rectangle.Width + Spacing.Width, start.Location.Y);
                if (port == null)
                {
                    location.X += parent.Rectangle.Width;
                }
            }

            group.Location = location;
            Shapes.Add(key, group);

            //Offset the group
            if (Orientation == FlowchartOrientation.Vertical)
            {
                group.Location = new PointF(location.X + (start.Rectangle.Width - group.Rectangle.Width) / 2, location.Y);
            }
            else
            {
                group.Location = new PointF(location.X, location.Y + (start.Rectangle.Height - group.Rectangle.Height) / 2);
            }

            //Next add two ports depending on the orientation
            Port newport = null;

            if (Orientation == FlowchartOrientation.Vertical)
            {
                newport = new Port(PortOrientation.Top);                 //Keep reference to add line
                group.Ports.Add("top", newport);

                group.Ports.Add("bottom", new Port(PortOrientation.Bottom));
            }
            else
            {
                newport = new Port(PortOrientation.Left);                 //Keep reference to add line
                group.Ports.Add("left", newport);

                group.Ports.Add("right", new Port(PortOrientation.Right));
            }

            //Finally link the group to the parent shape
            Line line = CreateElement(LineMode);

            if (port == null)
            {
                line.Start.Shape = parent;
            }
            else
            {
                line.Start.Port = port;
            }
            line.End.Port = newport;

            line.End.Marker = new Arrow(false);
            Lines.Add(Lines.CreateKey(), line);

            //Set up subchart
            subChart.Line  = line;
            subChart.Group = group;
            subChart.Port  = port;
            return(subChart);
        }
Example #2
0
		//Adds a process shape and line and returns a process
		private SubChart AddSubChartImplementation(string key, Shape parent, Port port)
		{
			SubChart subChart = new SubChart();
			PointF location = new PointF();
			Group group = Runtime.CreateGroup();
			SolidElement start = (port == null) ? (SolidElement) parent : (SolidElement) port;

			//Set the location
			if (Orientation == FlowchartOrientation.Vertical)
			{
				location = new PointF(start.Location.X, start.Location.Y + Spacing.Height);
				if (port == null) location.Y += parent.Rectangle.Height;
			}
			else
			{
				location = new PointF(start.Location.X  + start.Rectangle.Width + Spacing.Width, start.Location.Y);
				if (port == null) location.X += parent.Rectangle.Width;
			}
			
			group.Location = location;
			Shapes.Add(key,group);

			//Offset the group
			if (Orientation == FlowchartOrientation.Vertical)
			{
				group.Location = new PointF(location.X + (start.Rectangle.Width - group.Rectangle.Width) / 2,location.Y);
			}
			else
			{
				group.Location = new PointF(location.X,location.Y + (start.Rectangle.Height - group.Rectangle.Height) / 2);
			}

			//Next add two ports depending on the orientation
			Port newport = null;
			if (Orientation == FlowchartOrientation.Vertical)
			{
				newport = new Port(PortOrientation.Top); //Keep reference to add line
				group.Ports.Add("top",newport);
				
				group.Ports.Add("bottom",new Port(PortOrientation.Bottom));
			}
			else
			{
				newport = new Port(PortOrientation.Left); //Keep reference to add line
				group.Ports.Add("left",newport);

				group.Ports.Add("right",new Port(PortOrientation.Right));
			}
			
			//Finally link the group to the parent shape
			Line line = CreateElement(LineMode);
			
			if (port == null)
			{
				line.Start.Shape = parent;
			}
			else
			{
				line.Start.Port = port;
			}
			line.End.Port = newport;
			
			line.End.Marker = new Arrow(false);
			Lines.Add(Lines.CreateKey(),line);
			
			//Set up subchart
			subChart.Line = line;
			subChart.Group = group;
			subChart.Port = port;
			return subChart;
		}