Beispiel #1
0
        public Server()
        {
            //Add two ports to the server
            Port port;

            port             = new Port(PortOrientation.Top);
            port.BorderWidth = 2;
            Ports.Add("top", port);

            port             = new Port(PortOrientation.Bottom);
            port.BorderWidth = 2;
            Ports.Add("bottom", port);

            //Set the shape appearance
            Size        = new SizeF(120, 100);
            BorderWidth = 2;

            //Add the internal solidshape
            SolidElement solid = new SolidElement();

            solid.Location   = new PointF(10, 10);
            solid.Label      = new TextLabel();
            solid.Label.Text = "Server";

            Children.Add("solid", solid);

            ServerType = ServerType.Generic;
            Available  = false;
        }
Beispiel #2
0
        private void AddShapeText(SvgDocument document, SolidElement solid, string strClipId)
        {
            if (solid.Label.Text.Trim() == "")
            {
                return;
            }

            Style style = new Style();

            //Add clipping to style if required
            style.ClipPathId = strClipId;

            //Set up text object
            Text text = new Text();

            text.Label           = solid.Label;
            text.LayoutRectangle = solid.InternalRectangle;

            //Get style
            string classId = null;

            classId = document.AddClass(text.GetStyle(strClipId), "");

            //Create fragment and add to document
            XmlDocumentFragment frag           = null;
            XmlNode             newElementNode = null;

            frag          = document.CreateDocumentFragment();
            frag.InnerXml = text.ExtractText(0, 0, solid.Key + "Text");
            frag.FirstChild.Attributes.GetNamedItem("class").InnerText = classId;
            newElementNode = document.ContainerNode.AppendChild(frag);
        }
Beispiel #3
0
        public Server()
        {
            //Add two ports to the server
            Port port;

            port             = new Port(PortOrientation.Top);
            port.BorderWidth = 2;
            Ports.Add("top", port);

            port             = new Port(PortOrientation.Bottom);
            port.BorderWidth = 2;
            Ports.Add("bottom", port);

            //Set the shape appearance
            Size        = new SizeF(120, 100);
            BorderWidth = 2;

            //Add the internal applicationshape
            SolidElement application = new SolidElement();

            application.Location    = new PointF(10, 10);
            application.Label       = new TextLabel();
            application.Label.Text  = "Application";
            application.Label.Color = Color.FromArgb(66, 65, 66);

            Children.Add("application", application);

            //Set up default server colors
            ServerType = ServerType.Web;

            MinimumSize = new Size(32, 32);
        }
Beispiel #4
0
        private void SetColors(ServerType serverType)
        {
            //Get the application child element
            SolidElement application = (SolidElement)Children["application"];
            Port         port;

            if (serverType == ServerType.Web)
            {
                BorderColor             = Color.FromArgb(255, 24, 54, 118);
                GradientColor           = Color.FromArgb(255, 221, 223, 235);
                application.BorderColor = Color.FromArgb(255, 141, 163, 212);
                application.Label.Text  = "Website";

                port             = (Port)Ports["top"];
                port.BorderColor = Color.FromArgb(255, 141, 163, 212);

                port             = (Port)Ports["bottom"];
                port.BorderColor = Color.FromArgb(255, 141, 163, 212);
            }
            else if (serverType == ServerType.Business)
            {
                BorderColor             = Color.FromArgb(255, 91, 172, 17);
                GradientColor           = Color.FromArgb(255, 217, 233, 213);
                application.BorderColor = Color.FromArgb(255, 91, 172, 17);
                application.Label.Text  = "Business Objects";

                port             = (Port)Ports["top"];
                port.BorderColor = Color.FromArgb(255, 202, 210, 187);

                port             = (Port)Ports["bottom"];
                port.BorderColor = Color.FromArgb(255, 202, 210, 187);
            }
            else if (serverType == ServerType.SQL)
            {
                BorderColor             = Color.FromArgb(255, 189, 182, 110);
                GradientColor           = Color.FromArgb(255, 235, 230, 216);
                application.BorderColor = Color.FromArgb(255, 215, 214, 196);
                application.Label.Text  = "Database";

                port             = (Port)Ports["top"];
                port.BorderColor = Color.FromArgb(255, 215, 214, 196);

                port             = (Port)Ports["bottom"];
                port.BorderColor = Color.FromArgb(255, 215, 214, 196);
            }
            else if (serverType == ServerType.Generic)
            {
                BorderColor             = Color.FromArgb(255, 101, 28, 35);
                GradientColor           = Color.FromArgb(255, 234, 224, 222);
                application.BorderColor = Color.FromArgb(255, 195, 172, 166);
                application.Label.Text  = "Application";

                port             = (Port)Ports["top"];
                port.BorderColor = Color.FromArgb(255, 195, 172, 166);

                port             = (Port)Ports["bottom"];
                port.BorderColor = Color.FromArgb(255, 195, 172, 166);
            }
        }
