示例#1
0
        protected virtual Shape CreateElement(ShapeCreateMode mode, PointF location, FlowchartStencilType type)
        {
            Shape shape = null;

            if (mode == ShapeCreateMode.Shape)
            {
                shape = Runtime.CreateShape(location, new Size());
            }
            if (mode == ShapeCreateMode.Table)
            {
                shape = Runtime.CreateTable(location, new Size());
            }
            if (mode == ShapeCreateMode.ComplexShape)
            {
                shape = Runtime.CreateComplexShape(location, new Size());
            }

            shape.Location = location;
            FlowchartStencil stencil = (FlowchartStencil)Component.Instance.GetStencil(typeof(FlowchartStencil));

            shape.StencilItem = stencil[type];

            //Add ports if required
            AddPorts(shape);

            return(shape);
        }
示例#2
0
        public virtual Shape AddFlowShape(string key, PointF location, FlowchartStencilType type)
        {
            StencilItem stencil = Stencil[type];
            Shape       shape   = CreateElement(ShapeMode, location, type);

            Shapes.Add(key, shape);
            return(shape);
        }
示例#3
0
 public virtual Decision AddDecision(Shape decision, string trueKey, FlowchartStencilType trueType, string falseKey, FlowchartStencilType falseType)
 {
     if (!Runtime.ActiveContainer.Shapes.Contains(decision.Key))
     {
         throw new ArgumentException("Decision Shape not found in active container. Decision could not be added.", "decision");
     }
     return(AddDecisionImplementation(null, null, decision, "", trueKey, trueType, falseKey, falseType));
 }
示例#4
0
        public virtual Shape AddFlowShape(PointF location, FlowchartStencilType type)
        {
            StencilItem stencil = Stencil[type];
            Shape       shape   = CreateElement(ShapeMode, location, type);

            Model.Shapes.Add(Model.Shapes.CreateKey(), shape);
            return(shape);
        }
示例#5
0
        public virtual Process AddProcess(string key, Shape parent, FlowchartStencilType type)
        {
            if (!Runtime.ActiveContainer.Shapes.Contains(parent.Key))
            {
                throw new ArgumentException("Parent shape not found in active container. Process could not be added.", "parent");
            }

            return(AddProcessImplementation(key, parent, null, type));
        }
示例#6
0
        public virtual Process AddProcess(Shape parent, FlowchartStencilType type)
        {
            if (!Model.Shapes.ContainsKey(parent.Key))
            {
                throw new ArgumentException("Parent shape not found in active container. Process could not be added.", "parent");
            }

            return(AddProcessImplementation(Model.Shapes.CreateKey(), parent, null, type));
        }
		public virtual StencilItem this[FlowchartStencilType type]  
		{
			get  
			{
				string key = type.ToString();
				return (StencilItem) Dictionary[key];
			}
			set  
			{
				string key = type.ToString();
				Dictionary[key] = value;
			}
		}
 public virtual StencilItem this[FlowchartStencilType type]
 {
     get
     {
         string key = type.ToString();
         return((StencilItem)Dictionary[key]);
     }
     set
     {
         string key = type.ToString();
         Dictionary[key] = value;
     }
 }
示例#9
0
        public virtual Process AddProcess(string key, Port port, FlowchartStencilType type)
        {
            //Validate the parent
            if (!(port.Parent is Group))
            {
                Shape parent = (Shape)port.Parent;
                if (!Runtime.ActiveContainer.Shapes.Contains(parent.Key))
                {
                    throw new ArgumentException("Parent shape not found in active container. Process could not be added.", "parent");
                }
            }

            return(AddProcessImplementation(key, null, port, type));
        }
