Exemple #1
0
        public static void LayoutCircleDiagramItems(DiagramItem[] items, Size pageSize, double radius)
        {
            double phase      = -Math.PI / 2;
            double phaseDelta = 2 * Math.PI / items.Length;
            Point  center     = new Point(pageSize.Width / 2, pageSize.Height / 2);

            foreach (var item in items)
            {
                item.Position = DiagramDemoHelper.GetCircleDiagramItemPosition(radius, phase, center, item.DesiredSize);
                phase        += phaseDelta;
            }
        }
        void CreateRelationshipDiagram()
        {
            Dictionary <Employee, DiagramItem> employeeToDiagramItemCache = new Dictionary <Employee, DiagramItem>();
            var diagramItems = ViewModel.Employees.Select(employee => {
                var item = new DiagramContentItem()
                {
                    CustomStyleId = "employeeStyle", Content = employee, FontSize = 12, CanDelete = false, CanCopy = false
                };
                employeeToDiagramItemCache[employee] = item;
                return(item);
            }).ToArray();
            var diagramConnectors = ViewModel.Relationships.
                                    Select(employeeRelation => CreateDiagramConnector(employeeToDiagramItemCache[employeeRelation.Item1], employeeToDiagramItemCache[employeeRelation.Item2], employeeRelation.Item3)).ToArray();

            Array.ForEach <DiagramItem>(diagramConnectors, item => diagramControl.Items.Add(item));
            Array.ForEach <DiagramItem>(diagramItems, item => diagramControl.Items.Add(item));
            diagramControl.UpdateLayout();
            DiagramDemoHelper.LayoutCircleDiagramItems(diagramItems, diagramControl.PageSize, 300);
            diagramControl.SelectItem(diagramItems.First());
        }
Exemple #3
0
 public static void LoadDemoData(this DiagramControl diagramControl, string dataSourceName)
 {
     diagramControl.LoadDocument(DiagramDemoHelper.GetDataFilePath(dataSourceName));
 }
Exemple #4
0
        public static Stream GetDataStream(string fileName)
        {
            string path = DiagramDemoHelper.GetDataFilePath(fileName);

            return(File.OpenRead(path));
        }