Beispiel #5
0
        private void CalculateGuides(RenderList actions)
        {
            ArrayList list = new ArrayList();

            //Loop through actions and add rectangles
            foreach (Element element in actions)
            {
                if (element is Shape && element.Visible)
                {
                    ArrayList newList = new ArrayList();

                    //Get the rectangle from element
                    RectangleF newRect = element.Rectangle;

                    //If a solid element, get transform rectangle
                    if (element is SolidElement)
                    {
                        SolidElement solid = (SolidElement)element;
                        newRect = solid.TransformRectangle;
                    }

                    //Offset rectangle according to container
                    newRect.X += element.Container.Offset.X;
                    newRect.Y += element.Container.Offset.Y;

                    bool combine = false;

                    //Loop through the existing rectangles and see if they intersect
                    foreach (RectangleF rect in list)
                    {
                        //Determine if rectangles can be combined
                        if (Orientation == RulerOrientation.Top)
                        {
                            combine = rect.Contains(new PointF(newRect.X, rect.Y)) || rect.Contains(new PointF(newRect.Right, rect.Y));
                        }
                        else
                        {
                            combine = rect.Contains(new PointF(rect.X, newRect.Y)) || rect.Contains(new PointF(rect.X, newRect.Bottom));
                        }

                        //Add combined rectangle rectangle together, or add to new list if no intersection
                        if (combine)
                        {
                            newRect = CombineRectangle(newRect, rect);
                        }
                        else
                        {
                            newList.Add(rect);
                        }
                    }

                    //Add to new list if not combined
                    newList.Add(newRect);
                    list = newList;
                }
            }

            SetGuides((RectangleF[])list.ToArray(typeof(RectangleF)));
        }
        private void ArrangeImplementation(float spacingWidth, float spacingHeight)
        {
            float totalwidth = DisplayRectangle.Width - Margin.Left - Margin.Right;

            float   width        = Margin.Left;
            float   height       = Margin.Top + Tabs.CurrentTab.Scroll;
            Element lastElement  = null;
            PointF  lastLocation = new PointF();

            //Check if must include tab in height
            if (Tabs.CurrentTab.Visible)
            {
                height += Tabs.CurrentTab.Rectangle.Bottom;
            }

            Suspend();

            //Arrange each node according to the order of the renderlist
            foreach (Element element in RenderList)
            {
                //Set the location
                if (lastElement != null)
                {
                    if (lastElement is SolidElement)
                    {
                        SolidElement solid = (SolidElement)lastElement;
                        solid.Location = lastLocation;
                    }
                }

                lastElement  = element;
                lastLocation = new PointF(width, height);

                height += spacingHeight;

                SetLabel(lastElement);
            }

            //Set the final item
            if (lastElement != null)
            {
                if (lastElement is SolidElement)
                {
                    SolidElement solid = (SolidElement)lastElement;
                    solid.Location = lastLocation;
                }
                SetLabel(lastElement);
            }

            //Save the number of columns
            mLastCols = (int)System.Math.Floor((DisplayRectangle.Width - Margin.Left - Margin.Right) / Spacing.Width);

            //Enable disable scroll buttons
            CheckScrollButtons();

            Resume();
            Invalidate();
        }