示例#10
0
		protected virtual Shape CreateElement(ShapeCreateMode mode, PointF location, FlowchartStencilType type )
		{
			Shape shape = null;
			if (mode == ShapeCreateMode.Shape) shape = Runtime.CreateShape(location,new Size());
			if (mode == ShapeCreateMode.Table) shape = Runtime.CreateTable(location, new Size());
			if (mode == ShapeCreateMode.ComplexShape) shape = Runtime.CreateComplexShape(location, new Size());

			shape.Location = location;
			FlowchartStencil stencil = (FlowchartStencil) Component.Instance.GetStencil(typeof(FlowchartStencil));
			shape.StencilItem = stencil[type];

			//Add ports if required
			AddPorts(shape);

			return shape;
		}
示例#11
0
 public virtual Decision AddDecision(Shape parent, string decisionKey, string trueKey, FlowchartStencilType trueType, string falseKey, FlowchartStencilType falseType)
 {
     if (!Model.Shapes.ContainsKey(parent.Key))
     {
         throw new ArgumentException("Parent Shape not found in active container. Decision could not be added.", "parent");
     }
     return(AddDecisionImplementation(parent, null, null, decisionKey, trueKey, trueType, falseKey, falseType));
 }
示例#12
0
        private Decision AddDecisionImplementation(Shape parentShape, Port port, Shape decisionShape, string decisionKey, string trueKey, FlowchartStencilType trueType, string falseKey, FlowchartStencilType falseType)
        {
            Decision decision = new Decision();
            Process  process  = null;

            //Set the autolayout flag to false
            Suspend();

            //Determine whether to create decision
            if (decisionShape == null)
            {
                //Create a new decision key if not provided
                if (decisionKey == "")
                {
                    decisionKey = Runtime.ActiveContainer.Shapes.CreateKey();
                }

                //Add the decision shape and line
                if (port == null)
                {
                    process = AddProcess(decisionKey, parentShape, FlowchartStencilType.Decision);
                }
                else
                {
                    process = AddProcess(decisionKey, port, FlowchartStencilType.Decision);
                }
                decision.DecisionShape = process.Shape;
                decision.DecisionLine  = process.Line;
            }
            else
            {
                decision.DecisionShape = decisionShape;
            }

            //Add the true branch
            process = AddProcess(trueKey, decision.DecisionShape, trueType);

            decision.TrueShape = process.Shape;
            decision.TrueLine  = process.Line;

            //Add the true branch by swapping the orientation around and then swapping back
            Orientation = (Orientation == FlowchartOrientation.Vertical) ? Orientation = FlowchartOrientation.Horizontal : Orientation = FlowchartOrientation.Vertical;
            process     = AddProcess(falseKey, decision.DecisionShape, falseType);
            Orientation = (Orientation == FlowchartOrientation.Vertical) ? Orientation = FlowchartOrientation.Horizontal : Orientation = FlowchartOrientation.Vertical;

            decision.FalseShape = process.Shape;
            decision.FalseLine  = process.Line;
            decision.Port       = port;

            Resume();
            if (!Suspended)
            {
                Refresh();
            }

            return(decision);
        }
示例#13
0
        //Adds a process shape and line and returns a process
        private Process AddProcessImplementation(string key, Shape parent, Port port, FlowchartStencilType type)
        {
            PointF       location  = new PointF();
            Shape        flowShape = null;
            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 + Spacing.Width, start.Location.Y);
                if (port == null)
                {
                    location.X += parent.Rectangle.Width;
                }
            }

            //If the port parent is a group then offset by group location
            if (port != null && port.Parent is IContainer)
            {
                IContainer container = (IContainer)port.Parent;
                location = Geometry.OffsetPoint(location, container.Offset);
            }

            flowShape = AddFlowShape(key, location, type);

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

            //Add connecting flowline
            Line line = CreateElement(LineMode);

            if (port == null)
            {
                line.Start.Shape = parent;
            }
            else
            {
                line.Start.Port = port;
            }
            line.End.Shape  = flowShape;
            line.End.Marker = new Arrow(false);

            Runtime.ActiveContainer.Lines.Add(Runtime.ActiveContainer.Lines.CreateKey(), line);

            //Create the process object and return it
            Process process = new Process();

            process.Line  = line;
            process.Shape = flowShape;
            process.Port  = port;

            return(process);
        }
