Example #1
0
        private ObservableCollection <OrgContainerShape> GetSubNodes(XContainer element, OrgContainerShape parent, int level)
        {
            var             nodes    = new ObservableCollection <OrgContainerShape>();
            List <XElement> elements = new List <XElement>(element.Elements("Element"));

            if (elements.Count == 0)
            {
                return(nodes);
            }


            foreach (var subElement in elements)
            {
                OrgContainerShape node = this.CreateNode(subElement, parent);
                node.ShowCollapseButton = level < 4;
                if (node.Path.ToString() != "")
                {
                    node.BaseColor = Color.IndianRed;
                }


                this.radDiagram1.AddShape(node);

                this.GetSubNodes(subElement, node, level + 1);
                nodes.Add(node);
                node.IsCollapsed = true;
            }

            return(nodes);
        }
Example #2
0
        void addTeam_Click(object sender, EventArgs e)
        {
            var parentTeam = this.FindAncestor <OrgContainerShape>();
            var newTeam    = new OrgContainerShape()
            {
                Name      = "New " + parentTeam.Tag.ToString() + " Team",
                BaseColor = parentTeam.BaseColor,
            };

            parentTeam.ShowCollapseButton = true;
            newTeam.ToggleCollapseButton.ImagePrimitive.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
            newTeam.Text               = newTeam.Name;
            newTeam.Tag                = parentTeam.Tag.ToString();
            newTeam.Path               = string.Format("{0}|{1}", parentTeam.Path, newTeam.Name);
            newTeam.TeamMembers        = string.Format("0 Team Members");
            newTeam.ShowCollapseButton = false;
            OrgChartForm.currentLayoutSettings.Roots.Add(newTeam);

            var diagramElement = this.FindAncestor <RadDiagramElement>();

            diagramElement.AddShape(newTeam);

            RadDiagramConnection connection = new RadDiagramConnection();

            connection.ConnectionType = Telerik.Windows.Diagrams.Core.ConnectionType.Polyline;
            connection.Source         = parentTeam;
            connection.Target         = newTeam;
            connection.Route          = true;
            diagramElement.AddConnection(connection);

            diagramElement.SetLayout(Telerik.Windows.Diagrams.Core.LayoutType.Tree, OrgChartForm.currentLayoutSettings);
        }
Example #3
0
        protected override void OnLoad(EventArgs e)
        {
            OrgContainerShape sh = new OrgContainerShape();

            base.OnLoad(e);

            this.InitializeDiagram();
        }
Example #4
0
        private void btnColapse_Click(object sender, EventArgs e)
        {
            try {
                Application.Restart();
                OrgContainerShape sh = new OrgContainerShape();

                sh.Colapsar();
            } catch (Exception) {
                throw;
            }
        }
Example #5
0
        private void PopulateWithData()
        {
            XElement dataXml = XElement.Load(Directory.GetCurrentDirectory() + "\\Hersan.xml");
            IEnumerable <XElement> employees = dataXml.Elements();

            foreach (XElement element in dataXml.Elements("Element"))
            {
                OrgContainerShape node = this.CreateNode(element, null);
                node.BaseColor = Color.IndianRed;
                this.radDiagram1.AddShape(node);
                currentLayoutSettings.Roots.Add(node);
                this.GetSubNodes(element, node, 2);
                node.IsCollapsed = true;
            }
        }
Example #6
0
        private OrgContainerShape CreateNode(XElement element, OrgContainerShape parentNode)
        {
            OrgContainerShape orgTeam = new OrgContainerShape()
            {
                Name = Nom = element.Attribute("Depto").Value,
            };

            orgTeam.ToggleCollapseButton.ImagePrimitive.Visibility = Telerik.WinControls.ElementVisibility.Hidden;

            orgTeam.Text = orgTeam.Name;
            orgTeam.Tag  = Nombre = element.Attribute("Name").Value;
            orgTeam.Path = parentNode == null ? orgTeam.Name : string.Format("{0}|{1}", parentNode.Path, orgTeam.Name);
            currentLayoutSettings.Roots.Add(orgTeam);
            if (parentNode != null)
            {
                RadDiagramConnection connection = new RadDiagramConnection();
                connection.ConnectionType = Telerik.Windows.Diagrams.Core.ConnectionType.Polyline;
                connection.Source         = parentNode;
                connection.Target         = orgTeam;

                this.radDiagram1.AddConnection(connection);
            }

            var teamMembers = this.GetTeamMembers(element, orgTeam);
            var position    = new Telerik.Windows.Diagrams.Core.Point(10, 50);

            int memberCount = 0;

            foreach (var member in teamMembers)
            {
                this.radDiagram1.AddShape(member);
                orgTeam.Items.Add(member);
                member.Position = position;
                position.X     += member.Width + 20;
                if (++memberCount % 2 == 0)
                {
                    position = new Telerik.Windows.Diagrams.Core.Point(10, position.Y + member.Height + 10);
                }
            }

            orgTeam.IsCollapsedChanged += this.orgTeam_IsCollapsedChanged;
            return(orgTeam);
        }