Beispiel #7
0
        private string StyleFromShapeImplementation(SolidElement solid, string clipId)
        {
            StringBuilder style = new StringBuilder();

            //Sort out the fill
            style.Append("fill:");

            if (!solid.DrawBackground)
            {
                style.Append("none;");
            }
            else
            {
                if (solid.DrawGradient && solid.BackColor != solid.GradientColor)
                {
                    mLinearGradient = ExtractLinearGradient(solid.GradientMode, solid.BackColor, solid.GradientColor);
                    style.Append("url(#none);");
                }
                else
                {
                    mLinearGradient = "";
                    style.Append(GetCompatibleColor(solid.BackColor));
                    style.Append(";");
                }

                if (solid.Opacity < 100)
                {
                    style.Append("fill-opacity:0.");
                    style.Append(solid.Opacity.ToString());
                    style.Append(";");
                }
            }

            //Sort out the stroke, ignore custom pens and use defaults
            style.Append("stroke:");
            style.Append(GetCompatibleColor(solid.BorderColor));
            style.Append(";");
            style.Append("stroke-width:");
            style.Append(solid.BorderWidth);
            style.Append(";");
            style.Append(GetDashStyle(mSolid.BorderStyle, mSolid.BorderWidth));

            //Add clipping path id if required
            if (clipId != "")
            {
                style.Append("clip-path:url(#");
                style.Append(clipId);
                style.Append(");");
            }

            return(style.ToString());
        }
Beispiel #8
0
        private void AddShapeImage(SvgDocument document, SolidElement solid, string definitionId, string clipId)
        {
            ImageRef image = new ImageRef();

            XmlDocumentFragment frag       = null;
            XmlElement          newElement = null;

            string classId = null;
            string id      = null;

            image.SolidElement = solid;

            //Set up clipping if required
            if (solid.Clip)
            {
                System.Text.StringBuilder objBuilder = new System.Text.StringBuilder();

                objBuilder.Append("clip-path:url(\"#");
                objBuilder.Append(clipId);
                objBuilder.Append("\");");

                classId = document.AddClass(objBuilder.ToString(), "");
            }

            //Extract image
            image.Image = solid.Image;

            frag          = document.CreateDocumentFragment();
            frag.InnerXml = image.ExtractImage();

            //Create image element
            newElement = document.CreateElement("image");

            newElement.SetAttribute("href", "http://www.w3.org/1999/xlink", frag.FirstChild.Attributes.GetNamedItem("href").InnerXml);
            newElement.SetAttribute("x", frag.FirstChild.Attributes.GetNamedItem("x").InnerText);
            newElement.SetAttribute("y", frag.FirstChild.Attributes.GetNamedItem("y").InnerText);
            newElement.SetAttribute("width", frag.FirstChild.Attributes.GetNamedItem("width").InnerText);
            newElement.SetAttribute("height", frag.FirstChild.Attributes.GetNamedItem("height").InnerText);

            id = frag.FirstChild.Attributes.GetNamedItem("id").InnerText;
            newElement.SetAttribute("id", id);

            if (solid.Clip)
            {
                newElement.SetAttribute("class", classId);
            }

            //Append image to the current container
            document.ContainerNode.AppendChild(newElement);
        }
		private void AddShapeImage(SvgDocument document, SolidElement solid, string definitionId, string clipId)
		{
			ImageRef image = new ImageRef();

			XmlDocumentFragment frag = null;
			XmlElement newElement = null;

			string classId = null;
			string id = null;

			image.SolidElement = solid;

			//Set up clipping if required
			if (solid.Clip)
			{
				System.Text.StringBuilder objBuilder = new System.Text.StringBuilder();

				objBuilder.Append("clip-path:url(\"#");
				objBuilder.Append(clipId);
				objBuilder.Append("\");");

				classId = document.AddClass(objBuilder.ToString(), "");
			}

			//Extract image
			image.Image = solid.Image;

			frag = document.CreateDocumentFragment();
			frag.InnerXml = image.ExtractImage();

			//Create image element
			newElement = document.CreateElement("image");

			newElement.SetAttribute("href", "http://www.w3.org/1999/xlink", frag.FirstChild.Attributes.GetNamedItem("href").InnerXml);
			newElement.SetAttribute("x", frag.FirstChild.Attributes.GetNamedItem("x").InnerText);
			newElement.SetAttribute("y", frag.FirstChild.Attributes.GetNamedItem("y").InnerText);
			newElement.SetAttribute("width", frag.FirstChild.Attributes.GetNamedItem("width").InnerText);
			newElement.SetAttribute("height", frag.FirstChild.Attributes.GetNamedItem("height").InnerText);

			id = frag.FirstChild.Attributes.GetNamedItem("id").InnerText;
			newElement.SetAttribute("id", id);

			if (solid.Clip) newElement.SetAttribute("class", classId);

			//Append image to the current container
			document.ContainerNode.AppendChild(newElement);

		}
		private void AddShapeText(SvgDocument document, SolidElement solid, string strClipId)
		{
			if (solid.Label.Text.Trim() == "") return;

			Style style = new Style();

			//Add clipping to style if required
			style.ClipPathId = strClipId;

			//Set up text object
			Text text = new Text();
			text.Label = solid.Label;
			text.LayoutRectangle = solid.InternalRectangle;

			//Get style
			string classId = null;
			classId = document.AddClass(text.GetStyle(strClipId), "");

			//Create fragment and add to document
			XmlDocumentFragment frag = null;
			XmlNode newElementNode = null;

			frag = document.CreateDocumentFragment();
			frag.InnerXml = text.ExtractText(0, 0, solid.Key +"Text");
			frag.FirstChild.Attributes.GetNamedItem("class").InnerText = classId;
			newElementNode = document.ContainerNode.AppendChild(frag);
		}