示例#14
0
 public virtual Decision AddDecision(Port port, string decisionKey, string trueKey, FlowchartStencilType trueType, string falseKey, FlowchartStencilType falseType)
 {
     //Validate the parent
     if (!(port.Parent is Group))
     {
         Shape parent = (Shape)port.Parent;
         if (!Runtime.ActiveContainer.Shapes.Contains(parent.Key))
         {
             throw new ArgumentException("Parent Shape not found in active container. Decision could not be added.", "parent");
         }
     }
     return(AddDecisionImplementation(null, port, null, decisionKey, trueKey, trueType, falseKey, falseType));
 }
示例#15
0
        //Adds a process shape and line and returns a process
        private Process AddProcessImplementation(string key, Shape parent, Port port, FlowchartStencilType type)
        {
            PointF location  = new PointF();
            Shape  flowShape = null;
            Solid  start     = (port == null) ? (Solid)parent : (Solid)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.Bounds.Height;
                }
            }
            else
            {
                location = new PointF(start.Location.X + Spacing.Width, start.Location.Y);
                if (port == null)
                {
                    location.X += parent.Bounds.Width;
                }
            }

            flowShape = AddFlowShape(key, location, type);

            //Offset shape depending on size
            if (Orientation == FlowchartOrientation.Vertical)
            {
                flowShape.Location = new PointF(location.X + (start.Bounds.Width - flowShape.Bounds.Width) / 2, location.Y);
            }
            else
            {
                flowShape.Location = new PointF(location.X, location.Y + (start.Bounds.Height - flowShape.Bounds.Height) / 2);
            }

            //Add connecting flowline
            Link line = CreateElement(LineMode);

            if (port == null)
            {
                line.Start.Shape = parent;
            }
            else
            {
                line.Start.Port = port;
            }
            line.End.Shape  = flowShape;
            line.End.Marker = new Arrow(false);

            Model.Lines.Add(Model.Lines.CreateKey(), line);

            //Create the process object and return it
            Process process = new Process();

            process.Line  = line;
            process.Shape = flowShape;
            process.Port  = port;

            return(process);
        }
示例#16
0
		public virtual Shape AddFlowShape(string key, PointF location, FlowchartStencilType type)
		{
			StencilItem stencil = Stencil[type];
			Shape shape = CreateElement(ShapeMode, location, type);
			Shapes.Add(key, shape);
			return shape;
		}