Example #7
0
        private void InitializeDiagram()
        {
            CargaDocumento();
            OrgContainerShape org = new OrgContainerShape();

            this.WindowState = FormWindowState.Maximized;

            this.ApplyThemeRecursively(this.Controls);
            this.radDiagram1.BackColor = System.Drawing.Color.White;
            this.radDiagram1.ForeColor = System.Drawing.Color.Black;
            this.radDiagram1.IsInformationAdornerVisible = false;
            this.radDiagram1.ActiveTool            = Telerik.Windows.Diagrams.Core.MouseTool.PanTool;
            this.radDiagram1.IsSnapToGridEnabled   = false;
            this.radDiagram1.IsSnapToItemsEnabled  = false;
            this.radDiagram1.RouteConnections      = false;
            this.radDiagram1.RoutingService.Router = new Telerik.Windows.Diagrams.Core.OrgTreeRouter()
            {
                TreeLayoutType = Telerik.Windows.Diagrams.Core.TreeLayoutType.TreeDown
            };
            this.radDiagram1.RoutingService.AutoUpdate     = true;
            this.radDiagram1.RouteConnections              = true;
            this.radDiagram1.BackgroundGrid.Visibility     = Telerik.WinControls.ElementVisibility.Hidden;
            this.radDiagram1.BackgroundPageGrid.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
            this.radDiagram1.IsSettingsPaneEnabled         = false;
            currentLayoutSettings = new Telerik.Windows.Diagrams.Core.TreeLayoutSettings()
            {
                HorizontalSeparation         = 80d,
                VerticalSeparation           = 60d,
                UnderneathVerticalTopOffset  = 50d,
                UnderneathHorizontalOffset   = 130d,
                UnderneathVerticalSeparation = 40d,
                VerticalDistance             = 10d,
            };

            this.PopulateWithData();


            this.radDiagram1.Zoom = 0.8;
            this.radDiagram1.DiagramElement.HorizontalScrollbar.Value = 250;
            this.radDiagram1.DiagramElement.VerticalScrollbar.Value   = 100;
            this.radDiagram1.SetLayout(Telerik.Windows.Diagrams.Core.LayoutType.Tree, currentLayoutSettings);
        }
Example #8
0
        private RadDiagramShape CreateMemberShape(OrgContainerShape team, string xmlNodeMember)
        {
            RadDiagramShape member = new RadDiagramShape();

            member.IsConnectorsManipulationEnabled = false;
            member.ForeColor         = Color.White;
            member.IsRotationEnabled = false;
            member.IsResizingEnabled = false;
            member.Shape             = new Telerik.WinControls.RoundRectShape(0);
            member.BackColor         = Color.LightBlue;
            member.Width             = 190;
            member.Height            = 50;
            member.Tag = team;
            //member.Name = xmlNodeMember.ToString();
            member.DiagramShapeElement.TextAlignment = ContentAlignment.MiddleLeft;
            member.DiagramShapeElement.ImageLayout   = ImageLayout.None;
            member.DiagramShapeElement.Padding       = new System.Windows.Forms.Padding(5, 2, 2, 0);
            //member.DiagramShapeElement.Image = this.GetImageFromResource(member.Name);
            member.DiagramShapeElement.ImageAlignment    = ContentAlignment.MiddleLeft;
            member.DiagramShapeElement.TextImageRelation = TextImageRelation.ImageBeforeText;
            member.DiagramShapeElement.TextWrap          = false;
            member.Text = string.Format(" {0}\n {1}", member.Name, xmlNodeMember.ToString());
            return(member);
        }
Example #9
0
        private void OrgChartForm_Load(object sender, EventArgs e)
        {
            OrgContainerShape sh = new OrgContainerShape();

            sh.ToggleCollapseButton.ToggleState = Telerik.WinControls.Enumerations.ToggleState.On;
        }
Example #10
0
        private ObservableCollection <RadDiagramShape> GetTeamMembers(XContainer element, OrgContainerShape team)
        {
            //XElement data = XElement.Load(@"C:\Temp\Hersan.xml");
            XElement data = XElement.Load(Directory.GetCurrentDirectory() + "\\Hersan.xml");

            var members = new ObservableCollection <RadDiagramShape>();

            foreach (var xmlNodeMember in data.Elements("Element"))
            {
                RadDiagramShape member = this.CreateMemberShape(team, Nombre);
                members.Add(member);
            }

            return(members);
        }