Beispiel #11
0
 public ImageRef(SolidElement solid, Image image)
 {
     mImage = image;
     mSolid = solid;
 }
Beispiel #12
0
        public override void WriteElement(SvgDocument document, Element element)
        {
            SolidElement solid = (SolidElement)element;

            Definition definition = new Definition(solid.GetPath());
            Style      style      = null;

            //Add the definition
            //Determine definition
            DefinitionId = document.AddDefinition(definition.ExtractDefinition(), "");

            //Get style, no clipping path as this time
            style = new Style(solid);

            //Add the shadow use only if background is drawn, layer has shadows, and is a subclass of solid
            if (solid.DrawBackground && solid.Layer.DrawShadows && solid.GetType() != typeof(SolidElement) && solid.GetType() != typeof(Port))
            {
                StringBuilder stringBuilder = new System.Text.StringBuilder();
                double        opacity       = Math.Round(Convert.ToDouble(solid.Opacity / 1000F), 2);

                stringBuilder.Append("fill:");
                stringBuilder.Append(ColorTranslator.ToHtml(solid.Layer.ShadowColor));
                stringBuilder.Append(";fill-opacity:");
                stringBuilder.Append(opacity.ToString());
                stringBuilder.Append(";");

                ClassId = document.AddClass(stringBuilder.ToString(), "");

                document.AddUse(solid.Key.ToString() + "Shadow", DefinitionId, ClassId, "", solid.X + element.Layer.ShadowOffset.X, solid.Y + element.Layer.ShadowOffset.Y);
            }

            //Determine style
            ClassId = document.AddClass(style.GetStyle(), style.LinearGradient);

            //Add the use
            document.AddUse(solid.Key.ToString(), DefinitionId, ClassId, "", solid.X, solid.Y);

            SetNode(document.Node);

            if (solid.Image != null || solid.Label != null)
            {
                ClipId = document.AddClipPath(DefinitionId, 0, 0);

                //Add a group for the complex shape
                XmlElement newElement = null;

                StringBuilder builder = new StringBuilder();
                builder.Append("translate(");
                builder.Append(XmlConvert.ToString(solid.X));
                builder.Append(",");
                builder.Append(XmlConvert.ToString(solid.Y));
                builder.Append(")");

                newElement = document.CreateElement("g");
                newElement.SetAttribute("id", solid.Key + "Container");
                newElement.SetAttribute("transform", builder.ToString());

                document.ContainerNode.AppendChild(newElement);

                //Set the element as the temporary container node
                XmlNode temp = document.ContainerNode;
                document.ContainerNode = newElement;

                //Add images
                if (solid.Image != null)
                {
                    AddShapeImage(document, solid, DefinitionId, ClipId);
                }

                //Add text with a clipping path
                if (solid.Label != null)
                {
                    AddShapeText(document, solid, ClipId);
                }

                document.ContainerNode = temp;
            }
        }
