private static ListViewItem CreateRow(Step firstStep, Step secondStep)
        {
            var profile = (ProfileNode)firstStep.Left.Tag;

            var title = profile.Profile.Title;

            var leftPerson = (PersonNode)firstStep.Right.Tag;

            var leftName = PersonFormatter.GetName(leftPerson.Person);

            var leftJob = leftPerson.GetJobs(profile).First();

            var leftJobDescription = PersonFormatter.GetJob(leftJob);

            var rightPerson = (PersonNode)secondStep.Left.Tag;

            var rightName = PersonFormatter.GetName(rightPerson.Person);

            var rightJob = rightPerson.GetJobs(profile).First();

            var rightJobDescription = PersonFormatter.GetJob(rightJob);

            var subItems = new[] { title, leftName, leftJobDescription, rightName, rightJobDescription };

            var row = new ListViewItem(subItems);

            return(row);
        }
Esempio n. 2
0
        internal void AddJob(IPerson person)
        {
            var job = PersonFormatter.GetJob(person);

            _jobs[job] = person;
        }
        private void SaveImage(FileInfo fileInfo)
        {
            foreach (var node in _resultGraph.Nodes)
            {
                if (node.Tag is PersonNode personNode)
                {
                    node.Description = PersonFormatter.GetName(personNode.Person).Replace("\"", "'");
                }
                else if (node.Tag is ProfileNode profileNode)
                {
                    node.Description = profileNode.Profile.Title.Replace("\"", "'");
                }
            }

            foreach (var edge in _resultGraph.Edges)
            {
                if (_withJobs)
                {
                    PersonNode  personNode;
                    ProfileNode profileNode;

                    if (edge.SourceNode.Tag is PersonNode temp)
                    {
                        personNode  = temp;
                        profileNode = (ProfileNode)edge.TargetNode.Tag;
                    }
                    else
                    {
                        personNode  = (PersonNode)edge.TargetNode.Tag;
                        profileNode = (ProfileNode)edge.SourceNode.Tag;
                    }

                    var jobs = personNode.GetJobs(profileNode);

                    edge.Description = PersonFormatter.GetJob(jobs.First()).Replace("\"", "'");
                }
                else
                {
                    edge.Description = string.Empty;
                }
            }

            var dotText = _resultGraph.ToDotText();

            switch (fileInfo.Extension.ToLower())
            {
            case ".png":
            {
                _renderer.RenderImage(dotText, fileInfo.FullName, mitoSoft.Graphs.GraphVizInterop.Enums.LayoutEngine.dot, mitoSoft.Graphs.GraphVizInterop.Enums.ImageFormat.png);

                break;
            }

            case ".svg":
            {
                _renderer.RenderImage(dotText, fileInfo.FullName, mitoSoft.Graphs.GraphVizInterop.Enums.LayoutEngine.dot, mitoSoft.Graphs.GraphVizInterop.Enums.ImageFormat.svg);

                break;
            }

            case ".bmp":
            {
                var image = _renderer.RenderImage(dotText, mitoSoft.Graphs.GraphVizInterop.Enums.LayoutEngine.dot, mitoSoft.Graphs.GraphVizInterop.Enums.ImageFormat.png);

                image.Save(fileInfo.FullName, System.Drawing.Imaging.ImageFormat.Bmp);

                break;
            }

            case ".tif":
            case ".tiff":
            {
                var image = _renderer.RenderImage(dotText, mitoSoft.Graphs.GraphVizInterop.Enums.LayoutEngine.dot, mitoSoft.Graphs.GraphVizInterop.Enums.ImageFormat.png);

                image.Save(fileInfo.FullName, System.Drawing.Imaging.ImageFormat.Tiff);

                break;
            }

            case ".jpg":
            case ".jpeg":
            {
                _renderer.RenderImage(dotText, fileInfo.FullName, mitoSoft.Graphs.GraphVizInterop.Enums.LayoutEngine.dot, mitoSoft.Graphs.GraphVizInterop.Enums.ImageFormat.jpg);

                break;
            }

            case ".gif":
            {
                var image = _renderer.RenderImage(dotText, mitoSoft.Graphs.GraphVizInterop.Enums.LayoutEngine.dot, mitoSoft.Graphs.GraphVizInterop.Enums.ImageFormat.png);

                image.Save(fileInfo.FullName, System.Drawing.Imaging.ImageFormat.Gif);

                break;
            }

            default:
            {
                MessageBox.Show($"Unknown file format: {fileInfo.Extension}", "GraphWiz", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                return;
            }
            }

            Process.Start(fileInfo.FullName);
        }