Ejemplo n.º 1
0
 private void PreInit(Project project, int diameterOuter)
 {
     circleOuter = (CircleBase)CircleType.CreateInstance();
     circleOuter.IsToolbarHidden = true;
     circleOuter.FillStyle       = project.Design.FillStyles.White;
     circleOuter.Diameter        = diameterOuter;
 }
Ejemplo n.º 2
0
 public ActionCollection(Project project, ShapeBase parent, int diameter)
 {
     circleOuter = (CircleBase)CircleType.CreateInstance();
     circleOuter.IsToolbarHidden = true;
     //circleOuter.FillStyle = project.Design.FillStyles.White;
     circleOuter.Diameter = diameter;
     parent.Children.Add(circleOuter);
 }
Ejemplo n.º 3
0
    public Calendar(Project project, ShapeBase parent, int width, int height)
    {
        this.project = project;

        boxCalendar        = (BoxBase)BoxType.CreateInstance();
        boxCalendar.Tag    = int.MinValue;
        boxCalendar.Width  = width;
        boxCalendar.Height = height;
        parent.Children.Add(boxCalendar);

        Init();
    }
Ejemplo n.º 4
0
 /// <summary>
 /// For each loaded Type, a new <see cref="T:Dataweb.NShape.Advanced.Template" /> is created.
 /// These automatically created templates are not stored by the cache.
 /// </summary>
 /// <param name="shapeType"></param>
 private void CreateDefaultTemplate(ShapeType shapeType)
 {
     if (shapeType.SupportsAutoTemplates)
     {
         Template template = new Template(shapeType.Name, shapeType.CreateInstance());
         Repository.InsertTemplate(template);
     }
 }
        public void SetDefaultShapes(ShapeType tableShape, ShapeType relationshipShape, ShapeType lblShape)
        {
            TableShape = tableShape;
            RelationshipShape = relationshipShape;
            LblShape = lblShape;

            var charStyle = ((EntitySymbol) tableShape.CreateInstance()).ColumnCharacterStyle;
            baseEntityFont = new Font(charStyle.FontFamily, charStyle.SizeInPoints, FontStyle.Bold);
        }
Ejemplo n.º 6
0
    private void Init()
    {
#if BOX
        for (int i = 0, n = currWeekDays.Length; i < n; ++i)
        {
            currWeekDays[i]     = (BoxBase)BoxType.CreateInstance();
            currWeekDays[i].Tag = int.MinValue;
            boxCalendar.Children.Add(currWeekDays[i]);
        }
        currWeekDays[5].LineStyle = project.Design.LineStyles.Red;                      // Saturday, Суббота
        currWeekDays[6].LineStyle = project.Design.LineStyles.Red;                      // Sunday, Воскресенье
        PlaceWeekDays(false, currWeekDays);

        for (int i = 0, n = nextWeekDays.Length; i < n; ++i)
        {
            nextWeekDays[i]     = (BoxBase)BoxType.CreateInstance();
            nextWeekDays[i].Tag = int.MinValue;
            boxCalendar.Children.Add(nextWeekDays[i]);
        }
        nextWeekDays[5].LineStyle = project.Design.LineStyles.Red;                      // Saturday, Суббота
        nextWeekDays[6].LineStyle = project.Design.LineStyles.Red;                      // Sunday, Воскресенье
        PlaceWeekDays(true, nextWeekDays);
#else
        for (int i = 0, n = currWeekDays.Length; i < n; ++i)
        {
            currWeekDays[i]     = (PolylineBase)PolylineType.CreateInstance();
            currWeekDays[i].Tag = int.MinValue;
            boxCalendar.Children.Add(currWeekDays[i]);
        }
        currWeekDays[5].LineStyle = project.Design.LineStyles.Red;                      // Saturday, Суббота
        currWeekDays[6].LineStyle = project.Design.LineStyles.Red;                      // Sunday, Воскресенье
        PlaceWeekDays(false, currWeekDays);

        for (int i = 0, n = nextWeekDays.Length; i < n; ++i)
        {
            nextWeekDays[i]     = (PolylineBase)PolylineType.CreateInstance();
            nextWeekDays[i].Tag = int.MinValue;
            boxCalendar.Children.Add(nextWeekDays[i]);
        }
        nextWeekDays[5].LineStyle = project.Design.LineStyles.Red;                      // Saturday, Суббота
        nextWeekDays[6].LineStyle = project.Design.LineStyles.Red;                      // Sunday, Воскресенье
        PlaceWeekDays(true, nextWeekDays);
#endif
    }
Ejemplo n.º 7
0
    public RectangleBase AddAction(int id)
    {
        RectangleBase act = (RectangleBase)ActionType.CreateInstance();

        act.IsToolbarHidden = true;
        acts.Add(id, act);
        circleOuter.Children.Add(act);
        //	ChangePropCount();
        return(act);
    }