Beispiel #13
0
		public Style(SolidElement solid, string clipId)
		{
			mSolid = solid;
			mClipId = clipId;
			mStyle = StyleFromShapeImplementation(solid, clipId);
		}
Beispiel #14
0
		private string StyleFromShapeImplementation(SolidElement solid, string clipId)
		{
			StringBuilder style = new StringBuilder();

			//Sort out the fill
			style.Append("fill:");
			
			if (!solid.DrawBackground)
			{
				style.Append("none;");
			}
			else
			{
				if (solid.DrawGradient && solid.BackColor != solid.GradientColor)
				{
					mLinearGradient = ExtractLinearGradient(solid.GradientMode, solid.BackColor, solid.GradientColor);
					style.Append("url(#none);");
				}
				else
				{
					mLinearGradient = "";
					style.Append(GetCompatibleColor(solid.BackColor));
					style.Append(";");
				}

				if (solid.Opacity < 100)
				{
					style.Append("fill-opacity:0.");
					style.Append(solid.Opacity.ToString());
					style.Append(";");
				}
			}

			//Sort out the stroke, ignore custom pens and use defaults
			style.Append("stroke:");
			style.Append(GetCompatibleColor(solid.BorderColor));
			style.Append(";");
			style.Append("stroke-width:");
			style.Append(solid.BorderWidth);
			style.Append(";");
			style.Append(GetDashStyle(mSolid.BorderStyle, mSolid.BorderWidth));

			//Add clipping path id if required
			if (clipId != "")
			{
				style.Append("clip-path:url(#");
				style.Append(clipId);
				style.Append(");");
			}

			return style.ToString();
		}
Beispiel #15
0
        private void SetColors(ServerType serverType)
        {
            //Get the application child element
            SolidElement solid = (SolidElement)Children["solid"];
            Port         port;

            if (solid == null)
            {
                return;
            }

            if (serverType == ServerType.Web)
            {
                BorderColor       = Color.FromArgb(255, 24, 54, 118);
                BackColor         = Color.FromArgb(255, 241, 243, 255);
                solid.BorderColor = Color.FromArgb(255, 141, 163, 212);
                solid.Label.Text  = "Website";

                port             = (Port)Ports["top"];
                port.BorderColor = Color.FromArgb(255, 141, 163, 212);

                port             = (Port)Ports["bottom"];
                port.BorderColor = Color.FromArgb(255, 141, 163, 212);
            }
            else if (serverType == ServerType.Business)
            {
                BorderColor       = Color.FromArgb(255, 91, 172, 17);
                BackColor         = Color.FromArgb(255, 247, 253, 243);
                solid.BorderColor = Color.FromArgb(255, 202, 210, 187);
                solid.Label.Text  = "Business Objects";

                port             = (Port)Ports["top"];
                port.BorderColor = Color.FromArgb(255, 202, 210, 187);

                port             = (Port)Ports["bottom"];
                port.BorderColor = Color.FromArgb(255, 202, 210, 187);
            }
            else if (serverType == ServerType.SQL)
            {
                BorderColor       = Color.FromArgb(255, 189, 182, 110);
                BackColor         = Color.FromArgb(255, 255, 250, 236);
                solid.BorderColor = Color.FromArgb(255, 215, 214, 196);
                solid.Label.Text  = "Database";

                port             = (Port)Ports["top"];
                port.BorderColor = Color.FromArgb(255, 215, 214, 196);

                port             = (Port)Ports["bottom"];
                port.BorderColor = Color.FromArgb(255, 215, 214, 196);
            }
            else if (serverType == ServerType.Generic)
            {
                BorderColor       = Color.FromArgb(255, 101, 28, 35);
                BackColor         = Color.FromArgb(255, 254, 244, 242);
                solid.BorderColor = Color.FromArgb(255, 195, 172, 166);
                solid.Label.Text  = "Application";

                port             = (Port)Ports["top"];
                port.BorderColor = Color.FromArgb(255, 195, 172, 166);

                port             = (Port)Ports["bottom"];
                port.BorderColor = Color.FromArgb(255, 195, 172, 166);
            }
        }
        //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);
        }
