internal static void InitializeAimAnnotationWpfControl(AimAnnotationComponent component)
 {
     Instance = new AimAnnotationComponentWpfControl(component);
 }
 internal static void InitializeAimAnnotationWpfControl(AimAnnotationComponent component)
 {
     Instance = new AimAnnotationComponentWpfControl(component);
 }
        public TemplateWpfControl(AimAnnotationComponent component, AimAnnotationComponentWpfControl parentComponentControl)
        {
            Component = component;

            NodeControls = new List <IValidTreeControl>();

            if (component.AimTemplateTree != null)
            {
                TreeNodes = new List <AimTemplateTreeNode>(component.AimTemplateTree.TemplateNodes);
                TreeNodes.Sort(new TemplateTreeNodeOrderComparer());
            }
            else
            {
                TreeNodes = new List <AimTemplateTreeNode>();
            }

            InitializeComponent();

            _stackPanel.Children.Add(new AnnotationNameWpfControl(Component));

            var groupedNodes = new List <AimTemplateTreeNode>();

            foreach (AimTemplateTreeNode treeNode in TreeNodes)
            {
                // Start or add to group label control
                if (!String.IsNullOrEmpty(treeNode.GroupLabel))
                {
                    if (groupedNodes.Count > 0 && treeNode.GroupLabel == groupedNodes[0].GroupLabel)
                    {
                        groupedNodes.Add(treeNode);
                    }
                    else
                    {
                        // Finish and add the group label control
                        if (groupedNodes.Count > 0)
                        {
                            var groupLabel = new GroupLabelWpfControl(groupedNodes)
                            {
                                Header = groupedNodes[0].GroupLabel
                            };
                            _stackPanel.Children.Add(groupLabel);
                            NodeControls.Add(groupLabel);
                        }

                        groupedNodes = new List <AimTemplateTreeNode> {
                            treeNode
                        };
                    }
                }
                else
                {
                    // Finish and add the group label control
                    if (groupedNodes.Count > 0)
                    {
                        var groupLabel = new GroupLabelWpfControl(groupedNodes)
                        {
                            Header = groupedNodes[0].GroupLabel
                        };
                        groupedNodes.Clear();
                        _stackPanel.Children.Add(groupLabel);
                        NodeControls.Add(groupLabel);
                    }

                    if (treeNode is AimTemplateTreeAnatomicEntityNode)
                    {
                        var anatomicEntityControl =
                            new AnatomicEntityWpfControl((AimTemplateTreeAnatomicEntityNode)treeNode);
                        _stackPanel.Children.Add(anatomicEntityControl);
                        NodeControls.Add(anatomicEntityControl);
                    }
                    if (treeNode is AimTemplateTreeImagingObservationNode)
                    {
                        var imagingObservationControl =
                            new ImagingObservationWpfControl((AimTemplateTreeImagingObservationNode)treeNode);
                        _stackPanel.Children.Add(imagingObservationControl);
                        NodeControls.Add(imagingObservationControl);
                    }
                    if (treeNode is AimTemplateTreeInferenceNode)
                    {
                        var inferenceControl =
                            new InferenceWpfControl((AimTemplateTreeInferenceNode)treeNode);
                        _stackPanel.Children.Add(inferenceControl);
                        NodeControls.Add(inferenceControl);
                    }
                    if (treeNode is AimTemplateTreeGeometricShapeNode)
                    {
                        var geometricShapeControl =
                            new GeometricShapeWpfControl((AimTemplateTreeGeometricShapeNode)treeNode);
                        _stackPanel.Children.Add(geometricShapeControl);
                        NodeControls.Add(geometricShapeControl);
                    }
                    if (treeNode is AimTemplateTreeCalculationNode)
                    {
                        var calculationControl =
                            new CalculationWpfControl((AimTemplateTreeCalculationNode)treeNode);
                        _stackPanel.Children.Add(calculationControl);
                        NodeControls.Add(calculationControl);
                    }
                }
            }

            // Finish and add the group label control
            if (groupedNodes.Count > 0)
            {
                var groupLabel = new GroupLabelWpfControl(groupedNodes)
                {
                    Header = groupedNodes[0].GroupLabel
                };
                _stackPanel.Children.Add(groupLabel);
                NodeControls.Add(groupLabel);
            }
        }