Ejemplo n.º 8
0
    public TriangleBase AddProp(int id, ILineStyle lineStyle)
    {
        TriangleBase prop = (TriangleBase)PropType.CreateInstance();

        prop.IsToolbarHidden = true;
        if (lineStyle != null)
        {
            prop.LineStyle = lineStyle;
        }
        props.Add(id, prop);
        circleOuter.Children.Add(prop);
        ChangePropCount();
        return(prop);
    }
Ejemplo n.º 9
0
        /// <summary>
        /// Create tools for the shape toolbox and sort them into custom categories
        /// </summary>
        private void CreateTools()
        {
            toolSetPresenter.ToolSetController.Clear();
            toolSetPresenter.ToolSetController.AddTool(new SelectionTool(), true);

            string         category      = "Database Entities";
            DatabaseSymbol databaseShape = (DatabaseSymbol)project.ShapeTypes["Database"].CreateInstance();

            databaseShape.Width          = 120;
            databaseShape.Height         = 120;
            databaseShape.FillStyle      = project.Design.FillStyles.Yellow;
            databaseShape.CharacterStyle = project.Design.CharacterStyles.Heading3;
            databaseShape.Text           = "Database";
            CreateTemplateAndTool("Database", category, databaseShape);

            EntitySymbol tableShape = (EntitySymbol)project.ShapeTypes["Entity"].CreateInstance();

            tableShape.Width                = 100;
            tableShape.Height               = 160;
            tableShape.FillStyle            = project.Design.FillStyles.Red;
            tableShape.CharacterStyle       = project.Design.CharacterStyles.Heading3;
            tableShape.ParagraphStyle       = project.Design.ParagraphStyles.Title;
            tableShape.ColumnCharacterStyle = project.Design.CharacterStyles.Caption;
            tableShape.ColumnParagraphStyle = project.Design.ParagraphStyles.Label;
            CreateTemplateAndTool("Entity", category, tableShape);

            RectangularLine line;
            ShapeType       relationShapeType = project.ShapeTypes["RectangularLine"];

            line           = (RectangularLine)relationShapeType.CreateInstance();
            line.LineStyle = project.Design.LineStyles.Thick;
            CreateTemplateAndTool("Relationship", category, line);

            line             = (RectangularLine)relationShapeType.CreateInstance();
            line.LineStyle   = project.Design.LineStyles.Thick;
            line.EndCapStyle = project.Design.CapStyles.ClosedArrow;
            CreateTemplateAndTool("1:n Relationship", category, line);

            line               = (RectangularLine)relationShapeType.CreateInstance();
            line.LineStyle     = project.Design.LineStyles.Thick;
            line.StartCapStyle = project.Design.CapStyles.ClosedArrow;
            line.EndCapStyle   = project.Design.CapStyles.ClosedArrow;
            CreateTemplateAndTool("n:m Relationship", category, line);

            CloudSymbol cloudShape = (CloudSymbol)project.ShapeTypes["Cloud"].CreateInstance();

            cloudShape.FillStyle      = project.Design.FillStyles.Blue;
            cloudShape.CharacterStyle = project.Design.CharacterStyles.Heading1;
            cloudShape.Width          = 300;
            cloudShape.Height         = 160;
            cloudShape.Text           = "WAN / LAN";
            CreateTemplateAndTool("Cloud", category, cloudShape);

            category = "Description";
            Text text = (Text)project.ShapeTypes["Text"].CreateInstance();

            text.CharacterStyle = project.Design.CharacterStyles.Normal;
            text.Width          = 100;
            CreateTemplateAndTool("Text", category, text);

            AnnotationSymbol annotationShape = (AnnotationSymbol)project.ShapeTypes["Annotation"].CreateInstance();

            annotationShape.FillStyle      = project.Design.FillStyles.White;
            annotationShape.CharacterStyle = project.Design.CharacterStyles.Caption;
            annotationShape.ParagraphStyle = project.Design.ParagraphStyles.Text;
            annotationShape.Width          = 120;
            annotationShape.Height         = 120;
            CreateTemplateAndTool("Annotation", category, annotationShape);

            category = "Miscellaneous";
            RoundedBox roundedRectangle = (RoundedBox)project.ShapeTypes["RoundedBox"].CreateInstance();

            roundedRectangle.FillStyle = project.Design.FillStyles.Green;
            roundedRectangle.Width     = 120;
            roundedRectangle.Height    = 80;
            CreateTemplateAndTool("Box", category, roundedRectangle);

            Ellipse ellipse = (Ellipse)project.ShapeTypes["Ellipse"].CreateInstance();

            ellipse.FillStyle = project.Design.FillStyles.Yellow;
            ellipse.Width     = 120;
            ellipse.Height    = 80;
            CreateTemplateAndTool("Ellipse", category, ellipse);

            Picture picture = (Picture)project.ShapeTypes["Picture"].CreateInstance();

            picture.FillStyle = project.Design.FillStyles.Transparent;
            picture.Width     = 120;
            picture.Height    = 120;
            CreateTemplateAndTool("Picture", category, picture);

            ShapeType   arcShapeType = project.ShapeTypes["CircularArc"];
            CircularArc arc;

            arc           = (CircularArc)arcShapeType.CreateInstance();
            arc.LineStyle = project.Design.LineStyles.Thick;
            CreateTemplateAndTool("Arc", category, arc);

            arc             = (CircularArc)arcShapeType.CreateInstance();
            arc.LineStyle   = project.Design.LineStyles.Thick;
            arc.EndCapStyle = project.Design.CapStyles.ClosedArrow;
            CreateTemplateAndTool("Bowed Arrow", category, arc);

            arc               = (CircularArc)arcShapeType.CreateInstance();
            arc.LineStyle     = project.Design.LineStyles.Thick;
            arc.StartCapStyle = project.Design.CapStyles.ClosedArrow;
            arc.EndCapStyle   = project.Design.CapStyles.ClosedArrow;
            CreateTemplateAndTool("Bowed Double Arrow", category, arc);
        }
