示例#1
0
 public NodeAnnotation()
 {
     //Initialize sfdiagram
     diagram = new SfDiagram();
 }
        public override View GetSampleContent(Context context)
        {
            //Create SfDiagram.
            diagram = new SfDiagram(context);
            diagram.EnableSelection = false;

            FillColor = new Dictionary <string, Color>();
            FillColor.Add("Managing Director", Color.Rgb(239, 75, 93));
            FillColor.Add("Project Manager", Color.Rgb(49, 162, 255));
            FillColor.Add("Senior Manager", Color.Rgb(49, 162, 255));
            FillColor.Add("Project Lead", Color.Rgb(0, 194, 192));
            FillColor.Add("Senior S/W Engg", Color.Rgb(0, 194, 192));
            FillColor.Add("Software Engg", Color.Rgb(0, 194, 192));
            FillColor.Add("Team Lead", Color.Rgb(0, 194, 192));
            FillColor.Add("Project Trainee", Color.Rgb(255, 129, 0));

            StrokeColor = new Dictionary <string, Color>();
            StrokeColor.Add("Managing Director", Color.Rgb(201, 32, 61));
            StrokeColor.Add("Project Manager", Color.Rgb(23, 132, 206));
            StrokeColor.Add("Senior Manager", Color.Rgb(23, 132, 206));
            StrokeColor.Add("Project Lead", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Senior S/W Engg", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Software Engg", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Team Lead", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Project Trainee", Color.Rgb(206, 98, 9));

            dataModel = new DataModel();
            diagram.BackgroundColor  = Color.White;
            diagram.BeginNodeRender += Dia_BeginNodeRender;
            diagram.BeginNodeLayout += Dia_GetLayoutInfo;

            dataModel.Data();

            //To Represent DataSourceSttings Properties
            DataSourceSettings settings = new DataSourceSettings();

            settings.ParentId          = "ReportingPerson";
            settings.Id                = "Name";
            settings.DataSource        = dataModel.employee;
            diagram.DataSourceSettings = settings;

            //To Represent LayoutManager Properties
            diagram.LayoutManager = new LayoutManager()
            {
                Layout = new DirectedTreeLayout()
                {
                    Type = LayoutType.Organization,
                    HorizontalSpacing = 70 * MainActivity.factor,
                    VerticalSpacing   = 70 * MainActivity.factor
                }
            };

            for (int i = 0; i < diagram.Connectors.Count; i++)
            {
                diagram.Connectors[i].TargetDecoratorType = DecoratorType.None;
                diagram.Connectors[i].Style.StrokeBrush   = new SolidBrush(Color.Rgb(127, 132, 133));
            }
            diagram.NodeClicked     += Diagram_NodeClicked;
            diagram.ItemLongPressed += Diagram_ItemLongPressed;
            diagram.Loaded          += Diagram_Loaded;
            return(diagram);
        }
