Пример #1
0
		public void UpdateArrow(Arrow a, bool ignoredDirection)
		{
			if (_inc == ArrowAnchor.NoAnchor)
				CalculateAnchors();

			// Temporarily disable routing
			bool route = a.AutoRoute;
			a.SilentAutoRoute = false;

			// Preserve arrow anchoring
			int orgnAnchor = a.OrgnAnchor;
			int destAnchor = a.DestAnchor;

			switch(Type)
			{
				case TreeLayoutType.Cascading:
				{
					switch(ArrowStyle)
					{

						case TreeLayoutArrowType.Cascading2:
						{
							a.Style = MindFusion.FlowChartX.ArrowStyle.Cascading;
							bool v = false;
							if( Direction == TreeLayoutDirection.LeftToRight ||
								Direction == TreeLayoutDirection.RightToLeft)
							{
								if(!(ReversedArrows ^ ignoredDirection))
									v = true;
							}
							else
							{
								if(ReversedArrows ^ ignoredDirection)
									v = true;
							}
							if (v)
								a.CascadeOrientation = MindFusion.FlowChartX.Orientation.Vertical;
							else
								a.CascadeOrientation = MindFusion.FlowChartX.Orientation.Horizontal;

							a.SegmentCount = 2;

							// Adjust the arrow which connects the boxes.
							if (ignoredDirection)
								a.adjustEnds(_inc, _outg);
							else
								a.adjustEnds(_outg, _inc);

							SetAnchors(a, orgnAnchor, destAnchor);

							PointF ptMiddle = a.Points[1];
							PointF p0 = (!(ReversedArrows ^ ignoredDirection) ? a.Points[0] : a.Points[2]);
							PointF p2 = (!(ReversedArrows ^ ignoredDirection) ? a.Points[2] : a.Points[0]);
							if( Direction == TreeLayoutDirection.LeftToRight ||
								Direction == TreeLayoutDirection.RightToLeft)
							{
								ptMiddle.X = p0.X;
								ptMiddle.Y = p2.Y;
							}
							else
							{
								ptMiddle.X = p2.X;
								ptMiddle.Y = p0.Y;
							}
							a.Points[1] = ptMiddle;
							a.updateArrowHeads();
						}
							break;

						case TreeLayoutArrowType.Cascading3:
						{
							a.Style = MindFusion.FlowChartX.ArrowStyle.Cascading;
							a.SegmentCount = 3;

							if( Direction == TreeLayoutDirection.LeftToRight ||
								Direction == TreeLayoutDirection.RightToLeft)
								a.CascadeOrientation = MindFusion.FlowChartX.Orientation.Horizontal;
							else
								a.CascadeOrientation = MindFusion.FlowChartX.Orientation.Vertical;

							// Adjust the arrow which connects the boxes.
							if (ignoredDirection)
								a.adjustEnds(_inc, _outg);
							else
								a.adjustEnds(_outg, _inc);

							SetAnchors(a, orgnAnchor, destAnchor);

							PointF ptMiddle1 = a.Points[1];
							PointF ptMiddle2 = a.Points[2];
							if( Direction == TreeLayoutDirection.LeftToRight ||
								Direction == TreeLayoutDirection.RightToLeft)
							{
								ptMiddle1.X = ptMiddle2.X =
									(a.Points[0].X + a.Points[3].X)/2;
								ptMiddle1.Y = a.Points[0].Y;
								ptMiddle2.Y = a.Points[3].Y;
							}
							else
							{
								ptMiddle1.Y = ptMiddle2.Y =
									(a.Points[0].Y + a.Points[3].Y)/2;
								ptMiddle1.X = a.Points[0].X;
								ptMiddle2.X = a.Points[3].X;
							}

							a.Points[1] = ptMiddle1;
							a.Points[2] = ptMiddle2;
							a.updateArrowHeads();
						}
							break;

						case TreeLayoutArrowType.Rounded:
						{
							a.Style = MindFusion.FlowChartX.ArrowStyle.Bezier;
							a.SegmentCount = 1;

							// Adjust the arrow which connects the boxes.
							if (ignoredDirection)
								a.adjustEnds(_inc, _outg);
							else
								a.adjustEnds(_outg, _inc);

							SetAnchors(a, orgnAnchor, destAnchor);

							PointF ptMiddle = a.Points[1];
							PointF p0 = (!(ReversedArrows ^ ignoredDirection) ? a.Points[0] : a.Points[3]);
							PointF p3 = (!(ReversedArrows ^ ignoredDirection) ? a.Points[3] : a.Points[0]);
							if( Direction == TreeLayoutDirection.LeftToRight ||
								Direction == TreeLayoutDirection.RightToLeft)
							{
								ptMiddle.X = p0.X;
								ptMiddle.Y = p3.Y;
							}
							else
							{
								ptMiddle.X = p3.X;
								ptMiddle.Y = p0.Y;
							}

							a.Points[1] = ptMiddle;
							a.Points[2] = ptMiddle;
							a.updateArrowHeads();
						}
							break;

						case TreeLayoutArrowType.Straight:
						{
							a.Style = MindFusion.FlowChartX.ArrowStyle.Polyline;
							a.SegmentCount = 1;

							// Adjust the arrow which connects the boxes.
							if (ignoredDirection)
								a.adjustEnds(_inc, _outg);
							else
								a.adjustEnds(_outg, _inc);

							SetAnchors(a, orgnAnchor, destAnchor);
						}
							break;

					}
				}
					break;

				case TreeLayoutType.Centered:
				{
					switch(ArrowStyle)
					{

						case TreeLayoutArrowType.Cascading2:
							// Centered tree does not support
							// 2-segmented perpendicular arrows.
							break;

						case TreeLayoutArrowType.Cascading3:
						{
							a.Style = MindFusion.FlowChartX.ArrowStyle.Cascading;
							a.SegmentCount = 3;

							if( Direction == TreeLayoutDirection.LeftToRight ||
								Direction == TreeLayoutDirection.RightToLeft)
								a.CascadeOrientation = MindFusion.FlowChartX.Orientation.Horizontal;
							else
								a.CascadeOrientation = MindFusion.FlowChartX.Orientation.Vertical;

							// Adjust the arrow which connects the boxes.
							if (ignoredDirection)
								a.adjustEnds(_inc, _outg);
							else
								a.adjustEnds(_outg, _inc);

							SetAnchors(a, orgnAnchor, destAnchor);

							PointF ptMiddle1 = a.Points[1];
							PointF ptMiddle2 = a.Points[2];
							if( Direction == TreeLayoutDirection.LeftToRight ||
								Direction == TreeLayoutDirection.RightToLeft)
							{
								ptMiddle1.X = ptMiddle2.X =
									(a.Points[0].X + a.Points[3].X)/2;
								ptMiddle1.Y = a.Points[0].Y;
								ptMiddle2.Y = a.Points[3].Y;
							}
							else
							{
								ptMiddle1.Y = ptMiddle2.Y =
									(a.Points[0].Y + a.Points[3].Y)/2;
								ptMiddle1.X = a.Points[0].X;
								ptMiddle2.X = a.Points[3].X;
							}

							a.Points[1] = ptMiddle1;
							a.Points[2] = ptMiddle2;
							a.updateArrowHeads();
						}
							break;

						case TreeLayoutArrowType.Rounded:
						{
							a.Style = MindFusion.FlowChartX.ArrowStyle.Bezier;
							a.SegmentCount = 1;

							// Adjust the arrow which connects the boxes.
							if (ignoredDirection)
								a.adjustEnds(_inc, _outg);
							else
								a.adjustEnds(_outg, _inc);

							SetAnchors(a, orgnAnchor, destAnchor);

							PointF ptMiddle1 = a.Points[1];
							PointF ptMiddle2 = a.Points[2];
							if( Direction == TreeLayoutDirection.LeftToRight ||
								Direction == TreeLayoutDirection.RightToLeft)
							{
								ptMiddle1.X = a.Points[3].X;
								ptMiddle2.X = a.Points[0].X;
								ptMiddle1.Y = a.Points[0].Y;
								ptMiddle2.Y = a.Points[3].Y;
							}
							else
							{
								ptMiddle1.X = a.Points[0].X;
								ptMiddle2.X = a.Points[3].X;
								ptMiddle1.Y = a.Points[3].Y;
								ptMiddle2.Y = a.Points[0].Y;
							}

							a.Points[1] = ptMiddle1;
							a.Points[2] = ptMiddle2;
							a.updateArrowHeads();
						}
							break;

						case TreeLayoutArrowType.Straight:
						{
							a.Style = MindFusion.FlowChartX.ArrowStyle.Polyline;
							a.SegmentCount = 1;

							// Adjust the arrow which connects the boxes.
							if (ignoredDirection)
								a.adjustEnds(_inc, _outg);
							else
								a.adjustEnds(_outg, _inc);

							SetAnchors(a, orgnAnchor, destAnchor);
						}
							break;

					}
				}
					break;

				case TreeLayoutType.Radial:
				{
					// Ignore the arrow style
					a.arrangePoints(_anchoring);
				}
					break;

			}

			a.SilentAutoRoute = route;
		}