示例#17
0
		public virtual Process AddProcess(string key, Shape parent, FlowchartStencilType type)
		{
			if (! Runtime.ActiveContainer.Shapes.Contains(parent.Key)) throw new ArgumentException("Parent shape not found in active container. Process could not be added.","parent");

			return AddProcessImplementation(key, parent, null, type);
		}
        private void DrawStencilItem(StencilItem stencil, DrawShapeEventArgs e)
        {
            GraphicsPath         path        = e.Path;
            RectangleF           rect        = new Rectangle();
            FlowchartStencilType stencilType = (FlowchartStencilType)Enum.Parse(typeof(FlowchartStencilType), stencil.Key);

            float width  = e.Width;
            float height = e.Height;
            float percX  = 0;
            float percY  = 0;
            float perc   = 0;
            float midX   = 0;
            float midY   = 0;

            rect.Width  = width;
            rect.Height = height;
            midX        = width / 2;
            midY        = height / 2;

            if (stencilType == FlowchartStencilType.Default)
            {
                percX = 20;
                percY = 20;

                path.AddArc(0, 0, percX, percY, 180, 90);
                path.AddArc(width - percX, 0, percX, percY, 270, 90);
                path.AddArc(width - percX, height - percY, percX, percY, 0, 90);
                path.AddArc(0, height - percY, percX, percY, 90, 90);
                path.CloseFigure();

                stencil.Redraw = true;
            }
            else if (stencilType == FlowchartStencilType.Card)
            {
                percX = width * 0.2F;
                percY = height * 0.2F;

                path.AddLine(percX, 0, width, 0);
                path.AddLine(width, 0, width, height);
                path.AddLine(width, height, 0, height);
                path.AddLine(0, height, 0, percY);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Collate)
            {
                path.AddLine(0, 0, width, 0);
                path.AddLine(width, 0, 0, height);
                path.AddLine(0, height, width, height);
                path.AddLine(width, height, 0, 0);
            }
            else if (stencilType == FlowchartStencilType.Connector)
            {
                percX = width * 0.5F;
                percY = height * 0.5F;

                path.AddEllipse(percX, percY, width, height);
            }
            else if (stencilType == FlowchartStencilType.Data)
            {
                path.AddLine(midX / 2, 0, width, 0);
                path.AddLine(width, 0, (midX / 2) + midX, height);
                path.AddLine((midX / 2) + midX, height, 0, height);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Decision)
            {
                path.AddLine(midX, 0, width, midY);
                path.AddLine(width, midY, midX, height);
                path.AddLine(midX, height, 0, midY);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Delay)
            {
                percX = width * 0.2F;

                path.AddArc(percX, 0, width * 0.8F, height, 270, 180);
                path.AddLine(0, height, 0, 0);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Display)
            {
                percX = width * 0.2F;

                path.AddArc(percX, 0, width * 0.8F, height, 270, 180);

                path.AddLine(percX, height, 0, height / 2);
                path.AddLine(0, height / 2, percX, 0);

                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Direct)
            {
                percX = width * 0.3F;

                path.AddLine(width * 0.7F, height, percX, height);
                path.AddArc(0, 0, percX, height, 90, 180);
                path.AddLine(width * 0.7F, 0, percX, 0);
                path.AddArc(width * 0.7F, 0, percX, height, 270, -180);
                path.CloseFigure();

                path.StartFigure();
                path.AddEllipse(width * 0.7F, 0, percX, height);
            }
            else if (stencilType == FlowchartStencilType.Document)
            {
                PointF[] points = new PointF[4];

                points[0].X = 0;
                points[0].Y = height * 0.95F;
                points[1].X = width * 0.25F;
                points[1].Y = height;
                points[2].X = width * 0.75F;
                points[2].Y = height * 0.85F;
                points[3].X = width;
                points[3].Y = height * 0.8F;

                path.AddLine(new Point(0, 0), points[0]);
                path.AddCurve(points);
                path.AddLine(points[3], new PointF(width, 0));
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Extract)
            {
                percX = width * 0.25F;
                percY = height * 0.75F;

                path.AddLine(percX, 0, percX * 2, percY);
                path.AddLine(percX * 2, percY, 0, percY);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.InternalStorage)
            {
                perc = width * 0.15F;

                path.AddRectangle(rect);
                path.AddLine(perc, 0, perc, height);
                path.CloseFigure();

                path.AddLine(0, perc, width, perc);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.ManualInput)
            {
                percY = height * 0.25F;

                path.AddLine(0, percY, width, 0);
                path.AddLine(width, 0, width, height);
                path.AddLine(width, height, 0, height);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.ManualOperation)
            {
                percX = width * 0.2F;

                path.AddLine(0, 0, width, 0);
                path.AddLine(width, 0, width - percX, height);
                path.AddLine(width - percX, height, percX, height);

                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.MultiDocument)
            {
                PointF[] points = new PointF[4];

                width = width * 0.8F;

                points[0].X = 0;
                points[0].Y = height * 0.95F;
                points[1].X = width * 0.25F;
                points[1].Y = height;
                points[2].X = width * 0.75F;
                points[2].Y = height * 0.85F;
                points[3].X = width;
                points[3].Y = height * 0.8F;

                path.AddLine(new PointF(0, height * 0.2F), points[0]);
                path.AddCurve(points);
                path.AddLine(points[3], new PointF(width, height * 0.2F));
                path.CloseFigure();

                width = rect.Width;

                path.AddLine(width * 0.2F, height * 0.1F, width * 0.2F, 0);
                path.AddLine(width * 0.2F, 0, width, 0);
                path.AddLine(width, 0, width, height * 0.6F);
                path.AddLine(width, height * 0.6F, width * 0.9F, height * 0.6F);
                path.AddLine(width * 0.9F, height * 0.6F, width * 0.9F, height * 0.1F);
                path.CloseFigure();

                path.AddLine(width * 0.1F, height * 0.2F, width * 0.1F, height * 0.1F);
                path.AddLine(width * 0.1F, height * 0.1F, width * 0.9F, height * 0.1F);
                path.AddLine(width * 0.9F, height * 0.1F, width * 0.9F, height * 0.7F);
                path.AddLine(width * 0.9F, height * 0.7F, width * 0.8F, height * 0.7F);
                path.AddLine(width * 0.8F, height * 0.7F, width * 0.8F, height * 0.2F);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.OffPageConnector)
            {
                percX = width * 0.5F;
                percY = height * 0.75F;

                path.AddLine(0, 0, width, 0);
                path.AddLine(width, 0, width, percY);
                path.AddLine(width, percY, percX, height);
                path.AddLine(percX, height, 0, percY);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.PredefinedProcess)
            {
                perc = width * 0.1F;

                path.AddRectangle(rect);
                path.CloseFigure();

                path.AddLine(perc, 0, perc, height);
                path.CloseFigure();

                path.AddLine(width - perc, 0, width - perc, height);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Preparation)
            {
                percX = width * 0.2F;

                path.AddLine(0, midY, percX, 0);
                path.AddLine(percX, 0, width - percX, 0);
                path.AddLine(width - percX, 0, width, midY);
                path.AddLine(width, midY, width - percX, height);
                path.AddLine(width - percX, height, percX, height);

                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Process)
            {
                path.AddRectangle(new RectangleF(0, 0, width, height));
            }
            else if (stencilType == FlowchartStencilType.Process2)
            {
                percX = width * 0.2F;
                percY = height * 0.2F;

                if (percX < percY)
                {
                    percY = percX;
                }
                else
                {
                    percX = percY;
                }

                path.AddArc(0, 0, percX, percY, 180, 90);
                path.AddArc(width - percX, 0, percX, percY, 270, 90);
                path.AddArc(width - percX, height - percY, percX, percY, 0, 90);
                path.AddArc(0, height - percY, percX, percY, 90, 90);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Terminator)
            {
                percX = width * 0.5F;
                percY = height * 0.20F;

                path.AddArc(0, percY, percX, percY * 2, 90, 180);
                path.AddArc(width - percX, percY, percX, percY * 2, 270, 180);
                path.CloseFigure();

                stencil.KeepAspect = true;
            }
            else if (stencilType == FlowchartStencilType.Tape)
            {
                PointF[] points       = new PointF[5];
                PointF[] pointsBottom = new PointF[5];

                points[0].X = 0;
                points[0].Y = height * 0.05F;
                points[1].X = width * 0.25F;
                points[1].Y = height * 0.1F;
                points[2].X = width * 0.5F;
                points[2].Y = height * 0.05F;
                points[3].X = width * 0.75F;
                points[3].Y = 0;
                points[4].X = width;
                points[4].Y = height * 0.05F;

                pointsBottom[4].X = 0;
                pointsBottom[4].Y = height * 0.95F;
                pointsBottom[3].X = width * 0.25F;
                pointsBottom[3].Y = height;
                pointsBottom[2].X = width * 0.5F;
                pointsBottom[2].Y = height * 0.95F;
                pointsBottom[1].X = width * 0.75F;
                pointsBottom[1].Y = height * 0.9F;
                pointsBottom[0].X = width;
                pointsBottom[0].Y = height * 0.95F;

                path.AddCurve(points);
                path.AddLine(points[4], pointsBottom[0]);

                path.AddCurve(pointsBottom);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Junction)
            {
                percX = width * 0.25F;
                percY = height * 0.25F;

                if (percX > percY)
                {
                    perc = percX;
                }
                else
                {
                    perc = percY;
                }

                path.AddEllipse(perc, perc, perc * 2, perc * 2);
                path.CloseFigure();

                path.StartFigure();
                path.AddLine(perc * 2, perc, perc * 2, perc * 3);

                path.StartFigure();
                path.AddLine(perc, perc * 2, perc * 3, perc * 2);


                Matrix matrix = new Matrix(1, 0, 0, 1, 0, 0);

                //Rotate the matrix through 45 degress
                perc = perc * 2;
                matrix.RotateAt(45, new PointF(perc, perc));

                //Transform the graphicspath object
                path.Transform(matrix);
            }
            else if (stencilType == FlowchartStencilType.LogicalOr)
            {
                percX = width * 0.5F;
                percY = height * 0.5F;

                if (percX > percY)
                {
                    perc = percX;
                }
                else
                {
                    perc = percY;
                }

                path.AddEllipse(perc, perc, perc * 2, perc * 2);
                path.AddLine(perc * 2, perc, perc * 2, perc * 3);
                path.CloseFigure();
                path.AddLine(perc, perc * 2, perc * 3, perc * 2);
            }
            else if (stencilType == FlowchartStencilType.Sort)
            {
                percX = width * 0.5F;
                percY = height * 0.5F;

                path.AddLine(0, percY, percX, 0);
                path.AddLine(percX, 0, width, percY);

                path.AddLine(width, percY, percX, height);
                path.AddLine(percX, height, 0, percY);

                path.CloseFigure();
                path.StartFigure();

                path.AddLine(0, percY, width, percY);
            }
            else if (stencilType == FlowchartStencilType.Merge)
            {
                path.AddLine(0, 0, width, 0);
                path.AddLine(width, 0, width * 0.5F, height);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.StoredData)
            {
                percX = width * 0.3F;

                path.AddArc(0, 0, percX, height, 90, 180);
                path.AddArc(width * 0.85F, 0, percX, height, 270, -180);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Sequential)
            {
                if (width > height)
                {
                    perc = height;
                }
                else
                {
                    perc = width;
                }

                path.AddArc(0, 0, perc, perc, 45, -315);
                path.AddLine(perc * 0.5F, perc, perc, perc);
                path.AddLine(perc, perc, perc, perc * 0.85F);
                path.CloseFigure();
            }
            else if (stencilType == FlowchartStencilType.Magnetic)
            {
                percY = height * 0.4F;

                path.AddArc(0, -height * 0.2F, width, percY, 180, -180);
                path.AddLine(width, 0, width, height * 0.8F);
                path.AddArc(0, height * 0.6F, width, percY, 0, 180);
                path.AddLine(0, height * 0.8F, 0, 0);
                //path.CloseFigure();

                //Define two shapes so that not see through
                path.StartFigure();
                path.AddLine(0, 0, width, 0);
                path.AddArc(0, -height * 0.2F, width, percY, 0, 180);
            }
        }