示例#3
0
        public override View GetSampleContent(Context context)
        {
            m_context = context;
            //Initialize the SfDiagram and set its background color.
            diagram = new SfDiagram(context);
            diagram.EnableSelection = false;
            diagram.BackgroundColor = Color.White;
            //Initialize the nodes and set its properties.
            var node1 = DrawNode(280 * 2 * MainActivity.Factor, 140 * 2 * MainActivity.Factor, 175 * 2 * MainActivity.Factor, 70 * 2 * MainActivity.Factor, ShapeType.RoundedRectangle);

            node1.Style.StrokeBrush = new SolidBrush(Color.Rgb(206, 98, 9));
            node1.Annotations.Add(new Annotation()
            {
                Content = FlowDiagram.CreateLabel(context, "Establish Project" + "\n" + "and Team", (int)node1.Width, Color.White), HorizontalAlignment = HorizontalAlignment.Center
            });
            diagram.AddNode(node1);

            var node2 = DrawNode(280 * 2 * MainActivity.Factor, node1.OffsetY + (140 * 2 * MainActivity.Factor), 175 * 2 * MainActivity.Factor, 70 * 2 * MainActivity.Factor, ShapeType.RoundedRectangle);

            node2.Style.StrokeBrush = new SolidBrush(Color.Rgb(206, 98, 9));
            node2.Style.Brush       = new LinearGradientBrush(0, 30, 150, 30, new Color[] { Color.Rgb(255, 130, 0), Color.Rgb(255, 37, 0) }, null, GradientDrawingOptions.Clamp);
            node2.Style.StrokeWidth = 0;
            node2.Annotations.Add(new Annotation()
            {
                Content = FlowDiagram.CreateLabel(context, "Define Scope", (int)node2.Width, Color.White), HorizontalAlignment = HorizontalAlignment.Center
            });
            diagram.AddNode(node2);

            var node3 = DrawNode(280 * 2 * MainActivity.Factor, node2.OffsetY + (140 * 2 * MainActivity.Factor), 175 * 2 * MainActivity.Factor, 70 * 2 * MainActivity.Factor, ShapeType.RoundedRectangle);

            node3.Style.StrokeBrush = new SolidBrush(Color.Rgb(206, 98, 9));
            node3.Style.StrokeStyle = StrokeStyle.Dashed;
            node3.Annotations.Add(new Annotation()
            {
                Content = FlowDiagram.CreateLabel(context, "Analyze process As-Is", (int)node3.Width, Color.White), HorizontalAlignment = HorizontalAlignment.Center
            });
            diagram.AddNode(node3);

            var node4 = DrawNode(280 * 2 * MainActivity.Factor, node3.OffsetY + (140 * 2 * MainActivity.Factor), 175 * 2 * MainActivity.Factor, 70 * 2 * MainActivity.Factor, ShapeType.RoundedRectangle);

            node4.Style.StrokeBrush = new SolidBrush(Color.Rgb(206, 98, 9));
            node4.Style.StrokeWidth = 0;
            node4.Annotations.Add(new Annotation()
            {
                Content = FlowDiagram.CreateLabel(context, "Identify" + "\n" + "opportunities" + "\n" + "for improvement", (int)node4.Width, Color.White), HorizontalAlignment = HorizontalAlignment.Center
            });
            diagram.AddNode(node4);

            var node5 = DrawNode(280 * 2 * MainActivity.Factor, node4.OffsetY + (140 * 2 * MainActivity.Factor), 175 * 2 * MainActivity.Factor, 70 * 2 * MainActivity.Factor, ShapeType.RoundedRectangle);

            node5.Style.StrokeBrush = new SolidBrush(Color.Rgb(206, 98, 9));
            node5.Style.StrokeWidth = 0;
            node5.Annotations.Add(new Annotation()
            {
                Content = FlowDiagram.CreateLabel(context, "Design and" + "\n" + "implement improved" + "\n" + "processess", (int)node5.Width, Color.White), HorizontalAlignment = HorizontalAlignment.Center
            });
            diagram.AddNode(node5);

            var node6 = DrawCustomShape(53 * 2, 155 * 2);

            node6.Ports.Add(new Port()
            {
                NodeOffsetX = 1, NodeOffsetY = 0.5, IsVisible = false
            });
            diagram.AddNode(node6);
            var labelnode6 = new Node(context);

            labelnode6.OffsetX = 37.5f * 2 * MainActivity.Factor;
            labelnode6.OffsetY = 200 * 2 * MainActivity.Factor;
            labelnode6.Width   = 80 * 2 * MainActivity.Factor;
            labelnode6.Height  = 35 * 2 * MainActivity.Factor;
            labelnode6.Annotations.Add(new Annotation()
            {
                Content = "Sponsor", FontSize = 28 * MainActivity.Factor, HorizontalAlignment = HorizontalAlignment.Center
            });
            labelnode6.Style = new Style()
            {
                StrokeBrush = new SolidBrush(Color.Transparent),
                Brush       = new SolidBrush(Color.Transparent)
            };
            diagram.AddNode(labelnode6);

            var node7 = DrawCustomShape(53 * 2, 497 * 2);

            node7.Ports.Add(new Port()
            {
                NodeOffsetX = 1, NodeOffsetY = 0, IsVisible = false
            });
            node7.Ports.Add(new Port()
            {
                NodeOffsetX = 1, NodeOffsetY = 0.3, IsVisible = false
            });
            node7.Ports.Add(new Port()
            {
                NodeOffsetX = 1, NodeOffsetY = 0.6, IsVisible = false
            });
            node7.Ports.Add(new Port()
            {
                NodeOffsetX = 1, NodeOffsetY = 1, IsVisible = false
            });
            diagram.AddNode(node7);
            var labelnode7 = new Node(context);

            labelnode7.OffsetX = 55 * 2 * MainActivity.Factor;
            labelnode7.OffsetY = 545 * 2 * MainActivity.Factor;
            labelnode7.Width   = 60 * 2 * MainActivity.Factor;
            labelnode7.Height  = 50 * 2 * MainActivity.Factor;
            labelnode7.Annotations.Add(new Annotation()
            {
                Content = "Domain Experts", FontSize = 28 * MainActivity.Factor, HorizontalAlignment = HorizontalAlignment.Center
            });
            labelnode7.Style = new Style()
            {
                StrokeBrush = new SolidBrush(Color.Transparent),
                Brush       = new SolidBrush(Color.Transparent)
            };
            diagram.AddNode(labelnode7);

            var node8 = DrawCustomShape(590 * 2, 155 * 2);

            node8.Ports.Add(new Port()
            {
                NodeOffsetX = 0, NodeOffsetY = 0.5, IsVisible = false
            });
            diagram.AddNode(node8);
            var labelnode8 = new Node(context);

            labelnode8.OffsetX = 590.5f * 2 * MainActivity.Factor;
            labelnode8.OffsetY = 200 * 2 * MainActivity.Factor;
            labelnode8.Width   = 78 * 2 * MainActivity.Factor;
            labelnode8.Height  = 49 * 2 * MainActivity.Factor;
            labelnode8.Annotations.Add(new Annotation()
            {
                Content = "Project Manager", FontSize = 28 * MainActivity.Factor, HorizontalAlignment = HorizontalAlignment.Center
            });
            labelnode8.Style = new Style()
            {
                StrokeBrush = new SolidBrush(Color.Transparent),
                Brush       = new SolidBrush(Color.Transparent)
            };
            diagram.AddNode(labelnode8);

            var node9 = DrawCustomShape(590 * 2, 497 * 2);

            node9.Ports.Add(new Port()
            {
                NodeOffsetX = 0, NodeOffsetY = 0, IsVisible = false
            });
            node9.Ports.Add(new Port()
            {
                NodeOffsetX = 0, NodeOffsetY = 0.3, IsVisible = false
            });
            node9.Ports.Add(new Port()
            {
                NodeOffsetX = 0, NodeOffsetY = 0.6, IsVisible = false
            });
            node9.Ports.Add(new Port()
            {
                NodeOffsetX = 0, NodeOffsetY = 1, IsVisible = false
            });
            diagram.AddNode(node9);
            var labelnode9 = new Node(context);

            labelnode9.OffsetX = 591 * 2 * MainActivity.Factor;
            labelnode9.OffsetY = 550 * 2 * MainActivity.Factor;
            labelnode9.Width   = 65 * 2 * MainActivity.Factor;
            labelnode9.Height  = 39 * 2 * MainActivity.Factor;
            labelnode9.Annotations.Add(new Annotation()
            {
                Content = "Business Analyst", FontSize = 28 * MainActivity.Factor, HorizontalAlignment = HorizontalAlignment.Center
            });
            labelnode9.Style = new Style()
            {
                StrokeBrush = new SolidBrush(Color.Transparent),
                Brush       = new SolidBrush(Color.Transparent)
            };
            diagram.AddNode(labelnode9);

            diagram.AddConnector(DrawConnector(node1, node2, node1.Ports[2], node2.Ports[0], SegmentType.OrthoSegment, Color.Rgb(127, 132, 133), StrokeStyle.Default, DecoratorType.Filled45Arrow, Color.Rgb(127, 132, 133), Color.Rgb(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node2, node3, node2.Ports[2], node3.Ports[0], SegmentType.OrthoSegment, Color.Rgb(127, 132, 133), StrokeStyle.Default, DecoratorType.Filled45Arrow, Color.Rgb(127, 132, 133), Color.Rgb(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node3, node4, node3.Ports[2], node4.Ports[0], SegmentType.OrthoSegment, Color.Rgb(127, 132, 133), StrokeStyle.Default, DecoratorType.Filled45Arrow, Color.Rgb(127, 132, 133), Color.Rgb(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node4, node5, node4.Ports[2], node5.Ports[0], SegmentType.OrthoSegment, Color.Rgb(127, 132, 133), StrokeStyle.Default, DecoratorType.Filled45Arrow, Color.Rgb(127, 132, 133), Color.Rgb(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node6, node1, node6.Ports[0], node1.Ports[3], SegmentType.StraightSegment, Color.Rgb(127, 132, 133), StrokeStyle.Dashed, DecoratorType.Filled45Arrow, Color.Rgb(127, 132, 133), Color.Rgb(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node8, node1, node8.Ports[0], node1.Ports[1], SegmentType.StraightSegment, Color.Rgb(127, 132, 133), StrokeStyle.Dashed, DecoratorType.Filled45Arrow, Color.Rgb(127, 132, 133), Color.Rgb(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node7, node2, node7.Ports[0], node2.Ports[3], SegmentType.StraightSegment, Color.Black, StrokeStyle.Default, DecoratorType.Square, Color.Black, Color.Black, 6));

            diagram.AddConnector(DrawConnector(node7, node3, node7.Ports[1], node3.Ports[3], SegmentType.StraightSegment, Color.Black, StrokeStyle.Default, DecoratorType.Square, Color.Black, Color.Black, 6));

            diagram.AddConnector(DrawConnector(node7, node4, node7.Ports[2], node4.Ports[3], SegmentType.StraightSegment, Color.Black, StrokeStyle.Default, DecoratorType.Square, Color.Black, Color.Black, 6));

            diagram.AddConnector(DrawConnector(node7, node5, node7.Ports[3], node5.Ports[3], SegmentType.StraightSegment, Color.Black, StrokeStyle.Default, DecoratorType.Square, Color.Black, Color.Black, 6));

            diagram.AddConnector(DrawConnector(node9, node2, node9.Ports[0], node2.Ports[1], SegmentType.StraightSegment, Color.Black, StrokeStyle.Default, DecoratorType.Circle, Color.Black, Color.Black, 6));

            diagram.AddConnector(DrawConnector(node9, node3, node9.Ports[1], node3.Ports[1], SegmentType.StraightSegment, Color.Black, StrokeStyle.Default, DecoratorType.Circle, Color.Black, Color.Black, 6));

            diagram.AddConnector(DrawConnector(node9, node4, node9.Ports[2], node4.Ports[1], SegmentType.StraightSegment, Color.Black, StrokeStyle.Default, DecoratorType.Circle, Color.Black, Color.Black, 6));

            diagram.AddConnector(DrawConnector(node9, node5, node9.Ports[3], node5.Ports[1], SegmentType.StraightSegment, Color.Black, StrokeStyle.Default, DecoratorType.Circle, Color.Black, Color.Black, 6));
            diagram.Loaded += Diagram_Loaded;

            return(diagram);
        }
 public NodeCustomization()
 {
     //Initialize sfdiagram
     diagram = new SfDiagram();
 }
示例#5
0
        public override View GetSampleContent(Context context)
        {
            //Create SfDiagram.
            currentDensity = context.Resources.DisplayMetrics.Density;
            diagram        = new SfDiagram(context);
            diagram.ContextMenuSettings.Visibility = false;

            int width  = 150;
            int height = 75;

            width  = (int)(125 * MainActivity.Factor);
            height = (int)(60 * MainActivity.Factor);
            var node = AddNode(300, 400, width, height, "Goals");

            AddNodeStyle(node, GetColor("#d0ebff"), GetColor("#81bfea"));
            RootNode = node;
            diagram.AddNode(node);

            SColor.Add(GetColor("#d1afdf"));
            SColor.Add(GetColor("#90C8C2"));
            SColor.Add(GetColor("#8BC1B7"));
            SColor.Add(GetColor("#E2C180"));
            SColor.Add(GetColor("#BBBFD6"));
            SColor.Add(GetColor("#ACCBAA"));
            FColor.Add(GetColor("#e9d4f1"));
            FColor.Add(GetColor("#d4efed"));
            FColor.Add(GetColor("#c4f2e8"));
            FColor.Add(GetColor("#f7e0b3"));
            FColor.Add(GetColor("#DEE2FF"));
            FColor.Add(GetColor("#E5FEE4"));

            var ch1node = AddNode(100, 100, width, height, "Financial");

            index = rnd.Next(5);
            AddNodeStyle(ch1node, FColor[index], SColor[index]);
            diagram.AddNode(ch1node);

            var ch1childnode = AddNode(100, 100, width, height, "Investment");

            AddNodeStyle(ch1childnode, (ch1node.Style.Brush as SolidBrush).FillColor, (ch1node.Style.StrokeBrush as SolidBrush).FillColor);
            diagram.AddNode(ch1childnode);

            var ch2node = AddNode(100, 600, width, height, "Social");

            index = rnd.Next(5);
            AddNodeStyle(ch2node, FColor[index], SColor[index]);
            diagram.AddNode(ch2node);

            var ch2childnode1 = AddNode(100, 100, width, height, "Friends");

            AddNodeStyle(ch2childnode1, (ch2node.Style.Brush as SolidBrush).FillColor, (ch2node.Style.StrokeBrush as SolidBrush).FillColor);
            diagram.AddNode(ch2childnode1);

            var ch2childnode2 = AddNode(100, 100, width, height, "Family");

            AddNodeStyle(ch2childnode2, (ch2node.Style.Brush as SolidBrush).FillColor, (ch2node.Style.StrokeBrush as SolidBrush).FillColor);
            diagram.AddNode(ch2childnode2);

            var ch3node = AddNode(500, 100, width, height, "Personal");

            index = rnd.Next(5);
            AddNodeStyle(ch3node, FColor[index], SColor[index]);
            diagram.AddNode(ch3node);

            var ch3childnode1 = AddNode(500, 100, width, height, "Sports");

            AddNodeStyle(ch3childnode1, (ch3node.Style.Brush as SolidBrush).FillColor, (ch3node.Style.StrokeBrush as SolidBrush).FillColor);
            diagram.AddNode(ch3childnode1);

            var ch3childnode2 = AddNode(500, 100, width, height, "Food");

            AddNodeStyle(ch3childnode2, (ch3node.Style.Brush as SolidBrush).FillColor, (ch3node.Style.StrokeBrush as SolidBrush).FillColor);
            diagram.AddNode(ch3childnode2);

            var ch4node = AddNode(500, 600, width, height, "Work");

            index = rnd.Next(5);
            AddNodeStyle(ch4node, FColor[index], SColor[index]);
            diagram.AddNode(ch4node);

            var ch4childnode1 = AddNode(500, 100, width, height, "Project");

            AddNodeStyle(ch4childnode1, (ch4node.Style.Brush as SolidBrush).FillColor, (ch4node.Style.StrokeBrush as SolidBrush).FillColor);
            diagram.AddNode(ch4childnode1);

            var ch4childnode2 = AddNode(500, 100, width, height, "Career");

            AddNodeStyle(ch4childnode2, (ch4node.Style.Brush as SolidBrush).FillColor, (ch4node.Style.StrokeBrush as SolidBrush).FillColor);
            diagram.AddNode(ch4childnode2);

            diagram.AddConnector(AddConnector(node, ch1node));
            diagram.AddConnector(AddConnector(node, ch2node));
            diagram.AddConnector(AddConnector(node, ch3node));
            diagram.AddConnector(AddConnector(node, ch4node));
            diagram.AddConnector(AddConnector(ch1node, ch1childnode));
            diagram.AddConnector(AddConnector(ch2node, ch2childnode1));
            diagram.AddConnector(AddConnector(ch2node, ch2childnode2));
            diagram.AddConnector(AddConnector(ch3node, ch3childnode1));
            diagram.AddConnector(AddConnector(ch3node, ch3childnode2));
            diagram.AddConnector(AddConnector(ch4node, ch4childnode1));
            diagram.AddConnector(AddConnector(ch4node, ch4childnode2));

            diagram.UserHandleClicked += Diagram_UserHandleClicked;
            AddHandles();
            diagram.NodeClicked += Diagram_NodeClicked;

            diagram.Clicked          += Diagram_Clicked;
            diagram.Loaded           += Diagram_Loaded;
            SelectedNode              = node;
            diagram.ConnectorClicked += Diagram_ConnectorClicked;
            return(diagram);
        }
        public override View GetSampleContent(Context context)
        {
            m_context      = context;
            currentDensity = m_context.Resources.DisplayMetrics.Density;
            //Initialize the SfDiagram and set its background color.
            diagram = new SfDiagram(context);
            diagram.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            diagram.IsReadOnly       = true;
            ObservableCollection <Employee> employees = new ObservableCollection <Employee>();

            employees.Add(new Employee()
            {
                Name = "Elizabeth", EmpId = "1", ParentId = "", Designation = "CEO"
            });
            employees.Add(new Employee()
            {
                Name = "Christina", EmpId = "2", ParentId = "1", Designation = "Manager"
            });
            employees.Add(new Employee()
            {
                Name = "Yang", EmpId = "3", ParentId = "1", Designation = "Manager"
            });
            employees.Add(new Employee()
            {
                Name = "Yoshi", EmpId = "4", ParentId = "2", Designation = "Team Lead"
            });
            employees.Add(new Employee()
            {
                Name = "Yoshi", EmpId = "5", ParentId = "2", Designation = "Co-ordinator"
            });
            employees.Add(new Employee()
            {
                Name = "Philip", EmpId = "6", ParentId = "4", Designation = "Developer"
            });
            employees.Add(new Employee()
            {
                Name = "Philip", EmpId = "7", ParentId = "4", Designation = "Testing Engineer"
            });
            employees.Add(new Employee()
            {
                Name = "Roland", EmpId = "8", ParentId = "3", Designation = "Team Lead"
            });
            employees.Add(new Employee()
            {
                Name = "Yoshi", EmpId = "9", ParentId = "3", Designation = "Co-ordinator"
            });
            employees.Add(new Employee()
            {
                Name = "Yuonne", EmpId = "10", ParentId = "8", Designation = "Developer"
            });
            employees.Add(new Employee()
            {
                Name = "Philip", EmpId = "10", ParentId = "8", Designation = "Testing Engineer"
            });
            //Initializes the DataSourceSettings
            diagram.DataSourceSettings = new DataSourceSettings()
            {
                DataSource = employees, Id = "EmpId", ParentId = "ParentId"
            };
            //Initializes the Layout
            DirectedTreeLayout treelayout = new DirectedTreeLayout()
            {
                HorizontalSpacing = 80, VerticalSpacing = 50 * currentDensity, TreeOrientation = TreeOrientation.TopToBottom
            };

            diagram.LayoutManager = new LayoutManager()
            {
                Layout = treelayout
            };

            diagram.BeginNodeRender += Diagram_BeginNodeRender;

            diagram.Loaded += Diagram_Loaded;

            LinearLayout linearLayout = new LinearLayout(context)
            {
                Orientation = Android.Widget.Orientation.Vertical
            };

            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            layoutParams.TopMargin        = 25 * (int)MainActivity.Factor;
            linearLayout.LayoutParameters = layoutParams;

            LinearLayout typesBar = new LinearLayout(context);

            typesBar.SetBackgroundColor(Color.Rgb(245, 245, 245));
            layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            typesBar.SetMinimumHeight(200 * (int)MainActivity.Factor);
            typesBar.SetPadding(0, 10 * (int)MainActivity.Factor, 0, 10 * (int)MainActivity.Factor);
            TextView selectText = new TextView(context)
            {
                LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent),
                Text             = "Connector Types:",
                TextAlignment    = TextAlignment.Gravity,
                Gravity          = GravityFlags.Center | GravityFlags.CenterVertical,
                TextSize         = 15 * MainActivity.Factor
            };
            int width = (int)(context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.Density);

            selectText.SetMinimumWidth((int)(width * 0.4 * MainActivity.Factor));

            ImageButtonView straightButton = new ImageButtonView(context);

            straightButton.Click           += ButtonTouch;
            straightButton.ImageId          = "DiagramStraight";
            straightButton.LayoutParameters = new ViewGroup.LayoutParams(180 * (int)MainActivity.Factor, 180 * (int)MainActivity.Factor);

            ImageView straightImage = new ImageView(context);
            var       imageId       = straightButton.ImageId + ".png";

            if (imageId != null)
            {
                var imageData = LoadResource(imageId).ToArray();
                straightImage.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
            }
            straightImage.Layout((int)(40 * MainActivity.Factor), (int)(40 * MainActivity.Factor), (int)(110 * MainActivity.Factor), (int)(110 * MainActivity.Factor));

            straightButton.AddView(straightImage);

            ImageButtonView curveButton = new ImageButtonView(context);

            curveButton.Click           += ButtonTouch;
            curveButton.ImageId          = "DiagramCurve";
            curveButton.LayoutParameters = new ViewGroup.LayoutParams(180 * (int)MainActivity.Factor, 180 * (int)MainActivity.Factor);

            ImageView curveImage = new ImageView(context);

            imageId = curveButton.ImageId + ".png";
            if (imageId != null)
            {
                var imageData = LoadResource(imageId).ToArray();
                curveImage.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
            }
            curveImage.Layout((int)(40 * MainActivity.Factor), (int)(40 * MainActivity.Factor), (int)(110 * MainActivity.Factor), (int)(110 * MainActivity.Factor));

            curveButton.AddView(curveImage);

            ImageButtonView edgeButton = new ImageButtonView(context);

            edgeButton.Click           += ButtonTouch;
            edgeButton.LayoutParameters = new ViewGroup.LayoutParams(180 * (int)MainActivity.Factor, 180 * (int)MainActivity.Factor);
            edgeButton.ImageId          = "DiagramEdge";

            ImageView edgeImage = new ImageView(context);

            imageId = edgeButton.ImageId + ".png";
            if (imageId != null)
            {
                var imageData = LoadResource(imageId).ToArray();
                edgeImage.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
            }
            edgeImage.Layout((int)(40 * MainActivity.Factor), (int)(40 * MainActivity.Factor), (int)(110 * MainActivity.Factor), (int)(110 * MainActivity.Factor));

            edgeButton.AddView(edgeImage);

            buttons = new LinearLayout(context);
            buttons.SetMinimumWidth((int)(width - width * 0.4 * MainActivity.Factor));
            buttons.SetBackgroundColor(Color.Transparent);
            buttons.AddView(straightButton);
            TextView view = new TextView(context);

            view.SetWidth(30 * (int)MainActivity.Factor);
            view.SetBackgroundColor(Color.Transparent);
            buttons.AddView(view);
            buttons.AddView(curveButton);
            view = new TextView(context);
            view.SetWidth(30 * (int)MainActivity.Factor);
            view.SetBackgroundColor(Color.Transparent);
            buttons.AddView(view);
            buttons.AddView(edgeButton);

            typesBar.AddView(selectText);
            typesBar.AddView(buttons);

            linearLayout.AddView(typesBar);
            linearLayout.AddView(diagram);
            for (int i = 0; i < diagram.Connectors.Count; i++)
            {
                diagram.Connectors[i].TargetDecoratorType = DecoratorType.None;
                diagram.Connectors[i].Style.StrokeWidth   = 1;
            }
            return(linearLayout);
        }
示例#7
0
        public override View GetSampleContent(Context context)
        {
            currentDensity = context.Resources.DisplayMetrics.Density;
            //Initialize the SfDiagram instance and set background.
            diagram = new SfDiagram(context);
            diagram.BackgroundColor = Color.White;

            //Create nodes and set the offset, size and other properties.
            Node n1 = new Node(context);

            n1.ShapeType         = ShapeType.RoundedRectangle;
            n1.CornerRadius      = 90 * MainActivity.factor;
            n1.OffsetX           = 185 * MainActivity.factor;
            n1.OffsetY           = 80 * MainActivity.factor;
            n1.Width             = 320 * MainActivity.factor;
            n1.Height            = 110 * MainActivity.factor;
            n1.Style.Brush       = new SolidBrush(Color.Rgb(49, 162, 255));
            n1.Style.StrokeBrush = new SolidBrush(Color.Rgb(23, 132, 206));
            TextView content1 = CreateLabel(context, "New idea identified", (int)n1.Width, Color.Rgb(255, 255, 255));

            n1.Annotations.Add(new Annotation()
            {
                HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Content = content1
            });
            diagram.AddNode(n1);

            Node n2 = new Node(context);

            n2.OffsetX           = 185 * MainActivity.factor;
            n2.OffsetY           = 280 * MainActivity.factor;
            n2.Width             = 320 * MainActivity.factor;
            n2.Height            = 110 * MainActivity.factor;
            n2.ShapeType         = ShapeType.RoundedRectangle;
            n2.CornerRadius      = 15 * MainActivity.factor;
            n2.Style.Brush       = new SolidBrush(Color.Rgb(49, 162, 255));
            n2.Style.StrokeBrush = new SolidBrush(Color.Rgb(23, 132, 206));
            TextView content2 = CreateLabel(context, "Meeting With Boards", (int)n2.Width, Color.Rgb(255, 255, 255));

            n2.Annotations.Add(new Annotation()
            {
                HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Content = content2
            });
            diagram.AddNode(n2);

            Node n3 = new Node(context);

            n3.ShapeType         = ShapeType.Diamond;
            n3.OffsetX           = 195 * MainActivity.factor;
            n3.OffsetY           = 480 * MainActivity.factor;
            n3.Width             = 300 * MainActivity.factor;
            n3.Height            = 300 * MainActivity.factor;
            n3.Style.Brush       = new SolidBrush(Color.Rgb(0, 194, 192));
            n3.Style.StrokeBrush = new SolidBrush(Color.Rgb(4, 142, 135));
            TextView content3 = CreateLabel(context, "Board decides" + "\n" + "whether to" + "\n" + "proceed", (int)n3.Width, Color.Rgb(255, 255, 255));

            n3.Annotations.Add(new Annotation()
            {
                HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Content = content3
            });
            diagram.AddNode(n3);

            Node n4 = new Node(context);

            n4.ShapeType         = ShapeType.Diamond;
            n4.OffsetX           = 195 * MainActivity.factor;
            n4.OffsetY           = 870 * MainActivity.factor;
            n4.Width             = 300 * MainActivity.factor;
            n4.Height            = 300 * MainActivity.factor;
            n4.Style.Brush       = new SolidBrush(Color.Rgb(0, 194, 192));
            n4.Style.StrokeBrush = new SolidBrush(Color.Rgb(4, 142, 135));
            TextView content4 = CreateLabel(context, "Find Project" + "\n" + "Manager, write" + "\n" + "specification", (int)n4.Width, Color.Rgb(255, 255, 255));

            n4.Annotations.Add(new Annotation()
            {
                HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Content = content4
            });
            diagram.AddNode(n4);

            Node n5 = new Node(context);

            n5.Style.Brush       = new SolidBrush(Color.Rgb(49, 162, 255));
            n5.Style.StrokeBrush = new SolidBrush(Color.Rgb(23, 132, 206));
            n5.OffsetX           = 185 * MainActivity.factor;
            n5.OffsetY           = 1260 * MainActivity.factor;
            n5.Width             = 320 * MainActivity.factor;
            n5.Height            = 110 * MainActivity.factor;
            n5.ShapeType         = ShapeType.RoundedRectangle;
            n5.CornerRadius      = 90 * MainActivity.factor;
            TextView content5 = CreateLabel(context, "Implement and deliver", (int)n5.Width, Color.Rgb(255, 255, 255));

            n5.Annotations.Add(new Annotation()
            {
                HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Content = content5
            });
            diagram.AddNode(n5);

            Node n6 = new Node(context);

            n6.Style.Brush       = new SolidBrush(Color.Rgb(239, 75, 93));
            n6.Style.StrokeBrush = new SolidBrush(Color.Rgb(201, 32, 61));
            n6.OffsetX           = 674 * MainActivity.factor;
            n6.OffsetY           = 575 * MainActivity.factor;
            n6.Width             = 320 * MainActivity.factor;
            n6.Height            = 110 * MainActivity.factor;
            n6.ShapeType         = ShapeType.RoundedRectangle;
            n6.CornerRadius      = 15 * MainActivity.factor;
            TextView content6 = CreateLabel(context, "Reject and report the reason", (int)n6.Width, Color.Rgb(255, 255, 255));

            n6.Annotations.Add(new Annotation()
            {
                HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Content = content6
            });
            diagram.AddNode(n6);

            Node n7 = new Node(context);

            n7.Style.Brush       = new SolidBrush(Color.Rgb(239, 75, 93));
            n7.Style.StrokeBrush = new SolidBrush(Color.Rgb(201, 32, 61));
            n7.OffsetX           = 674 * MainActivity.factor;
            n7.OffsetY           = 965.599f * MainActivity.factor;
            n7.Width             = 320 * MainActivity.factor;
            n7.Height            = 110 * MainActivity.factor;
            n7.ShapeType         = ShapeType.RoundedRectangle;
            n7.CornerRadius      = 15 * MainActivity.factor;
            TextView content7 = CreateLabel(context, "Hire new resources", (int)n7.Width, Color.Rgb(255, 255, 255));

            n7.Annotations.Add(new Annotation()
            {
                HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Content = content7
            });
            diagram.AddNode(n7);

            //Create connector with its source and target node.
            Connector c1 = new Connector(context, n1, n2);

            diagram.AddConnector(c1);

            Connector c2 = new Connector(context, n2, n3);

            diagram.AddConnector(c2);

            Connector c3 = new Connector(context, n3, n4);
            //Create label for the connector.
            TextView label = CreateConnectorLabel(context, "Yes", 35, 10, 100, 50, GravityFlags.Right);

            label.SetPadding((int)(10 * MainActivity.factor), 0, (int)(10 * MainActivity.factor), (int)(10 * MainActivity.factor));
            c3.Annotations.Add(new Annotation()
            {
                Content = label, HorizontalAlignment = HorizontalAlignment.Left
            });
            diagram.AddConnector(c3);

            Connector c4     = new Connector(context, n4, n5);
            TextView  label2 = CreateConnectorLabel(context, "Yes", 35, 10, 100, 50, GravityFlags.Right);

            label2.SetPadding((int)(10 * MainActivity.factor), 0, (int)(10 * MainActivity.factor), (int)(10 * MainActivity.factor));
            c4.Annotations.Add(new Annotation()
            {
                Content = label2, HorizontalAlignment = HorizontalAlignment.Left
            });
            diagram.AddConnector(c4);
            diagram.IsReadOnly = false;
            Connector c5     = new Connector(context, n3, n6);
            TextView  label3 = CreateConnectorLabel(context, "No", 67, 10, 100, 50, GravityFlags.Bottom);

            //label3.SetPadding(0, (int)(10 * MainActivity.factor), (int)(10 * MainActivity.factor), 0);
            c5.Annotations.Add(new Annotation()
            {
                Content = label3
            });
            diagram.AddConnector(c5);

            Connector c6     = new Connector(context, n4, n7);
            TextView  label4 = CreateConnectorLabel(context, "No", 67, 10, 100, 50, GravityFlags.Bottom);

            //label4.SetPadding(0, 0,(int)( 10* MainActivity.factor), (int)(10 * MainActivity.factor));
            c6.Annotations.Add(new Annotation()
            {
                Content = label4
            });
            diagram.AddConnector(c6);

            //Set the stroke color for the connector.
            for (int i = 0; i < diagram.Connectors.Count; i++)
            {
                //Diagram.Connectors[i].TargetDecoratorType = DecoratorType.None;
                diagram.Connectors[i].Style.StrokeBrush                = new SolidBrush(Color.Rgb(127, 132, 133));
                diagram.Connectors[i].TargetDecoratorStyle.Fill        = (Color.Rgb(127, 132, 133));
                diagram.Connectors[i].TargetDecoratorStyle.StrokeColor = (Color.Rgb(127, 132, 133));
                diagram.Connectors[i].TargetDecoratorStyle.StrokeWidth = 4 * MainActivity.factor;
                diagram.Connectors[i].TargetDecoratorStyle.Size        = 14 * MainActivity.factor;
                diagram.Connectors[i].Style.StrokeWidth                = 2 * MainActivity.factor;
            }
            //Set the stroke size for node.
            for (int i = 0; i < diagram.Nodes.Count; i++)
            {
                diagram.Nodes[i].Style.StrokeWidth = 1;
            }
            diagram.Loaded                += Diagram_Loaded;
            diagram.ConnectorClicked      += Diagram_ConnectorClicked;
            diagram.PageSettings.GridSize  = 12 * currentDensity;
            diagram.PageSettings.GridColor = Color.Rgb(230, 230, 230);
            return(diagram);
        }
        public override View GetSampleContent(Context context)
        {
            Display        display        = ((Activity)context).WindowManager.DefaultDisplay;
            DisplayMetrics displayMetrics = new DisplayMetrics();

            display.GetMetrics(displayMetrics);

            var wInches = displayMetrics.WidthPixels / (double)displayMetrics.DensityDpi;
            var hInches = displayMetrics.HeightPixels / (double)displayMetrics.DensityDpi;

            double screenDiagonal = Math.Sqrt(Math.Pow(wInches, 2) + Math.Pow(hInches, 2));

            isTablet = screenDiagonal >= 7.0;

            //Create SfDiagram.
            diagram = new SfDiagram(context);
            diagram.EnableSelection = false;

            FillColor = new Dictionary <string, Color>();
            FillColor.Add("Managing Director", Color.Rgb(239, 75, 93));
            FillColor.Add("Project Manager", Color.Rgb(49, 162, 255));
            FillColor.Add("Senior Manager", Color.Rgb(49, 162, 255));
            FillColor.Add("Project Lead", Color.Rgb(0, 194, 192));
            FillColor.Add("Senior S/W Engg", Color.Rgb(0, 194, 192));
            FillColor.Add("Software Engg", Color.Rgb(0, 194, 192));
            FillColor.Add("Team Lead", Color.Rgb(0, 194, 192));
            FillColor.Add("Project Trainee", Color.Rgb(255, 129, 0));

            StrokeColor = new Dictionary <string, Color>();
            StrokeColor.Add("Managing Director", Color.Rgb(201, 32, 61));
            StrokeColor.Add("Project Manager", Color.Rgb(23, 132, 206));
            StrokeColor.Add("Senior Manager", Color.Rgb(23, 132, 206));
            StrokeColor.Add("Project Lead", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Senior S/W Engg", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Software Engg", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Team Lead", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Project Trainee", Color.Rgb(206, 98, 9));

            dataModel = new DataModel();
            diagram.BackgroundColor  = Color.White;
            diagram.BeginNodeRender += Dia_BeginNodeRender;

            dataModel.Data();

            //To Represent DataSourceSttings Properties
            DataSourceSettings settings = new DataSourceSettings();

            settings.ParentId          = "ReportingPerson";
            settings.Id                = "Name";
            settings.DataSource        = dataModel.employee;
            diagram.DataSourceSettings = settings;

            //(diagram.LayoutManager.Layout as DirectedTreeLayout).IsDraggable


            //To Represent LayoutManager Properties
            diagram.LayoutManager = new LayoutManager()
            {
                Layout = new DirectedTreeLayout()
                {
                    Type = LayoutType.Organization,
                    HorizontalSpacing = 70 * MainActivity.Factor,
                    VerticalSpacing   = 70 * MainActivity.Factor
                }
            };

            for (int i = 0; i < diagram.Connectors.Count; i++)
            {
                diagram.Connectors[i].TargetDecoratorType = DecoratorType.None;
                diagram.Connectors[i].Style.StrokeBrush   = new SolidBrush(Color.Rgb(127, 132, 133));
            }
            diagram.NodeClicked     += Diagram_NodeClicked;
            diagram.ItemLongPressed += Diagram_ItemLongPressed;
            diagram.Loaded          += Diagram_Loaded;

            int width = (int)(context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.Density) / 3;

            linearLayout4             = new LinearLayout(context);
            linearLayout4.Orientation = Android.Widget.Orientation.Vertical;
            linearLayout4.SetMinimumHeight((int)(190 * currentDensity));
            linearLayout4.SetMinimumWidth(width);
            diagram.LayoutNodeDropped += Diagram_OnLayoutNodeDropped;
            return(diagram);
        }
示例#9
0
        public NodeCustomization()
        {
            //Initialize sfdiagram
            diagram = new SfDiagram();
            var node1 = DrawNode(((float)(280)), 150, 155, 50, ShapeType.RoundedRectangle);

            node1.Style.StrokeBrush = new SolidBrush(UIColor.FromRGB(206, 98, 9));
            node1.Annotations.Add(new Annotation()
            {
                Content = CreateLabel("Establish Project and Team", 12)
            });
            diagram.AddNode(node1);

            var node2 = DrawNode(((float)(280)), (float)(node1.OffsetY + 90), 155, 50, ShapeType.RoundedRectangle);

            node2.Style.StrokeBrush = new SolidBrush(UIColor.FromRGB(206, 98, 9));
            node2.Style.Brush       = new LinearGradientBrush(0, 30, 150, 30, new UIColor[] { UIColor.FromRGB(255, 130, 0), UIColor.FromRGB(255, 37, 0) }, GradientDrawingOptions.DrawsAfterEndLocation);
            node2.Style.StrokeWidth = 0;
            node2.Annotations.Add(new Annotation()
            {
                Content = CreateLabel("Define Scope", 12)
            });
            diagram.AddNode(node2);

            var node3 = DrawNode(((float)(280)), (float)(node2.OffsetY + 90), 155, 50, ShapeType.RoundedRectangle);

            node3.Style.StrokeBrush = new SolidBrush(UIColor.FromRGB(206, 98, 9));
            node3.Style.StrokeStyle = StrokeStyle.Dashed;
            node3.Annotations.Add(new Annotation()
            {
                Content = CreateLabel("Analyze process As-Is", 12)
            });
            diagram.AddNode(node3);

            var node4 = DrawNode(((float)(280)), (float)(node3.OffsetY + 90), 155, 50, ShapeType.RoundedRectangle);

            node4.Style.StrokeBrush = new SolidBrush(UIColor.FromRGB(206, 98, 9));
            node4.Style.StrokeWidth = 0;
            node4.Annotations.Add(new Annotation()
            {
                Content = CreateLabel("Identify opportunities for improvement", 12)
            });
            diagram.AddNode(node4);

            var node5 = DrawNode(((float)(280)), (float)(node4.OffsetY + 90), 155, 50, ShapeType.RoundedRectangle);

            node5.Style.StrokeBrush = new SolidBrush(UIColor.FromRGB(206, 98, 9));
            node5.Style.StrokeWidth = 0;
            node5.Annotations.Add(new Annotation()
            {
                Content = CreateLabel("Design and implement improved processess", 12)
            });
            diagram.AddNode(node5);

            var node6 = DrawCustomShape(53, 155);

            node6.Ports.Add(new Port()
            {
                NodeOffsetX = 1, NodeOffsetY = 0.5, IsVisible = false
            });
            diagram.AddNode(node6);
            var labelnode6 = new Node(33.5f, 195, 80, 35);

            labelnode6.Annotations.Add(new Annotation()
            {
                Content = "Sponsor", FontSize = 10,
            });
            labelnode6.Style = new Style()
            {
                StrokeBrush = new SolidBrush(UIColor.Clear),
                Brush       = new SolidBrush(UIColor.Clear)
            };
            diagram.AddNode(labelnode6);

            var node7 = DrawCustomShape(53, 347);

            node7.Ports.Add(new Port()
            {
                NodeOffsetX = 1, NodeOffsetY = 0, IsVisible = false
            });
            node7.Ports.Add(new Port()
            {
                NodeOffsetX = 1, NodeOffsetY = 0.3, IsVisible = false
            });
            node7.Ports.Add(new Port()
            {
                NodeOffsetX = 1, NodeOffsetY = 0.6, IsVisible = false
            });
            node7.Ports.Add(new Port()
            {
                NodeOffsetX = 1, NodeOffsetY = 1, IsVisible = false
            });
            diagram.AddNode(node7);
            var labelnode7 = new Node(55, 393, 60, 50);

            labelnode7.Annotations.Add(new Annotation()
            {
                Content = "Domain Experts", FontSize = 10,
            });
            labelnode7.Style = new Style()
            {
                StrokeBrush = new SolidBrush(UIColor.Clear),
                Brush       = new SolidBrush(UIColor.Clear)
            };
            diagram.AddNode(labelnode7);

            var node8 = DrawCustomShape(590, 155);

            node8.Ports.Add(new Port()
            {
                NodeOffsetX = 0, NodeOffsetY = 0.5, IsVisible = false
            });
            diagram.AddNode(node8);
            var labelnode8 = new Node(590.5f, 200, 78, 49);

            labelnode8.Annotations.Add(new Annotation()
            {
                Content = "Project Manager", FontSize = 10,
            });
            labelnode8.Style = new Style()
            {
                StrokeBrush = new SolidBrush(UIColor.Clear),
                Brush       = new SolidBrush(UIColor.Clear)
            };
            diagram.AddNode(labelnode8);

            var node9 = DrawCustomShape(590, 347);

            node9.Ports.Add(new Port()
            {
                NodeOffsetX = 0, NodeOffsetY = 0, IsVisible = false
            });
            node9.Ports.Add(new Port()
            {
                NodeOffsetX = 0, NodeOffsetY = 0.3, IsVisible = false
            });
            node9.Ports.Add(new Port()
            {
                NodeOffsetX = 0, NodeOffsetY = 0.6, IsVisible = false
            });
            node9.Ports.Add(new Port()
            {
                NodeOffsetX = 0, NodeOffsetY = 1, IsVisible = false
            });
            diagram.AddNode(node9);
            var labelnode9 = new Node(591, 398.5f, 65, 39);

            labelnode9.Annotations.Add(new Annotation()
            {
                Content = "Business Analyst", FontSize = 10,
            });
            labelnode9.Style = new Style()
            {
                StrokeBrush = new SolidBrush(UIColor.Clear),
                Brush       = new SolidBrush(UIColor.Clear)
            };
            diagram.AddNode(labelnode9);

            diagram.AddConnector(DrawConnector(node1, node2, node1.Ports[2], node2.Ports[0], SegmentType.OrthoSegment, UIColor.FromRGB(127, 132, 133), StrokeStyle.Default, DecoratorType.Filled45Arrow, UIColor.FromRGB(127, 132, 133), UIColor.FromRGB(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node2, node3, node2.Ports[2], node3.Ports[0], SegmentType.OrthoSegment, UIColor.FromRGB(127, 132, 133), StrokeStyle.Default, DecoratorType.Filled45Arrow, UIColor.FromRGB(127, 132, 133), UIColor.FromRGB(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node3, node4, node3.Ports[2], node4.Ports[0], SegmentType.OrthoSegment, UIColor.FromRGB(127, 132, 133), StrokeStyle.Default, DecoratorType.Filled45Arrow, UIColor.FromRGB(127, 132, 133), UIColor.FromRGB(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node4, node5, node4.Ports[2], node5.Ports[0], SegmentType.OrthoSegment, UIColor.FromRGB(127, 132, 133), StrokeStyle.Default, DecoratorType.Filled45Arrow, UIColor.FromRGB(127, 132, 133), UIColor.FromRGB(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node6, node1, node6.Ports[0], node1.Ports[3], SegmentType.OrthoSegment, UIColor.FromRGB(127, 132, 133), StrokeStyle.Dashed, DecoratorType.Filled45Arrow, UIColor.FromRGB(127, 132, 133), UIColor.FromRGB(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node8, node1, node8.Ports[0], node1.Ports[1], SegmentType.OrthoSegment, UIColor.FromRGB(127, 132, 133), StrokeStyle.Dashed, DecoratorType.Filled45Arrow, UIColor.FromRGB(127, 132, 133), UIColor.FromRGB(127, 132, 133), 8));

            diagram.AddConnector(DrawConnector(node7, node2, node7.Ports[0], node2.Ports[3], SegmentType.StraightSegment, UIColor.Black, StrokeStyle.Default, DecoratorType.Square, UIColor.Black, UIColor.Black, 6));

            diagram.AddConnector(DrawConnector(node7, node3, node7.Ports[1], node3.Ports[3], SegmentType.StraightSegment, UIColor.Black, StrokeStyle.Default, DecoratorType.Square, UIColor.Black, UIColor.Black, 6));

            diagram.AddConnector(DrawConnector(node7, node4, node7.Ports[2], node4.Ports[3], SegmentType.StraightSegment, UIColor.Black, StrokeStyle.Default, DecoratorType.Square, UIColor.Black, UIColor.Black, 6));

            diagram.AddConnector(DrawConnector(node7, node5, node7.Ports[3], node5.Ports[3], SegmentType.StraightSegment, UIColor.Black, StrokeStyle.Default, DecoratorType.Square, UIColor.Black, UIColor.Black, 6));

            diagram.AddConnector(DrawConnector(node9, node2, node9.Ports[0], node2.Ports[1], SegmentType.StraightSegment, UIColor.Black, StrokeStyle.Default, DecoratorType.Circle, UIColor.Black, UIColor.Black, 6));

            diagram.AddConnector(DrawConnector(node9, node3, node9.Ports[1], node3.Ports[1], SegmentType.StraightSegment, UIColor.Black, StrokeStyle.Default, DecoratorType.Circle, UIColor.Black, UIColor.Black, 6));

            diagram.AddConnector(DrawConnector(node9, node4, node9.Ports[2], node4.Ports[1], SegmentType.StraightSegment, UIColor.Black, StrokeStyle.Default, DecoratorType.Circle, UIColor.Black, UIColor.Black, 6));

            diagram.AddConnector(DrawConnector(node9, node5, node9.Ports[3], node5.Ports[1], SegmentType.StraightSegment, UIColor.Black, StrokeStyle.Default, DecoratorType.Circle, UIColor.Black, UIColor.Black, 6));
        }
示例#10
0
        public OrganizationalChart()
        {
            selectionPicker1 = new UIPickerView();
            this.OptionView  = new UIView();

            string deviceType = UIDevice.CurrentDevice.Model;

            overviewLabel                  = new UILabel();
            overviewLabel.Text             = "Enable Overview";
            overviewLabel.TextColor        = UIColor.Black;
            overviewLabel.TextAlignment    = UITextAlignment.Left;
            overviewLabel.BackgroundColor  = UIColor.Clear;
            overviewLabel.Frame            = new CGRect(this.Frame.X + 10, 70, 150, 30);
            overviewSwitch                 = new UISwitch();
            overviewSwitch.On              = true;
            overviewSwitch.Frame           = new CGRect(this.Frame.X + 250, 70, 50, 30);
            overviewSwitch.TouchUpInside  += OverviewSwitch_TouchUpInside;
            overviewSwitch.BackgroundColor = UIColor.Clear;

            dragLabel                  = new UILabel();
            dragLabel.Text             = "Change Hierarchy";
            dragLabel.TextColor        = UIColor.Black;
            dragLabel.TextAlignment    = UITextAlignment.Left;
            dragLabel.BackgroundColor  = UIColor.Clear;
            dragLabel.Frame            = new CGRect(this.Frame.X + 10, 10, 150, 30);
            dragSwitch                 = new UISwitch();
            dragSwitch.On              = false;
            dragSwitch.Frame           = new CGRect(this.Frame.X + 250, 10, 50, 30);
            dragSwitch.TouchUpInside  += dragSwitch_TouchUpInside;
            dragSwitch.BackgroundColor = UIColor.Clear;

            diagram = new SfDiagram();
            //Dictionary collection
            FillColor = new Dictionary <string, UIColor>();
            FillColor.Add("Managing Director", UIColor.FromRGB(239, 75, 93));
            FillColor.Add("Project Manager", UIColor.FromRGB(49, 162, 255));
            FillColor.Add("Senior Manager", UIColor.FromRGB(49, 162, 255));
            FillColor.Add("Project Lead", UIColor.FromRGB(0, 194, 192));
            FillColor.Add("Senior S/W Engg", UIColor.FromRGB(0, 194, 192));
            FillColor.Add("Software Engg", UIColor.FromRGB(0, 194, 192));
            FillColor.Add("Team Lead", UIColor.FromRGB(0, 194, 192));
            FillColor.Add("Project Trainee", UIColor.FromRGB(255, 129, 0));

            StrokeColor = new Dictionary <string, CGColor>();
            StrokeColor.Add("Managing Director", UIColor.FromRGB(201, 32, 61).CGColor);
            StrokeColor.Add("Project Manager", UIColor.FromRGB(23, 132, 206).CGColor);
            StrokeColor.Add("Senior Manager", UIColor.FromRGB(23, 132, 206).CGColor);
            StrokeColor.Add("Project Lead", UIColor.FromRGB(4, 142, 135).CGColor);
            StrokeColor.Add("Senior S/W Engg", UIColor.FromRGB(4, 142, 135).CGColor);
            StrokeColor.Add("Software Engg", UIColor.FromRGB(4, 142, 135).CGColor);
            StrokeColor.Add("Team Lead", UIColor.FromRGB(4, 142, 135).CGColor);
            StrokeColor.Add("Project Trainee", UIColor.FromRGB(206, 98, 9).CGColor);

            diagram.BeginNodeRender   += Dia_BeginNodeRender;
            diagram.ItemLongPressed   += Dia_ItemLongPressed;
            diagram.LayoutNodeDropped += Diagram_OnLayoutNodeDropped;
            diagram.BackgroundColor    = UIColor.White;
            diagram.EnableSelectors    = false;
            diagram.NodeClicked       += Dia_NodeClicked;
            diagram.Loaded            += Dia_Loaded;
            //Initialize Method
            datamodel = new DataModel();
            datamodel.Data();

            //To Represent DataSourceSttings Properties
            DataSourceSettings settings = new DataSourceSettings();

            settings.ParentId          = "ReportingPerson";
            settings.Id                = "Name";
            settings.DataSource        = datamodel.employee;
            diagram.DataSourceSettings = settings;

            //To Represent LayoutManager Properties
            diagram.LayoutManager = new LayoutManager()
            {
                Layout = new DirectedTreeLayout()
                {
                    Type = LayoutType.Organization,
                    HorizontalSpacing = 35,
                }
            };

            for (int i = 0; i < diagram.Connectors.Count; i++)
            {
                diagram.Connectors[i].TargetDecoratorType = DecoratorType.None;
                diagram.Connectors[i].Style.StrokeBrush   = new SolidBrush(UIColor.FromRGB(127, 132, 133));
                diagram.Connectors[i].Style.StrokeWidth   = 1;
            }
            this.AddSubview(diagram);
            diagram.Width  = (float)this.Frame.Width;
            diagram.Height = (float)this.Frame.Height;
            OptionView.AddSubview(dragLabel);
            OptionView.AddSubview(dragSwitch);

            if (deviceType == "iPad")
            {
                OptionView.AddSubview(overviewLabel);
                OptionView.AddSubview(overviewSwitch);
                overviewPanel = new OverviewPanel();
                overviewPanel.Layer.BorderColor = UIColor.Orange.CGColor;
                overviewPanel.Layer.BorderWidth = 2;
                overviewPanel.Frame             = new CGRect(0,
                                                             0,
                                                             UIScreen.MainScreen.Bounds.Width / 2,
                                                             UIScreen.MainScreen.Bounds.Height / 4);
                diagram.AddSubview(overviewPanel);
                diagram.OverviewPanel = overviewPanel;
            }
        }
        public OrganizationalChart()
        {
            parentView = new UIView(this.Frame);
            //Initialize the sfdiagram
            diagram = new SfDiagram();
            //Dictionary collection
            FillColor = new Dictionary <string, UIColor>();
            FillColor.Add("Managing Director", UIColor.FromRGB(239, 75, 93));
            FillColor.Add("Project Manager", UIColor.FromRGB(49, 162, 255));
            FillColor.Add("Senior Manager", UIColor.FromRGB(49, 162, 255));
            FillColor.Add("Project Lead", UIColor.FromRGB(0, 194, 192));
            FillColor.Add("Senior S/W Engg", UIColor.FromRGB(0, 194, 192));
            FillColor.Add("Software Engg", UIColor.FromRGB(0, 194, 192));
            FillColor.Add("Team Lead", UIColor.FromRGB(0, 194, 192));
            FillColor.Add("Project Trainee", UIColor.FromRGB(255, 129, 0));

            StrokeColor = new Dictionary <string, CGColor>();
            StrokeColor.Add("Managing Director", UIColor.FromRGB(201, 32, 61).CGColor);
            StrokeColor.Add("Project Manager", UIColor.FromRGB(23, 132, 206).CGColor);
            StrokeColor.Add("Senior Manager", UIColor.FromRGB(23, 132, 206).CGColor);
            StrokeColor.Add("Project Lead", UIColor.FromRGB(4, 142, 135).CGColor);
            StrokeColor.Add("Senior S/W Engg", UIColor.FromRGB(4, 142, 135).CGColor);
            StrokeColor.Add("Software Engg", UIColor.FromRGB(4, 142, 135).CGColor);
            StrokeColor.Add("Team Lead", UIColor.FromRGB(4, 142, 135).CGColor);
            StrokeColor.Add("Project Trainee", UIColor.FromRGB(206, 98, 9).CGColor);

            //Defines the picker
            selectionPicker1 = new UIPickerView();
            this.OptionView  = new UIView();

            PickerModel model = new PickerModel(verticalOrientationlist);

            selectionPicker1.Model = model;

            //Represent the vertical label
            verticalLabel               = new UILabel();
            verticalLabel.Text          = "Orientation and ChartType";
            verticalLabel.TextColor     = UIColor.Black;
            verticalLabel.TextAlignment = UITextAlignment.Left;

            //Represent the vertical button
            verticalbutton = new UIButton();
            verticalbutton.SetTitle("Vertical", UIControlState.Normal);
            verticalbutton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            verticalbutton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            verticalbutton.Layer.CornerRadius  = 8;
            verticalbutton.Layer.BorderWidth   = 2;
            verticalbutton.TouchUpInside      += ShowPicker1;
            verticalbutton.BackgroundColor     = UIColor.Gray;
            verticalbutton.Layer.BorderColor   = UIColor.FromRGB(246, 246, 246).CGColor;

            //Represent the horizontal button
            horizontalbutton = new UIButton();

            horizontalbutton.SetTitle("Horizontal", UIControlState.Normal);
            horizontalbutton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            horizontalbutton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            horizontalbutton.Layer.CornerRadius  = 8;
            horizontalbutton.Layer.BorderWidth   = 2;
            horizontalbutton.TouchUpInside      += ShowPicker1;
            horizontalbutton.Layer.BorderColor   = UIColor.FromRGB(246, 246, 246).CGColor;

            //Represent the button
            doneButton.SetTitle("Done\t", UIControlState.Normal);
            doneButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            doneButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
            doneButton.TouchUpInside      += HidePicker;
            doneButton.Hidden          = true;
            doneButton.BackgroundColor = UIColor.FromRGB(246, 246, 246);

            model.PickerChanged += SelectedIndexChanged;

            selectionPicker1.ShowSelectionIndicator = true;
            selectionPicker1.Hidden = true;

            this.OptionView = new UIView();
        }
示例#12
0
        public FlowDiagram()
        {
            diagram = new SfDiagram();

            selectionPicker1 = new UIPickerView();
            this.OptionView  = new UIView();
            Node n1 = DrawNode(100, 30, 160, 55, ShapeType.RoundedRectangle, "New idea identified", 30, UIColor.FromRGB(49, 162, 255), UIColor.FromRGB(23, 132, 206));

            diagram.AddNode(n1);

            Node n2 = DrawNode(100, 130, 160, 55, ShapeType.RoundedRectangle, "Meeting With Board", 4, UIColor.FromRGB(49, 162, 255), UIColor.FromRGB(23, 132, 206));

            diagram.AddNode(n2);

            Node n3 = DrawNode(105, 230, 150, 150, ShapeType.Diamond, "Board decides \n whether to \n proceed ", 0, UIColor.FromRGB(0, 194, 192), UIColor.FromRGB(4, 142, 135));

            diagram.AddNode(n3);

            Node n4 = DrawNode(105, 425, 150, 150, ShapeType.Diamond, "Find Project  \n Manager, write \n specification", 0, UIColor.FromRGB(0, 194, 192), UIColor.FromRGB(4, 142, 135));

            diagram.AddNode(n4);

            Node n5 = DrawNode(90, 620, 180, 60, ShapeType.RoundedRectangle, "Implement and deliver", 30, UIColor.FromRGB(49, 162, 255), UIColor.FromRGB(23, 132, 206));

            diagram.AddNode(n5);

            Node n6 = DrawNode(320, 275, 200, 60, ShapeType.RoundedRectangle, "Reject and report the reason", 4, UIColor.FromRGB(239, 75, 93), UIColor.FromRGB(201, 32, 61));

            diagram.AddNode(n6);

            Node n7 = DrawNode(320, 470, 200, 60, ShapeType.RoundedRectangle, "Hire new resources", 4, UIColor.FromRGB(239, 75, 93), UIColor.FromRGB(201, 32, 61));

            diagram.AddNode(n7);

            //Create Connector
            Connector c1 = new Connector(n1, n2);

            diagram.AddConnector(c1);

            Connector c2 = new Connector(n2, n3);

            diagram.AddConnector(c2);

            Connector c3 = new Connector(n3, n4);

            c3.Annotations.Add(new Annotation()
            {
                Content = CreateConnectorLabel("Yes", -25, 10, 25, 20)
            });
            diagram.AddConnector(c3);

            Connector c4 = new Connector(n4, n5);

            c4.Annotations.Add(new Annotation()
            {
                Content = CreateConnectorLabel("Yes", -25, 10, 25, 20)
            });
            diagram.AddConnector(c4);

            Connector c5 = new Connector(n3, n6);

            c5.Annotations.Add(new Annotation()
            {
                Content = CreateConnectorLabel("No", 15, 15, 25, 20)
            });
            diagram.AddConnector(c5);

            Connector c6 = new Connector(n4, n7);

            c6.Annotations.Add(new Annotation()
            {
                Content = CreateConnectorLabel("No", 15, 15, 25, 20)
            });
            diagram.AddConnector(c6);

            for (int i = 0; i < diagram.Connectors.Count; i++)
            {
                diagram.Connectors[i].Style.StrokeBrush                = new SolidBrush(UIColor.FromRGB(127, 132, 133));
                diagram.Connectors[i].TargetDecoratorStyle.Fill        = (UIColor.FromRGB(127, 132, 133));
                diagram.Connectors[i].TargetDecoratorStyle.StrokeColor = (UIColor.FromRGB(127, 132, 133));
                diagram.Connectors[i].TargetDecoratorStyle.StrokeWidth = 1;
                diagram.Connectors[i].Style.StrokeWidth                = 1;
            }
            diagram.EnableTextEditing      = false;
            diagram.PageSettings.GridSize  = 12;
            diagram.PageSettings.GridColor = UIColor.FromRGB(230, 230, 230);
            this.AddSubview(diagram);

            gridColor                 = new UILabel();
            gridColor.Text            = "Grid Color";
            gridColor.TextColor       = UIColor.Black;
            gridColor.TextAlignment   = UITextAlignment.Left;
            gridColor.BackgroundColor = UIColor.Clear;

            colorView.BackgroundColor = UIColor.Clear;
            colorView.ScrollEnabled   = true;
            colorView.ShowsHorizontalScrollIndicator = true;
            colorView.ShowsVerticalScrollIndicator   = false;

            int x = 50;

            colorView.AddSubview(AddColorButton(10, UIColor.Red));
            colorView.AddSubview(AddColorButton((x * 1), UIColor.Orange));
            colorView.AddSubview(AddColorButton((x * 2), UIColor.FromRGB(0, 128, 0)));
            colorView.AddSubview(AddColorButton((x * 3), UIColor.Blue));
            colorView.AddSubview(AddColorButton((x * 4), UIColor.Purple));
            colorView.AddSubview(AddColorButton((x * 5), UIColor.FromRGB(51, 255, 255)));
            colorView.AddSubview(AddColorButton((x * 6), UIColor.FromRGB(255, 0, 255)));
            colorView.AddSubview(AddColorButton((x * 7), UIColor.Gray));
            colorView.AddSubview(AddColorButton((x * 8), UIColor.FromRGB(0, 255, 0)));
            colorView.AddSubview(AddColorButton((x * 9), UIColor.FromRGB(128, 0, 0)));
            colorView.AddSubview(AddColorButton((x * 10), UIColor.FromRGB(0, 0, 128)));
            colorView.AddSubview(AddColorButton((x * 11), UIColor.FromRGB(128, 128, 0)));
            colorView.AddSubview(AddColorButton((x * 12), UIColor.FromRGB(192, 192, 192)));
            colorView.AddSubview(AddColorButton((x * 13), UIColor.FromRGB(0, 128, 128)));
            colorView.ContentSize      = new CGSize(850, colorView.ContentSize.Height);
            enablegrid                 = new UILabel();
            enablegrid.Text            = "Show Grid";
            enablegrid.TextColor       = UIColor.Black;
            enablegrid.TextAlignment   = UITextAlignment.Left;
            enablegrid.BackgroundColor = UIColor.Clear;

            enablegrid                 = new UILabel();
            enablegrid.Text            = "Show Grid";
            enablegrid.TextColor       = UIColor.Black;
            enablegrid.TextAlignment   = UITextAlignment.Left;
            enablegrid.BackgroundColor = UIColor.Clear;

            gridswitch = new UISwitch();
            gridswitch.TouchUpInside  += Gridswitch_TouchUpInside;
            gridswitch.BackgroundColor = UIColor.Clear;

            snapgrid                 = new UILabel();
            snapgrid.Text            = "Snap To Grid";
            snapgrid.TextColor       = UIColor.Black;
            snapgrid.TextAlignment   = UITextAlignment.Left;
            snapgrid.BackgroundColor = UIColor.Clear;

            snapgridswitch = new UISwitch();
            snapgridswitch.TouchUpInside  += Snapgridswitch_TouchUpInside;
            snapgridswitch.BackgroundColor = UIColor.Clear;
            snapgridswitch.Enabled         = false;

            gridSize               = new UILabel();
            gridSize.Text          = "Size";
            gridSize.TextColor     = UIColor.Black;
            gridSize.TextAlignment = UITextAlignment.Left;

            plus = new UIButton();
            plus.BackgroundColor    = UIColor.White;
            plus.Layer.CornerRadius = 8;
            plus.Layer.BorderWidth  = 0.5f;
            plus.TouchUpInside     += Plus_TouchUpInside;
            plusimg       = new UIImageView();
            plusimg.Image = UIImage.FromBundle("Images/Diagram/CSplus.png");
            plus.AddSubview(plusimg);

            minus = new UIButton();
            minus.BackgroundColor    = UIColor.White;
            minus.Layer.CornerRadius = 8;
            minus.Layer.BorderWidth  = 0.5f;
            minus.TouchUpInside     += Minus_TouchUpInside;
            minusimg       = new UIImageView();
            minusimg.Image = UIImage.FromBundle("Images/Diagram/CSsub.png");
            minus.AddSubview(minusimg);

            sizeindicator                 = new UILabel();
            sizeindicator.Text            = width.ToString();
            sizeindicator.BackgroundColor = UIColor.Clear;
            sizeindicator.TextColor       = UIColor.Black;
            sizeindicator.TextAlignment   = UITextAlignment.Center;
            optionView();


            gridColor.Frame       = new CGRect(this.Frame.X + 10, 20, 100, 30);
            colorView.Frame       = new CGRect(this.Frame.X + 10, 60, 300, 45);
            colorView.ContentSize = new CGSize(850, colorView.ContentSize.Height);
            enablegrid.Frame      = new CGRect(this.Frame.X + 10, 120, 100, 30);
            gridswitch.Frame      = new CGRect(this.Frame.X + 250, 120, 40, 30);
            snapgrid.Frame        = new CGRect(this.Frame.X + 10, 170, 100, 30);
            snapgridswitch.Frame  = new CGRect(this.Frame.X + 250, 170, 40, 30);
            gridSize.Frame        = new CGRect(this.Frame.X + 10, 220, PopoverSize.Width - 20, 30);
            plus.Frame            = new CGRect(this.Frame.X + 160, 270, 30, 30);
            plusimg.Frame         = new CGRect(0, 0, 30, 30);
            minus.Frame           = new CGRect(this.Frame.X + 60, 270, 30, 30);
            minusimg.Frame        = new CGRect(0, 0, 30, 30);
            sizeindicator.Frame   = new CGRect(this.Frame.X + 110, 270, 30, 30);

            diagram.ConnectorClicked += Diagram_ConnectorClicked;
            diagram.ContextMenuSettings.Visibility = false;
        }
示例#13
0
 public FlowDiagram()
 {
     diagram = new SfDiagram();
 }