Beispiel #17
0
        protected virtual void RenderElement(Graphics graphics, Element element)
        {
            GraphicsPath path = element.GetPathInternal();

            if (path == null)
            {
                return;
            }

            //Create a brush if no custom brush defined
            if (element is SolidElement)
            {
                SolidElement solid = (SolidElement)element;
                if (solid.DrawBackground)
                {
                    if (solid.CustomBrush == null)
                    {
                        //Use a linear gradient brush if gradient requested
                        if (solid.DrawGradient)
                        {
                            LinearGradientBrush brush;
                            brush = new LinearGradientBrush(new RectangleF(0, 0, solid.Rectangle.Width, solid.Rectangle.Height), AdjustColor(solid.BackColor, 0, solid.Opacity), AdjustColor(solid.GradientColor, 0, solid.Opacity), solid.GradientMode);
                            if (solid.Blend != null)
                            {
                                brush.Blend = solid.Blend;
                            }
                            graphics.FillPath(brush, path);
                        }
                        //Draw normal solid brush
                        else
                        {
                            SolidBrush brush;
                            brush = new SolidBrush(solid.BackColor);

                            //Check if winforms renderer and adjust color as required
                            brush.Color = AdjustColor(solid.BackColor, 0, solid.Opacity);
                            graphics.FillPath(brush, path);
                        }
                    }
                    else
                    {
                        graphics.FillPath(solid.CustomBrush, path);
                    }
                }
            }

            Pen pen = null;

            if (element.CustomPen == null)
            {
                pen           = new Pen(element.BorderColor, element.BorderWidth);
                pen.DashStyle = element.BorderStyle;

                //Check if winforms renderer and adjust color as required
                pen.Color = AdjustColor(element.BorderColor, element.BorderWidth, element.Opacity);
            }
            else
            {
                pen = element.CustomPen;
            }

            graphics.DrawPath(pen, path);
        }
        //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);
        }
Beispiel #19
0
 public Style(SolidElement solid)
 {
     mSolid = solid;
     mStyle = StyleFromShapeImplementation(solid, "");
 }
Beispiel #20
0
        private void Form2_Load(object sender, System.EventArgs e)
        {
            Table table = new Table();

            //Set Element properties
            table.BackColor     = Color.White;
            table.GradientColor = Color.FromArgb(96, SystemColors.Highlight);
            table.Location      = new PointF(100, 50);
            table.Width         = 140;
            table.Height        = 500;
            table.Indent        = 10;
            table.Heading       = "Element";
            table.SubHeading    = "Class";

            //Add the fields group
            TableGroup fieldGroup = new TableGroup();

            fieldGroup.Text = "Fields";
            table.Groups.Add(fieldGroup);

            //Add the fields rows
            //Layer
            TableRow row = new TableRow();

            row.Text  = "Layer";
            row.Image = new Crainiate.ERM4.Image("Resource.publicfield.gif", "Crainiate.ERM4.Component");
            fieldGroup.Rows.Add(row);

            //SuspendEvents
            row       = new TableRow();
            row.Text  = "SuspendEvents";
            row.Image = new Crainiate.ERM4.Image("Resource.protectedfield.gif", "Crainiate.ERM4.Component");
            fieldGroup.Rows.Add(row);

            //Add the methods group
            TableGroup methodGroup = new TableGroup();

            methodGroup.Text = "Methods";
            table.Groups.Add(methodGroup);

            //Add the methods rows
            //AddPath
            row       = new TableRow();
            row.Text  = "AddPath";
            row.Image = new Crainiate.ERM4.Image("Resource.publicmethod.gif", "Crainiate.ERM4.Component");
            methodGroup.Rows.Add(row);

            row       = new TableRow();
            row.Image = new Crainiate.ERM4.Image("Resource.protectedmethod.gif", "Crainiate.ERM4.Component");
            row.Text  = "SetLayer";
            methodGroup.Rows.Add(row);

            //Add Element to model
            model1.Shapes.Add("Element", table);

            //Add a complex shape
            ComplexShape complex = new ComplexShape();

            //Set the shape appearance
            complex.Location    = new PointF(200, 100);
            complex.Size        = new SizeF(120, 100);
            complex.BorderWidth = 2;
            complex.BorderColor = Color.FromArgb(255, 24, 54, 118);
            complex.BackColor   = Color.FromArgb(255, 241, 243, 255);

            //Add the internal shape
            SolidElement solid = new SolidElement();

            solid.Location    = new PointF(10, 10);
            solid.Label       = new TextLabel();
            solid.Label.Text  = "Website";
            solid.BorderColor = Color.FromArgb(255, 141, 163, 212);

            //Add the internal shape to the complex shape
            complex.Children.Add("solid", solid);

            //Add the complex shape to the model
            model1.Shapes.Add("complex", complex);
        }