示例#19
0
		public virtual Process AddProcess(string key, Port port, FlowchartStencilType type)
		{
			//Validate the parent
			if (! (port.Parent is Group))
			{
				Shape parent = (Shape) port.Parent;
				if (! Runtime.ActiveContainer.Shapes.Contains(parent.Key)) throw new ArgumentException("Parent shape not found in active container. Process could not be added.","parent");
			}

			return AddProcessImplementation(key, null, port, type);
		}
示例#20
0
		private Decision AddDecisionImplementation(Shape parentShape, Port port, Shape decisionShape, string decisionKey, string trueKey, FlowchartStencilType trueType, string falseKey, FlowchartStencilType falseType)
		{
			Decision decision = new Decision();
			Process process = null;

			//Set the autolayout flag to false
			Suspend();

			//Determine whether to create decision
			if (decisionShape == null)
			{
				//Create a new decision key if not provided
				if (decisionKey == "") decisionKey = Runtime.ActiveContainer.Shapes.CreateKey();

				//Add the decision shape and line
				if (port == null)
				{
					process = AddProcess(decisionKey, parentShape, FlowchartStencilType.Decision);
				}
				else
				{
					process = AddProcess(decisionKey, port, FlowchartStencilType.Decision);
				}
				decision.DecisionShape = process.Shape;
				decision.DecisionLine = process.Line;
			}
			else
			{
				decision.DecisionShape = decisionShape;
			}

			//Add the true branch
			process = AddProcess(trueKey, decision.DecisionShape, trueType);

			decision.TrueShape = process.Shape;
			decision.TrueLine = process.Line;

			//Add the true branch by swapping the orientation around and then swapping back
			Orientation = (Orientation == FlowchartOrientation.Vertical) ? Orientation = FlowchartOrientation.Horizontal : Orientation = FlowchartOrientation.Vertical;
			process = AddProcess(falseKey, decision.DecisionShape, falseType);
			Orientation = (Orientation == FlowchartOrientation.Vertical) ? Orientation = FlowchartOrientation.Horizontal : Orientation = FlowchartOrientation.Vertical;

			decision.FalseShape = process.Shape;
			decision.FalseLine = process.Line;
			decision.Port = port;

			Resume();
			if (! Suspended) Refresh();

			return decision;
		}