Ejemplo n.º 10
0
        private void loadWebStatisticsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string statsDir = Path.Combine("Demo Programs", Path.Combine("WebVisits", "Sample Web Statistics"));

            openFileDialog.Filter           = "Web Statistics|*.xml|All files|*.*";
            openFileDialog.InitialDirectory = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Application.StartupPath)), statsDir);
            openFileDialog.FileName         = string.Empty;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                // Create a new diagram
                ShapeType boxType       = project.ShapeTypes["Ellipse"];
                ShapeType multiLineType = project.ShapeTypes["Polyline"];

                Dictionary <int, RectangleBase> boxes = new Dictionary <int, RectangleBase>();
                List <Polyline> lines = new List <Polyline>();
                //
                // Create shapes for the web pages and connect them with lines
                XmlScanner scanner = new XmlScanner(openFileDialog.FileName);
                scanner.ReadElement();
                scanner.ReadElement("WebVisits");
                scanner.ReadChild("Pages");
                if (scanner.ReadChild("Page"))
                {
                    do
                    {
                        scanner.ReadAttribute();                 // id attribute
                        RectangleBase box = (RectangleBase)boxType.CreateInstance(pageTemplate);
                        box.Width = 140;
                        boxes.Add(scanner.IntValue, box);
                        scanner.ReadAttribute();
                        box.Text = scanner.StringValue;
                    } while (scanner.ReadElement());
                }
                scanner.ReadParent();
                if (scanner.ReadChild("Referral"))
                {
                    do
                    {
                        scanner.ReadAttribute();                         // id1
                        int   id1    = scanner.IntValue;
                        Shape shape1 = boxes[id1];
                        scanner.ReadAttribute();                         // id2
                        int   id2    = scanner.IntValue;
                        Shape shape2 = boxes[id2];
                        scanner.ReadAttribute();                         // count
                        int      count = scanner.IntValue;
                        Polyline line  = (Polyline)multiLineType.CreateInstance();
                        line.EndCapStyle = project.Design.CapStyles.Arrow;
                        line.LineStyle   = GetLineStyle(count);
                        line.Connect(ControlPointId.FirstVertex, shape1, ControlPointId.Reference);
                        line.Connect(ControlPointId.LastVertex, shape2, ControlPointId.Reference);
                        lines.Add(line);
                    } while (scanner.ReadElement());
                }
                scanner.ReadParent();
                scanner.Close();
                //
                // Insert all shapes into the diagram
                int cnt = 0;
                foreach (Diagram d in project.Repository.GetDiagrams())
                {
                    ++cnt;
                }
                Diagram diagram = new Diagram(string.Format("WebVisits Diagram {0}", cnt));
                diagram.Width  = 1000;
                diagram.Height = 1000;
                diagram.BackgroundImageLayout = Dataweb.NShape.ImageLayoutMode.Fit;
                foreach (RectangleBase b in boxes.Values)
                {
                    diagram.Shapes.Add(b, project.Repository.ObtainNewTopZOrder(diagram));
                }
                foreach (Polyline l in lines)
                {
                    diagram.Shapes.Add(l, project.Repository.ObtainNewBottomZOrder(diagram));
                }

                boxes.Clear();
                lines.Clear();
                //
                // Insert the diagram (including all shapes) into the repository
                project.Repository.InsertDiagram(diagram);
                //
                // Layout the shapes
                if (layouter == null)
                {
                    layouter = new RepulsionLayouter(project);
                }
                layouter.SpringRate     = 14;
                layouter.Repulsion      = 7;
                layouter.RepulsionRange = 400;
                layouter.Friction       = 0;
                layouter.Mass           = 50;
                //
                layouter.AllShapes = diagram.Shapes;
                layouter.Shapes    = diagram.Shapes;

                layouter.Prepare();
                layouter.Execute(10);
                layouter.Fit(50, 50, diagram.Width - 100, diagram.Height - 100);
                //
                // Display the result
                display.Diagram = diagram;
            }
        }