Beispiel #21
0
 public Style(SolidElement solid, string clipId)
 {
     mSolid  = solid;
     mClipId = clipId;
     mStyle  = StyleFromShapeImplementation(solid, clipId);
 }
Beispiel #22
0
		public Style(SolidElement solid)
		{
			mSolid = solid;
			mStyle = StyleFromShapeImplementation(solid, "");
		}
Beispiel #23
0
		public ImageRef(SolidElement solid, Image image)
		{
			mImage = image;
			mSolid = solid;
		}
Beispiel #24
0
        private void LoadModel()
        {
            Crainiate.Diagramming.Component.Instance.DefaultFont = new Font("Tahoma", 8);

            //Add the DMZ zone to the model
            Zone dmz = new Zone();

            dmz.Location   = new Point(40, 20);
            dmz.Size       = new SizeF(220, 180);
            dmz.Label.Text = "DMZ";

            model1.Shapes.Add("dmz", dmz);

            //Add a server to the zone
            Server server = new Server();

            server.Location   = new PointF(50, 30);
            server.ServerType = ServerType.Web;

            SolidElement application = (SolidElement)server.Children["application"];

            application.Label.Text = "Company Website";

            dmz.Shapes.Add("server", server);

            //Add two ports to the zone
            Port port;

            port = new Port(PortOrientation.Top);
            dmz.Ports.Add("top", port);

            port = new Port(PortOrientation.Bottom);
            dmz.Ports.Add("bottom", port);

            //Add the internal zone to the model
            Zone intranet = new Zone();

            intranet.Location   = new Point(300, 20);
            intranet.Size       = new SizeF(220, 180);
            intranet.Label.Text = "Internal";

            model1.Shapes.Add("internal", intranet);

            //Add a server to the zone
            server            = new Server();
            server.Location   = new PointF(50, 30);
            server.ServerType = ServerType.Web;

            application            = (SolidElement)server.Children["application"];
            application.Label.Text = "Intranet";

            intranet.Shapes.Add("server", server);

            //Add a port to the zone
            port = new Port(PortOrientation.Bottom);
            intranet.Ports.Add("bottom", port);

            //Add zone3 to the model
            Zone zone3 = new Zone();

            zone3.Location   = new Point(300, 250);
            zone3.Size       = new SizeF(220, 280);
            zone3.Label.Text = "Zone3";

            model1.Shapes.Add("zone3", zone3);

            //Add two servers to the zone
            server            = new Server();
            server.Location   = new PointF(50, 30);
            server.ServerType = ServerType.Web;
            zone3.Shapes.Add("server", server);

            server            = new Server();
            server.Location   = new PointF(50, 150);
            server.ServerType = ServerType.Generic;
            zone3.Shapes.Add("server2", server);

            //Add two servers outside any zones
            Server business = new Server();

            business.Location   = new PointF(90, 260);
            business.ServerType = ServerType.Business;

            //Add a port to business
            port = new Port(PortOrientation.Right);
            business.Ports.Add("right", port);

            model1.Shapes.Add("business", business);

            Server sql = new Server();

            sql.Location   = new PointF(90, 400);
            sql.ServerType = ServerType.SQL;
            model1.Shapes.Add("database", sql);

            //Connect the dmz to the business server
            Connector connector = new Connector((Port)dmz.Ports["bottom"], (Port)business.Ports["top"]);

            connector.BorderColor = business.BorderColor;
            connector.BorderWidth = 2;
            connector.DrawShadow  = false;

            //Set up line marker (line cap)
            connector.End.Marker             = new Arrow();
            connector.End.Marker.BorderColor = business.BorderColor;
            connector.End.Marker.BackColor   = business.BorderColor;

            model1.Lines.Add("dmztobusiness", connector);

            //Connect intranet to business server
            connector             = new Connector((Port)intranet.Ports["bottom"], (Port)business.Ports["right"]);
            connector.BorderColor = business.BorderColor;
            connector.BorderWidth = 2;
            connector.DrawShadow  = false;

            //Set up line marker (line cap)
            connector.End.Marker             = new Arrow();
            connector.End.Marker.BorderColor = business.BorderColor;
            connector.End.Marker.BackColor   = business.BorderColor;

            model1.Lines.Add("intranettobusiness", connector);

            //Connect business to sql server
            connector             = new Connector((Port)business.Ports["bottom"], (Port)sql.Ports["top"]);
            connector.BorderColor = sql.BorderColor;
            connector.BorderWidth = 2;
            connector.DrawShadow  = false;

            //Set up line marker (line cap)
            connector.End.Marker             = new Arrow();
            connector.End.Marker.BorderColor = sql.BorderColor;
            connector.End.Marker.BackColor   = sql.BorderColor;

            model1.Lines.Add("businesstosql", connector);

            model1.Invalidate();
        }
        //Loop through layers and elements and render
        public virtual void RenderDiagramElements(Graphics graphics)
        {
            OnPreRender(graphics);

            //Set graphics
            graphics.InterpolationMode  = InterpolationMode;
            graphics.CompositingMode    = CompositingMode;
            graphics.CompositingQuality = CompositingQuality;
            graphics.SmoothingMode      = SmoothingMode;
            graphics.PixelOffsetMode    = PixelOffsetMode;

            bool drawBackgroundTemp = false;

            foreach (Layer layer in mLayers)
            {
                if (layer.Visible)
                {
                    mWorldOpacity = layer.Opacity;
                    mCurrentLayer = layer;

                    //Draw each element by checking if it is renderable and calling the render method
                    if (DrawShadows && layer.DrawShadows)
                    {
                        foreach (Element element in mElementRenderList)
                        {
                            if (element.Layer == layer && element.Visible)
                            {
                                if (SelectForPrint(element))
                                {
                                    //Draw shapes
                                    GraphicsState graphicsState = graphics.Save();

                                    graphics.TranslateTransform(element.Rectangle.X, element.Rectangle.Y);
                                    element.RenderShadow(graphics, this);
                                    graphics.Restore(graphicsState);
                                }
                            }
                        }
                    }

                    //Draw each element by checking if it is renderable and calling the render method
                    foreach (Element element in mElementRenderList)
                    {
                        if (element.Layer == layer && element.Visible)
                        {
                            if (SelectForPrint(element))
                            {
                                //Draw shapes
                                GraphicsState graphicsState = graphics.Save();
                                SolidElement  solid         = null;

                                if (element is SolidElement)
                                {
                                    solid = (SolidElement)element;
                                    drawBackgroundTemp    = solid.DrawBackground;
                                    solid.mDrawBackground = DrawBackground;
                                }

                                graphics.TranslateTransform(element.Rectangle.X, element.Rectangle.Y);
                                element.Render(graphics, this);
                                graphics.Restore(graphicsState);

                                if (element is SolidElement)
                                {
                                    solid.mDrawBackground = drawBackgroundTemp;
                                }
                            }
                        }
                    }
                }
            }

            //Reset current layer
            mCurrentLayer = null;

            OnPostRender(graphics);
        }