示例#21
0
		//Adds a process shape and line and returns a process
		private Process AddProcessImplementation(string key, Shape parent, Port port, FlowchartStencilType type)
		{
			PointF location = new PointF();
			Shape flowShape = null;
			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 + Spacing.Width, start.Location.Y);
				if (port == null) location.X += parent.Rectangle.Width;
			}

			//If the port parent is a group then offset by group location
			if (port != null && port.Parent is IContainer)
			{
				IContainer container = (IContainer) port.Parent;
				location = Geometry.OffsetPoint(location,container.Offset);
			}

			flowShape = AddFlowShape(key, location, type);

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

			//Add connecting flowline
			Line line = CreateElement(LineMode);
			if (port == null)
			{
				line.Start.Shape = parent;
			}
			else
			{
				line.Start.Port = port;
			}	
			line.End.Shape = flowShape;
			line.End.Marker = new Arrow(false);

			Runtime.ActiveContainer.Lines.Add(Runtime.ActiveContainer.Lines.CreateKey(),line);

			//Create the process object and return it 
			Process process = new Process();

			process.Line = line;
			process.Shape = flowShape;
			process.Port = port;

			return process;
		}
示例#22
0
		public virtual Decision AddDecision(Port port, string decisionKey,string trueKey, FlowchartStencilType trueType, string falseKey, FlowchartStencilType falseType)
		{
			//Validate the parent
			if (! (port.Parent is Group))
			{
				Shape parent = (Shape) port.Parent;
				if (! Runtime.ActiveContainer.Shapes.Contains(parent.Key))	throw new ArgumentException("Parent Shape not found in active container. Decision could not be added.","parent");
			}
			return AddDecisionImplementation(null, port, null, decisionKey, trueKey, trueType, falseKey, falseType);
		}
示例#23
0
		public virtual Decision AddDecision(Shape decision, string trueKey, FlowchartStencilType trueType, string falseKey, FlowchartStencilType falseType)
		{
			if (! Runtime.ActiveContainer.Shapes.Contains(decision.Key)) throw new ArgumentException("Decision Shape not found in active container. Decision could not be added.","decision");
			return AddDecisionImplementation(null,null,decision,"", trueKey, trueType, falseKey, falseType);
		}