Ejemplo n.º 11
0
        private static void CreateTemplatesFromShapeTypes(Project project, IList <String> shapeTypeNames, Int32 shapeSize, Boolean withModels, Boolean withTerminalMappings, Boolean withModelMappings, Int32 expectedShapeCount)
        {
            if (shapeTypeNames == null)
            {
                shapeTypeNames = new List <String>();
                shapeTypeNames.Add("Circle");
                shapeTypeNames.Add("PolyLine");
            }
            //
            foreach (String shapeTypeName in shapeTypeNames)
            {
                ShapeType shapeType = project.ShapeTypes[shapeTypeName];
                // Create a shape for the template
                Shape shape = shapeType.CreateInstance();
                shape.Fit(0, 0, shapeSize, shapeSize);
                // Create the template
                Template template = new Template(String.Format("{0} Template", shapeType.Name), shapeType.CreateInstance());
                if (shape is IPlanarShape)
                {
                    // Add optional data
                    if (withModels)
                    {
                        template.Shape.ModelObject = project.ModelObjectTypes["Core.GenericModelObject"].CreateInstance();
                        template.MapTerminal(TerminalId.Generic, ControlPointId.Reference);
                        if (withTerminalMappings)
                        {
                            foreach (ControlPointId id in template.Shape.GetControlPointIds(ControlPointCapabilities.Connect))
                            {
                                template.MapTerminal(TerminalId.Generic, id);
                            }
                        }
                        if (withModelMappings)
                        {
                            //
                            // Create ModelMappings
                            List <IModelMapping> modelMappings = new List <IModelMapping>(3);
                            // Create numeric- and format model mappings
                            NumericModelMapping numericMapping = new NumericModelMapping(2, 4, NumericModelMapping.MappingType.FloatInteger, 10, 0);
                            FormatModelMapping  formatMapping  = new FormatModelMapping(4, 2, FormatModelMapping.MappingType.StringString, "{0}");
                            // Create style model mapping
                            float             range             = expectedShapeCount / 15f;
                            StyleModelMapping styleModelMapping = new StyleModelMapping(1, 4, StyleModelMapping.MappingType.FloatStyle);
                            for (int i = 0; i < 15; ++i)
                            {
                                IStyle style = null;
                                switch (i)
                                {
                                case 0: style = project.Design.LineStyles.None; break;

                                case 1: style = project.Design.LineStyles.Dotted; break;

                                case 2: style = project.Design.LineStyles.Dashed; break;

                                case 3: style = project.Design.LineStyles.Special1; break;

                                case 4: style = project.Design.LineStyles.Special2; break;

                                case 5: style = project.Design.LineStyles.Normal; break;

                                case 6: style = project.Design.LineStyles.Blue; break;

                                case 7: style = project.Design.LineStyles.Green; break;

                                case 8: style = project.Design.LineStyles.Yellow; break;

                                case 9: style = project.Design.LineStyles.Red; break;

                                case 10: style = project.Design.LineStyles.HighlightDotted; break;

                                case 11: style = project.Design.LineStyles.HighlightDashed; break;

                                case 12: style = project.Design.LineStyles.Highlight; break;

                                case 13: style = project.Design.LineStyles.HighlightThick; break;

                                case 14: style = project.Design.LineStyles.Thick; break;

                                default: style = null; break;
                                }
                                if (style != null)
                                {
                                    styleModelMapping.AddValueRange(i * range, style);
                                }
                            }
                            modelMappings.Add(styleModelMapping);
                            //
                            foreach (IModelMapping modelMapping in modelMappings)
                            {
                                template.MapProperties(modelMapping);
                            }
                        }
                    }
                }
                else if (shape is ILinearShape)
                {
                    // Nothing else to do
                }
                else
                {
                    throw new NotImplementedException();
                }
                // Insert the template into the repository
                project.Repository.InsertAll(template);
            }
            Assert.AreEqual(EnumerationHelper.Count(project.Repository.GetTemplates()), shapeTypeNames.Count);
        }